cbf316f2 |
1 | /** @file |
2 | |
3 | Copyright (c) 2006, Intel Corporation |
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 |
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 | Module Name: |
14 | |
15 | Udp4Io.h |
16 | |
17 | Abstract: |
18 | |
19 | The helper routines to access UDP service. It is used by both |
20 | DHCP and MTFTP. |
21 | |
22 | |
23 | **/ |
24 | |
25 | #ifndef _UDP4IO_H_ |
26 | #define _UDP4IO_H_ |
27 | |
28 | #include <PiDxe.h>\r |
29 | \r |
30 | #include <Protocol/Udp4.h>\r |
31 | \r |
32 | #include <Library/UdpIoLib.h> |
33 | #include <Library/NetLib.h> |
34 | |
35 | typedef struct _UDP_IO_PORT UDP_IO_PORT; |
36 | |
37 | enum { |
38 | UDP_IO_RX_SIGNATURE = EFI_SIGNATURE_32 ('U', 'D', 'P', 'R'), |
39 | UDP_IO_TX_SIGNATURE = EFI_SIGNATURE_32 ('U', 'D', 'P', 'T'), |
40 | UDP_IO_SIGNATURE = EFI_SIGNATURE_32 ('U', 'D', 'P', 'I'), |
41 | }; |
42 | |
43 | typedef struct { |
44 | IP4_ADDR LocalAddr; |
45 | UINT16 LocalPort; |
46 | IP4_ADDR RemoteAddr; |
47 | UINT16 RemotePort; |
48 | } UDP_POINTS; |
49 | |
50 | // |
51 | // This prototype is used by both receive and transmission. |
52 | // When receiving Netbuf is allocated by UDP access point, and |
53 | // released by user. When transmitting, the NetBuf is from user, |
54 | // and provided to the callback as a reference. |
55 | // |
56 | typedef |
57 | VOID |
58 | (*UDP_IO_CALLBACK) ( |
59 | IN NET_BUF *Packet, |
60 | IN UDP_POINTS *Points, |
61 | IN EFI_STATUS IoStatus, |
62 | IN VOID *Context |
63 | ); |
64 | |
65 | // |
66 | // Each receive request is wrapped in an UDP_RX_TOKEN. Upon completion, |
67 | // the CallBack will be called. Only one receive request is send to UDP. |
68 | // HeadLen gives the length of the application's header. UDP_IO will |
69 | // make the application's header continous before delivery up. |
70 | // |
71 | typedef struct { |
72 | UINT32 Signature; |
73 | UDP_IO_PORT *UdpIo; |
74 | |
75 | UDP_IO_CALLBACK CallBack; |
76 | VOID *Context; |
77 | |
78 | UINT32 HeadLen; |
79 | EFI_UDP4_COMPLETION_TOKEN UdpToken; |
80 | } UDP_RX_TOKEN; |
81 | |
82 | // |
83 | // Each transmit request is wrapped in an UDP_TX_TOKEN. Upon completion, |
84 | // the CallBack will be called. There can be several transmit requests. |
85 | // |
86 | typedef struct { |
87 | UINT32 Signature; |
88 | NET_LIST_ENTRY Link; |
89 | UDP_IO_PORT *UdpIo; |
90 | |
91 | UDP_IO_CALLBACK CallBack; |
92 | NET_BUF *Packet; |
93 | VOID *Context; |
94 | |
95 | EFI_UDP4_SESSION_DATA UdpSession; |
96 | EFI_IPv4_ADDRESS Gateway; |
97 | |
98 | EFI_UDP4_COMPLETION_TOKEN UdpToken; |
99 | EFI_UDP4_TRANSMIT_DATA UdpTxData; |
100 | } UDP_TX_TOKEN; |
101 | |
84b5c78e |
102 | struct _UDP_IO_PORT { |
cbf316f2 |
103 | UINT32 Signature; |
104 | NET_LIST_ENTRY Link; |
105 | INTN RefCnt; |
106 | |
107 | // |
108 | // Handle used to create/destory UDP child |
109 | // |
110 | EFI_HANDLE Controller; |
111 | EFI_HANDLE Image; |
112 | EFI_HANDLE UdpHandle; |
113 | |
114 | EFI_UDP4_PROTOCOL *Udp; |
115 | EFI_UDP4_CONFIG_DATA UdpConfig; |
116 | EFI_SIMPLE_NETWORK_MODE SnpMode; |
117 | |
118 | NET_LIST_ENTRY SentDatagram; |
119 | UDP_RX_TOKEN *RecvRequest; |
120 | }; |
121 | |
122 | typedef |
123 | EFI_STATUS |
124 | (*UDP_IO_CONFIG) ( |
125 | IN UDP_IO_PORT *UdpIo, |
126 | IN VOID *Context |
127 | ); |
128 | |
129 | typedef |
130 | BOOLEAN |
131 | (*UDP_IO_TO_CANCEL) ( |
132 | IN UDP_TX_TOKEN *Token, |
133 | IN VOID *Context |
134 | ); |
135 | |
136 | UDP_IO_PORT * |
137 | UdpIoCreatePort ( |
138 | IN EFI_HANDLE Controller, |
139 | IN EFI_HANDLE ImageHandle, |
140 | IN UDP_IO_CONFIG Configure, |
141 | IN VOID *Context |
142 | ); |
143 | |
144 | EFI_STATUS |
145 | UdpIoFreePort ( |
146 | IN UDP_IO_PORT *UdpIo |
147 | ); |
148 | |
149 | VOID |
150 | UdpIoCleanPort ( |
151 | IN UDP_IO_PORT *UdpIo |
152 | ); |
153 | |
154 | EFI_STATUS |
155 | UdpIoSendDatagram ( |
156 | IN UDP_IO_PORT *UdpIo, |
157 | IN NET_BUF *Packet, |
158 | IN UDP_POINTS *EndPoint, OPTIONAL |
159 | IN IP4_ADDR Gateway, |
160 | IN UDP_IO_CALLBACK CallBack, |
161 | IN VOID *Context |
162 | ); |
163 | |
164 | VOID |
165 | UdpIoCancelSentDatagram ( |
166 | IN UDP_IO_PORT *UdpIo, |
167 | IN NET_BUF *Packet |
168 | ); |
169 | |
170 | EFI_STATUS |
171 | UdpIoRecvDatagram ( |
172 | IN UDP_IO_PORT *UdpIo, |
173 | IN UDP_IO_CALLBACK CallBack, |
174 | IN VOID *Context, |
175 | IN UINT32 HeadLen |
176 | ); |
177 | #endif |