]> git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/Ip6Dxe/Ip6If.h
NetworkPkg: Apply uncrustify changes
[mirror_edk2.git] / NetworkPkg / Ip6Dxe / Ip6If.h
1 /** @file
2 Definition for IP6 pseudo interface structure.
3
4 Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #ifndef __EFI_IP6_IF_H__
11 #define __EFI_IP6_IF_H__
12
13 #define IP6_LINK_RX_SIGNATURE SIGNATURE_32 ('I', 'P', '6', 'R')
14 #define IP6_LINK_TX_SIGNATURE SIGNATURE_32 ('I', 'P', '6', 'T')
15 #define IP6_INTERFACE_SIGNATURE SIGNATURE_32 ('I', 'P', '6', 'I')
16 #define IP6_ADDR_INFO_SIGNATURE SIGNATURE_32 ('I', 'P', 'A', 'I')
17
18 //
19 // This prototype is used by both receive and transmission.
20 // When receiving Netbuf is allocated by IP6_INTERFACE, and
21 // released by IP6. Flag shows whether the frame is received
22 // as unicast/multicast/anycast...
23 //
24 // When transmitting, the Netbuf is from IP6, and provided
25 // to the callback as a reference. Flag isn't used.
26 //
27 // IpInstance can be NULL which means that it is the IP6 driver
28 // itself sending the packets. IP6 driver may send packets that
29 // don't belong to any instance, such as ICMP errors, ICMP
30 // informational packets. IpInstance is used as a tag in
31 // this module.
32 //
33 typedef
34 VOID
35 (*IP6_FRAME_CALLBACK) (
36 NET_BUF *Packet,
37 EFI_STATUS IoStatus,
38 UINT32 LinkFlag,
39 VOID *Context
40 );
41
42 //
43 // Each receive request is wrapped in an IP6_LINK_RX_TOKEN.
44 // Upon completion, the Callback will be called. Only one
45 // receive request is send to MNP. IpInstance is always NULL.
46 // Reference MNP's spec for information.
47 //
48 typedef struct {
49 UINT32 Signature;
50 IP6_FRAME_CALLBACK CallBack;
51 VOID *Context;
52 EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken;
53 } IP6_LINK_RX_TOKEN;
54
55 //
56 // Each transmit request is wrapped in an IP6_LINK_TX_TOKEN.
57 // Upon completion, the Callback will be called.
58 //
59 typedef struct {
60 UINT32 Signature;
61 LIST_ENTRY Link;
62
63 IP6_PROTOCOL *IpInstance;
64 IP6_FRAME_CALLBACK CallBack;
65 NET_BUF *Packet;
66 VOID *Context;
67
68 EFI_MAC_ADDRESS DstMac;
69 EFI_MAC_ADDRESS SrcMac;
70
71 EFI_MANAGED_NETWORK_COMPLETION_TOKEN MnpToken;
72 EFI_MANAGED_NETWORK_TRANSMIT_DATA MnpTxData;
73 } IP6_LINK_TX_TOKEN;
74
75 struct _IP6_ADDRESS_INFO {
76 UINT32 Signature;
77 LIST_ENTRY Link;
78 EFI_IPv6_ADDRESS Address;
79 BOOLEAN IsAnycast;
80 UINT8 PrefixLength;
81 UINT32 ValidLifetime;
82 UINT32 PreferredLifetime;
83 };
84
85 //
86 // Callback to select which frame to cancel. Caller can cancel a
87 // single frame, or all the frame from an IP instance.
88 //
89 typedef
90 BOOLEAN
91 (*IP6_FRAME_TO_CANCEL) (
92 IP6_LINK_TX_TOKEN *Frame,
93 VOID *Context
94 );
95
96 struct _IP6_INTERFACE {
97 UINT32 Signature;
98 LIST_ENTRY Link;
99 INTN RefCnt;
100
101 //
102 // IP address and prefix length of the interface. The fileds
103 // are invalid if (Configured == FALSE)
104 //
105 LIST_ENTRY AddressList;
106 UINT32 AddressCount;
107 BOOLEAN Configured;
108
109 IP6_SERVICE *Service;
110
111 EFI_HANDLE Controller;
112 EFI_HANDLE Image;
113
114 //
115 // Queues to keep the frames sent and waiting ARP request.
116 //
117 LIST_ENTRY ArpQues;
118 LIST_ENTRY SentFrames;
119
120 //
121 // The interface's configuration variables
122 //
123 UINT32 DupAddrDetect;
124 LIST_ENTRY DupAddrDetectList;
125 LIST_ENTRY DelayJoinList;
126
127 //
128 // All the IP instances that have the same IP/SubnetMask are linked
129 // together through IpInstances. If any of the instance enables
130 // promiscuous receive, PromiscRecv is true.
131 //
132 LIST_ENTRY IpInstances;
133 BOOLEAN PromiscRecv;
134 };
135
136 /**
137 Create an IP6_INTERFACE.
138
139 @param[in] IpSb The IP6 service binding instance.
140 @param[in] LinkLocal If TRUE, the instance is created for link-local address.
141 Otherwise, it is not for a link-local address.
142
143 @return Point to the created IP6_INTERFACE, otherwise NULL.
144
145 **/
146 IP6_INTERFACE *
147 Ip6CreateInterface (
148 IN IP6_SERVICE *IpSb,
149 IN BOOLEAN LinkLocal
150 );
151
152 /**
153 Free the interface used by IpInstance. All the IP instance with
154 the same Ip/prefix pair share the same interface. It is reference
155 counted. All the frames that haven't been sent will be cancelled.
156 Because the IpInstance is optional, the caller must remove
157 IpInstance from the interface's instance list.
158
159 @param[in] Interface The interface used by the IpInstance.
160 @param[in] IpInstance The IP instance that free the interface. NULL if
161 the IP driver is releasing the default interface.
162
163 **/
164 VOID
165 Ip6CleanInterface (
166 IN IP6_INTERFACE *Interface,
167 IN IP6_PROTOCOL *IpInstance OPTIONAL
168 );
169
170 /**
171 Free the link layer transmit token. It will close the event
172 then free the memory used.
173
174 @param[in] Token Token to free.
175
176 **/
177 VOID
178 Ip6FreeLinkTxToken (
179 IN IP6_LINK_TX_TOKEN *Token
180 );
181
182 /**
183 Request Ip6OnFrameReceivedDpc as a DPC at TPL_CALLBACK
184
185 @param Event The receive event delivered to MNP for receive.
186 @param Context Context for the callback.
187
188 **/
189 VOID
190 EFIAPI
191 Ip6OnFrameReceived (
192 IN EFI_EVENT Event,
193 IN VOID *Context
194 );
195
196 /**
197 Request to receive the packet from the interface.
198
199 @param[in] CallBack Function to call when the receive finished.
200 @param[in] IpSb Points to the IP6 service binding instance.
201
202 @retval EFI_ALREADY_STARTED There is already a pending receive request.
203 @retval EFI_OUT_OF_RESOURCES Failed to allocate resources to receive.
204 @retval EFI_SUCCESS The receive request has been started.
205
206 **/
207 EFI_STATUS
208 Ip6ReceiveFrame (
209 IN IP6_FRAME_CALLBACK CallBack,
210 IN IP6_SERVICE *IpSb
211 );
212
213 /**
214 Send a frame from the interface. If the next hop is multicast address,
215 it is transmitted immediately. If the next hop is a unicast,
216 and the NextHop's MAC is not known, it will perform address resolution.
217 If some error happened, the CallBack won't be called. So, the caller
218 must test the return value, and take action when there is an error.
219
220 @param[in] Interface The interface to send the frame from
221 @param[in] IpInstance The IP child that request the transmission.
222 NULL if it is the IP6 driver itself.
223 @param[in] Packet The packet to transmit.
224 @param[in] NextHop The immediate destination to transmit the packet to.
225 @param[in] CallBack Function to call back when transmit finished.
226 @param[in] Context Opaque parameter to the call back.
227
228 @retval EFI_OUT_OF_RESOURCES Failed to allocate resource to send the frame.
229 @retval EFI_NO_MAPPING Can't resolve the MAC for the nexthop.
230 @retval EFI_SUCCESS The packet successfully transmitted.
231
232 **/
233 EFI_STATUS
234 Ip6SendFrame (
235 IN IP6_INTERFACE *Interface,
236 IN IP6_PROTOCOL *IpInstance OPTIONAL,
237 IN NET_BUF *Packet,
238 IN EFI_IPv6_ADDRESS *NextHop,
239 IN IP6_FRAME_CALLBACK CallBack,
240 IN VOID *Context
241 );
242
243 /**
244 The heartbeat timer of IP6 service instance. It times out
245 all of its IP6 children's received-but-not-delivered and
246 transmitted-but-not-recycle packets.
247
248 @param[in] Event The IP6 service instance's heart beat timer.
249 @param[in] Context The IP6 service instance.
250
251 **/
252 VOID
253 EFIAPI
254 Ip6TimerTicking (
255 IN EFI_EVENT Event,
256 IN VOID *Context
257 );
258
259 #endif