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 this notice is preserved and that due credit is given 7 * to the University of California at Berkeley. The name of the University 8 * may not be used to endorse or promote products derived from this 9 * software without specific prior written permission. This software 10 * is provided ``as is'' without express or implied warranty. 11 * 12 * @(#)ns.h 7.3 (Berkeley) 01/20/88 13 */ 14 15 /* 16 * Constants and Structures defined by the Xerox Network Software 17 * per "Internet Transport Protocols", XSIS 028112, December 1981 18 */ 19 20 /* 21 * Protocols 22 */ 23 #define NSPROTO_RI 1 /* Routing Information */ 24 #define NSPROTO_ECHO 2 /* Echo Protocol */ 25 #define NSPROTO_ERROR 3 /* Error Protocol */ 26 #define NSPROTO_PE 4 /* Packet Exchange */ 27 #define NSPROTO_SPP 5 /* Sequenced Packet */ 28 #define NSPROTO_RAW 255 /* Placemarker*/ 29 #define NSPROTO_MAX 256 /* Placemarker*/ 30 31 32 /* 33 * Port/Socket numbers: network standard functions 34 */ 35 36 #define NSPORT_RI 1 /* Routing Information */ 37 #define NSPORT_ECHO 2 /* Echo */ 38 #define NSPORT_RE 3 /* Router Error */ 39 40 /* 41 * Ports < NSPORT_RESERVED are reserved for priveleged 42 * processes (e.g. root). 43 */ 44 #define NSPORT_RESERVED 3000 45 46 /* flags passed to ns_output as last parameter */ 47 48 #define NS_FORWARDING 0x1 /* most of idp header exists */ 49 #define NS_ROUTETOIF 0x10 /* same as SO_DONTROUTE */ 50 #define NS_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */ 51 52 #define NS_MAXHOPS 15 53 54 /* flags passed to get/set socket option */ 55 #define SO_HEADERS_ON_INPUT 1 56 #define SO_HEADERS_ON_OUTPUT 2 57 #define SO_DEFAULT_HEADERS 3 58 #define SO_LAST_HEADER 4 59 #define SO_NSIP_ROUTE 5 60 #define SO_SEQNO 6 61 #define SO_ALL_PACKETS 7 62 #define SO_MTU 8 63 64 65 /* 66 * NS addressing 67 */ 68 union ns_host { 69 u_char c_host[6]; 70 u_short s_host[3]; 71 }; 72 73 union ns_net { 74 u_char c_net[4]; 75 u_short s_net[2]; 76 }; 77 78 union ns_net_u { 79 union ns_net net_e; 80 u_long long_e; 81 }; 82 83 struct ns_addr { 84 union ns_net x_net; 85 union ns_host x_host; 86 u_short x_port; 87 }; 88 89 /* 90 * Socket address, Xerox style 91 */ 92 struct sockaddr_ns { 93 u_short sns_family; 94 struct ns_addr sns_addr; 95 char sns_zero[2]; 96 }; 97 #define sns_port sns_addr.x_port 98 99 #ifdef vax 100 #define ns_netof(a) (*(long *) & ((a).x_net)) /* XXX - not needed */ 101 #endif 102 #define ns_neteqnn(a,b) (((a).s_net[0]==(b).s_net[0]) && \ 103 ((a).s_net[1]==(b).s_net[1])) 104 #define ns_neteq(a,b) ns_neteqnn((a).x_net, (b).x_net) 105 #define satons_addr(sa) (((struct sockaddr_ns *)&(sa))->sns_addr) 106 #define ns_hosteqnh(s,t) ((s).s_host[0] == (t).s_host[0] && \ 107 (s).s_host[1] == (t).s_host[1] && (s).s_host[2] == (t).s_host[2]) 108 #define ns_hosteq(s,t) (ns_hosteqnh((s).x_host,(t).x_host)) 109 #define ns_nullhost(x) (((x).x_host.s_host[0]==0) && \ 110 ((x).x_host.s_host[1]==0) && ((x).x_host.s_host[2]==0)) 111 112 #ifdef KERNEL 113 extern struct domain nsdomain; 114 union ns_host ns_thishost; 115 union ns_host ns_zerohost; 116 union ns_host ns_broadhost; 117 union ns_net ns_zeronet; 118 union ns_net ns_broadnet; 119 u_short ns_cksum(); 120 #endif 121