| 1 | /*********************************************************** |
| 2 | Copyright IBM Corporation 1987 |
| 3 | |
| 4 | All Rights Reserved |
| 5 | |
| 6 | Permission to use, copy, modify, and distribute this software and its |
| 7 | documentation for any purpose and without fee is hereby granted, |
| 8 | provided that the above copyright notice appear in all copies and that |
| 9 | both that copyright notice and this permission notice appear in |
| 10 | supporting documentation, and that the name of IBM not be |
| 11 | used in advertising or publicity pertaining to distribution of the |
| 12 | software without specific, written prior permission. |
| 13 | |
| 14 | IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING |
| 15 | ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL |
| 16 | IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR |
| 17 | ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, |
| 18 | WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, |
| 19 | ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS |
| 20 | SOFTWARE. |
| 21 | |
| 22 | ******************************************************************/ |
| 23 | |
| 24 | /* |
| 25 | * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison |
| 26 | */ |
| 27 | /* $Header: iso.h,v 4.9 88/09/11 18:06:38 hagens Exp $ */ |
| 28 | /* $Source: /usr/argo/sys/netiso/RCS/iso.h,v $ */ |
| 29 | /* @(#)iso.h 7.2 (Berkeley) %G% */ |
| 30 | |
| 31 | #ifndef __ISO__ |
| 32 | #define __ISO__ |
| 33 | |
| 34 | /* |
| 35 | * Return true if this is a multicast address |
| 36 | * This assumes that the bit transmission is lsb first. This |
| 37 | * assumption is valid for 802.3 but not 802.5. There is a |
| 38 | * kludge to get around this for 802.5 -- see if_lan.c |
| 39 | * where subnetwork header is setup. |
| 40 | */ |
| 41 | #define IS_MULTICAST(snpa)\ |
| 42 | ((snpa)[0] & 0x01) |
| 43 | |
| 44 | /* |
| 45 | * Protocols |
| 46 | */ |
| 47 | #define ISOPROTO_TP0 25 /* connection oriented transport protocol */ |
| 48 | #define ISOPROTO_TP1 26 /* not implemented */ |
| 49 | #define ISOPROTO_TP2 27 /* not implemented */ |
| 50 | #define ISOPROTO_TP3 28 /* not implemented */ |
| 51 | #define ISOPROTO_TP4 29 /* connection oriented transport protocol */ |
| 52 | #define ISOPROTO_TP ISOPROTO_TP4 /* tp-4 with negotiation */ |
| 53 | #define ISOPROTO_CLTP 30 /* connectionless transport (not yet impl.) */ |
| 54 | #define ISOPROTO_CLNP 31 /* connectionless internetworking protocol */ |
| 55 | #define ISOPROTO_X25 32 /* cons */ |
| 56 | #define ISOPROTO_INACT_NL 33 /* inactive network layer! */ |
| 57 | #define ISOPROTO_ESIS 34 /* ES-IS protocol */ |
| 58 | |
| 59 | #define ISOPROTO_RAW 255 /* raw clnp */ |
| 60 | #define ISOPROTO_MAX 256 |
| 61 | |
| 62 | #define ISO_PORT_RESERVED 1024 |
| 63 | #define ISO_PORT_USERRESERVED 5000 |
| 64 | /* |
| 65 | * Port/socket numbers: standard network functions |
| 66 | * NOT PRESENTLY USED |
| 67 | */ |
| 68 | #define ISO_PORT_MAINT 501 |
| 69 | #define ISO_PORT_ECHO 507 |
| 70 | #define ISO_PORT_DISCARD 509 |
| 71 | #define ISO_PORT_SYSTAT 511 |
| 72 | #define ISO_PORT_NETSTAT 515 |
| 73 | /* |
| 74 | * Port/socket numbers: non-standard application functions |
| 75 | */ |
| 76 | #define ISO_PORT_LOGIN 513 |
| 77 | /* |
| 78 | * Port/socket numbers: public use |
| 79 | */ |
| 80 | #define ISO_PORT_PUBLIC 1024 /* high bit set --> public */ |
| 81 | |
| 82 | /* |
| 83 | * Network layer protocol identifiers |
| 84 | */ |
| 85 | #define ISO8473_CLNP 0x81 |
| 86 | #define ISO9542_ESIS 0x82 |
| 87 | #define ISO9542X25_ESIS 0x8a |
| 88 | |
| 89 | #ifndef IN_CLASSA_NET |
| 90 | #include "../netinet/in.h" |
| 91 | #endif IN_CLASSA_NET |
| 92 | |
| 93 | /* |
| 94 | * Type 37 Address |
| 95 | * |
| 96 | * This address is named for the value of its AFI (37). This format |
| 97 | * supports an X.121 address. A type 37 address has the following format: |
| 98 | * |
| 99 | * <----- idp -------> <- dsp -> |
| 100 | * <- afi -> <- idi -> <- dsp -> |
| 101 | * | "37" | 7 bytes | 9 bytes | |
| 102 | * |
| 103 | * The idi contains 14 bcd digits of X.121 address. |
| 104 | * The use of the dsp part is unknown. |
| 105 | * |
| 106 | * The afi is considered the "network" portion of the address. |
| 107 | * This means that you can't have multihoming in the x.25 environment. |
| 108 | * Makes loopback a bear. |
| 109 | */ |
| 110 | #define BIGSOCKADDRS |
| 111 | #ifdef BIGSOCKADDRS |
| 112 | #define ADDR37_IDI_LEN 7 /* 14 bcd digits == 7 octets */ |
| 113 | #define ADDR37_DSP_LEN 9 |
| 114 | #else |
| 115 | #define ADDR37_IDI_LEN 7 /* 14 bcd digits == 7 octets */ |
| 116 | #define ADDR37_DSP_LEN 3 /* this is a lie to fit in sockaddr */ |
| 117 | #endif BIGSOCKADDRS |
| 118 | struct addr_37 { |
| 119 | u_char a37_idi[ADDR37_IDI_LEN]; /* initial domain identifier */ |
| 120 | u_char a37_dsp[ADDR37_DSP_LEN]; /* domain specific part */ |
| 121 | }; |
| 122 | |
| 123 | struct ovl_37 { /* overlay for type 37 address */ |
| 124 | u_char o37_afi; /* afi */ |
| 125 | u_char o37_x121[ADDR37_IDI_LEN]; /* X.121 address */ |
| 126 | u_char o37_dsp[ADDR37_DSP_LEN]; /* unknown use at this time */ |
| 127 | }; |
| 128 | |
| 129 | /* |
| 130 | * OSINET address |
| 131 | * |
| 132 | * This style address is used by the OSINET group |
| 133 | * An OSINET address has the following (variable-length) format |
| 134 | * |
| 135 | * <----- idp -------> <---------------- dsp ---------------------------> |
| 136 | * <- afi -> <- idi -> <---------------- dsp ---------------------------> |
| 137 | * | "47" | "0004" | 11 bytes | |
| 138 | * | afi(1)| osinetid | orgid(2) | subnet id(2) | (4-8) | nsap sel(1) | |
| 139 | * |
| 140 | * the afi, orgid, and subnet id are considered the "network" portion of |
| 141 | * the address. |
| 142 | */ |
| 143 | #ifdef BIGSOCKADDRS |
| 144 | #define ADDROSINET_IDI_LEN 2 |
| 145 | #define ADDROSINET_DSP_LEN 11 |
| 146 | #else |
| 147 | #define ADDROSINET_IDI_LEN 2 |
| 148 | #define ADDROSINET_DSP_LEN 8 /* this is a lie to fit in sockaddr */ |
| 149 | #endif BIGSOCKADDRS |
| 150 | struct addr_osinet { |
| 151 | u_char aosi_idi[ADDROSINET_IDI_LEN]; /* initial domain identifier */ |
| 152 | u_char aosi_dsp[ADDROSINET_DSP_LEN]; /* domain specific part */ |
| 153 | }; |
| 154 | |
| 155 | #define OVLOSINET_ID_LEN 2 |
| 156 | #ifdef BIGSOCKADDRS |
| 157 | #define OVLOSINET_ORGID_LEN 2 |
| 158 | #define OVLOSINET_SNETID_LEN 2 |
| 159 | #define OVLOSINET_SNPA_LEN 8 |
| 160 | #define OVLOSINET_NSAP_LEN 1 |
| 161 | #else |
| 162 | #define OVLOSINET_ORGID_LEN 2 |
| 163 | #define OVLOSINET_SNETID_LEN 2 |
| 164 | #define OVLOSINET_SNPA_LEN 5 /* this is a lie to fit in sockaddr */ |
| 165 | #define OVLOSINET_NSAP_LEN 1 |
| 166 | #endif BIGSOCKADDRS |
| 167 | struct ovl_osinet { /* overlay for osinet address */ |
| 168 | u_char oosi_afi; /* afi */ |
| 169 | u_char oosi_id[OVLOSINET_ID_LEN]; /* osinet id */ |
| 170 | u_char oosi_orgid[OVLOSINET_ORGID_LEN]; /* orgid */ |
| 171 | u_char oosi_snetid[OVLOSINET_SNETID_LEN]; /* subnet id */ |
| 172 | u_char oosi_snpa[OVLOSINET_SNPA_LEN]; /* snpa */ |
| 173 | u_char oosi_nsap[OVLOSINET_NSAP_LEN]; /* nsap sel */ |
| 174 | }; |
| 175 | |
| 176 | /* |
| 177 | * RFC 986 address |
| 178 | * |
| 179 | * This style address is used when DOD internet addresses are used |
| 180 | * The format of rfc986 addresses is: |
| 181 | * |
| 182 | * <----- idp -------> <---------------- dsp --------------------> |
| 183 | * <- afi -> <- idi -> <---------------- dsp --------------------> |
| 184 | * | "47" | "0006" | 6 bytes | |
| 185 | * | afi(1)| idi(2) | version (1) | inet addr (4) | proto id(1) | |
| 186 | * |
| 187 | * the afi, idi, and network portion of the inet address are considered |
| 188 | * the "network" portion of the address. |
| 189 | */ |
| 190 | #define ADDRRFC986_IDI_LEN 2 |
| 191 | #define ADDRRFC986_DSP_LEN 6 |
| 192 | struct addr_rfc986 { |
| 193 | u_char a986_idi[ADDRRFC986_IDI_LEN]; /* initial domain identifier */ |
| 194 | u_char a986_dsp[ADDRRFC986_DSP_LEN]; /* domain specific part */ |
| 195 | }; |
| 196 | |
| 197 | #define OVLRFC986_INET_LEN 4 |
| 198 | struct ovl_rfc986 { |
| 199 | u_char o986_afi; /* afi */ |
| 200 | u_char o986_idi[ADDRRFC986_IDI_LEN]; /* idi */ |
| 201 | u_char o986_vers; /* version */ |
| 202 | u_char o986_inetaddr[OVLRFC986_INET_LEN]; /* internet address */ |
| 203 | u_char o986_upid; /* upper protocol id */ |
| 204 | }; |
| 205 | #define RFC986V1 0x01 /* version of 986 addr */ |
| 206 | |
| 207 | #define AFI_37 0x37 /* bcd of "37" */ |
| 208 | #define AFI_OSINET 0x47 /* bcd of "47" */ |
| 209 | #define AFI_RFC986 0x47 /* bcd of "47" */ |
| 210 | #define AFI_SNA 0x00 /* SubNetwork Address; invalid really... |
| 211 | - used by ES-IS */ |
| 212 | |
| 213 | /* the idi for type 37 addresses is very different than the others */ |
| 214 | #define IDI_OSINET 0x0004 /* bcd of "0004" */ |
| 215 | #define IDI_RFC986 0x0006 /* bcd of "0006" */ |
| 216 | |
| 217 | /* |
| 218 | * This address type is used to store a subnetwork address in a |
| 219 | * sockaddr_iso. The isoa_len field should contain the length of the |
| 220 | * subnetwork address plus the length of the afi (ie +1 ). |
| 221 | * |
| 222 | * This address format is used only by the ES-IS protocol |
| 223 | */ |
| 224 | #define ADDRSNA_IDI_LEN 7 |
| 225 | struct addr_sn { |
| 226 | char sna_addr[ADDRSNA_IDI_LEN]; /* subnetwork address */ |
| 227 | }; |
| 228 | |
| 229 | /* |
| 230 | * Type 47 is the biggest address: 11 bytes. The length of iso_addr |
| 231 | * is 13 bytes. |
| 232 | */ |
| 233 | struct old_iso_addr { |
| 234 | u_char isoa_afi; /* authority and format id */ |
| 235 | union { |
| 236 | struct addr_37 addr_37; /* type 37 */ |
| 237 | struct addr_osinet addr_osinet; /* type osinet */ |
| 238 | struct addr_rfc986 addr_rfc986; /* type rfc986 */ |
| 239 | struct addr_sn addr_sn; /* subnetwork address */ |
| 240 | } isoa_u; |
| 241 | u_char isoa_len; /* length (in bytes) */ |
| 242 | }; |
| 243 | |
| 244 | /* The following looks like a sockaddr |
| 245 | * in case we decide to use tree routines */ |
| 246 | struct iso_addr { |
| 247 | u_char isoa_len; /* length (in bytes) */ |
| 248 | char isoa_genaddr[20]; /* general opaque address */ |
| 249 | }; |
| 250 | |
| 251 | #define t37_idi isoa_u.addr_37.a37_idi |
| 252 | #define t37_dsp isoa_u.addr_37.a37_dsp |
| 253 | #define osinet_idi isoa_u.addr_osinet.aosi_idi |
| 254 | #define osinet_dsp isoa_u.addr_osinet.aosi_dsp |
| 255 | #define rfc986_idi isoa_u.addr_rfc986.a986_idi |
| 256 | #define rfc986_dsp isoa_u.addr_rfc986.a986_dsp |
| 257 | #define sna_idi isoa_u.addr_sn.sna_addr |
| 258 | |
| 259 | /* |
| 260 | * An iso_addr is 18 bytes, a sockaddr_iso is therefore 20 bytes. |
| 261 | * the struct sockaddr data field has been changed to 22 bytes. |
| 262 | * |
| 263 | * severly changed osinet and t37 addresses from argo code, we don't want |
| 264 | * sockaddrs to grow bigger than the original 16 bytes so we changed the |
| 265 | * t37 and osinet addresses so that they were only 10 bytes long |
| 266 | */ |
| 267 | struct sockaddr_iso { |
| 268 | u_char siso_len; /* length */ |
| 269 | u_char siso_family; /* family */ |
| 270 | u_char siso_ssuffixlen; /* session suffix len */ |
| 271 | u_char siso_tsuffixlen; /* transport suffix len */ |
| 272 | /* u_char siso_nsaptype; /* someday?? */ |
| 273 | struct iso_addr siso_addr; /* network address */ |
| 274 | u_char siso_pad[3]; /* make multiple of sizeof long */ |
| 275 | }; |
| 276 | |
| 277 | #define siso_data siso_addr.isoa_genaddr |
| 278 | #define siso_nlen siso_addr.isoa_len |
| 279 | #define TSEL(s) ((caddr_t)((s)->siso_data + (s)->siso_nlen)) |
| 280 | |
| 281 | #define SAME_ISOADDR(a, b) \ |
| 282 | (bcmp((a)->siso_data, (b)->siso_data, (unsigned)(a)->siso_nlen)==0) |
| 283 | |
| 284 | #define NSAPTYPE_UNKNOWN -1 |
| 285 | #define NSAPTYPE_INET 0 |
| 286 | #define NSAPTYPE_X121BCD 1 |
| 287 | #define NSAPTYPE_X121BIN 2 |
| 288 | #define NSAPTYPE_DCCBCD 3 |
| 289 | #define NSAPTYPE_DCCBIN 4 |
| 290 | #define NSAPTYPE_OSINET 5 |
| 291 | #define NSAPTYPE_RFC986 6 |
| 292 | |
| 293 | #ifdef KERNEL |
| 294 | |
| 295 | extern int iso_netmatch(); |
| 296 | extern int iso_hash(); |
| 297 | extern int iso_addrmatch(); |
| 298 | extern struct iso_ifaddr *iso_iaonnetof(); |
| 299 | extern struct domain isodomain; |
| 300 | extern struct protosw isosw[]; |
| 301 | |
| 302 | #else |
| 303 | /* user utilities definitions from the iso library */ |
| 304 | |
| 305 | char *iso_ntoa(); |
| 306 | struct hostent *iso_gethostbyname(), *iso_gethostbyaddr(); |
| 307 | |
| 308 | #endif KERNEL |
| 309 | |
| 310 | #endif __ISO__ |
| 311 | #define _offsetof(t, m) ((int)((caddr_t)&((t *)0)->m)) |