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.
18 Ip4 internal functions and type defintions.
23 #ifndef __EFI_IP4_IMPL_H__
24 #define __EFI_IP4_IMPL_H__
28 #include <Protocol/Ip4.h>
29 #include <Protocol/Ip4Config.h>
30 #include <Protocol/Arp.h>
31 #include <Protocol/ManagedNetwork.h>
33 #include <Library/DebugLib.h>
34 #include <Library/UefiRuntimeServicesTableLib.h>
35 #include <Library/UefiDriverEntryPoint.h>
36 #include <Library/UefiBootServicesTableLib.h>
37 #include <Library/BaseLib.h>
38 #include <Library/UefiLib.h>
39 #include <Library/NetLib.h>
40 #include <Library/BaseMemoryLib.h>
41 #include <Library/MemoryAllocationLib.h>
43 #include "Ip4Common.h"
44 #include "Ip4Driver.h"
47 #include "Ip4Option.h"
51 #include "Ip4Output.h"
56 IP4_PROTOCOL_SIGNATURE
= EFI_SIGNATURE_32 ('I', 'P', '4', 'P'),
57 IP4_SERVICE_SIGNATURE
= EFI_SIGNATURE_32 ('I', 'P', '4', 'S'),
60 // The state of IP4 protocol. It starts from UNCONFIGED. if it is
61 // successfully configured, it goes to CONFIGED. if configure NULL
62 // is called, it becomes UNCONFIGED again. If (partly) destoried, it
65 IP4_STATE_UNCONFIGED
= 0,
70 // The state of IP4 service. It starts from UNSTARTED. It transits
71 // to STARTED if autoconfigure is started. If default address is
72 // configured, it becomes CONFIGED. and if partly destoried, it goes
75 IP4_SERVICE_UNSTARTED
= 0,
79 } IP4_IMPL_ENUM_TYPES
;
82 /// IP4_TXTOKEN_WRAP wraps the upper layer's transmit token.
83 /// The user's data is kept in the Packet. When fragment is
84 /// needed, each fragment of the Packet has a reference to the
85 /// Packet, no data is actually copied. The Packet will be
86 /// released when all the fragments of it have been recycled by
87 /// MNP. Upon then, the IP4_TXTOKEN_WRAP will be released, and
88 /// user's event signalled.
91 IP4_PROTOCOL
*IpInstance
;
92 EFI_IP4_COMPLETION_TOKEN
*Token
;
99 /// IP4_RXDATA_WRAP wraps the data IP4 child delivers to the
100 /// upper layers. The received packet is kept in the Packet.
101 /// The Packet itself may be constructured from some fragments.
102 /// All the fragments of the Packet is organized by a
103 /// IP4_ASSEMBLE_ENTRY structure. If the Packet is recycled by
104 /// the upper layer, the assemble entry and its associated
105 /// fragments will be freed at last.
109 IP4_PROTOCOL
*IpInstance
;
111 EFI_IP4_RECEIVE_DATA RxData
;
115 struct _IP4_PROTOCOL
{
118 EFI_IP4_PROTOCOL Ip4Proto
;
122 IP4_SERVICE
*Service
;
123 LIST_ENTRY Link
; // Link to all the IP protocol from the service
126 // User's transmit/receive tokens, and received/deliverd packets
129 NET_MAP TxTokens
; // map between (User's Token, IP4_TXTOKE_WRAP)
130 LIST_ENTRY Received
; // Received but not delivered packet
131 LIST_ENTRY Delivered
; // Delivered and to be recycled packets
132 EFI_LOCK RecycleLock
;
135 // Instance's address and route tables. There are two route tables.
136 // RouteTable is used by the IP4 driver to route packet. EfiRouteTable
137 // is used to communicate the current route info to the upper layer.
139 IP4_INTERFACE
*Interface
;
140 LIST_ENTRY AddrLink
; // Ip instances with the same IP address.
141 IP4_ROUTE_TABLE
*RouteTable
;
143 EFI_IP4_ROUTE_TABLE
*EfiRouteTable
;
144 UINT32 EfiRouteCount
;
147 // IGMP data for this instance
149 IP4_ADDR
*Groups
; // stored in network byte order
152 EFI_IP4_CONFIG_DATA ConfigData
;
156 struct _IP4_SERVICE
{
158 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding
;
163 // List of all the IP instances and interfaces, and default
164 // interface and route table and caches.
169 LIST_ENTRY Interfaces
;
171 IP4_INTERFACE
*DefaultInterface
;
172 IP4_ROUTE_TABLE
*DefaultRouteTable
;
175 // Ip reassemble utilities, and IGMP data
177 IP4_ASSEMBLE_TABLE Assemble
;
178 IGMP_SERVICE_DATA IgmpCtrl
;
181 // Low level protocol used by this service instance
184 EFI_HANDLE Controller
;
186 EFI_HANDLE MnpChildHandle
;
187 EFI_MANAGED_NETWORK_PROTOCOL
*Mnp
;
189 EFI_MANAGED_NETWORK_CONFIG_DATA MnpConfigData
;
190 EFI_SIMPLE_NETWORK_MODE SnpMode
;
195 // Auto configure staff
197 EFI_IP4_CONFIG_PROTOCOL
*Ip4Config
;
199 EFI_EVENT ReconfigEvent
;
200 EFI_EVENT ActiveEvent
;
203 // The string representation of the current mac address of the
204 // NIC this IP4_SERVICE works on.
209 #define IP4_INSTANCE_FROM_PROTOCOL(Ip4) \
210 CR ((Ip4), IP4_PROTOCOL, Ip4Proto, IP4_PROTOCOL_SIGNATURE)
212 #define IP4_SERVICE_FROM_PROTOCOL(Sb) \
213 CR ((Sb), IP4_SERVICE, ServiceBinding, IP4_SERVICE_SIGNATURE)
215 #define IP4_NO_MAPPING(IpInstance) (!(IpInstance)->Interface->Configured)
217 extern EFI_IP4_PROTOCOL mEfiIp4ProtocolTemplete
;
220 Ip4ServiceConfigMnp (
221 IN IP4_SERVICE
*IpSb
,
227 IN IP4_SERVICE
*IpSb
,
228 IN IP4_PROTOCOL
*IpInstance
233 IN IP4_PROTOCOL
*IpInstance
238 IN IP4_PROTOCOL
*IpInstance
,
239 IN EFI_IP4_COMPLETION_TOKEN
*Token
244 IN IP4_PROTOCOL
*IpInstance
,
246 IN EFI_IPv4_ADDRESS
*GroupAddress
257 Ip4SentPacketTicking (
259 IN NET_MAP_ITEM
*Item
,