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