netcore.h 7.2 KB

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