2 Tcp driver function header.
4 Copyright (c) 2005 - 2014, 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<BR>
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 _TCP4_DRIVER_H_
16 #define _TCP4_DRIVER_H_
18 #include <Protocol/ServiceBinding.h>
19 #include <Library/IpIoLib.h>
21 #define TCP4_DRIVER_SIGNATURE SIGNATURE_32 ('T', 'C', 'P', '4')
23 #define TCP4_PORT_KNOWN 1024
24 #define TCP4_PORT_USER_RESERVED 65535
26 #define TCP4_FROM_THIS(a) \
31 TCP4_DRIVER_SIGNATURE \
35 /// TCP heartbeat tick timer.
37 typedef struct _TCP4_HEARTBEAT_TIMER
{
38 EFI_EVENT TimerEvent
; ///< The event assoiated with the timer
39 INTN RefCnt
; ///< Number of reference
40 } TCP4_HEARTBEAT_TIMER
;
45 typedef struct _TCP4_SERVICE_DATA
{
47 EFI_HANDLE ControllerHandle
;
48 IP_IO
*IpIo
; // IP Io consumed by TCP4
49 EFI_SERVICE_BINDING_PROTOCOL Tcp4ServiceBinding
;
50 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
82 IN EFI_NET_SESSION_DATA
*NetSession
,
84 IN VOID
*Context OPTIONAL
88 Send the segment to IP via IpIo function.
90 @param Tcb Pointer to the TCP_CB of this TCP instance.
91 @param Nbuf Pointer to the TCP segment to be sent.
92 @param Src Source address of the TCP segment.
93 @param Dest Destination address of the TCP segment.
95 @retval 0 The segment was sent out successfully.
96 @retval -1 The segment was failed to send.
108 The procotol handler provided to the socket layer, used to
109 dispatch the socket level requests by calling the corresponding
112 @param Sock Pointer to the socket of this TCP instance.
113 @param Request The code of this operation request.
114 @param Data Pointer to the operation specific data passed in
115 together with the operation request.
117 @retval EFI_SUCCESS The socket request is completed successfully.
118 @retval other The error status returned by the corresponding TCP
126 IN VOID
*Data OPTIONAL
131 The entry point for Tcp4 driver, used to install Tcp4 driver on the ImageHandle.
133 @param ImageHandle The firmware allocated handle for this
135 @param SystemTable Pointer to the EFI system table.
137 @retval EFI_SUCCESS Driver loaded.
138 @retval other Driver not loaded.
143 Tcp4DriverEntryPoint (
144 IN EFI_HANDLE ImageHandle
,
145 IN EFI_SYSTEM_TABLE
*SystemTable
150 Tests to see if this driver supports a given controller.
152 If a child device is provided, it further tests to see if this driver supports
153 creating a handle for the specified child device.
155 @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
156 @param ControllerHandle The handle of the controller to test. This handle
157 must support a protocol interface that supplies
158 an I/O abstraction to the driver.
159 @param RemainingDevicePath A pointer to the remaining portion of a device path.
160 This parameter is ignored by device drivers, and is optional for bus drivers.
163 @retval EFI_SUCCESS The device specified by ControllerHandle and
164 RemainingDevicePath is supported by the driver
166 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
167 RemainingDevicePath is already being managed by
168 the driver specified by This.
169 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
170 RemainingDevicePath is already being managed by a
171 different driver or an application that requires
173 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
174 RemainingDevicePath is not supported by the driver
180 Tcp4DriverBindingSupported (
181 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
182 IN EFI_HANDLE ControllerHandle
,
183 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
187 Start this driver on ControllerHandle.
189 The Start() function is designed to be invoked from the EFI boot service
190 ConnectController(). As a result, much of the error checking on the parameters
191 to Start() has been moved into this common boot service. It is legal to call
192 Start() from other locations, but the following calling restrictions must be
193 followed or the system behavior will not be deterministic.
194 1. ControllerHandle must be a valid EFI_HANDLE.
195 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally
196 aligned EFI_DEVICE_PATH_PROTOCOL.
197 3. Prior to calling Start(), the Supported() function for the driver specified
198 by This must have been called with the same calling parameters, and Supported()
199 must have returned EFI_SUCCESS.
201 @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
202 @param ControllerHandle The handle of the controller to start. This handle
203 must support a protocol interface that supplies
204 an I/O abstraction to the driver.
205 @param RemainingDevicePath A pointer to the remaining portion of a device path.
206 This parameter is ignored by device drivers, and is
207 optional for bus drivers.
209 @retval EFI_SUCCESS The device was started.
210 @retval EFI_ALREADY_STARTED The device could not be started due to a device error.
211 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack
217 Tcp4DriverBindingStart (
218 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
219 IN EFI_HANDLE ControllerHandle
,
220 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
224 Stop this driver on ControllerHandle.
226 The Stop() function is designed to be invoked from the EFI boot service
227 DisconnectController(). As a result, much of the error checking on the parameters
228 to Stop() has been moved into this common boot service. It is legal to call Stop()
229 from other locations, but the following calling restrictions must be followed
230 or the system behavior will not be deterministic.
231 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call
232 to this same driver's Start() function.
233 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
234 EFI_HANDLE. In addition, all of these handles must have been created in this
235 driver's Start() function, and the Start() function must have called OpenProtocol()
236 on ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
238 @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
239 @param ControllerHandle A handle to the device being stopped. The handle must
240 support a bus specific I/O protocol for the driver
241 to use to stop the device.
242 @param NumberOfChildren The number of child device handles in ChildHandleBuffer.
243 @param ChildHandleBuffer An array of child handles to be freed. May be NULL if
244 NumberOfChildren is 0.
246 @retval EFI_SUCCESS The device was stopped.
247 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
252 Tcp4DriverBindingStop (
253 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
254 IN EFI_HANDLE ControllerHandle
,
255 IN UINTN NumberOfChildren
,
256 IN EFI_HANDLE
*ChildHandleBuffer
260 Open Ip4 and device path protocols for a created socket, and insert it in
263 @param This Pointer to the socket just created
264 @param Context Context of the socket
266 @retval EFI_SUCCESS This protocol is installed successfully.
267 @retval other Some error occured.
271 Tcp4CreateSocketCallback (
277 Close Ip4 and device path protocols for a socket, and remove it from socket list.
279 @param This Pointer to the socket to be removed
280 @param Context Context of the socket
284 Tcp4DestroySocketCallback (
290 Creates a child handle and installs a protocol.
292 The CreateChild() function installs a protocol on ChildHandle. If ChildHandle
293 is a pointer to NULL, then a new handle is created and returned in ChildHandle.
294 If ChildHandle is not a pointer to NULL, then the protocol installs on the existing
297 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
298 @param ChildHandle Pointer to the handle of the child to create. If it is NULL, then
299 a new handle is created. If it is a pointer to an existing UEFI
300 handle, then the protocol is added to the existing UEFI handle.
302 @retval EFI_SUCCES The protocol was added to ChildHandle.
303 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.
304 @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create
306 @retval other The child handle was not created.
311 Tcp4ServiceBindingCreateChild (
312 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
313 IN OUT EFI_HANDLE
*ChildHandle
317 Destroys a child handle with a protocol installed on it.
319 The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
320 that was installed by CreateChild() from ChildHandle. If the removed protocol is the
321 last protocol on ChildHandle, then ChildHandle is destroyed.
323 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
324 @param ChildHandle Handle of the child to destroy
326 @retval EFI_SUCCES The protocol was removed from ChildHandle.
327 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is
329 @retval EFI_INVALID_PARAMETER Child handle is NULL.
330 @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle
331 because its services are being used.
332 @retval other The child handle was not destroyed.
337 Tcp4ServiceBindingDestroyChild (
338 IN EFI_SERVICE_BINDING_PROTOCOL
*This
,
339 IN EFI_HANDLE ChildHandle