2 Definition for IP4 pesudo interface structure.
4 Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef __EFI_IP4_IF_H__
16 #define __EFI_IP4_IF_H__
18 #define IP4_FRAME_RX_SIGNATURE SIGNATURE_32 ('I', 'P', 'F', 'R')
19 #define IP4_FRAME_TX_SIGNATURE SIGNATURE_32 ('I', 'P', 'F', 'T')
20 #define IP4_FRAME_ARP_SIGNATURE SIGNATURE_32 ('I', 'P', 'F', 'A')
21 #define IP4_INTERFACE_SIGNATURE SIGNATURE_32 ('I', 'P', 'I', 'F')
24 This prototype is used by both receive and transmission.
25 When receiving Netbuf is allocated by IP4_INTERFACE, and
26 released by IP4. Flag shows whether the frame is received
27 as link broadcast/multicast...
29 When transmitting, the Netbuf is from IP4, and provided
30 to the callback as a reference. Flag isn't used.
32 @param[in] IpInstance The instance that sent or received the packet.
33 IpInstance can be NULL which means that it is the IP4 driver
34 itself sending the packets. IP4 driver may send packets that
35 don't belong to any instance, such as ICMP errors, ICMP echo
36 responses, or IGMP packets. IpInstance is used as a tag in
38 @param[in] Packet The sent or received packet.
39 @param[in] IoStatus Status of sending or receiving.
40 @param[in] LinkFlag Indicate if the frame is received as link broadcast/multicast.
41 When transmitting, it is not used.
42 @param[in] Context Additional data for callback.
48 (*IP4_FRAME_CALLBACK
)(
49 IN IP4_PROTOCOL
*IpInstance OPTIONAL
,
51 IN EFI_STATUS IoStatus
,
57 /// Each receive request is wrapped in an IP4_LINK_RX_TOKEN.
58 /// Upon completion, the Callback will be called. Only one
59 /// receive request is send to MNP. IpInstance is always NULL.
60 /// Reference MNP's spec for information.
64 IP4_INTERFACE
*Interface
;
66 IP4_PROTOCOL
*IpInstance
;
67 IP4_FRAME_CALLBACK CallBack
;
70 EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken
;
74 /// Each transmit request is wrapped in an IP4_LINK_TX_TOKEN.
75 /// Upon completion, the Callback will be called.
81 IP4_INTERFACE
*Interface
;
83 IP4_PROTOCOL
*IpInstance
;
84 IP4_FRAME_CALLBACK CallBack
;
88 EFI_MAC_ADDRESS DstMac
;
89 EFI_MAC_ADDRESS SrcMac
;
91 EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken
;
92 EFI_MANAGED_NETWORK_TRANSMIT_DATA MnpTxData
;
96 /// Only one ARP request is requested for all the frames in
97 /// a time. It is started for the first frames to the Ip. Any
98 /// subsequent transmission frame will be linked to Frames, and
99 /// be sent all at once the ARP requests succeed.
106 IP4_INTERFACE
*Interface
;
109 // ARP requesting staffs
111 EFI_EVENT OnResolved
;
117 Callback to select which frame to cancel. Caller can cancel a
118 single frame, or all the frame from an IP instance.
120 @param Frame The sending frame to check for cancellation.
121 @param Context Additional data for callback.
123 @retval TRUE The sending of the frame should be cancelled.
124 @retval FALSE Do not cancel the frame sending.
128 (*IP4_FRAME_TO_CANCEL
)(
129 IP4_LINK_TX_TOKEN
*Frame
,
134 // Each IP4 instance has its own station address. All the instances
135 // with the same station address share a single interface structure.
136 // Each interface has its own ARP child, and shares one MNP child.
137 // Notice the special cases that DHCP can configure the interface
138 // with 0.0.0.0/0.0.0.0.
140 struct _IP4_INTERFACE
{
146 // IP address and subnet mask of the interface. It also contains
147 // the subnet/net broadcast address for quick access. The fields
148 // are invalid if (Configured == FALSE)
152 IP4_ADDR SubnetBrdcast
;
157 // Handle used to create/destroy ARP child. All the IP children
158 // share one MNP which is owned by IP service binding.
160 EFI_HANDLE Controller
;
163 EFI_MANAGED_NETWORK_PROTOCOL
*Mnp
;
164 EFI_ARP_PROTOCOL
*Arp
;
165 EFI_HANDLE ArpHandle
;
168 // Queues to keep the frames sent and waiting ARP request.
171 LIST_ENTRY SentFrames
;
172 IP4_LINK_RX_TOKEN
*RecvRequest
;
175 // The interface's MAC and broadcast MAC address.
178 EFI_MAC_ADDRESS BroadcastMac
;
182 // All the IP instances that have the same IP/SubnetMask are linked
183 // together through IpInstances. If any of the instance enables
184 // promiscuous receive, PromiscRecv is true.
186 LIST_ENTRY IpInstances
;
191 Create an IP4_INTERFACE. Delay the creation of ARP instance until
192 the interface is configured.
194 @param[in] Mnp The shared MNP child of this IP4 service binding
196 @param[in] Controller The controller this IP4 service binding instance
197 is installed. Most like the UNDI handle.
198 @param[in] ImageHandle This driver's image handle.
200 @return Point to the created IP4_INTERFACE, otherwise NULL.
205 IN EFI_MANAGED_NETWORK_PROTOCOL
*Mnp
,
206 IN EFI_HANDLE Controller
,
207 IN EFI_HANDLE ImageHandle
211 Set the interface's address, create and configure
212 the ARP child if necessary.
214 @param Interface The interface to set the address.
215 @param IpAddr The interface's IP address.
216 @param SubnetMask The interface's netmask.
218 @retval EFI_SUCCESS The interface is configured with Ip/netmask pair,
219 and a ARP is created for it.
220 @retval Others Failed to set the interface's address.
225 IN OUT IP4_INTERFACE
*Interface
,
227 IN IP4_ADDR SubnetMask
231 Free the interface used by IpInstance. All the IP instance with
232 the same Ip/Netmask pair share the same interface. It is reference
233 counted. All the frames haven't been sent will be cancelled.
234 Because the IpInstance is optional, the caller must remove
235 IpInstance from the interface's instance list itself.
237 @param[in] Interface The interface used by the IpInstance.
238 @param[in] IpInstance The Ip instance that free the interface. NULL if
239 the Ip driver is releasing the default interface.
241 @retval EFI_SUCCESS The interface use IpInstance is freed.
246 IN IP4_INTERFACE
*Interface
,
247 IN IP4_PROTOCOL
*IpInstance OPTIONAL
251 Send a frame from the interface. If the next hop is broadcast or
252 multicast address, it is transmitted immediately. If the next hop
253 is a unicast, it will consult ARP to resolve the NextHop's MAC.
254 If some error happened, the CallBack won't be called. So, the caller
255 must test the return value, and take action when there is an error.
257 @param[in] Interface The interface to send the frame from
258 @param[in] IpInstance The IP child that request the transmission. NULL
259 if it is the IP4 driver itself.
260 @param[in] Packet The packet to transmit.
261 @param[in] NextHop The immediate destination to transmit the packet
263 @param[in] CallBack Function to call back when transmit finished.
264 @param[in] Context Opaque parameter to the call back.
266 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource to send the frame
267 @retval EFI_NO_MAPPING Can't resolve the MAC for the nexthop
268 @retval EFI_SUCCESS The packet is successfully transmitted.
269 @retval other Other error occurs.
274 IN IP4_INTERFACE
*Interface
,
275 IN IP4_PROTOCOL
*IpInstance OPTIONAL
,
278 IN IP4_FRAME_CALLBACK CallBack
,
283 Remove all the frames on the interface that pass the FrameToCancel,
284 either queued on ARP queues or that have already been delivered to
285 MNP and not yet recycled.
287 @param[in] Interface Interface to remove the frames from.
288 @param[in] IoStatus The transmit status returned to the frames'
290 @param[in] FrameToCancel Function to select the frame to cancel, NULL to
292 @param[in] Context Opaque parameters passed to FrameToCancel.
297 IN IP4_INTERFACE
*Interface
,
298 IN EFI_STATUS IoStatus
,
299 IN IP4_FRAME_TO_CANCEL FrameToCancel OPTIONAL
,
304 If there is a pending receive request, cancel it. Don't call
305 the receive request's callback because this function can be only
306 called if the instance or driver is tearing itself down. It
307 doesn't make sense to call it back. But it is necessary to call
308 the transmit token's callback to give it a chance to free the
309 packet and update the upper layer's transmit request status, say
312 @param[in] Interface The interface used by the IpInstance
317 IN IP4_INTERFACE
*Interface
321 Request to receive the packet from the interface.
323 @param[in] Interface The interface to receive the frames from.
324 @param[in] IpInstance The instance that requests the receive. NULL for
326 @param[in] CallBack Function to call when receive finished.
327 @param[in] Context Opaque parameter to the callback.
329 @retval EFI_ALREADY_STARTED There is already a pending receive request.
330 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource to receive.
331 @retval EFI_SUCCESS The recieve request has been started.
332 @retval other Other error occurs.
337 IN IP4_INTERFACE
*Interface
,
338 IN IP4_PROTOCOL
*IpInstance OPTIONAL
,
339 IN IP4_FRAME_CALLBACK CallBack
,