3 Copyright (c) 2005 - 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 Definition for IP4 pesudo interface structure.
24 #ifndef __EFI_IP4_IF_H__
25 #define __EFI_IP4_IF_H__
28 IP4_FRAME_RX_SIGNATURE
= EFI_SIGNATURE_32 ('I', 'P', 'F', 'R'),
29 IP4_FRAME_TX_SIGNATURE
= EFI_SIGNATURE_32 ('I', 'P', 'F', 'T'),
30 IP4_FRAME_ARP_SIGNATURE
= EFI_SIGNATURE_32 ('I', 'P', 'F', 'A'),
31 IP4_INTERFACE_SIGNATURE
= EFI_SIGNATURE_32 ('I', 'P', 'I', 'F')
35 This prototype is used by both receive and transmission.
36 When receiving Netbuf is allocated by IP4_INTERFACE, and
37 released by IP4. Flag shows whether the frame is received
38 as link broadcast/multicast...
40 When transmitting, the Netbuf is from IP4, and provided
41 to the callback as a reference. Flag isn't used.
43 @param IpInstance The instance that sent or received the packet.
44 IpInstance can be NULL which means that it is the IP4 driver
45 itself sending the packets. IP4 driver may send packets that
46 don't belong to any instance, such as ICMP errors, ICMP echo
47 responses, or IGMP packets. IpInstance is used as a tag in
49 @param Packet The sent or received packet.
50 @param IoStatus Status of sending or receiving.
51 @param LinkFlag Indicate if the frame is received as link broadcast/multicast.
52 When transmitting, it is not used.
53 @param Context Additional data for callback.
59 (*IP4_FRAME_CALLBACK
)(
60 IN IP4_PROTOCOL
*IpInstance
, OPTIONAL
62 IN EFI_STATUS IoStatus
,
68 /// Each receive request is wrapped in an IP4_LINK_RX_TOKEN.
69 /// Upon completion, the Callback will be called. Only one
70 /// receive request is send to MNP. IpInstance is always NULL.
71 /// Reference MNP's spec for information.
75 IP4_INTERFACE
*Interface
;
77 IP4_PROTOCOL
*IpInstance
;
78 IP4_FRAME_CALLBACK CallBack
;
81 EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken
;
85 /// Each transmit request is wrapped in an IP4_LINK_TX_TOKEN.
86 /// Upon completion, the Callback will be called.
92 IP4_INTERFACE
*Interface
;
94 IP4_PROTOCOL
*IpInstance
;
95 IP4_FRAME_CALLBACK CallBack
;
99 EFI_MAC_ADDRESS DstMac
;
100 EFI_MAC_ADDRESS SrcMac
;
102 EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken
;
103 EFI_MANAGED_NETWORK_TRANSMIT_DATA MnpTxData
;
107 /// Only one ARP request is requested for all the frames in
108 /// a time. It is started for the first frames to the Ip. Any
109 /// subsequent transmission frame will be linked to Frames, and
110 /// be sent all at once the ARP requests succeed.
117 IP4_INTERFACE
*Interface
;
120 // ARP requesting staffs
122 EFI_EVENT OnResolved
;
128 Callback to select which frame to cancel. Caller can cancel a
129 single frame, or all the frame from an IP instance.
131 @param Frame The sending frame to check for cancellation.
132 @param Context Additional data for callback.
134 @retval TRUE The sending of the frame should be cancelled.
135 @retval FALSE Do not cancel the frame sending.
139 (*IP4_FRAME_TO_CANCEL
)(
140 IP4_LINK_TX_TOKEN
*Frame
,
145 // Each IP4 instance has its own station address. All the instances
146 // with the same station address share a single interface structure.
147 // Each interface has its own ARP child, and shares one MNP child.
148 // Notice the special cases that DHCP can configure the interface
149 // with 0.0.0.0/0.0.0.0.
151 struct _IP4_INTERFACE
{
157 // IP address and subnet mask of the interface. It also contains
158 // the subnet/net broadcast address for quick access. The fileds
159 // are invalid if (Configured == FALSE)
163 IP4_ADDR SubnetBrdcast
;
168 // Handle used to create/destory ARP child. All the IP children
169 // share one MNP which is owned by IP service binding.
171 EFI_HANDLE Controller
;
174 EFI_MANAGED_NETWORK_PROTOCOL
*Mnp
;
175 EFI_ARP_PROTOCOL
*Arp
;
176 EFI_HANDLE ArpHandle
;
179 // Queues to keep the frames sent and waiting ARP request.
182 LIST_ENTRY SentFrames
;
183 IP4_LINK_RX_TOKEN
*RecvRequest
;
186 // The interface's MAC and broadcast MAC address.
189 EFI_MAC_ADDRESS BroadcastMac
;
193 // All the IP instances that have the same IP/SubnetMask are linked
194 // together through IpInstances. If any of the instance enables
195 // promiscuous receive, PromiscRecv is true.
197 LIST_ENTRY IpInstances
;
202 Create an IP4_INTERFACE. Delay the creation of ARP instance until
203 the interface is configured.
205 @param Mnp The shared MNP child of this IP4 service binding
207 @param Controller The controller this IP4 service binding instance
208 is installed. Most like the UNDI handle.
209 @param ImageHandle This driver's image handle
211 @return Point to the created IP4_INTERFACE, otherwise NULL.
216 IN EFI_MANAGED_NETWORK_PROTOCOL
*Mnp
,
217 IN EFI_HANDLE Controller
,
218 IN EFI_HANDLE ImageHandle
222 Set the interface's address, create and configure
223 the ARP child if necessary.
225 @param Interface The interface to set the address
226 @param IpAddr The interface's IP address
227 @param SubnetMask The interface's netmask
229 @retval EFI_SUCCESS The interface is configured with Ip/netmask pair,
230 and a ARP is created for it.
231 @retval Others Failed to set the interface's address.
236 IN OUT IP4_INTERFACE
*Interface
,
238 IN IP4_ADDR SubnetMask
242 Free the interface used by IpInstance. All the IP instance with
243 the same Ip/Netmask pair share the same interface. It is reference
244 counted. All the frames haven't been sent will be cancelled.
245 Because the IpInstance is optional, the caller must remove
246 IpInstance from the interface's instance list itself.
248 @param Interface The interface used by the IpInstance
249 @param IpInstance The Ip instance that free the interface. NULL if
250 the Ip driver is releasing the default interface.
252 @retval EFI_SUCCESS The interface use IpInstance is freed.
257 IN IP4_INTERFACE
*Interface
,
258 IN IP4_PROTOCOL
*IpInstance OPTIONAL
262 Send a frame from the interface. If the next hop is broadcast or
263 multicast address, it is transmitted immediately. If the next hop
264 is a unicast, it will consult ARP to resolve the NextHop's MAC.
265 If some error happened, the CallBack won't be called. So, the caller
266 must test the return value, and take action when there is an error.
268 @param Interface The interface to send the frame from
269 @param IpInstance The IP child that request the transmission. NULL
270 if it is the IP4 driver itself.
271 @param Packet The packet to transmit.
272 @param NextHop The immediate destination to transmit the packet
274 @param CallBack Function to call back when transmit finished.
275 @param Context Opaque parameter to the call back.
277 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource to send the frame
278 @retval EFI_NO_MAPPING Can't resolve the MAC for the nexthop
279 @retval EFI_SUCCESS The packet is successfully transmitted.
280 @retval other Other error occurs.
285 IN IP4_INTERFACE
*Interface
,
286 IN IP4_PROTOCOL
*IpInstance
, OPTIONAL
289 IN IP4_FRAME_CALLBACK CallBack
,
294 Remove all the frames on the interface that pass the FrameToCancel,
295 either queued on ARP queues or that have already been delivered to
296 MNP and not yet recycled.
298 @param Interface Interface to remove the frames from
299 @param IoStatus The transmit status returned to the frames'
301 @param FrameToCancel Function to select the frame to cancel, NULL to
303 @param Context Opaque parameters passed to FrameToCancel
310 IN IP4_INTERFACE
*Interface
,
311 IN EFI_STATUS IoStatus
,
312 IN IP4_FRAME_TO_CANCEL FrameToCancel
, OPTIONAL
317 If there is a pending receive request, cancel it. Don't call
318 the receive request's callback because this function can be only
319 called if the instance or driver is tearing itself down. It
320 doesn't make sense to call it back. But it is necessary to call
321 the transmit token's callback to give it a chance to free the
322 packet and update the upper layer's transmit request status, say
325 @param Interface The interface used by the IpInstance
332 IN IP4_INTERFACE
*Interface
336 Request to receive the packet from the interface.
338 @param Interface The interface to receive the frames from
339 @param IpInstance The instance that requests the receive. NULL for
341 @param CallBack Function to call when receive finished.
342 @param Context Opaque parameter to the callback
344 @retval EFI_ALREADY_STARTED There is already a pending receive request.
345 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource to receive
346 @retval EFI_SUCCESS The recieve request has been started.
347 @retval other Other error occurs.
352 IN IP4_INTERFACE
*Interface
,
353 IN IP4_PROTOCOL
*IpInstance
, OPTIONAL
354 IN IP4_FRAME_CALLBACK CallBack
,