iso.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /* $NetBSD: iso.h,v 1.13 2000/07/28 12:13:34 kleink Exp $ */
  2. /*-
  3. * Copyright (c) 1991, 1993
  4. * The Regents of the University of California. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. All advertising materials mentioning features or use of this software
  15. * must display the following acknowledgement:
  16. * This product includes software developed by the University of
  17. * California, Berkeley and its contributors.
  18. * 4. Neither the name of the University nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  23. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  28. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  29. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  31. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  32. * SUCH DAMAGE.
  33. *
  34. * @(#)iso.h 8.1 (Berkeley) 6/10/93
  35. */
  36. /***********************************************************
  37. Copyright IBM Corporation 1987
  38. All Rights Reserved
  39. Permission to use, copy, modify, and distribute this software and its
  40. documentation for any purpose and without fee is hereby granted,
  41. provided that the above copyright notice appear in all copies and that
  42. both that copyright notice and this permission notice appear in
  43. supporting documentation, and that the name of IBM not be
  44. used in advertising or publicity pertaining to distribution of the
  45. software without specific, written prior permission.
  46. IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  47. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  48. IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  49. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  50. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  51. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  52. SOFTWARE.
  53. ******************************************************************/
  54. /*
  55. * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
  56. */
  57. #ifndef _NETISO_ISO_H_
  58. #define _NETISO_ISO_H_
  59. #if 0
  60. #include <sys/ansi.h>
  61. #endif
  62. #if 0
  63. #ifndef sa_family_t
  64. typedef __sa_family_t sa_family_t;
  65. #define sa_family_t __sa_family_t
  66. #endif
  67. #endif
  68. /*
  69. * Return true if this is a multicast address
  70. * This assumes that the bit transmission is lsb first. This
  71. * assumption is valid for 802.3 but not 802.5. There is a
  72. * kludge to get around this for 802.5 -- see if_lan.c
  73. * where subnetwork header is setup.
  74. */
  75. #define IS_MULTICAST(snpa)\
  76. ((snpa)[0] & 0x01)
  77. /*
  78. * Protocols
  79. */
  80. #define ISOPROTO_TCP 6 /* IETF experiment */
  81. #define ISOPROTO_UDP 17 /* IETF experiment */
  82. #define ISOPROTO_TP0 25 /* connection oriented transport protocol */
  83. #define ISOPROTO_TP1 26 /* not implemented */
  84. #define ISOPROTO_TP2 27 /* not implemented */
  85. #define ISOPROTO_TP3 28 /* not implemented */
  86. #define ISOPROTO_TP4 29 /* connection oriented transport protocol */
  87. #define ISOPROTO_TP ISOPROTO_TP4 /* tp-4 with negotiation */
  88. #define ISOPROTO_CLTP 30 /* connectionless transport (not yet impl.) */
  89. #define ISOPROTO_CLNP 31 /* connectionless internetworking protocol */
  90. #define ISOPROTO_X25 32 /* cons */
  91. #define ISOPROTO_INACT_NL 33 /* inactive network layer! */
  92. #define ISOPROTO_ESIS 34 /* ES-IS protocol */
  93. #define ISOPROTO_INTRAISIS 35 /* IS-IS protocol */
  94. #define ISOPROTO_IDRP 36 /* Interdomain Routing Protocol */
  95. #define ISOPROTO_RAW 255 /* raw clnp */
  96. #define ISOPROTO_MAX 256
  97. #define ISO_PORT_RESERVED 1024
  98. #define ISO_PORT_USERRESERVED 5000
  99. /*
  100. * Port/socket numbers: standard network functions
  101. * NOT PRESENTLY USED
  102. */
  103. #define ISO_PORT_MAINT 501
  104. #define ISO_PORT_ECHO 507
  105. #define ISO_PORT_DISCARD 509
  106. #define ISO_PORT_SYSTAT 511
  107. #define ISO_PORT_NETSTAT 515
  108. /*
  109. * Port/socket numbers: non-standard application functions
  110. */
  111. #define ISO_PORT_LOGIN 513
  112. /*
  113. * Port/socket numbers: public use
  114. */
  115. #define ISO_PORT_PUBLIC 1024 /* high bit set --> public */
  116. /*
  117. * Network layer protocol identifiers
  118. */
  119. #define ISO8473_CLNP 0x81
  120. #define ISO9542_ESIS 0x82
  121. #define ISO9542X25_ESIS 0x8a
  122. #define ISO10589_ISIS 0x83
  123. #define ISO8878A_CONS 0x84
  124. #define ISO10747_IDRP 0x85
  125. #ifndef IN_CLASSA_NET
  126. #include <netinet/in.h>
  127. #endif /* IN_CLASSA_NET */
  128. /*
  129. * The following looks like a sockaddr to facilitate using tree lookup
  130. * routines
  131. */
  132. struct iso_addr {
  133. u_char isoa_len; /* length (in bytes) */
  134. char isoa_genaddr[20]; /* general opaque address */
  135. };
  136. struct sockaddr_iso {
  137. u_char siso_len; /* length */
  138. sa_family_t siso_family; /* family */
  139. u_char siso_plen; /* presentation selector length */
  140. u_char siso_slen; /* session selector length */
  141. u_char siso_tlen; /* transport selector length */
  142. struct iso_addr siso_addr; /* network address */
  143. u_char siso_pad[6]; /* space for gosip v2 sels */
  144. /* makes struct 32 bytes long */
  145. };
  146. #define siso_nlen siso_addr.isoa_len
  147. #define siso_data siso_addr.isoa_genaddr
  148. #define TSEL(s) ((caddr_t)((s)->siso_data + (s)->siso_nlen))
  149. #define SAME_ISOADDR(a, b) \
  150. (bcmp((a)->siso_data, (b)->siso_data, (unsigned)(a)->siso_nlen)==0)
  151. #define SAME_ISOIFADDR(a, b) (bcmp((a)->siso_data, (b)->siso_data, \
  152. (unsigned)((b)->siso_nlen - (b)->siso_tlen)) == 0)
  153. /*
  154. * The following are specific values for siso->siso_data[0],
  155. * otherwise known as the AFI:
  156. */
  157. #define AFI_37 0x37 /* bcd of "37" */
  158. #define AFI_OSINET 0x47 /* bcd of "47" */
  159. #define AFI_RFC986 0x47 /* bcd of "47" */
  160. #define AFI_SNA 0x00 /* SubNetwork Address; invalid really... */
  161. #ifdef _KERNEL
  162. extern struct domain isodomain;
  163. extern struct protosw isosw[];
  164. #define satosiso(sa) ((struct sockaddr_iso *)(sa))
  165. #define sisotosa(siso) ((struct sockaddr *)(siso))
  166. #else
  167. /* user utilities definitions from the iso library */
  168. #ifndef HAVE_SYS_CDEFS_H
  169. #define __P(x) x
  170. #define __BEGIN_DECLS
  171. #define __END_DECLS
  172. #else
  173. #include <sys/cdefs.h>
  174. #endif
  175. __BEGIN_DECLS
  176. struct iso_addr *iso_addr __P((const char *));
  177. char *iso_ntoa __P((const struct iso_addr *));
  178. /* THESE DON'T EXIST YET */
  179. struct hostent *iso_gethostbyname __P((const char *));
  180. struct hostent *iso_gethostbyaddr __P((const char *, int, int));
  181. __END_DECLS
  182. #endif /* _KERNEL */
  183. #endif /* _NETISO_ISO_H_ */