Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
3.3 KiB

  1. // -*- mode: C++; tab-width: 4; indent-tabs-mode: nil -*- (for GNU Emacs)
  2. //
  3. // Copyright (c) 1998-2000 Microsoft Corporation
  4. //
  5. // This file is part of the Microsoft Research IPv6 Network Protocol Stack.
  6. // You should have received a copy of the Microsoft End-User License Agreement
  7. // for this software along with this release; see the file "license.txt".
  8. // If not, please see http://www.research.microsoft.com/msripv6/license.htm,
  9. // or write to Microsoft Research, One Microsoft Way, Redmond, WA 98052-6399.
  10. //
  11. // Abstract:
  12. //
  13. // Protocol switch table for Internet Protocol Version 6.
  14. //
  15. #include "oscfg.h"
  16. #include "ndis.h"
  17. #include "ip6imp.h"
  18. #include "ip6def.h"
  19. //
  20. // The Protocol Switch Table is an array of handlers, one for
  21. // each possible value of the IPv6 Next Header field.
  22. //
  23. ProtocolSwitch ProtocolSwitchTable[MAX_IP_PROTOCOL + 1];
  24. //* ProtoTabInit - Initialize the Protocol Switch Table.
  25. //
  26. // Called during IPv6 initialization.
  27. //
  28. void
  29. ProtoTabInit(void)
  30. {
  31. //
  32. // Null entries will cause ICMP error messages to be sent for
  33. // the unknown header types.
  34. //
  35. RtlZeroMemory(ProtocolSwitchTable, sizeof(ProtocolSwitchTable));
  36. //
  37. // Define the fixed entries required by the IPv6 specification.
  38. // Other protocols must register with us via IPv6RegisterULProtocol.
  39. //
  40. // Note that HopByHopOptionsReceive is not here because
  41. // it gets special treatment in IPv6Receive.
  42. //
  43. ProtocolSwitchTable[IP_PROTOCOL_V6].DataReceive = IPv6HeaderReceive;
  44. ProtocolSwitchTable[IP_PROTOCOL_ICMPv6].DataReceive = ICMPv6Receive;
  45. ProtocolSwitchTable[IP_PROTOCOL_ICMPv6].ControlReceive =
  46. ICMPv6ControlReceive;
  47. ProtocolSwitchTable[IP_PROTOCOL_FRAGMENT].DataReceive = FragmentReceive;
  48. ProtocolSwitchTable[IP_PROTOCOL_FRAGMENT].ControlReceive =
  49. ExtHdrControlReceive;
  50. ProtocolSwitchTable[IP_PROTOCOL_DEST_OPTS].DataReceive =
  51. DestinationOptionsReceive;
  52. ProtocolSwitchTable[IP_PROTOCOL_DEST_OPTS].ControlReceive =
  53. ExtHdrControlReceive;
  54. ProtocolSwitchTable[IP_PROTOCOL_ROUTING].DataReceive = RoutingReceive;
  55. ProtocolSwitchTable[IP_PROTOCOL_ROUTING].ControlReceive =
  56. ExtHdrControlReceive;
  57. ProtocolSwitchTable[IP_PROTOCOL_AH].DataReceive =
  58. AuthenticationHeaderReceive;
  59. ProtocolSwitchTable[IP_PROTOCOL_AH].ControlReceive = ExtHdrControlReceive;
  60. ProtocolSwitchTable[IP_PROTOCOL_ESP].DataReceive =
  61. EncapsulatingSecurityPayloadReceive;
  62. ProtocolSwitchTable[IP_PROTOCOL_ESP].ControlReceive = ExtHdrControlReceive;
  63. }
  64. //* IPv6RegisterULProtocol - Register an upper layer protocol with IPv6.
  65. //
  66. // Higher protocols (e.g. TCP) call this to let IP know they're there.
  67. //
  68. // This routine does not check whether or not a given protocol is already
  69. // registered, therefore it can also be used to unregister a protocol by
  70. // overwriting its entry. This is considered a feature.
  71. //
  72. // REVIEW: decide exactly what this should look like.
  73. //
  74. void
  75. IPv6RegisterULProtocol(
  76. uchar Protocol, // Protocol below handlers refer to.
  77. ProtoRecvProc *RecvHandler, // Routine to receive incoming packets.
  78. ProtoControlRecvProc *CtrlHandler) // Routine to receive control packets.
  79. {
  80. ASSERT(Protocol <= MAX_IP_PROTOCOL);
  81. ProtocolSwitchTable[Protocol].DataReceive = RecvHandler;
  82. ProtocolSwitchTable[Protocol].ControlReceive = CtrlHandler;
  83. }