ipsec_misc.h
Go to the documentation of this file.
1 /**
2  * @file ipsec_misc.h
3  * @brief Helper routines for IPsec
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2022-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneIPSEC Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.0
29  **/
30 
31 #ifndef _IPSEC_MISC_H
32 #define _IPSEC_MISC_H
33 
34 //Dependencies
35 #include "ipsec/ipsec.h"
36 
37 //C++ guard
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 //IPsec related constants
43 extern const uint8_t IPSEC_INVALID_SPI[4];
44 
45 //IPsec related functions
47  IpsecPolicyAction policyAction, const IpsecSelector *selector);
48 
50 
52  IpsecProtocol protocol, uint32_t spi);
53 
55  const IpsecSelector *selector);
56 
58  const uint8_t *id, size_t idLen);
59 
61  const IpsecSelector *selector2);
62 
64  const IpsecSelector *selector2, IpsecSelector *result);
65 
67  const IpsecPacketInfo *packet, IpsecSelector *selector);
68 
69 //C++ guard
70 #ifdef __cplusplus
71 }
72 #endif
73 
74 #endif
uint32_t spi
Definition: ah.h:143
signed int int_t
Definition: compiler_port.h:49
int bool_t
Definition: compiler_port.h:53
error_t
Error codes.
Definition: error.h:43
uint8_t idType
Definition: ike.h:1363
IPsec (IP security)
#define IpsecSadEntry
Definition: ipsec.h:36
IpsecPolicyAction
Policy action.
Definition: ipsec.h:229
IpsecProtocol
Security protocols.
Definition: ipsec.h:190
error_t ipsecDeriveSelector(const IpsecSpdEntry *spdEntry, const IpsecPacketInfo *packet, IpsecSelector *selector)
Derive SAD selector from SPD entry and triggering packet.
Definition: ipsec_misc.c:802
int_t ipsecAllocateSadEntry(IpsecContext *context)
Allocate a new entry in the SAD database.
Definition: ipsec_misc.c:96
IpsecPadEntry * ipsecFindPadEntry(IpsecContext *context, uint8_t idType, const uint8_t *id, size_t idLen)
Find PAD entry that matches the specified identification data.
Definition: ipsec_misc.c:243
IpsecSadEntry * ipsecFindInboundSadEntry(IpsecContext *context, IpsecProtocol protocol, uint32_t spi)
Search the SAD database for a matching inbound entry.
Definition: ipsec_misc.c:134
bool_t ipsecIntersectSelectors(const IpsecSelector *selector1, const IpsecSelector *selector2, IpsecSelector *result)
Calculate the intersection of two selectors.
Definition: ipsec_misc.c:545
const uint8_t IPSEC_INVALID_SPI[4]
Definition: ipsec_misc.c:40
IpsecSpdEntry * ipsecFindSpdEntry(IpsecContext *context, IpsecPolicyAction policyAction, const IpsecSelector *selector)
Search the SPD database for a matching entry.
Definition: ipsec_misc.c:51
bool_t ipsecIsSubsetSelector(const IpsecSelector *selector1, const IpsecSelector *selector2)
Test if a selector is a subset of another selector.
Definition: ipsec_misc.c:362
IpsecSadEntry * ipsecFindOutboundSadEntry(IpsecContext *context, const IpsecSelector *selector)
Search the SAD database for a matching outbound entry.
Definition: ipsec_misc.c:174
uint8_t protocol
Definition: ipv4.h:296
IPsec context.
Definition: ipsec.h:434
IP packet information.
Definition: ipsec.h:316
Peer Authorization Database (PAD) entry.
Definition: ipsec.h:400
IPsec selector.
Definition: ipsec.h:302
Security Policy Database (SPD) entry.
Definition: ipsec.h:344