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