]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h
Clean up to update the reference of the these macros:
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4Dxe / Ip4Impl.h
CommitLineData
83cbd279 1/** @file\r
2\r
c4a62a12 3Copyright (c) 2005 - 2007, Intel Corporation \r
83cbd279 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
12Module Name:\r
13\r
14 Ip4Impl.h\r
15\r
16Abstract:\r
17\r
18 Ip4 internal functions and type defintions.\r
19\r
20\r
21**/\r
22\r
23#ifndef __EFI_IP4_IMPL_H__\r
24#define __EFI_IP4_IMPL_H__\r
25\r
772db4bb 26#include <PiDxe.h>\r
27\r
5f778b1f 28#include <Protocol/Ip4.h>\r
29#include <Protocol/Ip4Config.h>\r
772db4bb 30#include <Protocol/Arp.h>\r
31#include <Protocol/ManagedNetwork.h>\r
32\r
33#include <Library/DebugLib.h>\r
34#include <Library/UefiRuntimeServicesTableLib.h>\r
35#include <Library/UefiDriverEntryPoint.h>\r
36#include <Library/UefiBootServicesTableLib.h>\r
37#include <Library/BaseLib.h>\r
83cbd279 38#include <Library/UefiLib.h>\r
39#include <Library/NetLib.h>\r
40#include <Library/BaseMemoryLib.h>\r
41#include <Library/MemoryAllocationLib.h>\r
42\r
43#include "Ip4Common.h"\r
44#include "Ip4Driver.h"\r
45#include "Ip4If.h"\r
46#include "Ip4Icmp.h"\r
47#include "Ip4Option.h"\r
48#include "Ip4Igmp.h"\r
49#include "Ip4Route.h"\r
50#include "Ip4Input.h"\r
51#include "Ip4Output.h"\r
52\r
c6bc765f 53\r
54\r
5405e9a6 55typedef enum {\r
f3f2e05d 56 IP4_PROTOCOL_SIGNATURE = SIGNATURE_32 ('I', 'P', '4', 'P'),\r
57 IP4_SERVICE_SIGNATURE = SIGNATURE_32 ('I', 'P', '4', 'S'),\r
83cbd279 58\r
59 //\r
60 // The state of IP4 protocol. It starts from UNCONFIGED. if it is\r
61 // successfully configured, it goes to CONFIGED. if configure NULL\r
62 // is called, it becomes UNCONFIGED again. If (partly) destoried, it\r
63 // becomes DESTORY.\r
64 //\r
65 IP4_STATE_UNCONFIGED = 0,\r
66 IP4_STATE_CONFIGED,\r
67 IP4_STATE_DESTORY,\r
68\r
69 //\r
70 // The state of IP4 service. It starts from UNSTARTED. It transits\r
71 // to STARTED if autoconfigure is started. If default address is\r
72 // configured, it becomes CONFIGED. and if partly destoried, it goes\r
73 // to DESTORY.\r
74 //\r
75 IP4_SERVICE_UNSTARTED = 0,\r
76 IP4_SERVICE_STARTED,\r
77 IP4_SERVICE_CONFIGED,\r
78 IP4_SERVICE_DESTORY\r
5405e9a6 79} IP4_IMPL_ENUM_TYPES;\r
83cbd279 80\r
96e1079f 81///\r
82/// IP4_TXTOKEN_WRAP wraps the upper layer's transmit token.\r
83/// The user's data is kept in the Packet. When fragment is\r
84/// needed, each fragment of the Packet has a reference to the\r
85/// Packet, no data is actually copied. The Packet will be\r
86/// released when all the fragments of it have been recycled by\r
87/// MNP. Upon then, the IP4_TXTOKEN_WRAP will be released, and\r
88/// user's event signalled.\r
89///\r
83cbd279 90typedef struct {\r
91 IP4_PROTOCOL *IpInstance;\r
92 EFI_IP4_COMPLETION_TOKEN *Token;\r
93 NET_BUF *Packet;\r
94 BOOLEAN Sent;\r
95 INTN Life;\r
96} IP4_TXTOKEN_WRAP;\r
97\r
96e1079f 98///\r
99/// IP4_RXDATA_WRAP wraps the data IP4 child delivers to the\r
100/// upper layers. The received packet is kept in the Packet.\r
101/// The Packet itself may be constructured from some fragments.\r
102/// All the fragments of the Packet is organized by a\r
103/// IP4_ASSEMBLE_ENTRY structure. If the Packet is recycled by\r
104/// the upper layer, the assemble entry and its associated\r
105/// fragments will be freed at last.\r
106///\r
83cbd279 107typedef struct {\r
e48e37fc 108 LIST_ENTRY Link;\r
83cbd279 109 IP4_PROTOCOL *IpInstance;\r
110 NET_BUF *Packet;\r
111 EFI_IP4_RECEIVE_DATA RxData;\r
112} IP4_RXDATA_WRAP;\r
113\r
c6bc765f 114\r
115struct _IP4_PROTOCOL {\r
83cbd279 116 UINT32 Signature;\r
117\r
118 EFI_IP4_PROTOCOL Ip4Proto;\r
119 EFI_HANDLE Handle;\r
120 INTN State;\r
121\r
122 IP4_SERVICE *Service;\r
e48e37fc 123 LIST_ENTRY Link; // Link to all the IP protocol from the service\r
83cbd279 124\r
125 //\r
126 // User's transmit/receive tokens, and received/deliverd packets\r
127 //\r
128 NET_MAP RxTokens;\r
129 NET_MAP TxTokens; // map between (User's Token, IP4_TXTOKE_WRAP)\r
e48e37fc 130 LIST_ENTRY Received; // Received but not delivered packet\r
131 LIST_ENTRY Delivered; // Delivered and to be recycled packets\r
83cbd279 132 EFI_LOCK RecycleLock;\r
133\r
134 //\r
135 // Instance's address and route tables. There are two route tables.\r
136 // RouteTable is used by the IP4 driver to route packet. EfiRouteTable\r
137 // is used to communicate the current route info to the upper layer.\r
138 //\r
139 IP4_INTERFACE *Interface;\r
e48e37fc 140 LIST_ENTRY AddrLink; // Ip instances with the same IP address.\r
83cbd279 141 IP4_ROUTE_TABLE *RouteTable;\r
142\r
143 EFI_IP4_ROUTE_TABLE *EfiRouteTable;\r
144 UINT32 EfiRouteCount;\r
145\r
146 //\r
147 // IGMP data for this instance\r
148 //\r
149 IP4_ADDR *Groups; // stored in network byte order\r
150 UINT32 GroupCount;\r
151\r
152 EFI_IP4_CONFIG_DATA ConfigData;\r
153\r
c6bc765f 154};\r
83cbd279 155\r
c6bc765f 156struct _IP4_SERVICE {\r
83cbd279 157 UINT32 Signature;\r
158 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;\r
159 INTN State;\r
160 BOOLEAN InDestory;\r
161\r
162 //\r
163 // List of all the IP instances and interfaces, and default\r
164 // interface and route table and caches.\r
165 //\r
166 UINTN NumChildren;\r
e48e37fc 167 LIST_ENTRY Children;\r
83cbd279 168\r
e48e37fc 169 LIST_ENTRY Interfaces;\r
83cbd279 170\r
171 IP4_INTERFACE *DefaultInterface;\r
172 IP4_ROUTE_TABLE *DefaultRouteTable;\r
173\r
174 //\r
175 // Ip reassemble utilities, and IGMP data\r
176 //\r
177 IP4_ASSEMBLE_TABLE Assemble;\r
178 IGMP_SERVICE_DATA IgmpCtrl;\r
179\r
180 //\r
181 // Low level protocol used by this service instance\r
182 //\r
183 EFI_HANDLE Image;\r
184 EFI_HANDLE Controller;\r
185\r
186 EFI_HANDLE MnpChildHandle;\r
187 EFI_MANAGED_NETWORK_PROTOCOL *Mnp;\r
188\r
189 EFI_MANAGED_NETWORK_CONFIG_DATA MnpConfigData;\r
190 EFI_SIMPLE_NETWORK_MODE SnpMode;\r
191\r
192 EFI_EVENT Timer;\r
193\r
194 //\r
195 // Auto configure staff\r
196 //\r
197 EFI_IP4_CONFIG_PROTOCOL *Ip4Config;\r
198 EFI_EVENT DoneEvent;\r
199 EFI_EVENT ReconfigEvent;\r
36ee91ca 200 EFI_EVENT ActiveEvent;\r
83cbd279 201\r
202 //\r
203 // The string representation of the current mac address of the\r
204 // NIC this IP4_SERVICE works on.\r
205 //\r
206 CHAR16 *MacString;\r
c6bc765f 207};\r
83cbd279 208\r
209#define IP4_INSTANCE_FROM_PROTOCOL(Ip4) \\r
210 CR ((Ip4), IP4_PROTOCOL, Ip4Proto, IP4_PROTOCOL_SIGNATURE)\r
211\r
212#define IP4_SERVICE_FROM_PROTOCOL(Sb) \\r
213 CR ((Sb), IP4_SERVICE, ServiceBinding, IP4_SERVICE_SIGNATURE)\r
214\r
215#define IP4_NO_MAPPING(IpInstance) (!(IpInstance)->Interface->Configured)\r
216\r
217extern EFI_IP4_PROTOCOL mEfiIp4ProtocolTemplete;\r
218\r
2ff29212 219/**\r
220 Config the MNP parameter used by IP. The IP driver use one MNP\r
221 child to transmit/receive frames. By default, it configures MNP\r
222 to receive unicast/multicast/broadcast. And it will enable/disable\r
223 the promiscous receive according to whether there is IP child\r
224 enable that or not. If Force is FALSE, it will iterate through\r
225 all the IP children to check whether the promiscuous receive\r
226 setting has been changed. If it hasn't been changed, it won't\r
227 reconfigure the MNP. If Force is TRUE, the MNP is configured no\r
228 matter whether that is changed or not.\r
229\r
230 @param IpSb The IP4 service instance that is to be changed.\r
231 @param Force Force the configuration or not.\r
232\r
233 @retval EFI_SUCCESS The MNP is successfully configured/reconfigured.\r
234 @retval Others Configuration failed.\r
235\r
236**/\r
83cbd279 237EFI_STATUS\r
238Ip4ServiceConfigMnp (\r
239 IN IP4_SERVICE *IpSb,\r
240 IN BOOLEAN Force\r
241 );\r
242\r
2ff29212 243/**\r
244 Intiialize the IP4_PROTOCOL structure to the unconfigured states.\r
245\r
246 @param IpSb The IP4 service instance.\r
247 @param IpInstance The IP4 child instance.\r
248\r
249 @return None\r
250\r
251**/\r
83cbd279 252VOID\r
253Ip4InitProtocol (\r
2ff29212 254 IN IP4_SERVICE *IpSb,\r
255 IN OUT IP4_PROTOCOL *IpInstance\r
83cbd279 256 );\r
257\r
2ff29212 258/**\r
259 Clean up the IP4 child, release all the resources used by it.\r
260\r
261 @param IpInstance The IP4 child to clean up.\r
262\r
263 @retval EFI_SUCCESS The IP4 child is cleaned up\r
264 @retval EFI_DEVICE_ERROR Some resources failed to be released\r
265\r
266**/\r
83cbd279 267EFI_STATUS\r
268Ip4CleanProtocol (\r
269 IN IP4_PROTOCOL *IpInstance\r
270 );\r
271\r
2ff29212 272/**\r
273 Cancel the user's receive/transmit request.\r
274\r
275 @param IpInstance The IP4 child\r
276 @param Token The token to cancel. If NULL, all token will be\r
277 cancelled.\r
278\r
279 @retval EFI_SUCCESS The token is cancelled\r
280 @retval EFI_NOT_FOUND The token isn't found on either the\r
281 transmit/receive queue\r
282 @retval EFI_DEVICE_ERROR Not all token is cancelled when Token is NULL.\r
283\r
284**/\r
83cbd279 285EFI_STATUS\r
286Ip4Cancel (\r
287 IN IP4_PROTOCOL *IpInstance,\r
2ff29212 288 IN EFI_IP4_COMPLETION_TOKEN *Token OPTIONAL\r
83cbd279 289 );\r
290\r
2ff29212 291/**\r
292 Change the IP4 child's multicast setting. The caller\r
293 should make sure that the parameters is valid.\r
294\r
295 @param IpInstance The IP4 child to change the setting.\r
296 @param JoinFlag TRUE to join the group, otherwise leave it\r
297 @param GroupAddress The target group address\r
298\r
299 @retval EFI_ALREADY_STARTED Want to join the group, but already a member of it\r
300 @retval EFI_OUT_OF_RESOURCES Failed to allocate some resources.\r
301 @retval EFI_DEVICE_ERROR Failed to set the group configuraton\r
302 @retval EFI_SUCCESS Successfully updated the group setting.\r
303 @retval EFI_NOT_FOUND Try to leave the group which it isn't a member.\r
304\r
305**/\r
83cbd279 306EFI_STATUS\r
307Ip4Groups (\r
308 IN IP4_PROTOCOL *IpInstance,\r
309 IN BOOLEAN JoinFlag,\r
2ff29212 310 IN EFI_IPv4_ADDRESS *GroupAddress OPTIONAL\r
83cbd279 311 );\r
312\r
2ff29212 313/**\r
314 The heart beat timer of IP4 service instance. It times out\r
315 all of its IP4 children's received-but-not-delivered and\r
316 transmitted-but-not-recycle packets, and provides time input\r
317 for its IGMP protocol.\r
318\r
319 @param Event The IP4 service instance's heart beat timer.\r
320 @param Context The IP4 service instance.\r
321\r
322 @return None\r
323\r
324**/\r
83cbd279 325VOID\r
326EFIAPI\r
327Ip4TimerTicking (\r
328 IN EFI_EVENT Event,\r
329 IN VOID *Context\r
330 );\r
331\r
2ff29212 332/**\r
333 Decrease the life of the transmitted packets. If it is\r
334 decreased to zero, cancel the packet. This function is\r
335 called by Ip4PacketTimerTicking which time out both the\r
336 received-but-not-delivered and transmitted-but-not-recycle\r
337 packets.\r
338\r
339 @param Map The IP4 child's transmit map.\r
340 @param Item Current transmitted packet\r
341 @param Context Not used.\r
342\r
343 @retval EFI_SUCCESS Always returns EFI_SUCCESS\r
344\r
345**/\r
83cbd279 346EFI_STATUS\r
347Ip4SentPacketTicking (\r
348 IN NET_MAP *Map,\r
349 IN NET_MAP_ITEM *Item,\r
350 IN VOID *Context\r
351 );\r
352#endif\r