PageRenderTime 81ms CodeModel.GetById 41ms RepoModel.GetById 0ms app.codeStats 0ms

/sys/netipx/ipx_pcb.h

https://github.com/blacklion/GEOM-Events
C Header | 150 lines | 60 code | 13 blank | 77 comment | 0 complexity | 746339cf9ec6efcb14ae90ce2cdd7d6d MD5 | raw file
  1. /*-
  2. * Copyright (c) 1984, 1985, 1986, 1987, 1993
  3. * The Regents of the University of California.
  4. * Copyright (c) 2004-2006 Robert N. M. Watson
  5. * 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. * 4. 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. * Copyright (c) 1995, Mike Mitchell
  32. * All rights reserved.
  33. *
  34. * Redistribution and use in source and binary forms, with or without
  35. * modification, are permitted provided that the following conditions
  36. * are met:
  37. * 1. Redistributions of source code must retain the above copyright
  38. * notice, this list of conditions and the following disclaimer.
  39. * 2. Redistributions in binary form must reproduce the above copyright
  40. * notice, this list of conditions and the following disclaimer in the
  41. * documentation and/or other materials provided with the distribution.
  42. * 3. All advertising materials mentioning features or use of this software
  43. * must display the following acknowledgement:
  44. * This product includes software developed by the University of
  45. * California, Berkeley and its contributors.
  46. * 4. Neither the name of the University nor the names of its contributors
  47. * may be used to endorse or promote products derived from this software
  48. * without specific prior written permission.
  49. *
  50. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  51. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  52. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  53. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  54. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  55. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  56. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  57. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  58. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  59. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  60. * SUCH DAMAGE.
  61. *
  62. * @(#)ipx_pcb.h
  63. *
  64. * $FreeBSD$
  65. */
  66. #ifndef _NETIPX_IPX_PCB_H_
  67. #define _NETIPX_IPX_PCB_H_
  68. /*
  69. * IPX protocol interface control block.
  70. */
  71. struct ipxpcb {
  72. LIST_ENTRY(ipxpcb) ipxp_list;
  73. struct socket *ipxp_socket; /* back pointer to socket */
  74. struct ipx_addr ipxp_faddr; /* destination address */
  75. struct ipx_addr ipxp_laddr; /* socket's address */
  76. caddr_t ipxp_pcb; /* protocol specific stuff */
  77. struct route ipxp_route; /* routing information */
  78. struct ipx_addr ipxp_lastdst; /* validate cached route for dg socks*/
  79. short ipxp_flags;
  80. u_char ipxp_dpt; /* default packet type for ipx_output */
  81. u_char ipxp_rpt; /* last received packet type by ipx_input() */
  82. struct mtx ipxp_mtx;
  83. };
  84. /*
  85. * Additional IPX pcb-related types and variables.
  86. */
  87. LIST_HEAD(ipxpcbhead, ipxpcb);
  88. extern struct ipxpcbhead ipxpcb_list;
  89. extern struct ipxpcbhead ipxrawpcb_list;
  90. #ifdef _KERNEL
  91. extern struct mtx ipxpcb_list_mtx;
  92. #endif
  93. /*
  94. * IPX/SPX PCB flags.
  95. */
  96. #define IPXP_IN_ABORT 0x1 /* Calling abort through socket. */
  97. #define IPXP_RAWIN 0x2 /* Show headers on input. */
  98. #define IPXP_RAWOUT 0x4 /* Show header on output. */
  99. #define IPXP_ALL_PACKETS 0x8 /* Turn off higher proto processing. */
  100. #define IPXP_CHECKSUM 0x10 /* Use checksum on this socket. */
  101. #define IPXP_DROPPED 0x20 /* Connection dropped. */
  102. #define IPXP_SPX 0x40 /* SPX PCB. */
  103. #define IPX_WILDCARD 1
  104. #define ipxp_lport ipxp_laddr.x_port
  105. #define ipxp_fport ipxp_faddr.x_port
  106. #define sotoipxpcb(so) ((struct ipxpcb *)((so)->so_pcb))
  107. /*
  108. * Nominal space allocated to an IPX socket.
  109. */
  110. #define IPXSNDQ 16384
  111. #define IPXRCVQ 40960
  112. #ifdef _KERNEL
  113. int ipx_pcballoc(struct socket *so, struct ipxpcbhead *head,
  114. struct thread *p);
  115. int ipx_pcbbind(struct ipxpcb *ipxp, struct sockaddr *nam,
  116. struct thread *p);
  117. int ipx_pcbconnect(struct ipxpcb *ipxp, struct sockaddr *nam,
  118. struct thread *p);
  119. void ipx_pcbdetach(struct ipxpcb *ipxp);
  120. void ipx_pcbdisconnect(struct ipxpcb *ipxp);
  121. void ipx_pcbfree(struct ipxpcb *ipxp);
  122. struct ipxpcb *ipx_pcblookup(struct ipx_addr *faddr, u_short lport, int wildp);
  123. void ipx_getpeeraddr(struct ipxpcb *ipxp, struct sockaddr **nam);
  124. void ipx_getsockaddr(struct ipxpcb *ipxp, struct sockaddr **nam);
  125. #define IPX_LIST_LOCK_INIT() mtx_init(&ipxpcb_list_mtx, "ipx_list_mtx", \
  126. NULL, MTX_DEF | MTX_RECURSE)
  127. #define IPX_LIST_LOCK() mtx_lock(&ipxpcb_list_mtx)
  128. #define IPX_LIST_UNLOCK() mtx_unlock(&ipxpcb_list_mtx)
  129. #define IPX_LIST_LOCK_ASSERT() mtx_assert(&ipxpcb_list_mtx, MA_OWNED)
  130. #define IPX_LOCK_INIT(ipx) mtx_init(&(ipx)->ipxp_mtx, "ipx_mtx", NULL, \
  131. MTX_DEF)
  132. #define IPX_LOCK_DESTROY(ipx) mtx_destroy(&(ipx)->ipxp_mtx)
  133. #define IPX_LOCK(ipx) mtx_lock(&(ipx)->ipxp_mtx)
  134. #define IPX_UNLOCK(ipx) mtx_unlock(&(ipx)->ipxp_mtx)
  135. #define IPX_LOCK_ASSERT(ipx) mtx_assert(&(ipx)->ipxp_mtx, MA_OWNED)
  136. #endif /* _KERNEL */
  137. #endif /* !_NETIPX_IPX_PCB_H_ */