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
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.
25 #include <Protocol/Ip4.h>
\r
26 #include <Library/IpIoLib.h>
\r
27 #include <Library/NetLib.h>
30 // type and code define for ICMP protocol error got
\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
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
53 // this error will be delivered to the
\r
54 // listening transportation layer protocol
\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
63 ICMP_ERR_UNREACH_SRCFAIL,
\r
64 ICMP_ERR_TIMXCEED_INTRANS,
\r
65 ICMP_ERR_TIMXCEED_REASS,
\r
70 typedef struct _ICMP_ERROR_INFO {
\r
75 #define EFI_IP4_HEADER_LEN(HdrPtr) ((HdrPtr)->HeaderLength << 2)
77 extern EFI_IP4_CONFIG_DATA mIpIoDefaultIpConfigData;
79 typedef struct _EFI_NET_SESSION_DATA {
82 EFI_IP4_HEADER *IpHdr;
83 } EFI_NET_SESSION_DATA;
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
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
105 typedef struct _IP_IO {
108 // the node used to link this IpIo to the active IpIo list.
110 NET_LIST_ENTRY Entry;
112 // the list used to maintain the IP instance for different sending purpose.
114 NET_LIST_ENTRY IpList;
117 // the ip instance consumed by this IP IO
119 EFI_HANDLE Controller;
121 EFI_HANDLE ChildHandle;
122 EFI_IP4_PROTOCOL *Ip;
123 BOOLEAN IsConfigured;
126 // some ip config data can be changed
131 // token and event used to get data from IP
133 EFI_IP4_COMPLETION_TOKEN RcvToken;
136 // list entry used to link the token passed to IP_IO
138 NET_LIST_ENTRY PendingSndList;
141 // User interface used to get notify from IP_IO
145 PKT_RCVD_NOTIFY PktRcvdNotify;
146 PKT_SENT_NOTIFY PktSentNotify;
149 typedef struct _IP_IO_OPEN_DATA {
150 EFI_IP4_CONFIG_DATA IpConfigData;
153 PKT_RCVD_NOTIFY PktRcvdNotify;
154 PKT_SENT_NOTIFY PktSentNotify;
157 typedef struct _IP_IO_SEND_ENTRY {
158 NET_LIST_ENTRY Entry;
162 EFI_IP4_PROTOCOL *Ip;
164 EFI_IP4_COMPLETION_TOKEN *SndToken;
167 typedef EFI_IP4_OVERRIDE_DATA IP_IO_OVERRIDE;
169 typedef struct _IP_IO_IP_INFO {
172 NET_LIST_ENTRY Entry;
173 EFI_HANDLE ChildHandle;
174 EFI_IP4_PROTOCOL *Ip;
175 EFI_IP4_COMPLETION_TOKEN DummyRcvToken;
182 IN EFI_HANDLE Controller
198 IN IP_IO_OPEN_DATA *OpenData
205 IN IP_IO_IP_INFO *Sender,
206 IN VOID *Context OPTIONAL,
207 IN VOID *NotifyData OPTIONAL,
209 IN IP_IO_OVERRIDE *OverrideData
225 IN IP_IO_IP_INFO *IpInfo,
226 IN OUT EFI_IP4_CONFIG_DATA *Ip4ConfigData OPTIONAL
232 IN IP_IO_IP_INFO *IpInfo
242 IpIoGetIcmpErrStatus (
243 IN ICMP_ERROR IcmpError,
244 OUT BOOLEAN *IsHard, OPTIONAL
245 OUT BOOLEAN *Notify OPTIONAL