PageRenderTime 48ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/DE2_115_WEB_SERVER_RGMII_ENET0/Software/web_bsp/iniche/src/tcp/protosw.h

https://gitlab.com/rainbowguardians/RainbowHard
C Header | 239 lines | 103 code | 26 blank | 110 comment | 0 complexity | 280f67992bbb7bedbba6f7ed23692e96 MD5 | raw file
  1. /*
  2. * FILENAME: protosw.h
  3. *
  4. * Copyright 1997-2007 By InterNiche Technologies, Inc. All rights reserved.
  5. *
  6. * Protocol switch table.
  7. *
  8. * Each protocol has a handle initializing one of these structures,
  9. * which is used for protocol-protocol and system-protocol communication.
  10. *
  11. * A protocol is called through the pr_init entry before any other.
  12. * Thereafter it is called every 200ms through the pr_fasttimo entry and
  13. * every 500ms through the pr_slowtimo for timer based actions.
  14. * The system will call the pr_drain entry if it is low on space and
  15. * this should throw away any non-critical data.
  16. *
  17. * Protocols pass data between themselves as chains of mbufs using
  18. * the pr_input and pr_output hooks. Pr_input passes data up (towards
  19. * UNIX) and pr_output passes it down (towards the imps); control
  20. * information passes up and down on pr_ctlinput and pr_ctloutput.
  21. * The protocol is responsible for the space occupied by any the
  22. * arguments to these entries and must dispose it.
  23. *
  24. * The userreq routine interfaces protocols to the system and is
  25. * described below.
  26. *
  27. * MODULE: INET
  28. *
  29. * PORTABLE: yes
  30. */
  31. /* Additional Copyrights: */
  32. /*
  33. * Copyright (c) 1982, 1986 Regents of the University of California.
  34. * All rights reserved.
  35. *
  36. * Redistribution and use in source and binary forms, with or without
  37. * modification, are permitted provided that the following conditions
  38. * are met:
  39. * 1. Redistributions of source code must retain the above copyright
  40. * notice, this list of conditions and the following disclaimer.
  41. * 2. Redistributions in binary form must reproduce the above copyright
  42. * notice, this list of conditions and the following disclaimer in the
  43. * documentation and/or other materials provided with the distribution.
  44. * 3. [rescinded 22 July 1999]
  45. * 4. Neither the name of the University nor the names of its contributors
  46. * may be used to endorse or promote products derived from this software
  47. * without specific prior written permission.
  48. *
  49. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  50. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  51. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  52. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  53. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  54. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  55. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  56. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  57. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  58. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  59. * SUCH DAMAGE.
  60. */
  61. #ifndef PROTOSW_H
  62. #define PROTOSW_H 1
  63. struct ifnet; /* pre-declaration to supress warnings */
  64. struct protosw
  65. {
  66. short pr_type; /* socket type used for */
  67. short pr_protocol; /* protocol number */
  68. short pr_flags; /* see below */
  69. /* protocol-protocol hooks */
  70. void (*pr_input) __P ((struct mbuf *, NET ifp));
  71. #ifdef CTL_INPUT
  72. /* input to protocol (from below) */
  73. void (*pr_ctlinput)__P ((int, struct sockaddr *));
  74. /* control input (from below) */
  75. #endif
  76. #ifdef CTL_OUTPUT
  77. /* control output (from above) */
  78. int (*pr_ctloutput) __P((int, struct socket *, int, int, void *));
  79. #endif
  80. /* user-protocol hook */
  81. int (*pr_usrreq) __P ((struct socket *, struct mbuf *, struct mbuf *));
  82. /* user request: see list below */
  83. /* utility hooks */
  84. void (*pr_init) __P ((void)); /* initialization hook */
  85. #ifdef DO_DELAY_ACKS
  86. int (*pr_fasttimo) __P ((void)); /* fast timeout (200ms) */
  87. #endif
  88. void (*pr_slowtimo) __P ((void)); /* slow timeout (500ms) */
  89. };
  90. /*
  91. * Values for pr_flags
  92. */
  93. #define PR_ATOMIC 0x01 /* exchange atomic messages only */
  94. #define PR_ADDR 0x02 /* addresses given with messages */
  95. /* in the current implementation, PR_ADDR needs PR_ATOMIC to work */
  96. #define PR_CONNREQUIRED 0x04 /* connection required by protocol */
  97. #define PR_WANTRCVD 0x08 /* want PRU_RCVD calls */
  98. #define PR_RIGHTS 0x10 /* passes capabilities */
  99. /*
  100. * The arguments to usrreq are:
  101. * (*protosw[].pr_usrreq)(up, req, m, nam, opt);
  102. * where up is a (struct socket *), req is one of these requests,
  103. * m is a optional mbuf chain containing a message,
  104. * nam is an optional mbuf chain containing an address,
  105. * and opt is a pointer to a socketopt structure or nil.
  106. * The protocol is responsible for disposal of the mbuf chain m,
  107. * the caller is responsible for any space held by nam and opt.
  108. * A non-zero return from usrreq gives an
  109. * UNIX error number which should be passed to higher level software.
  110. */
  111. #define PRU_ATTACH 0 /* attach protocol to up */
  112. #define PRU_DETACH 1 /* detach protocol from up */
  113. #define PRU_BIND 2 /* bind socket to address */
  114. #define PRU_LISTEN 3 /* listen for connection */
  115. #define PRU_CONNECT 4 /* establish connection to peer */
  116. #define PRU_ACCEPT 5 /* accept connection from peer */
  117. #define PRU_DISCONNECT 6 /* disconnect from peer */
  118. #define PRU_SHUTDOWN 7 /* won't send any more data */
  119. #define PRU_RCVD 8 /* have taken data; more room now */
  120. #define PRU_SEND 9 /* send this data */
  121. #define PRU_ABORT 10 /* abort (fast DISCONNECT, DETATCH) */
  122. #define PRU_CONTROL 11 /* control operations on protocol */
  123. #define PRU_SENSE 12 /* return status into m */
  124. #define PRU_RCVOOB 13 /* retrieve out of band data */
  125. #define PRU_SENDOOB 14 /* send out of band data */
  126. #define PRU_SOCKADDR 15 /* fetch socket's address */
  127. #define PRU_PEERADDR 16 /* fetch peer's address */
  128. #define PRU_CONNECT2 17 /* connect two sockets */
  129. /* begin for protocols internal use */
  130. #define PRU_FASTTIMO 18 /* 200ms timeout */
  131. #define PRU_SLOWTIMO 19 /* 500ms timeout */
  132. #define PRU_PROTORCV 20 /* receive from below */
  133. #define PRU_PROTOSEND 21 /* send to below */
  134. #define PRU_NREQ 21
  135. #ifdef PRUREQUESTS
  136. char * prurequests[] = {
  137. "ATTACH", "DETACH", "BIND", "LISTEN",
  138. "CONNECT", "ACCEPT", "DISCONNECT", "SHUTDOWN",
  139. "RCVD", "SEND", "ABORT", "CONTROL",
  140. "SENSE", "RCVOOB", "SENDOOB", "SOCKADDR",
  141. "PEERADDR", "CONNECT2", "FASTTIMO", "SLOWTIMO",
  142. "PROTORCV", "PROTOSEND",
  143. };
  144. #endif
  145. /*
  146. * The arguments to the ctlinput routine are
  147. * (*protosw[].pr_ctlinput)(cmd, arg);
  148. * where cmd is one of the commands below, and arg is
  149. * an optional argument (caddr_t).
  150. *
  151. * N.B. The IMP code, in particular, pressumes the values
  152. * of some of the commands; change with extreme care.
  153. * TODO:
  154. * spread out codes so new ICMP codes can be
  155. * accomodated more easily
  156. */
  157. #define PRC_IFDOWN 0 /* interface transition */
  158. #define PRC_ROUTEDEAD 1 /* select new route if possible */
  159. #define PRC_QUENCH 4 /* some said to slow down */
  160. #define PRC_MSGSIZE 5 /* message size forced drop */
  161. #define PRC_HOSTDEAD 6 /* normally from IMP */
  162. #define PRC_HOSTUNREACH 7 /* ditto */
  163. #define PRC_UNREACH_NET 8 /* no route to network */
  164. #define PRC_UNREACH_HOST 9 /* no route to host */
  165. #define PRC_UNREACH_PROTOCOL 10 /* dst says bad protocol */
  166. #define PRC_UNREACH_PORT 11 /* bad port # */
  167. #define PRC_UNREACH_NEEDFRAG 12 /* IP_DF caused drop */
  168. #define PRC_UNREACH_SRCFAIL 13 /* source route failed */
  169. #define PRC_REDIRECT_NET 14 /* net routing redirect */
  170. #define PRC_REDIRECT_HOST 15 /* host routing redirect */
  171. #define PRC_REDIRECT_TOSNET 16 /* redirect for type of service & net */
  172. #define PRC_REDIRECT_TOSHOST 17 /* redirect for tos & host */
  173. #define PRC_TIMXCEED_INTRANS 18 /* packet lifetime expired in transit */
  174. #define PRC_TIMXCEED_REASS 19 /* lifetime expired on reass q */
  175. #define PRC_PARAMPROB 20 /* header incorrect */
  176. #define PRC_NCMDS 21
  177. #ifdef PRCREQUESTS
  178. char * prcrequests[] = {
  179. "IFDOWN", "ROUTEDEAD", "#2", "#3",
  180. "QUENCH", "MSGSIZE", "HOSTDEAD", "HOSTUNREACH",
  181. "NET-UNREACH", "HOST-UNREACH", "PROTO-UNREACH", "PORT-UNREACH",
  182. "FRAG-UNREACH", "SRCFAIL-UNREACH", "NET-REDIRECT", "HOST-REDIRECT",
  183. "TOSNET-REDIRECT", "TOSHOST-REDIRECT", "TX-INTRANS", "TX-REASS",
  184. "PARAMPROB"
  185. };
  186. #endif
  187. /*
  188. * The arguments to ctloutput are:
  189. * (*protosw[].pr_ctloutput)(req, so, level, optname, optval);
  190. * req is one of the actions listed below, so is a (struct socket *),
  191. * level is an indication of which protocol layer the option is intended.
  192. * optname is a protocol dependent socket option request,
  193. * optval is a pointer to a mbuf-chain pointer, for value-return results.
  194. * The protocol is responsible for disposal of the mbuf chain *optval
  195. * if supplied,
  196. * the caller is responsible for any space held by *optval, when returned.
  197. * A non-zero return from usrreq gives an
  198. * UNIX error number which should be passed to higher level software.
  199. */
  200. #define PRCO_GETOPT 0
  201. #define PRCO_SETOPT 1
  202. #define PRCO_NCMDS 2
  203. #ifdef PRCOREQUESTS
  204. char * prcorequests[] =
  205. {
  206. "GETOPT",
  207. "SETOPT",
  208. };
  209. #endif
  210. extern struct protosw * pffindtype __P ((int, int));
  211. extern struct protosw * pffindproto __P ((int, int, int));
  212. #endif /* PROTOSW_H */
  213. /* end of file protosw.h */