]> git.proxmox.com Git - mirror_edk2.git/blob - NetworkPkg/IpSecDxe/IkeService.h
NetworkPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / NetworkPkg / IpSecDxe / IkeService.h
1 /** @file
2 Prototypes definitions of IKE service.
3
4 Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #ifndef _IKE_SERVICE_H_
11 #define _IKE_SERVICE_H_
12
13 #include "Ike.h"
14 #include "IpSecImpl.h"
15 #include "IkeCommon.h"
16 #include "Ikev2/Utility.h"
17
18 #define IPSEC_CRYPTO_LIB_MEMORY 128 * 1024
19
20 /**
21 This is prototype definition of general interface to intialize a IKE negotiation.
22
23 @param[in] UdpService Point to Udp Servcie used for the IKE packet sending.
24 @param[in] SpdEntry Point to SPD entry related to this IKE negotiation.
25 @param[in] PadEntry Point to PAD entry related to this IKE negotiation.
26 @param[in] RemoteIp Point to IP Address which the remote peer to negnotiate.
27
28 @retval EFI_SUCCESS The operation is successful.
29 @return Otherwise The operation is failed.
30
31 **/
32 typedef
33 EFI_STATUS
34 (*IKE_NEGOTIATE_SA) (
35 IN IKE_UDP_SERVICE * UdpService,
36 IN IPSEC_SPD_ENTRY * SpdEntry,
37 IN IPSEC_PAD_ENTRY * PadEntry,
38 IN EFI_IP_ADDRESS * RemoteIp
39 );
40
41 /**
42 This is prototype definition fo general interface to start a IKE negotiation at Quick Mode.
43
44 This function will be called when the related IKE SA is existed and start to
45 create a Child SA.
46
47 @param[in] IkeSaSession Point to IKE SA Session related to this Negotiation.
48 @param[in] SpdEntry Point to SPD entry related to this Negotiation.
49 @param[in] Context Point to data passed from the caller.
50
51 @retval EFI_SUCCESS The operation is successful.
52 @retval Otherwise The operation is failed.
53
54 **/
55 typedef
56 EFI_STATUS
57 (*IKE_NEGOTIATE_CHILD_SA) (
58 IN UINT8 *IkeSaSession,
59 IN IPSEC_SPD_ENTRY *SpdEntry,
60 IN UINT8 *Context
61 );
62
63 /**
64 This is prototype definition of the general interface when initialize a Inforamtion
65 Exchange.
66
67 @param[in] IkeSaSession Point to IKE SA Session related to.
68 @param[in] Context Point to data passed from caller.
69
70 **/
71 typedef
72 EFI_STATUS
73 (*IKE_NEGOTIATE_INFO) (
74 IN UINT8 *IkeSaSession,
75 IN UINT8 *Context
76 );
77
78 /**
79 This is prototype definition of the general interface when recived a IKE Pakcet
80 for the IKE SA establishing.
81
82 @param[in] UdpService Point to UDP service used to send IKE Packet.
83 @param[in] IkePacket Point to received IKE packet.
84
85 **/
86 typedef
87 VOID
88 (*IKE_HANDLE_SA) (
89 IN IKE_UDP_SERVICE *UdpService,
90 IN IKE_PACKET *IkePacket
91 );
92
93 /**
94 This is prototyp definition of the general interface when recived a IKE Packet
95 xfor the Child SA establishing.
96
97 @param[in] UdpService Point to UDP service used to send IKE packet.
98 @param[in] IkePacket Point to received IKE packet.
99
100 **/
101 typedef
102 VOID
103 (*IKE_HANDLE_CHILD_SA) (
104 IN IKE_UDP_SERVICE *UdpService,
105 IN IKE_PACKET *IkePacket
106 );
107
108 /**
109 This is prototype definition of the general interface when received a IKE
110 information Packet.
111
112 @param[in] UdpService Point to UDP service used to send IKE packet.
113 @param[in] IkePacket Point to received IKE packet.
114
115 **/
116 typedef
117 VOID
118 (*IKE_HANDLE_INFO) (
119 IN IKE_UDP_SERVICE *UdpService,
120 IN IKE_PACKET *IkePacket
121 );
122
123 typedef struct _IKE_EXCHANGE_INTERFACE {
124 UINT8 IkeVer;
125 IKE_NEGOTIATE_SA NegotiateSa;
126 IKE_NEGOTIATE_CHILD_SA NegotiateChildSa;
127 IKE_NEGOTIATE_INFO NegotiateInfo;
128 IKE_HANDLE_SA HandleSa;
129 IKE_HANDLE_CHILD_SA HandleChildSa;
130 IKE_HANDLE_INFO HandleInfo;
131 } IKE_EXCHANGE_INTERFACE;
132
133 /**
134 Open and configure a UDPIO of Udp4 for IKE packet receiving.
135
136 This function is called at the IPsecDriverBinding start. IPsec create a UDP4 and
137 a UDP4 IO for each NIC handle.
138
139 @param[in] Private Point to IPSEC_PRIVATE_DATA
140 @param[in] Controller Handler for NIC card.
141 @param[in] ImageHandle The handle that contains the EFI_DRIVER_BINDING_PROTOCOL instance.
142
143 @retval EFI_SUCCESS The Operation is successful.
144 @retval EFI_OUT_OF_RESOURCE The required system resource can't be allocated.
145
146 **/
147 EFI_STATUS
148 IkeOpenInputUdp4 (
149 IN IPSEC_PRIVATE_DATA *Private,
150 IN EFI_HANDLE Controller,
151 IN EFI_HANDLE ImageHandle
152 );
153
154 /**
155 Open and configure a UDPIO of Udp6 for IKE packet receiving.
156
157 This function is called at the IPsecDriverBinding start. IPsec create a UDP6 and UDP6
158 IO for each NIC handle.
159
160 @param[in] Private Point to IPSEC_PRIVATE_DATA
161 @param[in] Controller Handler for NIC card.
162 @param[in] ImageHandle The handle that contains the EFI_DRIVER_BINDING_PROTOCOL instance.
163
164 @retval EFI_SUCCESS The Operation is successful.
165 @retval EFI_OUT_OF_RESOURCE The required system resource can't be allocated.
166
167 **/
168 EFI_STATUS
169 IkeOpenInputUdp6 (
170 IN IPSEC_PRIVATE_DATA *Private,
171 IN EFI_HANDLE Controller,
172 IN EFI_HANDLE ImageHandle
173 );
174
175 /**
176 The general interface of starting IPsec Key Exchange.
177
178 This function is called when start a IKE negotiation to get a Key.
179
180 @param[in] UdpService Point to IKE_UDP_SERVICE which will be used for
181 IKE packet sending.
182 @param[in] SpdEntry Point to the SPD entry related to the IKE negotiation.
183 @param[in] RemoteIp Point to EFI_IP_ADDRESS related to the IKE negotiation.
184
185 @retval EFI_SUCCESS The Operation is successful.
186 @retval EFI_ACCESS_DENIED No related PAD entry was found.
187
188 **/
189 EFI_STATUS
190 IkeNegotiate (
191 IN IKE_UDP_SERVICE *UdpService,
192 IN IPSEC_SPD_ENTRY *SpdEntry,
193 IN EFI_IP_ADDRESS *RemoteIp
194 );
195
196 /**
197 The general interface when receive a IKE packet.
198
199 This function is called when UDP IO receives a IKE packet.
200
201 @param[in] Packet Point to received IKE packet.
202 @param[in] EndPoint Point to UDP_END_POINT which contains the information of
203 Remote IP and Port.
204 @param[in] IoStatus The Status of Recieve Token.
205 @param[in] Context Point to data passed from the caller.
206
207 **/
208 VOID
209 EFIAPI
210 IkeDispatch (
211 IN NET_BUF *Packet,
212 IN UDP_END_POINT *EndPoint,
213 IN EFI_STATUS IoStatus,
214 IN VOID *Context
215 );
216
217 /**
218 Check if the NIC handle is binded to a Udp service.
219
220 @param[in] Private Pointer of IPSEC_PRIVATE_DATA
221 @param[in] Handle The Handle of the NIC card
222 @param[in] IpVersion The version of the IP stack.
223
224 @return a pointer of IKE_UDP_SERVICE.
225
226 **/
227 IKE_UDP_SERVICE *
228 IkeLookupUdp (
229 IN IPSEC_PRIVATE_DATA *Private,
230 IN EFI_HANDLE Handle,
231 IN UINT8 IpVersion
232 );
233
234
235 /**
236 Delete all established IKE SAs and related Child SAs.
237
238 This function is the subfunction of the IpSecCleanupAllSa(). It first calls
239 IkeDeleteChildSa() to delete all Child SAs then send out the related
240 Information packet.
241
242 @param[in] Private Pointer of the IPSEC_PRIVATE_DATA.
243 @param[in] IsDisableIpsec Indicate whether needs to disable IPsec.
244
245 **/
246 VOID
247 IkeDeleteAllSas (
248 IN IPSEC_PRIVATE_DATA *Private,
249 IN BOOLEAN IsDisableIpsec
250 );
251
252
253 extern IKE_EXCHANGE_INTERFACE mIkev1Exchange;
254 extern IKE_EXCHANGE_INTERFACE mIkev2Exchange;
255
256 #endif