FreeBSD/Linux Kernel Cross Reference
sys/netns/ns.h
1 /* $NetBSD: ns.h,v 1.17 2003/08/07 16:33:45 agc Exp $ */
2
3 /*
4 * Copyright (c) 1984, 1985, 1986, 1987, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * @(#)ns.h 8.1 (Berkeley) 6/10/93
32 */
33
34 /*
35 * Constants and Structures defined by the Xerox Network Software
36 * per "Internet Transport Protocols", XSIS 028112, December 1981
37 */
38
39 /*
40 * Protocols
41 */
42 #define NSPROTO_RI 1 /* Routing Information */
43 #define NSPROTO_ECHO 2 /* Echo Protocol */
44 #define NSPROTO_ERROR 3 /* Error Protocol */
45 #define NSPROTO_PE 4 /* Packet Exchange */
46 #define NSPROTO_SPP 5 /* Sequenced Packet */
47 #define NSPROTO_RAW 255 /* Placemarker*/
48 #define NSPROTO_MAX 256 /* Placemarker*/
49
50
51 /*
52 * Port/Socket numbers: network standard functions
53 */
54
55 #define NSPORT_RI 1 /* Routing Information */
56 #define NSPORT_ECHO 2 /* Echo */
57 #define NSPORT_RE 3 /* Router Error */
58
59 /*
60 * Ports < NSPORT_RESERVED are reserved for privileged
61 * processes (e.g. root).
62 */
63 #define NSPORT_RESERVED 3000
64
65 /* flags passed to ns_output as last parameter */
66
67 #define NS_FORWARDING 0x1 /* most of idp header exists */
68 #define NS_ROUTETOIF SO_DONTROUTE /* bypass routing tables */
69 #define NS_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */
70
71 #define NS_MAXHOPS 15
72
73 /* flags passed to get/set socket option */
74 #define SO_HEADERS_ON_INPUT 1
75 #define SO_HEADERS_ON_OUTPUT 2
76 #define SO_DEFAULT_HEADERS 3
77 #define SO_LAST_HEADER 4
78 #define SO_NSIP_ROUTE 5
79 #define SO_SEQNO 6
80 #define SO_ALL_PACKETS 7
81 #define SO_MTU 8
82
83
84 /*
85 * NS addressing
86 */
87 union ns_host {
88 u_int8_t c_host[6];
89 u_int16_t s_host[3];
90 };
91
92 union ns_net {
93 u_int8_t c_net[4];
94 u_int16_t s_net[2];
95 };
96
97 union ns_net_u {
98 union ns_net net_e;
99 u_int32_t long_e;
100 };
101
102 struct ns_addr {
103 union ns_net x_net;
104 union ns_host x_host;
105 u_int16_t x_port;
106 };
107
108 /*
109 * Socket address, Xerox style
110 */
111 struct sockaddr_ns {
112 u_char sns_len;
113 u_char sns_family;
114 struct ns_addr sns_addr;
115 char sns_zero[2];
116 };
117 #define sns_port sns_addr.x_port
118
119 #define ns_neteqnn(a,b) (((a).s_net[0]==(b).s_net[0]) && \
120 ((a).s_net[1]==(b).s_net[1]))
121 #define ns_neteq(a,b) ns_neteqnn((a).x_net, (b).x_net)
122 #define satons_addr(sa) (((struct sockaddr_ns *)&(sa))->sns_addr)
123 #define ns_hosteqnh(s,t) ((s).s_host[0] == (t).s_host[0] && \
124 (s).s_host[1] == (t).s_host[1] && (s).s_host[2] == (t).s_host[2])
125 #define ns_hosteq(s,t) (ns_hosteqnh((s).x_host,(t).x_host))
126 #define ns_nullhost(x) (((x).x_host.s_host[0]==0) && \
127 ((x).x_host.s_host[1]==0) && ((x).x_host.s_host[2]==0))
128
129 #ifdef _KERNEL
130 extern struct domain nsdomain;
131 extern union ns_host ns_thishost;
132 extern union ns_host ns_zerohost;
133 extern union ns_host ns_broadhost;
134 extern union ns_net ns_zeronet;
135 extern union ns_net ns_broadnet;
136
137 #define satosns(sa) ((struct sockaddr_ns *)(sa))
138 #define snstosa(sns) ((struct sockaddr *)(sns))
139
140 extern struct sockaddr_ns ns_netmask, ns_hostmask;
141 #else
142
143 #include <sys/cdefs.h>
144
145 __BEGIN_DECLS
146 extern struct ns_addr ns_addr __P((const char *));
147 extern char *ns_ntoa __P((struct ns_addr));
148 __END_DECLS
149
150 #endif
Cache object: 92511d21c960c1291882137b69f025b2
|