16 #include <odp/helper/odph_api.h>
18 #include <odp_ipsec_sp_db.h>
33 ODPH_ERR(
"Error: shared mem reserve failed.\n");
40 ODPH_ERR(
"Error: shared mem alloc failed.\n");
43 memset(sp_db, 0,
sizeof(*sp_db));
46 int create_sp_db_entry(
char *input,
odp_bool_t both_supported)
53 sp_db_entry_t *entry = &sp_db->array[sp_db->index];
56 if (MAX_DB <= sp_db->index)
60 local = malloc(strlen(input) + 1);
70 while (NULL != (token = strtok_r(str,
",", &save))) {
76 parse_ipv4_string(token,
77 &entry->src_subnet.addr,
78 &entry->src_subnet.mask);
81 parse_ipv4_string(token,
82 &entry->dst_subnet.addr,
83 &entry->dst_subnet.mask);
86 if (0 == strcmp(token,
"in"))
92 if (0 == strcmp(token,
"esp")) {
94 }
else if (0 == strcmp(token,
"ah")) {
96 }
else if (0 == strcmp(token,
"both")) {
102 printf(
"ERROR: extra token \"%s\" at position %d\n",
112 if (!both_supported && (entry->ah && entry->esp)) {
113 printf(
"ERROR: enabling both AH and ESP is not supported\n");
120 printf(
"ERROR: \"%s\" contains %d tokens, expected 4\n",
129 entry->next = sp_db->list;
136 void dump_sp_db_entry(sp_db_entry_t *entry)
138 char src_subnet_str[MAX_STRING];
139 char dst_subnet_str[MAX_STRING];
141 printf(
" %s %s %s %s:%s\n",
142 ipv4_subnet_str(src_subnet_str, &entry->src_subnet),
143 ipv4_subnet_str(dst_subnet_str, &entry->dst_subnet),
144 entry->input ?
"in" :
"out",
145 entry->esp ?
"esp" :
"none",
146 entry->ah ?
"ah" :
"none");
149 void dump_sp_db(
void)
151 sp_db_entry_t *entry;
154 "Security policy table\n"
155 "---------------------\n");
157 for (entry = sp_db->list; NULL != entry; entry = entry->next)
158 dump_sp_db_entry(entry);
#define ODP_SHM_INVALID
Invalid shared memory block.
void * odp_shm_addr(odp_shm_t shm)
Shared memory block address.
odp_shm_t odp_shm_reserve(const char *name, uint64_t size, uint64_t align, uint32_t flags)
Reserve a contiguous block of shared memory.
bool odp_bool_t
Boolean type.