]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.h
Clean up to update the reference of the these macros:
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4Dxe / Ip4If.h
CommitLineData
83cbd279 1/** @file\r
2\r
3Copyright (c) 2005 - 2006, Intel Corporation\r
4All rights reserved. This program and the accompanying materials\r
5are licensed and made available under the terms and conditions of the BSD License\r
6which accompanies this distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
12\r
13Module Name:\r
14\r
15 Ip4If.h\r
16\r
17Abstract:\r
18\r
19 Definition for IP4 pesudo interface structure.\r
20\r
21\r
22**/\r
23\r
24#ifndef __EFI_IP4_IF_H__\r
25#define __EFI_IP4_IF_H__\r
26\r
5405e9a6 27typedef enum {\r
f3f2e05d 28 IP4_FRAME_RX_SIGNATURE = SIGNATURE_32 ('I', 'P', 'F', 'R'),\r
29 IP4_FRAME_TX_SIGNATURE = SIGNATURE_32 ('I', 'P', 'F', 'T'),\r
30 IP4_FRAME_ARP_SIGNATURE = SIGNATURE_32 ('I', 'P', 'F', 'A'),\r
31 IP4_INTERFACE_SIGNATURE = SIGNATURE_32 ('I', 'P', 'I', 'F')\r
5405e9a6 32} IP4_IF_ENUM_TYPES;\r
33\r
34/**\r
35 This prototype is used by both receive and transmission.\r
36 When receiving Netbuf is allocated by IP4_INTERFACE, and\r
37 released by IP4. Flag shows whether the frame is received\r
38 as link broadcast/multicast...\r
39\r
40 When transmitting, the Netbuf is from IP4, and provided\r
41 to the callback as a reference. Flag isn't used.\r
42\r
43 @param IpInstance The instance that sent or received the packet.\r
44 IpInstance can be NULL which means that it is the IP4 driver\r
45 itself sending the packets. IP4 driver may send packets that\r
46 don't belong to any instance, such as ICMP errors, ICMP echo\r
47 responses, or IGMP packets. IpInstance is used as a tag in\r
48 this module.\r
49 @param Packet The sent or received packet.\r
50 @param IoStatus Status of sending or receiving.\r
51 @param LinkFlag Indicate if the frame is received as link broadcast/multicast.\r
52 When transmitting, it is not used.\r
53 @param Context Additional data for callback.\r
54\r
55 @return None.\r
56**/\r
83cbd279 57typedef\r
58VOID\r
5405e9a6 59(*IP4_FRAME_CALLBACK)(\r
60 IN IP4_PROTOCOL *IpInstance, OPTIONAL\r
61 IN NET_BUF *Packet,\r
62 IN EFI_STATUS IoStatus,\r
63 IN UINT32 LinkFlag,\r
64 IN VOID *Context\r
83cbd279 65 );\r
66\r
96e1079f 67///\r
68/// Each receive request is wrapped in an IP4_LINK_RX_TOKEN.\r
69/// Upon completion, the Callback will be called. Only one\r
70/// receive request is send to MNP. IpInstance is always NULL.\r
71/// Reference MNP's spec for information.\r
72///\r
83cbd279 73typedef struct {\r
74 UINT32 Signature;\r
75 IP4_INTERFACE *Interface;\r
76\r
77 IP4_PROTOCOL *IpInstance;\r
78 IP4_FRAME_CALLBACK CallBack;\r
79 VOID *Context;\r
80\r
81 EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken;\r
82} IP4_LINK_RX_TOKEN;\r
83\r
96e1079f 84///\r
85/// Each transmit request is wrapped in an IP4_LINK_TX_TOKEN.\r
86/// Upon completion, the Callback will be called.\r
87///\r
83cbd279 88typedef struct {\r
89 UINT32 Signature;\r
e48e37fc 90 LIST_ENTRY Link;\r
83cbd279 91\r
92 IP4_INTERFACE *Interface;\r
93\r
94 IP4_PROTOCOL *IpInstance;\r
95 IP4_FRAME_CALLBACK CallBack;\r
96 NET_BUF *Packet;\r
97 VOID *Context;\r
98\r
99 EFI_MAC_ADDRESS DstMac;\r
100 EFI_MAC_ADDRESS SrcMac;\r
101\r
102 EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken;\r
103 EFI_MANAGED_NETWORK_TRANSMIT_DATA MnpTxData;\r
104} IP4_LINK_TX_TOKEN;\r
105\r
96e1079f 106///\r
107/// Only one ARP request is requested for all the frames in\r
108/// a time. It is started for the first frames to the Ip. Any\r
109/// subsequent transmission frame will be linked to Frames, and\r
110/// be sent all at once the ARP requests succeed.\r
111///\r
83cbd279 112typedef struct {\r
113 UINT32 Signature;\r
e48e37fc 114 LIST_ENTRY Link;\r
83cbd279 115\r
e48e37fc 116 LIST_ENTRY Frames;\r
83cbd279 117 IP4_INTERFACE *Interface;\r
118\r
119 //\r
120 // ARP requesting staffs\r
121 //\r
122 EFI_EVENT OnResolved;\r
123 IP4_ADDR Ip;\r
124 EFI_MAC_ADDRESS Mac;\r
125} IP4_ARP_QUE;\r
126\r
5405e9a6 127/**\r
128 Callback to select which frame to cancel. Caller can cancel a\r
129 single frame, or all the frame from an IP instance.\r
130\r
131 @param Frame The sending frame to check for cancellation.\r
132 @param Context Additional data for callback.\r
133\r
134 @retval TRUE The sending of the frame should be cancelled.\r
135 @retval FALSE Do not cancel the frame sending.\r
136**/\r
83cbd279 137typedef\r
138BOOLEAN\r
5405e9a6 139(*IP4_FRAME_TO_CANCEL)(\r
83cbd279 140 IP4_LINK_TX_TOKEN *Frame,\r
141 VOID *Context\r
142 );\r
143\r
144//\r
145// Each IP4 instance has its own station address. All the instances\r
146// with the same station address share a single interface structure.\r
147// Each interface has its own ARP child, and shares one MNP child.\r
148// Notice the special cases that DHCP can configure the interface\r
149// with 0.0.0.0/0.0.0.0.\r
150//\r
c6bc765f 151struct _IP4_INTERFACE {\r
83cbd279 152 UINT32 Signature;\r
e48e37fc 153 LIST_ENTRY Link;\r
83cbd279 154 INTN RefCnt;\r
155\r
156 //\r
157 // IP address and subnet mask of the interface. It also contains\r
158 // the subnet/net broadcast address for quick access. The fileds\r
159 // are invalid if (Configured == FALSE)\r
160 //\r
161 IP4_ADDR Ip;\r
162 IP4_ADDR SubnetMask;\r
163 IP4_ADDR SubnetBrdcast;\r
164 IP4_ADDR NetBrdcast;\r
165 BOOLEAN Configured;\r
166\r
167 //\r
168 // Handle used to create/destory ARP child. All the IP children\r
169 // share one MNP which is owned by IP service binding.\r
170 //\r
171 EFI_HANDLE Controller;\r
172 EFI_HANDLE Image;\r
173\r
174 EFI_MANAGED_NETWORK_PROTOCOL *Mnp;\r
175 EFI_ARP_PROTOCOL *Arp;\r
176 EFI_HANDLE ArpHandle;\r
177\r
178 //\r
179 // Queues to keep the frames sent and waiting ARP request.\r
180 //\r
e48e37fc 181 LIST_ENTRY ArpQues;\r
182 LIST_ENTRY SentFrames;\r
83cbd279 183 IP4_LINK_RX_TOKEN *RecvRequest;\r
184\r
185 //\r
186 // The interface's MAC and broadcast MAC address.\r
187 //\r
188 EFI_MAC_ADDRESS Mac;\r
189 EFI_MAC_ADDRESS BroadcastMac;\r
190 UINT32 HwaddrLen;\r
191\r
192 //\r
193 // All the IP instances that have the same IP/SubnetMask are linked\r
194 // together through IpInstances. If any of the instance enables\r
195 // promiscuous receive, PromiscRecv is true.\r
196 //\r
e48e37fc 197 LIST_ENTRY IpInstances;\r
83cbd279 198 BOOLEAN PromiscRecv;\r
c6bc765f 199};\r
83cbd279 200\r
2ff29212 201/**\r
202 Create an IP4_INTERFACE. Delay the creation of ARP instance until\r
203 the interface is configured.\r
204\r
205 @param Mnp The shared MNP child of this IP4 service binding\r
206 instance\r
207 @param Controller The controller this IP4 service binding instance\r
208 is installed. Most like the UNDI handle.\r
209 @param ImageHandle This driver's image handle\r
210\r
211 @return Point to the created IP4_INTERFACE, otherwise NULL.\r
212\r
213**/\r
83cbd279 214IP4_INTERFACE *\r
215Ip4CreateInterface (\r
216 IN EFI_MANAGED_NETWORK_PROTOCOL *Mnp,\r
217 IN EFI_HANDLE Controller,\r
218 IN EFI_HANDLE ImageHandle\r
219 );\r
220\r
2ff29212 221/**\r
222 Set the interface's address, create and configure\r
223 the ARP child if necessary.\r
224\r
225 @param Interface The interface to set the address\r
226 @param IpAddr The interface's IP address\r
227 @param SubnetMask The interface's netmask\r
228\r
229 @retval EFI_SUCCESS The interface is configured with Ip/netmask pair,\r
230 and a ARP is created for it.\r
231 @retval Others Failed to set the interface's address.\r
232\r
233**/\r
83cbd279 234EFI_STATUS\r
235Ip4SetAddress (\r
2ff29212 236 IN OUT IP4_INTERFACE *Interface,\r
237 IN IP4_ADDR IpAddr,\r
238 IN IP4_ADDR SubnetMask\r
83cbd279 239 );\r
240\r
2ff29212 241/**\r
242 Free the interface used by IpInstance. All the IP instance with\r
243 the same Ip/Netmask pair share the same interface. It is reference\r
244 counted. All the frames haven't been sent will be cancelled.\r
245 Because the IpInstance is optional, the caller must remove\r
246 IpInstance from the interface's instance list itself.\r
247\r
248 @param Interface The interface used by the IpInstance\r
249 @param IpInstance The Ip instance that free the interface. NULL if\r
250 the Ip driver is releasing the default interface.\r
251\r
252 @retval EFI_SUCCESS The interface use IpInstance is freed.\r
253\r
254**/\r
83cbd279 255EFI_STATUS\r
256Ip4FreeInterface (\r
257 IN IP4_INTERFACE *Interface,\r
2ff29212 258 IN IP4_PROTOCOL *IpInstance OPTIONAL\r
83cbd279 259 );\r
260\r
2ff29212 261/**\r
262 Send a frame from the interface. If the next hop is broadcast or\r
263 multicast address, it is transmitted immediately. If the next hop\r
264 is a unicast, it will consult ARP to resolve the NextHop's MAC.\r
265 If some error happened, the CallBack won't be called. So, the caller\r
266 must test the return value, and take action when there is an error.\r
267\r
268 @param Interface The interface to send the frame from\r
269 @param IpInstance The IP child that request the transmission. NULL\r
270 if it is the IP4 driver itself.\r
271 @param Packet The packet to transmit.\r
272 @param NextHop The immediate destination to transmit the packet\r
273 to.\r
274 @param CallBack Function to call back when transmit finished.\r
275 @param Context Opaque parameter to the call back.\r
276\r
277 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource to send the frame\r
278 @retval EFI_NO_MAPPING Can't resolve the MAC for the nexthop\r
279 @retval EFI_SUCCESS The packet is successfully transmitted.\r
280 @retval other Other error occurs.\r
281\r
282**/\r
83cbd279 283EFI_STATUS\r
284Ip4SendFrame (\r
285 IN IP4_INTERFACE *Interface,\r
286 IN IP4_PROTOCOL *IpInstance, OPTIONAL\r
287 IN NET_BUF *Packet,\r
288 IN IP4_ADDR NextHop,\r
289 IN IP4_FRAME_CALLBACK CallBack,\r
290 IN VOID *Context\r
291 );\r
292\r
2ff29212 293/**\r
294 Remove all the frames on the interface that pass the FrameToCancel,\r
295 either queued on ARP queues or that have already been delivered to\r
296 MNP and not yet recycled.\r
297\r
298 @param Interface Interface to remove the frames from\r
299 @param IoStatus The transmit status returned to the frames'\r
300 callback\r
301 @param FrameToCancel Function to select the frame to cancel, NULL to\r
302 select all\r
303 @param Context Opaque parameters passed to FrameToCancel\r
304\r
305 @return NONE\r
306\r
307**/\r
83cbd279 308VOID\r
309Ip4CancelFrames (\r
310 IN IP4_INTERFACE *Interface,\r
311 IN EFI_STATUS IoStatus,\r
312 IN IP4_FRAME_TO_CANCEL FrameToCancel, OPTIONAL\r
313 IN VOID *Context\r
314 );\r
315\r
2ff29212 316/**\r
317 If there is a pending receive request, cancel it. Don't call\r
318 the receive request's callback because this function can be only\r
319 called if the instance or driver is tearing itself down. It\r
320 doesn't make sense to call it back. But it is necessary to call\r
321 the transmit token's callback to give it a chance to free the\r
322 packet and update the upper layer's transmit request status, say\r
323 that from the UDP.\r
324\r
325 @param Interface The interface used by the IpInstance\r
326\r
327 @return None\r
328\r
329**/\r
83cbd279 330VOID\r
331Ip4CancelReceive (\r
332 IN IP4_INTERFACE *Interface\r
333 );\r
334\r
2ff29212 335/**\r
336 Request to receive the packet from the interface.\r
337\r
338 @param Interface The interface to receive the frames from\r
339 @param IpInstance The instance that requests the receive. NULL for\r
340 the driver itself.\r
341 @param CallBack Function to call when receive finished.\r
342 @param Context Opaque parameter to the callback\r
343\r
344 @retval EFI_ALREADY_STARTED There is already a pending receive request.\r
345 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource to receive\r
346 @retval EFI_SUCCESS The recieve request has been started.\r
347 @retval other Other error occurs.\r
348\r
349**/\r
83cbd279 350EFI_STATUS\r
351Ip4ReceiveFrame (\r
352 IN IP4_INTERFACE *Interface,\r
353 IN IP4_PROTOCOL *IpInstance, OPTIONAL\r
354 IN IP4_FRAME_CALLBACK CallBack,\r
355 IN VOID *Context\r
356 );\r
357\r
358#endif\r