3 Copyright (c) 2005 - 2006, Intel Corporation<BR>
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<BR>
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.
14 #ifndef _TCP4_DRIVER_H_
15 #define _TCP4_DRIVER_H_
17 #include <Protocol/ServiceBinding.h>
18 #include <Library/IpIoLib.h>
20 #define TCP4_DRIVER_SIGNATURE SIGNATURE_32 ('T', 'C', 'P', '4')
22 #define TCP4_PORT_KNOWN 1024
23 #define TCP4_PORT_USER_RESERVED 65535
25 #define TCP4_FROM_THIS(a) \
30 TCP4_DRIVER_SIGNATURE \
34 /// TCP heartbeat tick timer.
36 typedef struct _TCP4_HEARTBEAT_TIMER
{
37 EFI_EVENT TimerEvent
; ///< The event assoiated with the timer
38 INTN RefCnt
; ///< Number of reference
39 } TCP4_HEARTBEAT_TIMER
;
44 typedef struct _TCP4_SERVICE_DATA
{
46 EFI_HANDLE ControllerHandle
;
47 IP_IO
*IpIo
; // IP Io consumed by TCP4
48 EFI_SERVICE_BINDING_PROTOCOL Tcp4ServiceBinding
;
49 EFI_HANDLE DriverBindingHandle
;
51 LIST_ENTRY SocketList
;
57 typedef struct _TCP4_PROTO_DATA
{
58 TCP4_SERVICE_DATA
*TcpService
;
64 Packet receive callback function provided to IP_IO, used to call
65 the proper function to handle the packet received by IP.
67 @param Status Status of the received packet.
68 @param IcmpErr ICMP error number.
69 @param NetSession Pointer to the net session of this packet.
70 @param Pkt Pointer to the recieved packet.
71 @param Context Pointer to the context configured in IpIoOpen(), not used
80 IN ICMP_ERROR IcmpErr
,
81 IN EFI_NET_SESSION_DATA
*NetSession
,
83 IN VOID
*Context OPTIONAL
87 Send the segment to IP via IpIo function.
89 @param Tcb Pointer to the TCP_CB of this TCP instance.
90 @param Nbuf Pointer to the TCP segment to be sent.
91 @param Src Source address of the TCP segment.
92 @param Dest Destination address of the TCP segment.
94 @retval 0 The segment was sent out successfully.
95 @retval -1 The segment was failed to send.
107 The procotol handler provided to the socket layer, used to
108 dispatch the socket level requests by calling the corresponding
111 @param Sock Pointer to the socket of this TCP instance.
112 @param Request The code of this operation request.
113 @param Data Pointer to the operation specific data passed in
114 together with the operation request.
116 @retval EFI_SUCCESS The socket request is completed successfully.
117 @retval other The error status returned by the corresponding TCP
124 IN SOCK_REQUEST Request
,
125 IN VOID
*Data OPTIONAL
130 The entry point for Tcp4 driver, used to install Tcp4 driver on the ImageHandle.
132 @param ImageHandle The firmware allocated handle for this
134 @param SystemTable Pointer to the EFI system table.
136 @retval EFI_SUCCESS Driver loaded.
137 @retval other Driver not loaded.
142 Tcp4DriverEntryPoint (
143 IN EFI_HANDLE ImageHandle
,
144 IN EFI_SYSTEM_TABLE
*SystemTable
149 Tests to see if this driver supports a given controller.
151 If a child device is provided, it further tests to see if this driver supports
152 creating a handle for the specified child device.
154 @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
155 @param ControllerHandle The handle of the controller to test. This handle
156 must support a protocol interface that supplies
157 an I/O abstraction to the driver.
158 @param RemainingDevicePath A pointer to the remaining portion of a device path.
159 This parameter is ignored by device drivers, and is optional for bus drivers.
162 @retval EFI_SUCCESS The device specified by ControllerHandle and
163 RemainingDevicePath is supported by the driver
165 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
166 RemainingDevicePath is already being managed by
167 the driver specified by This.
168 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
169 RemainingDevicePath is already being managed by a
170 different driver or an application that requires
172 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
173 RemainingDevicePath is not supported by the driver
179 Tcp4DriverBindingSupported (
180 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
181 IN EFI_HANDLE ControllerHandle
,
182 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
186 Start this driver on ControllerHandle.
188 The Start() function is designed to be invoked from the EFI boot service
189 ConnectController(). As a result, much of the error checking on the parameters
190 to Start() has been moved into this common boot service. It is legal to call
191 Start() from other locations, but the following calling restrictions must be
192 followed or the system behavior will not be deterministic.
193 1. ControllerHandle must be a valid EFI_HANDLE.
194 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally
195 aligned EFI_DEVICE_PATH_PROTOCOL.
196 3. Prior to calling Start(), the Supported() function for the driver specified
197 by This must have been called with the same calling parameters, and Supported()
198 must have returned EFI_SUCCESS.
200 @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
201 @param ControllerHandle The handle of the controller to start. This handle
202 must support a protocol interface that supplies
203 an I/O abstraction to the driver.
204 @param RemainingDevicePath A pointer to the remaining portion of a device path.
205 This parameter is ignored by device drivers, and is
206 optional for bus drivers.
208 @retval EFI_SUCCESS The device was started.
209 @retval EFI_ALREADY_STARTED The device could not be started due to a device error.
210 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack
216 Tcp4DriverBindingStart (
217 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
218 IN EFI_HANDLE ControllerHandle
,
219 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
223 Stop this driver on ControllerHandle.
225 The Stop() function is designed to be invoked from the EFI boot service
226 DisconnectController(). As a result, much of the error checking on the parameters
227 to Stop() has been moved into this common boot service. It is legal to call Stop()
228 from other locations, but the following calling restrictions must be followed
229 or the system behavior will not be deterministic.
230 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call
231 to this same driver's Start() function.
232 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
233 EFI_HANDLE. In addition, all of these handles must have been created in this
234 driver's Start() function, and the Start() function must have called OpenProtocol()
235 on ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
237 @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
238 @param ControllerHandle A handle to the device being stopped. The handle must
239 support a bus specific I/O protocol for the driver
240 to use to stop the device.
241 @param NumberOfChildren The number of child device handles in ChildHandleBuffer.
242 @param ChildHandleBuffer An array of child handles to be freed. May be NULL if
243 NumberOfChildren is 0.
245 @retval EFI_SUCCESS The device was stopped.
246 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
251 Tcp4DriverBindingStop (
252 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
253 IN EFI_HANDLE ControllerHandle
,
254 IN UINTN NumberOfChildren
,
255 IN EFI_HANDLE
*ChildHandleBuffer
259 Open Ip4 and device path protocols for a created socket, and insert it in
262 @param This Pointer to the socket just created
263 @param Context Context of the socket
265 @retval EFI_SUCCESS This protocol is installed successfully.
266 @retval other Some error occured.
270 Tcp4CreateSocketCallback (
276 Close Ip4 and device path protocols for a socket, and remove it from socket list.
278 @param This Pointer to the socket to be removed
279 @param Context Context of the socket
283 Tcp4DestroySocketCallback (
289 Creates a child handle and installs a protocol.
291 The CreateChild() function installs a protocol on ChildHandle. If ChildHandle
292 is a pointer to NULL, then a new handle is created and returned in ChildHandle.
293 If ChildHandle is not a pointer to NULL, then the protocol installs on the existing
296 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
297 @param ChildHandle Pointer to the handle of the child to create. If it is NULL, then
298 a new handle is created. If it is a pointer to an existing UEFI
299 handle, then the protocol is added to the existing UEFI handle.
301 @retval EFI_SUCCES The protocol was added to ChildHandle.
302 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
303 @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create
305 @retval other The child handle was not created.
310 Tcp4ServiceBindingCreateChild (
311 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
312 IN OUT EFI_HANDLE
*ChildHandle
316 Destroys a child handle with a protocol installed on it.
318 The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
319 that was installed by CreateChild() from ChildHandle. If the removed protocol is the
320 last protocol on ChildHandle, then ChildHandle is destroyed.
322 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
323 @param ChildHandle Handle of the child to destroy
325 @retval EFI_SUCCES The protocol was removed from ChildHandle.
326 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is
328 @retval EFI_INVALID_PARAMETER Child handle is not a valid UEFI Handle.
329 @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle
330 because its services are being used.
331 @retval other The child handle was not destroyed.
336 Tcp4ServiceBindingDestroyChild (
337 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
338 IN EFI_HANDLE ChildHandle