]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.h
EFI_SIGNATURE_32 has been replaced by SIGNATURE_32
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Tcp4Dxe / Tcp4Driver.h
1 /** @file
2
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>
8
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.
11
12 **/
13
14 #ifndef _TCP4_DRIVER_H_
15 #define _TCP4_DRIVER_H_
16
17 #include <Protocol/ServiceBinding.h>
18 #include <Library/IpIoLib.h>
19
20 #define TCP4_DRIVER_SIGNATURE SIGNATURE_32 ('T', 'C', 'P', '4')
21
22 #define TCP4_PORT_KNOWN 1024
23 #define TCP4_PORT_USER_RESERVED 65535
24
25 #define TCP4_FROM_THIS(a) \
26 CR ( \
27 (a), \
28 TCP4_SERVICE_DATA, \
29 Tcp4ServiceBinding, \
30 TCP4_DRIVER_SIGNATURE \
31 )
32
33 ///
34 /// TCP heartbeat tick timer.
35 ///
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;
40
41 ///
42 /// TCP service data
43 ///
44 typedef struct _TCP4_SERVICE_DATA {
45 UINT32 Signature;
46 EFI_HANDLE ControllerHandle;
47 IP_IO *IpIo; // IP Io consumed by TCP4
48 EFI_SERVICE_BINDING_PROTOCOL Tcp4ServiceBinding;
49 EFI_HANDLE DriverBindingHandle;
50 CHAR16 *MacString;
51 LIST_ENTRY SocketList;
52 } TCP4_SERVICE_DATA;
53
54 ///
55 /// TCP protocol data
56 ///
57 typedef struct _TCP4_PROTO_DATA {
58 TCP4_SERVICE_DATA *TcpService;
59 TCP_CB *TcpPcb;
60 } TCP4_PROTO_DATA;
61
62
63 /**
64 Packet receive callback function provided to IP_IO, used to call
65 the proper function to handle the packet received by IP.
66
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
72 now.
73
74 @return None
75
76 **/
77 VOID
78 Tcp4RxCallback (
79 IN EFI_STATUS Status,
80 IN ICMP_ERROR IcmpErr,
81 IN EFI_NET_SESSION_DATA *NetSession,
82 IN NET_BUF *Pkt,
83 IN VOID *Context OPTIONAL
84 );
85
86 /**
87 Send the segment to IP via IpIo function.
88
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.
93
94 @retval 0 The segment was sent out successfully.
95 @retval -1 The segment was failed to send.
96
97 **/
98 INTN
99 TcpSendIpPacket (
100 IN TCP_CB *Tcb,
101 IN NET_BUF *Nbuf,
102 IN UINT32 Src,
103 IN UINT32 Dest
104 );
105
106 /**
107 The procotol handler provided to the socket layer, used to
108 dispatch the socket level requests by calling the corresponding
109 TCP layer functions.
110
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.
115
116 @retval EFI_SUCCESS The socket request is completed successfully.
117 @retval other The error status returned by the corresponding TCP
118 layer function.
119
120 **/
121 EFI_STATUS
122 Tcp4Dispatcher (
123 IN SOCKET *Sock,
124 IN SOCK_REQUEST Request,
125 IN VOID *Data OPTIONAL
126 );
127
128
129 /**
130 The entry point for Tcp4 driver, used to install Tcp4 driver on the ImageHandle.
131
132 @param ImageHandle The firmware allocated handle for this
133 driver image.
134 @param SystemTable Pointer to the EFI system table.
135
136 @retval EFI_SUCCESS Driver loaded.
137 @retval other Driver not loaded.
138
139 **/
140 EFI_STATUS
141 EFIAPI
142 Tcp4DriverEntryPoint (
143 IN EFI_HANDLE ImageHandle,
144 IN EFI_SYSTEM_TABLE *SystemTable
145 );
146
147
148 /**
149 Tests to see if this driver supports a given controller.
150
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.
153
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.
160
161
162 @retval EFI_SUCCESS The device specified by ControllerHandle and
163 RemainingDevicePath is supported by the driver
164 specified by This.
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
171 exclusive access.
172 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
173 RemainingDevicePath is not supported by the driver
174 specified by This.
175
176 **/
177 EFI_STATUS
178 EFIAPI
179 Tcp4DriverBindingSupported (
180 IN EFI_DRIVER_BINDING_PROTOCOL *This,
181 IN EFI_HANDLE ControllerHandle,
182 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
183 );
184
185 /**
186 Start this driver on ControllerHandle.
187
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.
199
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.
207
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
211 of resources.
212
213 **/
214 EFI_STATUS
215 EFIAPI
216 Tcp4DriverBindingStart (
217 IN EFI_DRIVER_BINDING_PROTOCOL *This,
218 IN EFI_HANDLE ControllerHandle,
219 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
220 );
221
222 /**
223 Stop this driver on ControllerHandle.
224
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.
236
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.
244
245 @retval EFI_SUCCESS The device was stopped.
246 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
247
248 **/
249 EFI_STATUS
250 EFIAPI
251 Tcp4DriverBindingStop (
252 IN EFI_DRIVER_BINDING_PROTOCOL *This,
253 IN EFI_HANDLE ControllerHandle,
254 IN UINTN NumberOfChildren,
255 IN EFI_HANDLE *ChildHandleBuffer
256 );
257
258 /**
259 Open Ip4 and device path protocols for a created socket, and insert it in
260 socket list.
261
262 @param This Pointer to the socket just created
263 @param Context Context of the socket
264
265 @retval EFI_SUCCESS This protocol is installed successfully.
266 @retval other Some error occured.
267
268 **/
269 EFI_STATUS
270 Tcp4CreateSocketCallback (
271 IN SOCKET *This,
272 IN VOID *Context
273 );
274
275 /**
276 Close Ip4 and device path protocols for a socket, and remove it from socket list.
277
278 @param This Pointer to the socket to be removed
279 @param Context Context of the socket
280
281 **/
282 VOID
283 Tcp4DestroySocketCallback (
284 IN SOCKET *This,
285 IN VOID *Context
286 );
287
288 /**
289 Creates a child handle and installs a protocol.
290
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
294 ChildHandle.
295
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.
300
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
304 the child.
305 @retval other The child handle was not created.
306
307 **/
308 EFI_STATUS
309 EFIAPI
310 Tcp4ServiceBindingCreateChild (
311 IN EFI_SERVICE_BINDING_PROTOCOL *This,
312 IN OUT EFI_HANDLE *ChildHandle
313 );
314
315 /**
316 Destroys a child handle with a protocol installed on it.
317
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.
321
322 @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
323 @param ChildHandle Handle of the child to destroy
324
325 @retval EFI_SUCCES The protocol was removed from ChildHandle.
326 @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is
327 being removed.
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.
332
333 **/
334 EFI_STATUS
335 EFIAPI
336 Tcp4ServiceBindingDestroyChild (
337 IN EFI_SERVICE_BINDING_PROTOCOL *This,
338 IN EFI_HANDLE ChildHandle
339 );
340
341 #endif