2 Definition for IP4 pesudo interface structure.
4 Copyright (c) 2005 - 2006, Intel Corporation.<BR>
5 All rights reserved. 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__
19 IP4_FRAME_RX_SIGNATURE
= SIGNATURE_32 ('I', 'P', 'F', 'R'),
20 IP4_FRAME_TX_SIGNATURE
= SIGNATURE_32 ('I', 'P', 'F', 'T'),
21 IP4_FRAME_ARP_SIGNATURE
= SIGNATURE_32 ('I', 'P', 'F', 'A'),
22 IP4_INTERFACE_SIGNATURE
= SIGNATURE_32 ('I', 'P', 'I', 'F')
26 This prototype is used by both receive and transmission.
27 When receiving Netbuf is allocated by IP4_INTERFACE, and
28 released by IP4. Flag shows whether the frame is received
29 as link broadcast/multicast...
31 When transmitting, the Netbuf is from IP4, and provided
32 to the callback as a reference. Flag isn't used.
34 @param[in] IpInstance The instance that sent or received the packet.
35 IpInstance can be NULL which means that it is the IP4 driver
36 itself sending the packets. IP4 driver may send packets that
37 don't belong to any instance, such as ICMP errors, ICMP echo
38 responses, or IGMP packets. IpInstance is used as a tag in
40 @param[in] Packet The sent or received packet.
41 @param[in] IoStatus Status of sending or receiving.
42 @param[in] LinkFlag Indicate if the frame is received as link broadcast/multicast.
43 When transmitting, it is not used.
44 @param[in] Context Additional data for callback.
50 (*IP4_FRAME_CALLBACK
)(
51 IN IP4_PROTOCOL
*IpInstance OPTIONAL
,
53 IN EFI_STATUS IoStatus
,
59 /// Each receive request is wrapped in an IP4_LINK_RX_TOKEN.
60 /// Upon completion, the Callback will be called. Only one
61 /// receive request is send to MNP. IpInstance is always NULL.
62 /// Reference MNP's spec for information.
66 IP4_INTERFACE
*Interface
;
68 IP4_PROTOCOL
*IpInstance
;
69 IP4_FRAME_CALLBACK CallBack
;
72 EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken
;
76 /// Each transmit request is wrapped in an IP4_LINK_TX_TOKEN.
77 /// Upon completion, the Callback will be called.
83 IP4_INTERFACE
*Interface
;
85 IP4_PROTOCOL
*IpInstance
;
86 IP4_FRAME_CALLBACK CallBack
;
90 EFI_MAC_ADDRESS DstMac
;
91 EFI_MAC_ADDRESS SrcMac
;
93 EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken
;
94 EFI_MANAGED_NETWORK_TRANSMIT_DATA MnpTxData
;
98 /// Only one ARP request is requested for all the frames in
99 /// a time. It is started for the first frames to the Ip. Any
100 /// subsequent transmission frame will be linked to Frames, and
101 /// be sent all at once the ARP requests succeed.
108 IP4_INTERFACE
*Interface
;
111 // ARP requesting staffs
113 EFI_EVENT OnResolved
;
119 Callback to select which frame to cancel. Caller can cancel a
120 single frame, or all the frame from an IP instance.
122 @param Frame The sending frame to check for cancellation.
123 @param Context Additional data for callback.
125 @retval TRUE The sending of the frame should be cancelled.
126 @retval FALSE Do not cancel the frame sending.
130 (*IP4_FRAME_TO_CANCEL
)(
131 IP4_LINK_TX_TOKEN
*Frame
,
136 // Each IP4 instance has its own station address. All the instances
137 // with the same station address share a single interface structure.
138 // Each interface has its own ARP child, and shares one MNP child.
139 // Notice the special cases that DHCP can configure the interface
140 // with 0.0.0.0/0.0.0.0.
142 struct _IP4_INTERFACE
{
148 // IP address and subnet mask of the interface. It also contains
149 // the subnet/net broadcast address for quick access. The fileds
150 // are invalid if (Configured == FALSE)
154 IP4_ADDR SubnetBrdcast
;
159 // Handle used to create/destory ARP child. All the IP children
160 // share one MNP which is owned by IP service binding.
162 EFI_HANDLE Controller
;
165 EFI_MANAGED_NETWORK_PROTOCOL
*Mnp
;
166 EFI_ARP_PROTOCOL
*Arp
;
167 EFI_HANDLE ArpHandle
;
170 // Queues to keep the frames sent and waiting ARP request.
173 LIST_ENTRY SentFrames
;
174 IP4_LINK_RX_TOKEN
*RecvRequest
;
177 // The interface's MAC and broadcast MAC address.
180 EFI_MAC_ADDRESS BroadcastMac
;
184 // All the IP instances that have the same IP/SubnetMask are linked
185 // together through IpInstances. If any of the instance enables
186 // promiscuous receive, PromiscRecv is true.
188 LIST_ENTRY IpInstances
;
193 Create an IP4_INTERFACE. Delay the creation of ARP instance until
194 the interface is configured.
196 @param[in] Mnp The shared MNP child of this IP4 service binding
198 @param[in] Controller The controller this IP4 service binding instance
199 is installed. Most like the UNDI handle.
200 @param[in] ImageHandle This driver's image handle
202 @return Point to the created IP4_INTERFACE, otherwise NULL.
207 IN EFI_MANAGED_NETWORK_PROTOCOL
*Mnp
,
208 IN EFI_HANDLE Controller
,
209 IN EFI_HANDLE ImageHandle
213 Set the interface's address, create and configure
214 the ARP child if necessary.
216 @param Interface The interface to set the address
217 @param IpAddr The interface's IP address
218 @param SubnetMask The interface's netmask
220 @retval EFI_SUCCESS The interface is configured with Ip/netmask pair,
221 and a ARP is created for it.
222 @retval Others Failed to set the interface's address.
227 IN OUT IP4_INTERFACE
*Interface
,
229 IN IP4_ADDR SubnetMask
233 Free the interface used by IpInstance. All the IP instance with
234 the same Ip/Netmask pair share the same interface. It is reference
235 counted. All the frames haven't been sent will be cancelled.
236 Because the IpInstance is optional, the caller must remove
237 IpInstance from the interface's instance list itself.
239 @param[in] Interface The interface used by the IpInstance
240 @param[in] IpInstance The Ip instance that free the interface. NULL if
241 the Ip driver is releasing the default interface.
243 @retval EFI_SUCCESS The interface use IpInstance is freed.
248 IN IP4_INTERFACE
*Interface
,
249 IN IP4_PROTOCOL
*IpInstance OPTIONAL
253 Send a frame from the interface. If the next hop is broadcast or
254 multicast address, it is transmitted immediately. If the next hop
255 is a unicast, it will consult ARP to resolve the NextHop's MAC.
256 If some error happened, the CallBack won't be called. So, the caller
257 must test the return value, and take action when there is an error.
259 @param[in] Interface The interface to send the frame from
260 @param[in] IpInstance The IP child that request the transmission. NULL
261 if it is the IP4 driver itself.
262 @param[in] Packet The packet to transmit.
263 @param[in] NextHop The immediate destination to transmit the packet
265 @param[in] CallBack Function to call back when transmit finished.
266 @param[in] Context Opaque parameter to the call back.
268 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource to send the frame
269 @retval EFI_NO_MAPPING Can't resolve the MAC for the nexthop
270 @retval EFI_SUCCESS The packet is successfully transmitted.
271 @retval other Other error occurs.
276 IN IP4_INTERFACE
*Interface
,
277 IN IP4_PROTOCOL
*IpInstance OPTIONAL
,
280 IN IP4_FRAME_CALLBACK CallBack
,
285 Remove all the frames on the interface that pass the FrameToCancel,
286 either queued on ARP queues or that have already been delivered to
287 MNP and not yet recycled.
289 @param[in] Interface Interface to remove the frames from
290 @param[in] IoStatus The transmit status returned to the frames'
292 @param[in] FrameToCancel Function to select the frame to cancel, NULL to
294 @param[in] Context Opaque parameters passed to FrameToCancel
299 IN IP4_INTERFACE
*Interface
,
300 IN EFI_STATUS IoStatus
,
301 IN IP4_FRAME_TO_CANCEL FrameToCancel OPTIONAL
,
306 If there is a pending receive request, cancel it. Don't call
307 the receive request's callback because this function can be only
308 called if the instance or driver is tearing itself down. It
309 doesn't make sense to call it back. But it is necessary to call
310 the transmit token's callback to give it a chance to free the
311 packet and update the upper layer's transmit request status, say
314 @param[in] Interface The interface used by the IpInstance
319 IN IP4_INTERFACE
*Interface
323 Request to receive the packet from the interface.
325 @param[in] Interface The interface to receive the frames from
326 @param[in] IpInstance The instance that requests the receive. NULL for
328 @param[in] CallBack Function to call when receive finished.
329 @param[in] Context Opaque parameter to the callback
331 @retval EFI_ALREADY_STARTED There is already a pending receive request.
332 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource to receive
333 @retval EFI_SUCCESS The recieve request has been started.
334 @retval other Other error occurs.
339 IN IP4_INTERFACE
*Interface
,
340 IN IP4_PROTOCOL
*IpInstance OPTIONAL
,
341 IN IP4_FRAME_CALLBACK CallBack
,