aboutsummaryrefslogtreecommitdiff
path: root/example/ipsec/odp_ipsec_sp_db.h
blob: 735c20ed50171f425aa59beefcf4ed1bf9175bbb (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
/* Copyright (c) 2014, Linaro Limited
 * All rights reserved.
 *
 * SPDX-License-Identifier:     BSD-3-Clause
 */

#ifndef ODP_IPSEC_SP_DB_H_
#define ODP_IPSEC_SP_DB_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <odp_ipsec_misc.h>

/**
 * Security Policy (SP) data base entry
 */
typedef struct sp_db_entry_s {
	struct sp_db_entry_s *next;        /**< Next entry on list */
	ip_addr_range_t       src_subnet;  /**< Source IPv4 subnet/range */
	ip_addr_range_t       dst_subnet;  /**< Destination IPv4 subnet/range */
	odp_bool_t            input;       /**< Direction when applied */
	odp_bool_t            esp;         /**< Enable cipher (ESP) */
	odp_bool_t            ah;          /**< Enable authentication (AH) */
} sp_db_entry_t;

/**
 * Security Policy (SP) data base global structure
 */
typedef struct sp_db_s {
	uint32_t         index;          /**< Index of next available entry */
	sp_db_entry_t   *list;		 /**< List of active entries */
	sp_db_entry_t    array[MAX_DB];	 /**< Entry storage */
} sp_db_t;

/** Global pointer to sp db */
extern sp_db_t *sp_db;

/** Initialize SP database global control structure */
void init_sp_db(void);

/**
 * Create an SP DB entry
 *
 * String is of the format "SrcSubNet:DstSubNet:(in|out):(ah|esp|both)"
 *
 * @param input  Pointer to string describing SP
 *
 * @return 0 if successful else -1
 */
int create_sp_db_entry(char *input);

/**
 * Display one SP DB entry
 *
 * @param entry  Pointer to entry to display
 */
void dump_sp_db_entry(sp_db_entry_t *entry);

/**
 * Display the SP DB
 */
void dump_sp_db(void);

#ifdef __cplusplus
}
#endif

#endif