Changed the code style. it could pass EBC and ICC build.
[mirror_edk2.git] / MdeModulePkg / Include / Library / IpIoLib.h
CommitLineData
cbf316f2 1/** @file
2
3Copyright (c) 2005 - 2007, Intel Corporation
4All rights reserved. This program and the accompanying materials
5are licensed and made available under the terms and conditions of the BSD License
6which accompanies this distribution. The full text of the license may be found at
7http://opensource.org/licenses/bsd-license.php
8
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12Module Name:
13
14 IpIo.h
15
16Abstract:
17
18
19**/
20
21#ifndef _IP_IO_H_
22#define _IP_IO_H_
23
24#include <PiDxe.h>
25#include <Protocol/Ip4.h>\r
26#include <Library/IpIoLib.h>\r
27#include <Library/NetLib.h>
28
29//\r
30// type and code define for ICMP protocol error got\r
31// from IP\r
32//\r
33#define ICMP_TYPE_UNREACH 3\r
34#define ICMP_TYPE_TIMXCEED 11\r
35#define ICMP_TYPE_PARAMPROB 12\r
36#define ICMP_TYPE_SOURCEQUENCH 4\r
37\r
38#define ICMP_CODE_UNREACH_NET 0\r
39#define ICMP_CODE_UNREACH_HOST 1\r
40#define ICMP_CODE_UNREACH_PROTOCOL 2\r
41#define ICMP_CODE_UNREACH_PORT 3\r
42#define ICMP_CODE_UNREACH_NEEDFRAG 4\r
43#define ICMP_CODE_UNREACH_SRCFAIL 5\r
44#define ICMP_CODE_UNREACH_NET_UNKNOWN 6\r
45#define ICMP_CODE_UNREACH_HOST_UNKNOWN 7\r
46#define ICMP_CODE_UNREACH_ISOLATED 8\r
47#define ICMP_CODE_UNREACH_NET_PROHIB 9\r
48#define ICMP_CODE_UNREACH_HOST_PROHIB 10\r
49#define ICMP_CODE_UNREACH_TOSNET 11\r
50#define ICMP_CODE_UNREACH_TOSHOST 12\r
51\r
52//\r
53// this error will be delivered to the\r
54// listening transportation layer protocol\r
55// consuming IpIO\r
56//\r
57typedef enum {\r
58 ICMP_ERR_UNREACH_NET = 0,\r
59 ICMP_ERR_UNREACH_HOST,\r
60 ICMP_ERR_UNREACH_PROTOCOL,\r
61 ICMP_ERR_UNREACH_PORT,\r
62 ICMP_ERR_MSGSIZE,\r
63 ICMP_ERR_UNREACH_SRCFAIL,\r
64 ICMP_ERR_TIMXCEED_INTRANS,\r
65 ICMP_ERR_TIMXCEED_REASS,\r
66 ICMP_ERR_QUENCH,\r
67 ICMP_ERR_PARAMPROB\r
68} ICMP_ERROR;\r
69\r
70typedef struct _ICMP_ERROR_INFO {\r
cbf316f2 71 BOOLEAN IsHard;\r
72 BOOLEAN Notify;\r
73} ICMP_ERROR_INFO;\r
74
cbf316f2 75#define EFI_IP4_HEADER_LEN(HdrPtr) ((HdrPtr)->HeaderLength << 2)
76
77extern EFI_IP4_CONFIG_DATA mIpIoDefaultIpConfigData;
78
79typedef struct _EFI_NET_SESSION_DATA {
80 IP4_ADDR Source;
81 IP4_ADDR Dest;
82 EFI_IP4_HEADER *IpHdr;
83} EFI_NET_SESSION_DATA;
84
85typedef
86VOID
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
96typedef
97VOID
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
105typedef 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
149typedef 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
157typedef 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
8a67d61d 167typedef EFI_IP4_OVERRIDE_DATA IP_IO_OVERRIDE;
cbf316f2 168
169typedef 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
179IP_IO *
180IpIoCreate (
181 IN EFI_HANDLE Image,
182 IN EFI_HANDLE Controller
183 );
184
185EFI_STATUS
186IpIoDestroy (
187 IN IP_IO *IpIo
188 );
189
190EFI_STATUS
191IpIoStop (
192 IN IP_IO *IpIo
193 );
194
195EFI_STATUS
196IpIoOpen (
197 IN IP_IO *IpIo,
198 IN IP_IO_OPEN_DATA *OpenData
199 );
200
201EFI_STATUS
202IpIoSend (
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
212VOID
213IpIoCancelTxToken (
214 IN IP_IO *IpIo,
215 IN VOID *Packet
216 );
217
218IP_IO_IP_INFO *
219IpIoAddIp (
220 IN IP_IO *IpIo
221 );
222
223EFI_STATUS
224IpIoConfigIp (
225 IN IP_IO_IP_INFO *IpInfo,
226 IN OUT EFI_IP4_CONFIG_DATA *Ip4ConfigData OPTIONAL
227 );
228
229VOID
230IpIoRemoveIp (
231 IN IP_IO *IpIo,
232 IN IP_IO_IP_INFO *IpInfo
233 );
234
235IP_IO_IP_INFO *
236IpIoFindSender (
237 IN OUT IP_IO **IpIo,
238 IN IP4_ADDR Src
239 );
240
241EFI_STATUS
242IpIoGetIcmpErrStatus (
243 IN ICMP_ERROR IcmpError,
244 OUT BOOLEAN *IsHard, OPTIONAL
245 OUT BOOLEAN *Notify OPTIONAL
246 );
247
248#endif