]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.h
GCC Cleanup: UINT8_MAX is defined already in standard header file.
[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
83cbd279 28 IP4_FRAME_RX_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', 'F', 'R'),\r
29 IP4_FRAME_TX_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', 'F', 'T'),\r
30 IP4_FRAME_ARP_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', 'F', 'A'),\r
31 IP4_INTERFACE_SIGNATURE = EFI_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
201IP4_INTERFACE *\r
202Ip4CreateInterface (\r
203 IN EFI_MANAGED_NETWORK_PROTOCOL *Mnp,\r
204 IN EFI_HANDLE Controller,\r
205 IN EFI_HANDLE ImageHandle\r
206 );\r
207\r
208EFI_STATUS\r
209Ip4SetAddress (\r
210 IN IP4_INTERFACE *Interface,\r
211 IN IP4_ADDR IpAddr,\r
212 IN IP4_ADDR SubnetMask\r
213 );\r
214\r
215EFI_STATUS\r
216Ip4FreeInterface (\r
217 IN IP4_INTERFACE *Interface,\r
218 IN IP4_PROTOCOL *IpInstance OPTIONAL\r
219 );\r
220\r
221EFI_STATUS\r
222Ip4SendFrame (\r
223 IN IP4_INTERFACE *Interface,\r
224 IN IP4_PROTOCOL *IpInstance, OPTIONAL\r
225 IN NET_BUF *Packet,\r
226 IN IP4_ADDR NextHop,\r
227 IN IP4_FRAME_CALLBACK CallBack,\r
228 IN VOID *Context\r
229 );\r
230\r
231VOID\r
232Ip4CancelFrames (\r
233 IN IP4_INTERFACE *Interface,\r
234 IN EFI_STATUS IoStatus,\r
235 IN IP4_FRAME_TO_CANCEL FrameToCancel, OPTIONAL\r
236 IN VOID *Context\r
237 );\r
238\r
239VOID\r
240Ip4CancelReceive (\r
241 IN IP4_INTERFACE *Interface\r
242 );\r
243\r
244EFI_STATUS\r
245Ip4ReceiveFrame (\r
246 IN IP4_INTERFACE *Interface,\r
247 IN IP4_PROTOCOL *IpInstance, OPTIONAL\r
248 IN IP4_FRAME_CALLBACK CallBack,\r
249 IN VOID *Context\r
250 );\r
251\r
252#endif\r