Leaked source code of windows server 2003
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.

101 lines
3.5 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_HOP_BY_HOP].ControlReceive =
  44. ExtHdrControlReceive;
  45. ProtocolSwitchTable[IP_PROTOCOL_V6].DataReceive = IPv6HeaderReceive;
  46. ProtocolSwitchTable[IP_PROTOCOL_ICMPv6].DataReceive = ICMPv6Receive;
  47. ProtocolSwitchTable[IP_PROTOCOL_ICMPv6].ControlReceive =
  48. ICMPv6ControlReceive;
  49. ProtocolSwitchTable[IP_PROTOCOL_FRAGMENT].DataReceive = FragmentReceive;
  50. ProtocolSwitchTable[IP_PROTOCOL_FRAGMENT].ControlReceive =
  51. ExtHdrControlReceive;
  52. ProtocolSwitchTable[IP_PROTOCOL_DEST_OPTS].DataReceive =
  53. DestinationOptionsReceive;
  54. ProtocolSwitchTable[IP_PROTOCOL_DEST_OPTS].ControlReceive =
  55. ExtHdrControlReceive;
  56. ProtocolSwitchTable[IP_PROTOCOL_ROUTING].DataReceive = RoutingReceive;
  57. ProtocolSwitchTable[IP_PROTOCOL_ROUTING].ControlReceive =
  58. ExtHdrControlReceive;
  59. ProtocolSwitchTable[IP_PROTOCOL_AH].DataReceive =
  60. AuthenticationHeaderReceive;
  61. ProtocolSwitchTable[IP_PROTOCOL_AH].ControlReceive = ExtHdrControlReceive;
  62. ProtocolSwitchTable[IP_PROTOCOL_ESP].DataReceive =
  63. EncapsulatingSecurityPayloadReceive;
  64. ProtocolSwitchTable[IP_PROTOCOL_ESP].ControlReceive = ExtHdrControlReceive;
  65. }
  66. //* IPv6RegisterULProtocol - Register an upper layer protocol with IPv6.
  67. //
  68. // Higher protocols (e.g. TCP) call this to let IP know they're there.
  69. //
  70. // This routine does not check whether or not a given protocol is already
  71. // registered, therefore it can also be used to unregister a protocol by
  72. // overwriting its entry. This is considered a feature.
  73. //
  74. // REVIEW: decide exactly what this should look like.
  75. //
  76. void
  77. IPv6RegisterULProtocol(
  78. uchar Protocol, // Protocol below handlers refer to.
  79. ProtoRecvProc *RecvHandler, // Routine to receive incoming packets.
  80. ProtoControlRecvProc *CtrlHandler) // Routine to receive control packets.
  81. {
  82. ASSERT(Protocol <= MAX_IP_PROTOCOL);
  83. ProtocolSwitchTable[Protocol].DataReceive = RecvHandler;
  84. ProtocolSwitchTable[Protocol].ControlReceive = CtrlHandler;
  85. }