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