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