]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.h
Clean up for GCC tool-chain.
[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
27enum {\r
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
32};\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// IpInstance can be NULL which means that it is the IP4 driver\r
44// itself sending the packets. IP4 driver may send packets that\r
45// don't belong to any instance, such as ICMP errors, ICMP echo\r
46// responses, or IGMP packets. IpInstance is used as a tag in\r
47// this module.\r
48//\r
49typedef\r
50VOID\r
51(*IP4_FRAME_CALLBACK) (\r
52 IP4_PROTOCOL *IpInstance, OPTIONAL\r
53 NET_BUF *Packet,\r
54 EFI_STATUS IoStatus,\r
55 UINT32 LinkFlag,\r
56 VOID *Context\r
57 );\r
58\r
59//\r
60// Each receive request is wrapped in an IP4_LINK_RX_TOKEN.\r
61// Upon completion, the Callback will be called. Only one\r
62// receive request is send to MNP. IpInstance is always NULL.\r
63// Reference MNP's spec for information.\r
64//\r
65typedef struct {\r
66 UINT32 Signature;\r
67 IP4_INTERFACE *Interface;\r
68\r
69 IP4_PROTOCOL *IpInstance;\r
70 IP4_FRAME_CALLBACK CallBack;\r
71 VOID *Context;\r
72\r
73 EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken;\r
74} IP4_LINK_RX_TOKEN;\r
75\r
76//\r
77// Each transmit request is wrapped in an IP4_LINK_TX_TOKEN.\r
78// Upon completion, the Callback will be called.\r
79//\r
80typedef struct {\r
81 UINT32 Signature;\r
e48e37fc 82 LIST_ENTRY Link;\r
83cbd279 83\r
84 IP4_INTERFACE *Interface;\r
85\r
86 IP4_PROTOCOL *IpInstance;\r
87 IP4_FRAME_CALLBACK CallBack;\r
88 NET_BUF *Packet;\r
89 VOID *Context;\r
90\r
91 EFI_MAC_ADDRESS DstMac;\r
92 EFI_MAC_ADDRESS SrcMac;\r
93\r
94 EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken;\r
95 EFI_MANAGED_NETWORK_TRANSMIT_DATA MnpTxData;\r
96} IP4_LINK_TX_TOKEN;\r
97\r
98//\r
99// Only one ARP request is requested for all the frames in\r
100// a time. It is started for the first frames to the Ip. Any\r
101// subsequent transmission frame will be linked to Frames, and\r
102// be sent all at once the ARP requests succeed.\r
103//\r
104typedef struct {\r
105 UINT32 Signature;\r
e48e37fc 106 LIST_ENTRY Link;\r
83cbd279 107\r
e48e37fc 108 LIST_ENTRY Frames;\r
83cbd279 109 IP4_INTERFACE *Interface;\r
110\r
111 //\r
112 // ARP requesting staffs\r
113 //\r
114 EFI_EVENT OnResolved;\r
115 IP4_ADDR Ip;\r
116 EFI_MAC_ADDRESS Mac;\r
117} IP4_ARP_QUE;\r
118\r
119//\r
120// Callback to select which frame to cancel. Caller can cancel a\r
121// single frame, or all the frame from an IP instance.\r
122//\r
123typedef\r
124BOOLEAN\r
125(*IP4_FRAME_TO_CANCEL) (\r
126 IP4_LINK_TX_TOKEN *Frame,\r
127 VOID *Context\r
128 );\r
129\r
130//\r
131// Each IP4 instance has its own station address. All the instances\r
132// with the same station address share a single interface structure.\r
133// Each interface has its own ARP child, and shares one MNP child.\r
134// Notice the special cases that DHCP can configure the interface\r
135// with 0.0.0.0/0.0.0.0.\r
136//\r
137struct _IP4_INTERFACE {\r
138 UINT32 Signature;\r
e48e37fc 139 LIST_ENTRY Link;\r
83cbd279 140 INTN RefCnt;\r
141\r
142 //\r
143 // IP address and subnet mask of the interface. It also contains\r
144 // the subnet/net broadcast address for quick access. The fileds\r
145 // are invalid if (Configured == FALSE)\r
146 //\r
147 IP4_ADDR Ip;\r
148 IP4_ADDR SubnetMask;\r
149 IP4_ADDR SubnetBrdcast;\r
150 IP4_ADDR NetBrdcast;\r
151 BOOLEAN Configured;\r
152\r
153 //\r
154 // Handle used to create/destory ARP child. All the IP children\r
155 // share one MNP which is owned by IP service binding.\r
156 //\r
157 EFI_HANDLE Controller;\r
158 EFI_HANDLE Image;\r
159\r
160 EFI_MANAGED_NETWORK_PROTOCOL *Mnp;\r
161 EFI_ARP_PROTOCOL *Arp;\r
162 EFI_HANDLE ArpHandle;\r
163\r
164 //\r
165 // Queues to keep the frames sent and waiting ARP request.\r
166 //\r
e48e37fc 167 LIST_ENTRY ArpQues;\r
168 LIST_ENTRY SentFrames;\r
83cbd279 169 IP4_LINK_RX_TOKEN *RecvRequest;\r
170\r
171 //\r
172 // The interface's MAC and broadcast MAC address.\r
173 //\r
174 EFI_MAC_ADDRESS Mac;\r
175 EFI_MAC_ADDRESS BroadcastMac;\r
176 UINT32 HwaddrLen;\r
177\r
178 //\r
179 // All the IP instances that have the same IP/SubnetMask are linked\r
180 // together through IpInstances. If any of the instance enables\r
181 // promiscuous receive, PromiscRecv is true.\r
182 //\r
e48e37fc 183 LIST_ENTRY IpInstances;\r
83cbd279 184 BOOLEAN PromiscRecv;\r
185};\r
186\r
187IP4_INTERFACE *\r
188Ip4CreateInterface (\r
189 IN EFI_MANAGED_NETWORK_PROTOCOL *Mnp,\r
190 IN EFI_HANDLE Controller,\r
191 IN EFI_HANDLE ImageHandle\r
192 );\r
193\r
194EFI_STATUS\r
195Ip4SetAddress (\r
196 IN IP4_INTERFACE *Interface,\r
197 IN IP4_ADDR IpAddr,\r
198 IN IP4_ADDR SubnetMask\r
199 );\r
200\r
201EFI_STATUS\r
202Ip4FreeInterface (\r
203 IN IP4_INTERFACE *Interface,\r
204 IN IP4_PROTOCOL *IpInstance OPTIONAL\r
205 );\r
206\r
207EFI_STATUS\r
208Ip4SendFrame (\r
209 IN IP4_INTERFACE *Interface,\r
210 IN IP4_PROTOCOL *IpInstance, OPTIONAL\r
211 IN NET_BUF *Packet,\r
212 IN IP4_ADDR NextHop,\r
213 IN IP4_FRAME_CALLBACK CallBack,\r
214 IN VOID *Context\r
215 );\r
216\r
217VOID\r
218Ip4CancelFrames (\r
219 IN IP4_INTERFACE *Interface,\r
220 IN EFI_STATUS IoStatus,\r
221 IN IP4_FRAME_TO_CANCEL FrameToCancel, OPTIONAL\r
222 IN VOID *Context\r
223 );\r
224\r
225VOID\r
226Ip4CancelReceive (\r
227 IN IP4_INTERFACE *Interface\r
228 );\r
229\r
230EFI_STATUS\r
231Ip4ReceiveFrame (\r
232 IN IP4_INTERFACE *Interface,\r
233 IN IP4_PROTOCOL *IpInstance, OPTIONAL\r
234 IN IP4_FRAME_CALLBACK CallBack,\r
235 IN VOID *Context\r
236 );\r
237\r
238#endif\r