]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.h
Update the copyright notice format
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Tcp4Dxe / Tcp4Driver.h
CommitLineData
83cbd279 1/** @file\r
dab714aa 2 Tcp driver function header.\r
83cbd279 3\r
e5eed7d3
HT
4Copyright (c) 2005 - 2009, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials\r
83cbd279 6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
dfc1f033 8http://opensource.org/licenses/bsd-license.php<BR>\r
83cbd279 9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
83cbd279 13**/\r
14\r
15#ifndef _TCP4_DRIVER_H_\r
16#define _TCP4_DRIVER_H_\r
17\r
18#include <Protocol/ServiceBinding.h>\r
19#include <Library/IpIoLib.h>\r
20\r
7dc2fc3d 21#define TCP4_DRIVER_SIGNATURE SIGNATURE_32 ('T', 'C', 'P', '4')\r
83cbd279 22\r
23#define TCP4_PORT_KNOWN 1024\r
24#define TCP4_PORT_USER_RESERVED 65535\r
25\r
dfc1f033 26#define TCP4_FROM_THIS(a) \\r
27 CR ( \\r
28 (a), \\r
29 TCP4_SERVICE_DATA, \\r
30 Tcp4ServiceBinding, \\r
31 TCP4_DRIVER_SIGNATURE \\r
32 )\r
276dcc1b 33 \r
34///\r
35/// TCP heartbeat tick timer.\r
36///\r
83cbd279 37typedef struct _TCP4_HEARTBEAT_TIMER {\r
276dcc1b 38 EFI_EVENT TimerEvent; ///< The event assoiated with the timer\r
39 INTN RefCnt; ///< Number of reference\r
83cbd279 40} TCP4_HEARTBEAT_TIMER;\r
41\r
276dcc1b 42///\r
43/// TCP service data\r
44///\r
83cbd279 45typedef struct _TCP4_SERVICE_DATA {\r
46 UINT32 Signature;\r
47 EFI_HANDLE ControllerHandle;\r
48 IP_IO *IpIo; // IP Io consumed by TCP4\r
49 EFI_SERVICE_BINDING_PROTOCOL Tcp4ServiceBinding;\r
50 EFI_HANDLE DriverBindingHandle;\r
51 CHAR16 *MacString;\r
e48e37fc 52 LIST_ENTRY SocketList;\r
83cbd279 53} TCP4_SERVICE_DATA;\r
54\r
276dcc1b 55///\r
56/// TCP protocol data\r
57///\r
58typedef struct _TCP4_PROTO_DATA {\r
59 TCP4_SERVICE_DATA *TcpService;\r
60 TCP_CB *TcpPcb;\r
61} TCP4_PROTO_DATA;\r
dfc1f033 62\r
63\r
64/**\r
65 Packet receive callback function provided to IP_IO, used to call\r
66 the proper function to handle the packet received by IP.\r
67\r
68 @param Status Status of the received packet.\r
69 @param IcmpErr ICMP error number.\r
70 @param NetSession Pointer to the net session of this packet.\r
71 @param Pkt Pointer to the recieved packet.\r
72 @param Context Pointer to the context configured in IpIoOpen(), not used\r
73 now.\r
74\r
75 @return None\r
76\r
77**/\r
83cbd279 78VOID\r
e798cd87 79EFIAPI\r
83cbd279 80Tcp4RxCallback (\r
81 IN EFI_STATUS Status,\r
b45b45b2 82 IN UINT8 IcmpErr,\r
83cbd279 83 IN EFI_NET_SESSION_DATA *NetSession,\r
84 IN NET_BUF *Pkt,\r
85 IN VOID *Context OPTIONAL\r
86 );\r
87\r
dfc1f033 88/**\r
89 Send the segment to IP via IpIo function.\r
90\r
91 @param Tcb Pointer to the TCP_CB of this TCP instance.\r
92 @param Nbuf Pointer to the TCP segment to be sent.\r
93 @param Src Source address of the TCP segment.\r
94 @param Dest Destination address of the TCP segment.\r
95\r
96 @retval 0 The segment was sent out successfully.\r
97 @retval -1 The segment was failed to send.\r
98\r
99**/\r
83cbd279 100INTN\r
101TcpSendIpPacket (\r
102 IN TCP_CB *Tcb,\r
103 IN NET_BUF *Nbuf,\r
104 IN UINT32 Src,\r
105 IN UINT32 Dest\r
106 );\r
107\r
dfc1f033 108/**\r
109 The procotol handler provided to the socket layer, used to\r
110 dispatch the socket level requests by calling the corresponding\r
111 TCP layer functions.\r
112\r
113 @param Sock Pointer to the socket of this TCP instance.\r
114 @param Request The code of this operation request.\r
115 @param Data Pointer to the operation specific data passed in\r
116 together with the operation request.\r
117\r
118 @retval EFI_SUCCESS The socket request is completed successfully.\r
119 @retval other The error status returned by the corresponding TCP\r
120 layer function.\r
121\r
122**/\r
83cbd279 123EFI_STATUS\r
124Tcp4Dispatcher (\r
125 IN SOCKET *Sock,\r
f6b7393c 126 IN UINT8 Request,\r
dfc1f033 127 IN VOID *Data OPTIONAL\r
83cbd279 128 );\r
129\r
83cbd279 130\r
dfc1f033 131/**\r
132 The entry point for Tcp4 driver, used to install Tcp4 driver on the ImageHandle.\r
83cbd279 133\r
dfc1f033 134 @param ImageHandle The firmware allocated handle for this\r
135 driver image.\r
136 @param SystemTable Pointer to the EFI system table.\r
137\r
138 @retval EFI_SUCCESS Driver loaded.\r
139 @retval other Driver not loaded.\r
140\r
141**/\r
83cbd279 142EFI_STATUS\r
143EFIAPI\r
144Tcp4DriverEntryPoint (\r
145 IN EFI_HANDLE ImageHandle,\r
146 IN EFI_SYSTEM_TABLE *SystemTable\r
147 );\r
148\r
dfc1f033 149\r
150/**\r
151 Tests to see if this driver supports a given controller.\r
152 \r
153 If a child device is provided, it further tests to see if this driver supports \r
154 creating a handle for the specified child device.\r
155\r
156 @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
157 @param ControllerHandle The handle of the controller to test. This handle \r
158 must support a protocol interface that supplies \r
159 an I/O abstraction to the driver.\r
160 @param RemainingDevicePath A pointer to the remaining portion of a device path. \r
161 This parameter is ignored by device drivers, and is optional for bus drivers.\r
162\r
163\r
164 @retval EFI_SUCCESS The device specified by ControllerHandle and\r
165 RemainingDevicePath is supported by the driver \r
166 specified by This.\r
167 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and\r
168 RemainingDevicePath is already being managed by \r
169 the driver specified by This.\r
170 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and\r
171 RemainingDevicePath is already being managed by a \r
172 different driver or an application that requires \r
173 exclusive access.\r
174 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and\r
175 RemainingDevicePath is not supported by the driver \r
176 specified by This.\r
177 \r
178**/\r
83cbd279 179EFI_STATUS\r
180EFIAPI\r
181Tcp4DriverBindingSupported (\r
120db52c 182 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
83cbd279 183 IN EFI_HANDLE ControllerHandle,\r
120db52c 184 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
83cbd279 185 );\r
186\r
dfc1f033 187/**\r
188 Start this driver on ControllerHandle. \r
189 \r
190 The Start() function is designed to be invoked from the EFI boot service \r
191 ConnectController(). As a result, much of the error checking on the parameters \r
192 to Start() has been moved into this common boot service. It is legal to call \r
193 Start() from other locations, but the following calling restrictions must be \r
194 followed or the system behavior will not be deterministic.\r
195 1. ControllerHandle must be a valid EFI_HANDLE.\r
196 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally \r
197 aligned EFI_DEVICE_PATH_PROTOCOL.\r
198 3. Prior to calling Start(), the Supported() function for the driver specified \r
199 by This must have been called with the same calling parameters, and Supported() \r
200 must have returned EFI_SUCCESS.\r
201\r
202 @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
203 @param ControllerHandle The handle of the controller to start. This handle \r
204 must support a protocol interface that supplies \r
205 an I/O abstraction to the driver.\r
206 @param RemainingDevicePath A pointer to the remaining portion of a device path. \r
207 This parameter is ignored by device drivers, and is \r
208 optional for bus drivers.\r
209\r
210 @retval EFI_SUCCESS The device was started.\r
211 @retval EFI_ALREADY_STARTED The device could not be started due to a device error.\r
212 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack \r
213 of resources.\r
214\r
215**/\r
83cbd279 216EFI_STATUS\r
217EFIAPI\r
218Tcp4DriverBindingStart (\r
120db52c 219 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
83cbd279 220 IN EFI_HANDLE ControllerHandle,\r
120db52c 221 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
83cbd279 222 );\r
223\r
dfc1f033 224/**\r
225 Stop this driver on ControllerHandle.\r
226 \r
227 The Stop() function is designed to be invoked from the EFI boot service \r
228 DisconnectController(). As a result, much of the error checking on the parameters \r
229 to Stop() has been moved into this common boot service. It is legal to call Stop() \r
230 from other locations, but the following calling restrictions must be followed \r
231 or the system behavior will not be deterministic.\r
232 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call \r
233 to this same driver's Start() function.\r
234 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r
235 EFI_HANDLE. In addition, all of these handles must have been created in this \r
236 driver's Start() function, and the Start() function must have called OpenProtocol() \r
237 on ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
238 \r
239 @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
240 @param ControllerHandle A handle to the device being stopped. The handle must \r
241 support a bus specific I/O protocol for the driver \r
242 to use to stop the device.\r
243 @param NumberOfChildren The number of child device handles in ChildHandleBuffer.\r
244 @param ChildHandleBuffer An array of child handles to be freed. May be NULL if \r
245 NumberOfChildren is 0.\r
246\r
247 @retval EFI_SUCCESS The device was stopped.\r
248 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r
249\r
250**/\r
83cbd279 251EFI_STATUS\r
252EFIAPI\r
253Tcp4DriverBindingStop (\r
254 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
255 IN EFI_HANDLE ControllerHandle,\r
256 IN UINTN NumberOfChildren,\r
257 IN EFI_HANDLE *ChildHandleBuffer\r
258 );\r
259\r
dfc1f033 260/**\r
261 Open Ip4 and device path protocols for a created socket, and insert it in \r
262 socket list.\r
263 \r
264 @param This Pointer to the socket just created\r
265 @param Context Context of the socket\r
266 \r
267 @retval EFI_SUCCESS This protocol is installed successfully.\r
268 @retval other Some error occured.\r
269 \r
270**/\r
4f6e31e4 271EFI_STATUS\r
272Tcp4CreateSocketCallback (\r
273 IN SOCKET *This,\r
274 IN VOID *Context\r
275 );\r
276\r
dfc1f033 277/**\r
278 Close Ip4 and device path protocols for a socket, and remove it from socket list. \r
279 \r
280 @param This Pointer to the socket to be removed\r
281 @param Context Context of the socket\r
282 \r
283**/\r
4f6e31e4 284VOID\r
285Tcp4DestroySocketCallback (\r
286 IN SOCKET *This,\r
287 IN VOID *Context\r
288 );\r
289\r
dfc1f033 290/**\r
291 Creates a child handle and installs a protocol.\r
292 \r
293 The CreateChild() function installs a protocol on ChildHandle. If ChildHandle \r
294 is a pointer to NULL, then a new handle is created and returned in ChildHandle. \r
295 If ChildHandle is not a pointer to NULL, then the protocol installs on the existing \r
296 ChildHandle.\r
297\r
298 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.\r
299 @param ChildHandle Pointer to the handle of the child to create. If it is NULL, then \r
300 a new handle is created. If it is a pointer to an existing UEFI \r
301 handle, then the protocol is added to the existing UEFI handle.\r
302\r
303 @retval EFI_SUCCES The protocol was added to ChildHandle.\r
304 @retval EFI_INVALID_PARAMETER ChildHandle is NULL.\r
305 @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create\r
306 the child.\r
307 @retval other The child handle was not created.\r
308\r
309**/\r
83cbd279 310EFI_STATUS\r
311EFIAPI\r
312Tcp4ServiceBindingCreateChild (\r
276dcc1b 313 IN EFI_SERVICE_BINDING_PROTOCOL *This,\r
314 IN OUT EFI_HANDLE *ChildHandle\r
83cbd279 315 );\r
316\r
dfc1f033 317/**\r
318 Destroys a child handle with a protocol installed on it.\r
319 \r
320 The DestroyChild() function does the opposite of CreateChild(). It removes a protocol \r
321 that was installed by CreateChild() from ChildHandle. If the removed protocol is the \r
322 last protocol on ChildHandle, then ChildHandle is destroyed.\r
323\r
324 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.\r
325 @param ChildHandle Handle of the child to destroy\r
326\r
327 @retval EFI_SUCCES The protocol was removed from ChildHandle.\r
328 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is \r
329 being removed.\r
330 @retval EFI_INVALID_PARAMETER Child handle is not a valid UEFI Handle.\r
331 @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle\r
332 because its services are being used.\r
333 @retval other The child handle was not destroyed.\r
334 \r
335**/\r
83cbd279 336EFI_STATUS\r
337EFIAPI\r
338Tcp4ServiceBindingDestroyChild (\r
339 IN EFI_SERVICE_BINDING_PROTOCOL *This,\r
340 IN EFI_HANDLE ChildHandle\r
341 );\r
342\r
343#endif\r