]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.h
sync comments, fix function header, rename variable name to follow coding style.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4Dxe / Ip4If.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
13 Module Name:
14
15 Ip4If.h
16
17 Abstract:
18
19 Definition for IP4 pesudo interface structure.
20
21
22 **/
23
24 #ifndef __EFI_IP4_IF_H__
25 #define __EFI_IP4_IF_H__
26
27 typedef enum {
28 IP4_FRAME_RX_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', 'F', 'R'),
29 IP4_FRAME_TX_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', 'F', 'T'),
30 IP4_FRAME_ARP_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', 'F', 'A'),
31 IP4_INTERFACE_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', 'I', 'F')
32 } IP4_IF_ENUM_TYPES;
33
34 /**
35 This prototype is used by both receive and transmission.
36 When receiving Netbuf is allocated by IP4_INTERFACE, and
37 released by IP4. Flag shows whether the frame is received
38 as link broadcast/multicast...
39
40 When transmitting, the Netbuf is from IP4, and provided
41 to the callback as a reference. Flag isn't used.
42
43 @param IpInstance The instance that sent or received the packet.
44 IpInstance can be NULL which means that it is the IP4 driver
45 itself sending the packets. IP4 driver may send packets that
46 don't belong to any instance, such as ICMP errors, ICMP echo
47 responses, or IGMP packets. IpInstance is used as a tag in
48 this module.
49 @param Packet The sent or received packet.
50 @param IoStatus Status of sending or receiving.
51 @param LinkFlag Indicate if the frame is received as link broadcast/multicast.
52 When transmitting, it is not used.
53 @param Context Additional data for callback.
54
55 @return None.
56 **/
57 typedef
58 VOID
59 (*IP4_FRAME_CALLBACK)(
60 IN IP4_PROTOCOL *IpInstance, OPTIONAL
61 IN NET_BUF *Packet,
62 IN EFI_STATUS IoStatus,
63 IN UINT32 LinkFlag,
64 IN VOID *Context
65 );
66
67 ///
68 /// Each receive request is wrapped in an IP4_LINK_RX_TOKEN.
69 /// Upon completion, the Callback will be called. Only one
70 /// receive request is send to MNP. IpInstance is always NULL.
71 /// Reference MNP's spec for information.
72 ///
73 typedef struct {
74 UINT32 Signature;
75 IP4_INTERFACE *Interface;
76
77 IP4_PROTOCOL *IpInstance;
78 IP4_FRAME_CALLBACK CallBack;
79 VOID *Context;
80
81 EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken;
82 } IP4_LINK_RX_TOKEN;
83
84 ///
85 /// Each transmit request is wrapped in an IP4_LINK_TX_TOKEN.
86 /// Upon completion, the Callback will be called.
87 ///
88 typedef struct {
89 UINT32 Signature;
90 LIST_ENTRY Link;
91
92 IP4_INTERFACE *Interface;
93
94 IP4_PROTOCOL *IpInstance;
95 IP4_FRAME_CALLBACK CallBack;
96 NET_BUF *Packet;
97 VOID *Context;
98
99 EFI_MAC_ADDRESS DstMac;
100 EFI_MAC_ADDRESS SrcMac;
101
102 EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken;
103 EFI_MANAGED_NETWORK_TRANSMIT_DATA MnpTxData;
104 } IP4_LINK_TX_TOKEN;
105
106 ///
107 /// Only one ARP request is requested for all the frames in
108 /// a time. It is started for the first frames to the Ip. Any
109 /// subsequent transmission frame will be linked to Frames, and
110 /// be sent all at once the ARP requests succeed.
111 ///
112 typedef struct {
113 UINT32 Signature;
114 LIST_ENTRY Link;
115
116 LIST_ENTRY Frames;
117 IP4_INTERFACE *Interface;
118
119 //
120 // ARP requesting staffs
121 //
122 EFI_EVENT OnResolved;
123 IP4_ADDR Ip;
124 EFI_MAC_ADDRESS Mac;
125 } IP4_ARP_QUE;
126
127 /**
128 Callback to select which frame to cancel. Caller can cancel a
129 single frame, or all the frame from an IP instance.
130
131 @param Frame The sending frame to check for cancellation.
132 @param Context Additional data for callback.
133
134 @retval TRUE The sending of the frame should be cancelled.
135 @retval FALSE Do not cancel the frame sending.
136 **/
137 typedef
138 BOOLEAN
139 (*IP4_FRAME_TO_CANCEL)(
140 IP4_LINK_TX_TOKEN *Frame,
141 VOID *Context
142 );
143
144 //
145 // Each IP4 instance has its own station address. All the instances
146 // with the same station address share a single interface structure.
147 // Each interface has its own ARP child, and shares one MNP child.
148 // Notice the special cases that DHCP can configure the interface
149 // with 0.0.0.0/0.0.0.0.
150 //
151 struct _IP4_INTERFACE {
152 UINT32 Signature;
153 LIST_ENTRY Link;
154 INTN RefCnt;
155
156 //
157 // IP address and subnet mask of the interface. It also contains
158 // the subnet/net broadcast address for quick access. The fileds
159 // are invalid if (Configured == FALSE)
160 //
161 IP4_ADDR Ip;
162 IP4_ADDR SubnetMask;
163 IP4_ADDR SubnetBrdcast;
164 IP4_ADDR NetBrdcast;
165 BOOLEAN Configured;
166
167 //
168 // Handle used to create/destory ARP child. All the IP children
169 // share one MNP which is owned by IP service binding.
170 //
171 EFI_HANDLE Controller;
172 EFI_HANDLE Image;
173
174 EFI_MANAGED_NETWORK_PROTOCOL *Mnp;
175 EFI_ARP_PROTOCOL *Arp;
176 EFI_HANDLE ArpHandle;
177
178 //
179 // Queues to keep the frames sent and waiting ARP request.
180 //
181 LIST_ENTRY ArpQues;
182 LIST_ENTRY SentFrames;
183 IP4_LINK_RX_TOKEN *RecvRequest;
184
185 //
186 // The interface's MAC and broadcast MAC address.
187 //
188 EFI_MAC_ADDRESS Mac;
189 EFI_MAC_ADDRESS BroadcastMac;
190 UINT32 HwaddrLen;
191
192 //
193 // All the IP instances that have the same IP/SubnetMask are linked
194 // together through IpInstances. If any of the instance enables
195 // promiscuous receive, PromiscRecv is true.
196 //
197 LIST_ENTRY IpInstances;
198 BOOLEAN PromiscRecv;
199 };
200
201 IP4_INTERFACE *
202 Ip4CreateInterface (
203 IN EFI_MANAGED_NETWORK_PROTOCOL *Mnp,
204 IN EFI_HANDLE Controller,
205 IN EFI_HANDLE ImageHandle
206 );
207
208 EFI_STATUS
209 Ip4SetAddress (
210 IN IP4_INTERFACE *Interface,
211 IN IP4_ADDR IpAddr,
212 IN IP4_ADDR SubnetMask
213 );
214
215 EFI_STATUS
216 Ip4FreeInterface (
217 IN IP4_INTERFACE *Interface,
218 IN IP4_PROTOCOL *IpInstance OPTIONAL
219 );
220
221 EFI_STATUS
222 Ip4SendFrame (
223 IN IP4_INTERFACE *Interface,
224 IN IP4_PROTOCOL *IpInstance, OPTIONAL
225 IN NET_BUF *Packet,
226 IN IP4_ADDR NextHop,
227 IN IP4_FRAME_CALLBACK CallBack,
228 IN VOID *Context
229 );
230
231 VOID
232 Ip4CancelFrames (
233 IN IP4_INTERFACE *Interface,
234 IN EFI_STATUS IoStatus,
235 IN IP4_FRAME_TO_CANCEL FrameToCancel, OPTIONAL
236 IN VOID *Context
237 );
238
239 VOID
240 Ip4CancelReceive (
241 IN IP4_INTERFACE *Interface
242 );
243
244 EFI_STATUS
245 Ip4ReceiveFrame (
246 IN IP4_INTERFACE *Interface,
247 IN IP4_PROTOCOL *IpInstance, OPTIONAL
248 IN IP4_FRAME_CALLBACK CallBack,
249 IN VOID *Context
250 );
251
252 #endif