netcore.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. /*++
  2. Copyright (c) 2013 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. netcore.h
  5. Abstract:
  6. This header contains internal definitions for the core networking library.
  7. Author:
  8. Evan Green 4-Apr-2013
  9. --*/
  10. //
  11. // ------------------------------------------------------------------- Includes
  12. //
  13. //
  14. // Redefine the API define into an export.
  15. //
  16. #define NET_API __DLLEXPORT
  17. #include <minoca/net/netdrv.h>
  18. //
  19. // ---------------------------------------------------------------- Definitions
  20. //
  21. //
  22. // Define the allocation tag used across the networking core library.
  23. //
  24. #define NET_CORE_ALLOCATION_TAG 0x4374654E // 'CteN'
  25. //
  26. // Define the maximum number of incoming but not accepted connections that are
  27. // allowed to accumulate in a socket.
  28. //
  29. #define NET_MAX_INCOMING_CONNECTIONS 512
  30. #define NET_PRINT_ADDRESS_STRING_LENGTH 200
  31. //
  32. // ------------------------------------------------------ Data Type Definitions
  33. //
  34. //
  35. // -------------------------------------------------------------------- Globals
  36. //
  37. //
  38. // Define the global debug flag, which propagates throughout the networking
  39. // subsystem.
  40. //
  41. extern BOOL NetGlobalDebug;
  42. //
  43. // Define the list of supported socket types.
  44. //
  45. extern LIST_ENTRY NetProtocolList;
  46. extern LIST_ENTRY NetNetworkList;
  47. extern LIST_ENTRY NetDataLinkList;
  48. extern PSHARED_EXCLUSIVE_LOCK NetPluginListLock;
  49. //
  50. // Define the list of raw sockets. These do not get put in the socket trees.
  51. //
  52. extern LIST_ENTRY NetRawSocketsList;
  53. extern PSHARED_EXCLUSIVE_LOCK NetRawSocketsLock;
  54. //
  55. // -------------------------------------------------------- Function Prototypes
  56. //
  57. KSTATUS
  58. NetpInitializeNetworkLayer (
  59. VOID
  60. );
  61. /*++
  62. Routine Description:
  63. This routine initialize support for generic Network layer functionality.
  64. Arguments:
  65. None.
  66. Return Value:
  67. Status code.
  68. --*/
  69. KSTATUS
  70. NetpInitializeBuffers (
  71. VOID
  72. );
  73. /*++
  74. Routine Description:
  75. This routine initializes support for network buffers.
  76. Arguments:
  77. None.
  78. Return Value:
  79. Status code.
  80. --*/
  81. VOID
  82. NetpDestroyBuffers (
  83. VOID
  84. );
  85. /*++
  86. Routine Description:
  87. This routine destroys any allocations made during network buffer
  88. initialization.
  89. Arguments:
  90. None.
  91. Return Value:
  92. None.
  93. --*/
  94. COMPARISON_RESULT
  95. NetpCompareNetworkAddresses (
  96. PNETWORK_ADDRESS FirstAddress,
  97. PNETWORK_ADDRESS SecondAddress
  98. );
  99. /*++
  100. Routine Description:
  101. This routine compares two network addresses.
  102. Arguments:
  103. FirstAddress - Supplies a pointer to the left side of the comparison.
  104. SecondAddress - Supplies a pointer to the second side of the comparison.
  105. Return Value:
  106. Same if the two nodes have the same value.
  107. Ascending if the first node is less than the second node.
  108. Descending if the second node is less than the first node.
  109. --*/
  110. COMPARISON_RESULT
  111. NetpCompareFullyBoundSockets (
  112. PRED_BLACK_TREE Tree,
  113. PRED_BLACK_TREE_NODE FirstNode,
  114. PRED_BLACK_TREE_NODE SecondNode
  115. );
  116. /*++
  117. Routine Description:
  118. This routine compares two fully bound sockets, where both the local and
  119. remote addresses are fixed.
  120. Arguments:
  121. Tree - Supplies a pointer to the Red-Black tree that owns both nodes.
  122. FirstNode - Supplies a pointer to the left side of the comparison.
  123. SecondNode - Supplies a pointer to the second side of the comparison.
  124. Return Value:
  125. Same if the two nodes have the same value.
  126. Ascending if the first node is less than the second node.
  127. Descending if the second node is less than the first node.
  128. --*/
  129. COMPARISON_RESULT
  130. NetpCompareLocallyBoundSockets (
  131. PRED_BLACK_TREE Tree,
  132. PRED_BLACK_TREE_NODE FirstNode,
  133. PRED_BLACK_TREE_NODE SecondNode
  134. );
  135. /*++
  136. Routine Description:
  137. This routine compares two locally bound sockets, where the local address
  138. and port are fixed.
  139. Arguments:
  140. Tree - Supplies a pointer to the Red-Black tree that owns both nodes.
  141. FirstNode - Supplies a pointer to the left side of the comparison.
  142. SecondNode - Supplies a pointer to the second side of the comparison.
  143. Return Value:
  144. Same if the two nodes have the same value.
  145. Ascending if the first node is less than the second node.
  146. Descending if the second node is less than the first node.
  147. --*/
  148. COMPARISON_RESULT
  149. NetpCompareUnboundSockets (
  150. PRED_BLACK_TREE Tree,
  151. PRED_BLACK_TREE_NODE FirstNode,
  152. PRED_BLACK_TREE_NODE SecondNode
  153. );
  154. /*++
  155. Routine Description:
  156. This routine compares two unbound sockets, meaning only the local port
  157. number is known.
  158. Arguments:
  159. Tree - Supplies a pointer to the Red-Black tree that owns both nodes.
  160. FirstNode - Supplies a pointer to the left side of the comparison.
  161. SecondNode - Supplies a pointer to the second side of the comparison.
  162. Return Value:
  163. Same if the two nodes have the same value.
  164. Ascending if the first node is less than the second node.
  165. Descending if the second node is less than the first node.
  166. --*/
  167. //
  168. // Prototypes to the entry points for built in protocols.
  169. //
  170. VOID
  171. NetpUdpInitialize (
  172. VOID
  173. );
  174. /*++
  175. Routine Description:
  176. This routine initializes support for UDP sockets.
  177. Arguments:
  178. None.
  179. Return Value:
  180. None.
  181. --*/
  182. VOID
  183. NetpTcpInitialize (
  184. VOID
  185. );
  186. /*++
  187. Routine Description:
  188. This routine initializes support for TCP sockets.
  189. Arguments:
  190. None.
  191. Return Value:
  192. None.
  193. --*/
  194. VOID
  195. NetpRawInitialize (
  196. VOID
  197. );
  198. /*++
  199. Routine Description:
  200. This routine initializes support for raw sockets.
  201. Arguments:
  202. None.
  203. Return Value:
  204. None.
  205. --*/
  206. VOID
  207. NetpNetlinkGenericInitialize (
  208. ULONG Phase
  209. );
  210. /*++
  211. Routine Description:
  212. This routine initializes support for UDP sockets.
  213. Arguments:
  214. Phase - Supplies the phase of the initialization. Phase 0 happens before
  215. the networking core registers with the kernel, meaning sockets cannot
  216. be created. Phase 1 happens after the networking core has registered
  217. with the kernel allowing socket creation.
  218. Return Value:
  219. None.
  220. --*/
  221. //
  222. // Prototypes to entry points for built in networks.
  223. //
  224. VOID
  225. NetpIp4Initialize (
  226. VOID
  227. );
  228. /*++
  229. Routine Description:
  230. This routine initializes support for IPv4 packets.
  231. Arguments:
  232. None.
  233. Return Value:
  234. None.
  235. --*/
  236. VOID
  237. NetpArpInitialize (
  238. VOID
  239. );
  240. /*++
  241. Routine Description:
  242. This routine initializes support for ARP packets.
  243. Arguments:
  244. None.
  245. Return Value:
  246. None.
  247. --*/
  248. VOID
  249. NetpNetlinkInitialize (
  250. VOID
  251. );
  252. /*++
  253. Routine Description:
  254. This routine initializes support for netlink packets.
  255. Arguments:
  256. None.
  257. Return Value:
  258. None.
  259. --*/
  260. //
  261. // Prototypes to entry points for built in data link layers.
  262. //
  263. VOID
  264. NetpEthernetInitialize (
  265. VOID
  266. );
  267. /*++
  268. Routine Description:
  269. This routine initializes support for Ethernet frames.
  270. Arguments:
  271. None.
  272. Return Value:
  273. None.
  274. --*/
  275. //
  276. // Prototypes to entry points for built in components.
  277. //
  278. VOID
  279. NetpDhcpInitialize (
  280. VOID
  281. );
  282. /*++
  283. Routine Description:
  284. This routine initializes support for DHCP.
  285. Arguments:
  286. None.
  287. Return Value:
  288. None.
  289. --*/