changes for var. length sockaddrs, routing lookup changes,
[unix-history] / usr / src / sys / netns / ns.h
CommitLineData
8ae0e4b4 1/*
240edf1f
KS
2 * Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California.
3 * All rights reserved.
8ae0e4b4 4 *
240edf1f 5 * Redistribution and use in source and binary forms are permitted
616d42db
KB
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * advertising materials, and other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley. The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
240edf1f 16 *
4dcdd98e 17 * @(#)ns.h 7.5 (Berkeley) %G%
8ae0e4b4 18 */
ebc0bbdd
KS
19
20/*
21 * Constants and Structures defined by the Xerox Network Software
22 * per "Internet Transport Protocols", XSIS 028112, December 1981
23 */
24
25/*
26 * Protocols
27 */
28#define NSPROTO_RI 1 /* Routing Information */
29#define NSPROTO_ECHO 2 /* Echo Protocol */
30#define NSPROTO_ERROR 3 /* Error Protocol */
31#define NSPROTO_PE 4 /* Packet Exchange */
32#define NSPROTO_SPP 5 /* Sequenced Packet */
33#define NSPROTO_RAW 255 /* Placemarker*/
34#define NSPROTO_MAX 256 /* Placemarker*/
35
36
37/*
38 * Port/Socket numbers: network standard functions
39 */
40
41#define NSPORT_RI 1 /* Routing Information */
42#define NSPORT_ECHO 2 /* Echo */
43#define NSPORT_RE 3 /* Router Error */
44
45/*
46 * Ports < NSPORT_RESERVED are reserved for priveleged
47 * processes (e.g. root).
48 */
49#define NSPORT_RESERVED 3000
50
51/* flags passed to ns_output as last parameter */
52
53#define NS_FORWARDING 0x1 /* most of idp header exists */
54#define NS_ROUTETOIF 0x10 /* same as SO_DONTROUTE */
077a00ce 55#define NS_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */
ebc0bbdd
KS
56
57#define NS_MAXHOPS 15
58
59/* flags passed to get/set socket option */
60#define SO_HEADERS_ON_INPUT 1
61#define SO_HEADERS_ON_OUTPUT 2
62#define SO_DEFAULT_HEADERS 3
63#define SO_LAST_HEADER 4
64#define SO_NSIP_ROUTE 5
7427b6ea 65#define SO_SEQNO 6
b7369600 66#define SO_ALL_PACKETS 7
f17a37ec 67#define SO_MTU 8
ebc0bbdd
KS
68
69
70/*
71 * NS addressing
72 */
73union ns_host {
74 u_char c_host[6];
75 u_short s_host[3];
76};
77
78union ns_net {
79 u_char c_net[4];
80 u_short s_net[2];
81};
82
0d615f84
KS
83union ns_net_u {
84 union ns_net net_e;
85 u_long long_e;
86};
87
ebc0bbdd
KS
88struct ns_addr {
89 union ns_net x_net;
90 union ns_host x_host;
91 u_short x_port;
92};
93
94/*
95 * Socket address, Xerox style
96 */
97struct sockaddr_ns {
4dcdd98e
KS
98 u_char sns_len;
99 u_char sns_family;
ebc0bbdd 100 struct ns_addr sns_addr;
0003c8d5 101 char sns_zero[2];
ebc0bbdd
KS
102};
103#define sns_port sns_addr.x_port
104
f1e269d4
KS
105#ifdef vax
106#define ns_netof(a) (*(long *) & ((a).x_net)) /* XXX - not needed */
107#endif
108#define ns_neteqnn(a,b) (((a).s_net[0]==(b).s_net[0]) && \
f6a09cd7 109 ((a).s_net[1]==(b).s_net[1]))
f1e269d4 110#define ns_neteq(a,b) ns_neteqnn((a).x_net, (b).x_net)
ebc0bbdd
KS
111#define satons_addr(sa) (((struct sockaddr_ns *)&(sa))->sns_addr)
112#define ns_hosteqnh(s,t) ((s).s_host[0] == (t).s_host[0] && \
113 (s).s_host[1] == (t).s_host[1] && (s).s_host[2] == (t).s_host[2])
114#define ns_hosteq(s,t) (ns_hosteqnh((s).x_host,(t).x_host))
115#define ns_nullhost(x) (((x).x_host.s_host[0]==0) && \
116 ((x).x_host.s_host[1]==0) && ((x).x_host.s_host[2]==0))
117
ebc0bbdd
KS
118#ifdef KERNEL
119extern struct domain nsdomain;
58bca61d
MK
120union ns_host ns_thishost;
121union ns_host ns_zerohost;
122union ns_host ns_broadhost;
123union ns_net ns_zeronet;
124union ns_net ns_broadnet;
ebc0bbdd
KS
125u_short ns_cksum();
126#endif