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