Changed the code style. it could pass EBC and ICC build.
[mirror_edk2.git] / MdeModulePkg / Include / Library / IpIoLib.h
1 /** @file
2
3 Copyright (c) 2005 - 2007, 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 Module Name:
13
14 IpIo.h
15
16 Abstract:
17
18
19 **/
20
21 #ifndef _IP_IO_H_
22 #define _IP_IO_H_
23
24 #include <PiDxe.h>
25 #include <Protocol/Ip4.h>
26 #include <Library/IpIoLib.h>
27 #include <Library/NetLib.h>
28
29 //
30 // type and code define for ICMP protocol error got
31 // from IP
32 //
33 #define ICMP_TYPE_UNREACH 3
34 #define ICMP_TYPE_TIMXCEED 11
35 #define ICMP_TYPE_PARAMPROB 12
36 #define ICMP_TYPE_SOURCEQUENCH 4
37
38 #define ICMP_CODE_UNREACH_NET 0
39 #define ICMP_CODE_UNREACH_HOST 1
40 #define ICMP_CODE_UNREACH_PROTOCOL 2
41 #define ICMP_CODE_UNREACH_PORT 3
42 #define ICMP_CODE_UNREACH_NEEDFRAG 4
43 #define ICMP_CODE_UNREACH_SRCFAIL 5
44 #define ICMP_CODE_UNREACH_NET_UNKNOWN 6
45 #define ICMP_CODE_UNREACH_HOST_UNKNOWN 7
46 #define ICMP_CODE_UNREACH_ISOLATED 8
47 #define ICMP_CODE_UNREACH_NET_PROHIB 9
48 #define ICMP_CODE_UNREACH_HOST_PROHIB 10
49 #define ICMP_CODE_UNREACH_TOSNET 11
50 #define ICMP_CODE_UNREACH_TOSHOST 12
51
52 //
53 // this error will be delivered to the
54 // listening transportation layer protocol
55 // consuming IpIO
56 //
57 typedef enum {
58 ICMP_ERR_UNREACH_NET = 0,
59 ICMP_ERR_UNREACH_HOST,
60 ICMP_ERR_UNREACH_PROTOCOL,
61 ICMP_ERR_UNREACH_PORT,
62 ICMP_ERR_MSGSIZE,
63 ICMP_ERR_UNREACH_SRCFAIL,
64 ICMP_ERR_TIMXCEED_INTRANS,
65 ICMP_ERR_TIMXCEED_REASS,
66 ICMP_ERR_QUENCH,
67 ICMP_ERR_PARAMPROB
68 } ICMP_ERROR;
69
70 typedef struct _ICMP_ERROR_INFO {
71 BOOLEAN IsHard;
72 BOOLEAN Notify;
73 } ICMP_ERROR_INFO;
74
75 #define EFI_IP4_HEADER_LEN(HdrPtr) ((HdrPtr)->HeaderLength << 2)
76
77 extern EFI_IP4_CONFIG_DATA mIpIoDefaultIpConfigData;
78
79 typedef struct _EFI_NET_SESSION_DATA {
80 IP4_ADDR Source;
81 IP4_ADDR Dest;
82 EFI_IP4_HEADER *IpHdr;
83 } EFI_NET_SESSION_DATA;
84
85 typedef
86 VOID
87 (*PKT_RCVD_NOTIFY) (
88 IN EFI_STATUS Status, // rcvd pkt result
89 IN ICMP_ERROR IcmpErr, // if Status == EFI_ICMP_ERROR, this
90 // field is valid for user
91 IN EFI_NET_SESSION_DATA *NetSession, // the communication point
92 IN NET_BUF *Pkt, // packet received
93 IN VOID *Context // the Context provided by user for recive data
94 );
95
96 typedef
97 VOID
98 (*PKT_SENT_NOTIFY) (
99 IN EFI_STATUS Status, // sent pkt result
100 IN VOID *Context, // the context provided by user for sending data
101 IN VOID *Sender, // the sender to be notified
102 IN VOID *NotifyData // sent pkt related data to notify
103 );
104
105 typedef struct _IP_IO {
106
107 //
108 // the node used to link this IpIo to the active IpIo list.
109 //
110 NET_LIST_ENTRY Entry;
111
112 // the list used to maintain the IP instance for different sending purpose.
113 //
114 NET_LIST_ENTRY IpList;
115
116 //
117 // the ip instance consumed by this IP IO
118 //
119 EFI_HANDLE Controller;
120 EFI_HANDLE Image;
121 EFI_HANDLE ChildHandle;
122 EFI_IP4_PROTOCOL *Ip;
123 BOOLEAN IsConfigured;
124
125 //
126 // some ip config data can be changed
127 //
128 UINT8 Protocol;
129
130 //
131 // token and event used to get data from IP
132 //
133 EFI_IP4_COMPLETION_TOKEN RcvToken;
134
135 //
136 // list entry used to link the token passed to IP_IO
137 //
138 NET_LIST_ENTRY PendingSndList;
139
140 //
141 // User interface used to get notify from IP_IO
142 //
143 VOID *RcvdContext;
144 VOID *SndContext;
145 PKT_RCVD_NOTIFY PktRcvdNotify;
146 PKT_SENT_NOTIFY PktSentNotify;
147 } IP_IO;
148
149 typedef struct _IP_IO_OPEN_DATA {
150 EFI_IP4_CONFIG_DATA IpConfigData;
151 VOID *RcvdContext;
152 VOID *SndContext;
153 PKT_RCVD_NOTIFY PktRcvdNotify;
154 PKT_SENT_NOTIFY PktSentNotify;
155 } IP_IO_OPEN_DATA;
156
157 typedef struct _IP_IO_SEND_ENTRY {
158 NET_LIST_ENTRY Entry;
159 IP_IO *IpIo;
160 VOID *Context;
161 VOID *NotifyData;
162 EFI_IP4_PROTOCOL *Ip;
163 NET_BUF *Pkt;
164 EFI_IP4_COMPLETION_TOKEN *SndToken;
165 } IP_IO_SEND_ENTRY;
166
167 typedef EFI_IP4_OVERRIDE_DATA IP_IO_OVERRIDE;
168
169 typedef struct _IP_IO_IP_INFO {
170 IP4_ADDR Addr;
171 IP4_ADDR SubnetMask;
172 NET_LIST_ENTRY Entry;
173 EFI_HANDLE ChildHandle;
174 EFI_IP4_PROTOCOL *Ip;
175 EFI_IP4_COMPLETION_TOKEN DummyRcvToken;
176 INTN RefCnt;
177 } IP_IO_IP_INFO;
178
179 IP_IO *
180 IpIoCreate (
181 IN EFI_HANDLE Image,
182 IN EFI_HANDLE Controller
183 );
184
185 EFI_STATUS
186 IpIoDestroy (
187 IN IP_IO *IpIo
188 );
189
190 EFI_STATUS
191 IpIoStop (
192 IN IP_IO *IpIo
193 );
194
195 EFI_STATUS
196 IpIoOpen (
197 IN IP_IO *IpIo,
198 IN IP_IO_OPEN_DATA *OpenData
199 );
200
201 EFI_STATUS
202 IpIoSend (
203 IN IP_IO *IpIo,
204 IN NET_BUF *Pkt,
205 IN IP_IO_IP_INFO *Sender,
206 IN VOID *Context OPTIONAL,
207 IN VOID *NotifyData OPTIONAL,
208 IN IP4_ADDR Dest,
209 IN IP_IO_OVERRIDE *OverrideData
210 );
211
212 VOID
213 IpIoCancelTxToken (
214 IN IP_IO *IpIo,
215 IN VOID *Packet
216 );
217
218 IP_IO_IP_INFO *
219 IpIoAddIp (
220 IN IP_IO *IpIo
221 );
222
223 EFI_STATUS
224 IpIoConfigIp (
225 IN IP_IO_IP_INFO *IpInfo,
226 IN OUT EFI_IP4_CONFIG_DATA *Ip4ConfigData OPTIONAL
227 );
228
229 VOID
230 IpIoRemoveIp (
231 IN IP_IO *IpIo,
232 IN IP_IO_IP_INFO *IpInfo
233 );
234
235 IP_IO_IP_INFO *
236 IpIoFindSender (
237 IN OUT IP_IO **IpIo,
238 IN IP4_ADDR Src
239 );
240
241 EFI_STATUS
242 IpIoGetIcmpErrStatus (
243 IN ICMP_ERROR IcmpError,
244 OUT BOOLEAN *IsHard, OPTIONAL
245 OUT BOOLEAN *Notify OPTIONAL
246 );
247
248 #endif