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>
26 #include <Library/IpIoLib.h>
27 #include <Library/NetLib.h>
30 // type and code define for ICMP protocol error got
33 #define ICMP_TYPE_UNREACH 3
34 #define ICMP_TYPE_TIMXCEED 11
35 #define ICMP_TYPE_PARAMPROB 12
36 #define ICMP_TYPE_SOURCEQUENCH 4
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
53 // this error will be delivered to the
54 // listening transportation layer protocol
58 ICMP_ERR_UNREACH_NET
= 0,
59 ICMP_ERR_UNREACH_HOST
,
60 ICMP_ERR_UNREACH_PROTOCOL
,
61 ICMP_ERR_UNREACH_PORT
,
63 ICMP_ERR_UNREACH_SRCFAIL
,
64 ICMP_ERR_TIMXCEED_INTRANS
,
65 ICMP_ERR_TIMXCEED_REASS
,
70 typedef struct _ICMP_ERROR_INFO
{
77 #define EFI_IP4_HEADER_LEN(HdrPtr) ((HdrPtr)->HeaderLength << 2)
79 extern EFI_IP4_CONFIG_DATA mIpIoDefaultIpConfigData
;
81 typedef struct _EFI_NET_SESSION_DATA
{
84 EFI_IP4_HEADER
*IpHdr
;
85 } EFI_NET_SESSION_DATA
;
90 IN EFI_STATUS Status
, // rcvd pkt result
91 IN ICMP_ERROR IcmpErr
, // if Status == EFI_ICMP_ERROR, this
92 // field is valid for user
93 IN EFI_NET_SESSION_DATA
*NetSession
, // the communication point
94 IN NET_BUF
*Pkt
, // packet received
95 IN VOID
*Context
// the Context provided by user for recive data
101 IN EFI_STATUS Status
, // sent pkt result
102 IN VOID
*Context
, // the context provided by user for sending data
103 IN VOID
*Sender
, // the sender to be notified
104 IN VOID
*NotifyData
// sent pkt related data to notify
107 typedef struct _IP_IO
{
110 // the node used to link this IpIo to the active IpIo list.
112 NET_LIST_ENTRY Entry
;
114 // the list used to maintain the IP instance for different sending purpose.
116 NET_LIST_ENTRY IpList
;
119 // the ip instance consumed by this IP IO
121 EFI_HANDLE Controller
;
123 EFI_HANDLE ChildHandle
;
124 EFI_IP4_PROTOCOL
*Ip
;
125 BOOLEAN IsConfigured
;
128 // some ip config data can be changed
133 // token and event used to get data from IP
135 EFI_IP4_COMPLETION_TOKEN RcvToken
;
138 // list entry used to link the token passed to IP_IO
140 NET_LIST_ENTRY PendingSndList
;
143 // User interface used to get notify from IP_IO
147 PKT_RCVD_NOTIFY PktRcvdNotify
;
148 PKT_SENT_NOTIFY PktSentNotify
;
151 typedef struct _IP_IO_OPEN_DATA
{
152 EFI_IP4_CONFIG_DATA IpConfigData
;
155 PKT_RCVD_NOTIFY PktRcvdNotify
;
156 PKT_SENT_NOTIFY PktSentNotify
;
159 typedef struct _IP_IO_SEND_ENTRY
{
160 NET_LIST_ENTRY Entry
;
164 EFI_IP4_PROTOCOL
*Ip
;
166 EFI_IP4_COMPLETION_TOKEN
*SndToken
;
169 typedef EFI_IP4_OVERRIDE_DATA IP_IO_OVERRIDE
;
171 typedef struct _IP_IO_IP_INFO
{
174 NET_LIST_ENTRY Entry
;
175 EFI_HANDLE ChildHandle
;
176 EFI_IP4_PROTOCOL
*Ip
;
177 EFI_IP4_COMPLETION_TOKEN DummyRcvToken
;
184 IN EFI_HANDLE Controller
200 IN IP_IO_OPEN_DATA
*OpenData
207 IN IP_IO_IP_INFO
*Sender
,
208 IN VOID
*Context OPTIONAL
,
209 IN VOID
*NotifyData OPTIONAL
,
211 IN IP_IO_OVERRIDE
*OverrideData
227 IN IP_IO_IP_INFO
*IpInfo
,
228 IN OUT EFI_IP4_CONFIG_DATA
*Ip4ConfigData OPTIONAL
234 IN IP_IO_IP_INFO
*IpInfo
244 IpIoGetIcmpErrStatus (
245 IN ICMP_ERROR IcmpError
,
246 OUT BOOLEAN
*IsHard
, OPTIONAL
247 OUT BOOLEAN
*Notify OPTIONAL