]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h
Update to support to produce Component Name and & Component Name 2 protocol based...
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4Dxe / Ip4Impl.h
1 /** @file
2
3 Copyright (c) 2005 - 2006, 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 Ip4Impl.h
15
16 Abstract:
17
18 Ip4 internal functions and type defintions.
19
20
21 **/
22
23 #ifndef __EFI_IP4_IMPL_H__
24 #define __EFI_IP4_IMPL_H__
25
26 #include <PiDxe.h>
27
28 #include <Protocol/IP4.h>
29 #include <Protocol/IP4Config.h>
30 #include <Protocol/Arp.h>
31 #include <Protocol/ManagedNetwork.h>
32
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>
42
43 #include "Ip4Common.h"
44 #include "Ip4Driver.h"
45 #include "Ip4If.h"
46 #include "Ip4Icmp.h"
47 #include "Ip4Option.h"
48 #include "Ip4Igmp.h"
49 #include "Ip4Route.h"
50 #include "Ip4Input.h"
51 #include "Ip4Output.h"
52
53 enum {
54 IP4_PROTOCOL_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', '4', 'P'),
55 IP4_SERVICE_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', '4', 'S'),
56
57 //
58 // The state of IP4 protocol. It starts from UNCONFIGED. if it is
59 // successfully configured, it goes to CONFIGED. if configure NULL
60 // is called, it becomes UNCONFIGED again. If (partly) destoried, it
61 // becomes DESTORY.
62 //
63 IP4_STATE_UNCONFIGED = 0,
64 IP4_STATE_CONFIGED,
65 IP4_STATE_DESTORY,
66
67 //
68 // The state of IP4 service. It starts from UNSTARTED. It transits
69 // to STARTED if autoconfigure is started. If default address is
70 // configured, it becomes CONFIGED. and if partly destoried, it goes
71 // to DESTORY.
72 //
73 IP4_SERVICE_UNSTARTED = 0,
74 IP4_SERVICE_STARTED,
75 IP4_SERVICE_CONFIGED,
76 IP4_SERVICE_DESTORY
77 };
78
79 //
80 // IP4_TXTOKEN_WRAP wraps the upper layer's transmit token.
81 // The user's data is kept in the Packet. When fragment is
82 // needed, each fragment of the Packet has a reference to the
83 // Packet, no data is actually copied. The Packet will be
84 // released when all the fragments of it have been recycled by
85 // MNP. Upon then, the IP4_TXTOKEN_WRAP will be released, and
86 // user's event signalled.
87 //
88 typedef struct {
89 IP4_PROTOCOL *IpInstance;
90 EFI_IP4_COMPLETION_TOKEN *Token;
91 NET_BUF *Packet;
92 BOOLEAN Sent;
93 INTN Life;
94 } IP4_TXTOKEN_WRAP;
95
96 //
97 // IP4_RXDATA_WRAP wraps the data IP4 child delivers to the
98 // upper layers. The received packet is kept in the Packet.
99 // The Packet itself may be constructured from some fragments.
100 // All the fragments of the Packet is organized by a
101 // IP4_ASSEMBLE_ENTRY structure. If the Packet is recycled by
102 // the upper layer, the assemble entry and its associated
103 // fragments will be freed at last.
104 //
105 typedef struct {
106 NET_LIST_ENTRY Link;
107 IP4_PROTOCOL *IpInstance;
108 NET_BUF *Packet;
109 EFI_IP4_RECEIVE_DATA RxData;
110 } IP4_RXDATA_WRAP;
111
112 struct _IP4_PROTOCOL {
113 UINT32 Signature;
114
115 EFI_IP4_PROTOCOL Ip4Proto;
116 EFI_HANDLE Handle;
117 INTN State;
118
119 IP4_SERVICE *Service;
120 NET_LIST_ENTRY Link; // Link to all the IP protocol from the service
121
122 //
123 // User's transmit/receive tokens, and received/deliverd packets
124 //
125 NET_MAP RxTokens;
126 NET_MAP TxTokens; // map between (User's Token, IP4_TXTOKE_WRAP)
127 NET_LIST_ENTRY Received; // Received but not delivered packet
128 NET_LIST_ENTRY Delivered; // Delivered and to be recycled packets
129 EFI_LOCK RecycleLock;
130
131 //
132 // Instance's address and route tables. There are two route tables.
133 // RouteTable is used by the IP4 driver to route packet. EfiRouteTable
134 // is used to communicate the current route info to the upper layer.
135 //
136 IP4_INTERFACE *Interface;
137 NET_LIST_ENTRY AddrLink; // Ip instances with the same IP address.
138 IP4_ROUTE_TABLE *RouteTable;
139
140 EFI_IP4_ROUTE_TABLE *EfiRouteTable;
141 UINT32 EfiRouteCount;
142
143 //
144 // IGMP data for this instance
145 //
146 IP4_ADDR *Groups; // stored in network byte order
147 UINT32 GroupCount;
148
149 EFI_IP4_CONFIG_DATA ConfigData;
150
151 };
152
153 struct _IP4_SERVICE {
154 UINT32 Signature;
155 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
156 INTN State;
157 BOOLEAN InDestory;
158
159 //
160 // List of all the IP instances and interfaces, and default
161 // interface and route table and caches.
162 //
163 UINTN NumChildren;
164 NET_LIST_ENTRY Children;
165
166 NET_LIST_ENTRY Interfaces;
167
168 IP4_INTERFACE *DefaultInterface;
169 IP4_ROUTE_TABLE *DefaultRouteTable;
170
171 //
172 // Ip reassemble utilities, and IGMP data
173 //
174 IP4_ASSEMBLE_TABLE Assemble;
175 IGMP_SERVICE_DATA IgmpCtrl;
176
177 //
178 // Low level protocol used by this service instance
179 //
180 EFI_HANDLE Image;
181 EFI_HANDLE Controller;
182
183 EFI_HANDLE MnpChildHandle;
184 EFI_MANAGED_NETWORK_PROTOCOL *Mnp;
185
186 EFI_MANAGED_NETWORK_CONFIG_DATA MnpConfigData;
187 EFI_SIMPLE_NETWORK_MODE SnpMode;
188
189 EFI_EVENT Timer;
190
191 //
192 // Auto configure staff
193 //
194 EFI_IP4_CONFIG_PROTOCOL *Ip4Config;
195 EFI_EVENT DoneEvent;
196 EFI_EVENT ReconfigEvent;
197
198 //
199 // The string representation of the current mac address of the
200 // NIC this IP4_SERVICE works on.
201 //
202 CHAR16 *MacString;
203 };
204
205 #define IP4_INSTANCE_FROM_PROTOCOL(Ip4) \
206 CR ((Ip4), IP4_PROTOCOL, Ip4Proto, IP4_PROTOCOL_SIGNATURE)
207
208 #define IP4_SERVICE_FROM_PROTOCOL(Sb) \
209 CR ((Sb), IP4_SERVICE, ServiceBinding, IP4_SERVICE_SIGNATURE)
210
211 #define IP4_NO_MAPPING(IpInstance) (!(IpInstance)->Interface->Configured)
212
213 extern EFI_IP4_PROTOCOL mEfiIp4ProtocolTemplete;
214
215 EFI_STATUS
216 Ip4ServiceConfigMnp (
217 IN IP4_SERVICE *IpSb,
218 IN BOOLEAN Force
219 );
220
221 VOID
222 Ip4InitProtocol (
223 IN IP4_SERVICE *IpSb,
224 IN IP4_PROTOCOL *IpInstance
225 );
226
227 EFI_STATUS
228 Ip4CleanProtocol (
229 IN IP4_PROTOCOL *IpInstance
230 );
231
232 EFI_STATUS
233 Ip4Cancel (
234 IN IP4_PROTOCOL *IpInstance,
235 IN EFI_IP4_COMPLETION_TOKEN *Token
236 );
237
238 EFI_STATUS
239 Ip4Groups (
240 IN IP4_PROTOCOL *IpInstance,
241 IN BOOLEAN JoinFlag,
242 IN EFI_IPv4_ADDRESS *GroupAddress
243 );
244
245 VOID
246 EFIAPI
247 Ip4TimerTicking (
248 IN EFI_EVENT Event,
249 IN VOID *Context
250 );
251
252 EFI_STATUS
253 Ip4SentPacketTicking (
254 IN NET_MAP *Map,
255 IN NET_MAP_ITEM *Item,
256 IN VOID *Context
257 );
258 #endif