blob: d9c84b29bc2e8bf9a8fe6fe3f99d6e9acf4434b4 (
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2014-2018 Linaro Limited
*/
/** @cond _ODP_HIDE_FROM_DOXYGEN_ */
#ifndef ODP_IPSEC_FWD_DB_H_
#define ODP_IPSEC_FWD_DB_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <odp_api.h>
#include <odp_ipsec_misc.h>
#define OIF_LEN 32
/**
* Forwarding data base entry
*/
typedef struct fwd_db_entry_s {
struct fwd_db_entry_s *next; /**< Next entry on list */
char oif[OIF_LEN]; /**< Output interface name */
odp_pktio_t pktio; /**< Output PktI/O interface */
odp_pktout_queue_t pktout; /**< Output transmit queue */
uint8_t src_mac[ODPH_ETHADDR_LEN]; /**< Output source MAC */
uint8_t dst_mac[ODPH_ETHADDR_LEN]; /**< Output destination MAC */
ip_addr_range_t subnet; /**< Subnet for this router */
} fwd_db_entry_t;
/**
* Forwarding data base global structure
*/
typedef struct fwd_db_s {
uint32_t index; /**< Next available entry */
fwd_db_entry_t *list; /**< List of active routes */
fwd_db_entry_t array[MAX_DB]; /**< Entry storage */
} fwd_db_t;
/** Global pointer to fwd db */
extern fwd_db_t *fwd_db;
/** Initialize FWD DB */
void init_fwd_db(void);
/**
* Create a forwarding database entry
*
* String is of the format "SubNet,Intf,NextHopMAC"
*
* @param input Pointer to string describing route
*
* @param if_names Array of Name of the interfaces available
*
* @param if_count number of interfaces in if_names array
*
* @return 0 if successful else -1
*/
int create_fwd_db_entry(char *input, char **if_names, int if_count);
/**
* Scan FWD DB entries and resolve output queue and source MAC address
*
* @param intf Interface name string
* @param pktio Output packet interface
* @param outq Output queue for packet transmit
* @param mac MAC address of this interface
*/
void resolve_fwd_db(char *intf, odp_pktio_t pktio, odp_pktout_queue_t pktout,
uint8_t *mac);
/**
* Display one forwarding database entry
*
* @param entry Pointer to entry to display
*/
void dump_fwd_db_entry(fwd_db_entry_t *entry);
/**
* Display the forwarding database
*/
void dump_fwd_db(void);
/**
* Find a matching forwarding database entry
*
* @param dst_ip Destination IPv4 address
*
* @return pointer to forwarding DB entry else NULL
*/
fwd_db_entry_t *find_fwd_db_entry(uint32_t dst_ip);
#ifdef __cplusplus
}
#endif
#endif
|