1 /* 2 * Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 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. 16 * 17 * @(#)ns.h 7.4 (Berkeley) 06/29/88 18 */ 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 */ 55 #define NS_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */ 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 65 #define SO_SEQNO 6 66 #define SO_ALL_PACKETS 7 67 #define SO_MTU 8 68 69 70 /* 71 * NS addressing 72 */ 73 union ns_host { 74 u_char c_host[6]; 75 u_short s_host[3]; 76 }; 77 78 union ns_net { 79 u_char c_net[4]; 80 u_short s_net[2]; 81 }; 82 83 union ns_net_u { 84 union ns_net net_e; 85 u_long long_e; 86 }; 87 88 struct 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 */ 97 struct sockaddr_ns { 98 u_short sns_family; 99 struct ns_addr sns_addr; 100 char sns_zero[2]; 101 }; 102 #define sns_port sns_addr.x_port 103 104 #ifdef vax 105 #define ns_netof(a) (*(long *) & ((a).x_net)) /* XXX - not needed */ 106 #endif 107 #define ns_neteqnn(a,b) (((a).s_net[0]==(b).s_net[0]) && \ 108 ((a).s_net[1]==(b).s_net[1])) 109 #define ns_neteq(a,b) ns_neteqnn((a).x_net, (b).x_net) 110 #define satons_addr(sa) (((struct sockaddr_ns *)&(sa))->sns_addr) 111 #define ns_hosteqnh(s,t) ((s).s_host[0] == (t).s_host[0] && \ 112 (s).s_host[1] == (t).s_host[1] && (s).s_host[2] == (t).s_host[2]) 113 #define ns_hosteq(s,t) (ns_hosteqnh((s).x_host,(t).x_host)) 114 #define ns_nullhost(x) (((x).x_host.s_host[0]==0) && \ 115 ((x).x_host.s_host[1]==0) && ((x).x_host.s_host[2]==0)) 116 117 #ifdef KERNEL 118 extern struct domain nsdomain; 119 union ns_host ns_thishost; 120 union ns_host ns_zerohost; 121 union ns_host ns_broadhost; 122 union ns_net ns_zeronet; 123 union ns_net ns_broadnet; 124 u_short ns_cksum(); 125 #endif 126