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