aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-generic/include/protocols/ipsec.h
blob: 5bb0d21694a49536e710ae7add9cc3088716f4d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* SPDX-License-Identifier: BSD-3-Clause
 * Copyright (c) 2016-2018 Linaro Limited
 */


/**
 * @file
 *
 * ODP IPSec headers
 */

#ifndef ODP_IPSEC_H_
#define ODP_IPSEC_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <odp/api/align.h>
#include <odp/api/byteorder.h>
#include <odp/api/debug.h>

#include <stdint.h>

/** @addtogroup odp_header ODP HEADER
 *  @{
 */

#define _ODP_ESPHDR_LEN      8    /**< IPSec ESP header length */
#define _ODP_ESPTRL_LEN      2    /**< IPSec ESP trailer length */
#define _ODP_AHHDR_LEN      12    /**< IPSec AH header length */

/**
 * IPSec ESP header
 */
typedef struct ODP_PACKED {
	odp_u32be_t spi;     /**< Security Parameter Index */
	odp_u32be_t seq_no;  /**< Sequence Number */
	uint8_t     iv[];    /**< Initialization vector */
} _odp_esphdr_t;

/** @internal Compile time assert */
ODP_STATIC_ASSERT(sizeof(_odp_esphdr_t) == _ODP_ESPHDR_LEN,
		  "_ODP_ESPHDR_T__SIZE_ERROR");

/**
 * IPSec ESP trailer
 */
typedef struct ODP_PACKED {
	uint8_t pad_len;      /**< Padding length (0-255) */
	uint8_t next_header;  /**< Next header protocol */
	uint8_t icv[];        /**< Integrity Check Value (optional) */
} _odp_esptrl_t;

/** @internal Compile time assert */
ODP_STATIC_ASSERT(sizeof(_odp_esptrl_t) == _ODP_ESPTRL_LEN,
		  "_ODP_ESPTRL_T__SIZE_ERROR");

/**
 * IPSec AH header
 */
typedef struct ODP_PACKED {
	uint8_t     next_header; /**< Next header protocol */
	uint8_t     ah_len;      /**< AH header length */
	odp_u16be_t pad;         /**< Padding (must be 0) */
	odp_u32be_t spi;         /**< Security Parameter Index */
	odp_u32be_t seq_no;      /**< Sequence Number */
	uint8_t     icv[];       /**< Integrity Check Value */
} _odp_ahhdr_t;

/** @internal Compile time assert */
ODP_STATIC_ASSERT(sizeof(_odp_ahhdr_t) == _ODP_AHHDR_LEN,
		  "_ODP_AHHDR_T__SIZE_ERROR");

/**
 * @}
 */

#ifdef __cplusplus
}
#endif

#endif