Ip6If.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. /** @file
  2. Definition for IP6 pseudo interface structure.
  3. Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef __EFI_IP6_IF_H__
  7. #define __EFI_IP6_IF_H__
  8. #define IP6_LINK_RX_SIGNATURE SIGNATURE_32 ('I', 'P', '6', 'R')
  9. #define IP6_LINK_TX_SIGNATURE SIGNATURE_32 ('I', 'P', '6', 'T')
  10. #define IP6_INTERFACE_SIGNATURE SIGNATURE_32 ('I', 'P', '6', 'I')
  11. #define IP6_ADDR_INFO_SIGNATURE SIGNATURE_32 ('I', 'P', 'A', 'I')
  12. //
  13. // This prototype is used by both receive and transmission.
  14. // When receiving Netbuf is allocated by IP6_INTERFACE, and
  15. // released by IP6. Flag shows whether the frame is received
  16. // as unicast/multicast/anycast...
  17. //
  18. // When transmitting, the Netbuf is from IP6, and provided
  19. // to the callback as a reference. Flag isn't used.
  20. //
  21. // IpInstance can be NULL which means that it is the IP6 driver
  22. // itself sending the packets. IP6 driver may send packets that
  23. // don't belong to any instance, such as ICMP errors, ICMP
  24. // informational packets. IpInstance is used as a tag in
  25. // this module.
  26. //
  27. typedef
  28. VOID
  29. (*IP6_FRAME_CALLBACK) (
  30. NET_BUF *Packet,
  31. EFI_STATUS IoStatus,
  32. UINT32 LinkFlag,
  33. VOID *Context
  34. );
  35. //
  36. // Each receive request is wrapped in an IP6_LINK_RX_TOKEN.
  37. // Upon completion, the Callback will be called. Only one
  38. // receive request is send to MNP. IpInstance is always NULL.
  39. // Reference MNP's spec for information.
  40. //
  41. typedef struct {
  42. UINT32 Signature;
  43. IP6_FRAME_CALLBACK CallBack;
  44. VOID *Context;
  45. EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken;
  46. } IP6_LINK_RX_TOKEN;
  47. //
  48. // Each transmit request is wrapped in an IP6_LINK_TX_TOKEN.
  49. // Upon completion, the Callback will be called.
  50. //
  51. typedef struct {
  52. UINT32 Signature;
  53. LIST_ENTRY Link;
  54. IP6_PROTOCOL *IpInstance;
  55. IP6_FRAME_CALLBACK CallBack;
  56. NET_BUF *Packet;
  57. VOID *Context;
  58. EFI_MAC_ADDRESS DstMac;
  59. EFI_MAC_ADDRESS SrcMac;
  60. EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken;
  61. EFI_MANAGED_NETWORK_TRANSMIT_DATA MnpTxData;
  62. } IP6_LINK_TX_TOKEN;
  63. struct _IP6_ADDRESS_INFO {
  64. UINT32 Signature;
  65. LIST_ENTRY Link;
  66. EFI_IPv6_ADDRESS Address;
  67. BOOLEAN IsAnycast;
  68. UINT8 PrefixLength;
  69. UINT32 ValidLifetime;
  70. UINT32 PreferredLifetime;
  71. };
  72. //
  73. // Callback to select which frame to cancel. Caller can cancel a
  74. // single frame, or all the frame from an IP instance.
  75. //
  76. typedef
  77. BOOLEAN
  78. (*IP6_FRAME_TO_CANCEL) (
  79. IP6_LINK_TX_TOKEN *Frame,
  80. VOID *Context
  81. );
  82. struct _IP6_INTERFACE {
  83. UINT32 Signature;
  84. LIST_ENTRY Link;
  85. INTN RefCnt;
  86. //
  87. // IP address and prefix length of the interface. The fileds
  88. // are invalid if (Configured == FALSE)
  89. //
  90. LIST_ENTRY AddressList;
  91. UINT32 AddressCount;
  92. BOOLEAN Configured;
  93. IP6_SERVICE *Service;
  94. EFI_HANDLE Controller;
  95. EFI_HANDLE Image;
  96. //
  97. // Queues to keep the frames sent and waiting ARP request.
  98. //
  99. LIST_ENTRY ArpQues;
  100. LIST_ENTRY SentFrames;
  101. //
  102. // The interface's configuration variables
  103. //
  104. UINT32 DupAddrDetect;
  105. LIST_ENTRY DupAddrDetectList;
  106. LIST_ENTRY DelayJoinList;
  107. //
  108. // All the IP instances that have the same IP/SubnetMask are linked
  109. // together through IpInstances. If any of the instance enables
  110. // promiscuous receive, PromiscRecv is true.
  111. //
  112. LIST_ENTRY IpInstances;
  113. BOOLEAN PromiscRecv;
  114. };
  115. /**
  116. Create an IP6_INTERFACE.
  117. @param[in] IpSb The IP6 service binding instance.
  118. @param[in] LinkLocal If TRUE, the instance is created for link-local address.
  119. Otherwise, it is not for a link-local address.
  120. @return Point to the created IP6_INTERFACE, otherwise NULL.
  121. **/
  122. IP6_INTERFACE *
  123. Ip6CreateInterface (
  124. IN IP6_SERVICE *IpSb,
  125. IN BOOLEAN LinkLocal
  126. );
  127. /**
  128. Free the interface used by IpInstance. All the IP instance with
  129. the same Ip/prefix pair share the same interface. It is reference
  130. counted. All the frames that haven't been sent will be cancelled.
  131. Because the IpInstance is optional, the caller must remove
  132. IpInstance from the interface's instance list.
  133. @param[in] Interface The interface used by the IpInstance.
  134. @param[in] IpInstance The IP instance that free the interface. NULL if
  135. the IP driver is releasing the default interface.
  136. **/
  137. VOID
  138. Ip6CleanInterface (
  139. IN IP6_INTERFACE *Interface,
  140. IN IP6_PROTOCOL *IpInstance OPTIONAL
  141. );
  142. /**
  143. Free the link layer transmit token. It will close the event
  144. then free the memory used.
  145. @param[in] Token Token to free.
  146. **/
  147. VOID
  148. Ip6FreeLinkTxToken (
  149. IN IP6_LINK_TX_TOKEN *Token
  150. );
  151. /**
  152. Request Ip6OnFrameReceivedDpc as a DPC at TPL_CALLBACK
  153. @param Event The receive event delivered to MNP for receive.
  154. @param Context Context for the callback.
  155. **/
  156. VOID
  157. EFIAPI
  158. Ip6OnFrameReceived (
  159. IN EFI_EVENT Event,
  160. IN VOID *Context
  161. );
  162. /**
  163. Request to receive the packet from the interface.
  164. @param[in] CallBack Function to call when the receive finished.
  165. @param[in] IpSb Points to the IP6 service binding instance.
  166. @retval EFI_ALREADY_STARTED There is already a pending receive request.
  167. @retval EFI_OUT_OF_RESOURCES Failed to allocate resources to receive.
  168. @retval EFI_SUCCESS The receive request has been started.
  169. **/
  170. EFI_STATUS
  171. Ip6ReceiveFrame (
  172. IN IP6_FRAME_CALLBACK CallBack,
  173. IN IP6_SERVICE *IpSb
  174. );
  175. /**
  176. Send a frame from the interface. If the next hop is multicast address,
  177. it is transmitted immediately. If the next hop is a unicast,
  178. and the NextHop's MAC is not known, it will perform address resolution.
  179. If some error happened, the CallBack won't be called. So, the caller
  180. must test the return value, and take action when there is an error.
  181. @param[in] Interface The interface to send the frame from
  182. @param[in] IpInstance The IP child that request the transmission.
  183. NULL if it is the IP6 driver itself.
  184. @param[in] Packet The packet to transmit.
  185. @param[in] NextHop The immediate destination to transmit the packet to.
  186. @param[in] CallBack Function to call back when transmit finished.
  187. @param[in] Context Opaque parameter to the call back.
  188. @retval EFI_OUT_OF_RESOURCES Failed to allocate resource to send the frame.
  189. @retval EFI_NO_MAPPING Can't resolve the MAC for the nexthop.
  190. @retval EFI_SUCCESS The packet successfully transmitted.
  191. **/
  192. EFI_STATUS
  193. Ip6SendFrame (
  194. IN IP6_INTERFACE *Interface,
  195. IN IP6_PROTOCOL *IpInstance OPTIONAL,
  196. IN NET_BUF *Packet,
  197. IN EFI_IPv6_ADDRESS *NextHop,
  198. IN IP6_FRAME_CALLBACK CallBack,
  199. IN VOID *Context
  200. );
  201. /**
  202. The heartbeat timer of IP6 service instance. It times out
  203. all of its IP6 children's received-but-not-delivered and
  204. transmitted-but-not-recycle packets.
  205. @param[in] Event The IP6 service instance's heart beat timer.
  206. @param[in] Context The IP6 service instance.
  207. **/
  208. VOID
  209. EFIAPI
  210. Ip6TimerTicking (
  211. IN EFI_EVENT Event,
  212. IN VOID *Context
  213. );
  214. #endif