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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright (c) 2016-2018 Linaro Limited
*/
/**
* @file
*
* ODP IP Lookup Table
*/
#ifndef ODPH_IPLOOKUP_TABLE_H_
#define ODPH_IPLOOKUP_TABLE_H_
#include <odp/helper/table.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup odph_iplookuptable ODPH IP LOOKUP TABLE
* IP lookup table
*
* @details
* This is an implementation of the IP lookup table. The key of this table is
* IPv4 address (32 bits), and the value can be defined by user. This table uses
* the 16,8,8 ip lookup (longest prefix matching) algorithm.
*
* @{
*/
/**
* IP Lookup Prefix
*/
typedef struct {
uint32_t ip; /**< IPv4 address */
uint8_t cidr; /**< CIDR value for prefix matching */
} odph_iplookup_prefix_t;
/**
* Create an IP lookup table
*
* @param name Name of the table to be created
* @param ODP_IGNORED_1 Unused
* @param ODP_IGNORED_2 Unused
* @param value_size Byte size of each entry in the table
*
* @return Handle of the created ip lookup table
* @retval NULL If table create failed
*/
odph_table_t odph_iplookup_table_create(const char *name,
uint32_t ODP_IGNORED_1,
uint32_t ODP_IGNORED_2,
uint32_t value_size);
/**
* Lookup an IP lookup table by name
*
* @param name Name of the table to be located
*
* @return Handle of the located ip lookup table
* @retval NULL No table matching supplied name found
*/
odph_table_t odph_iplookup_table_lookup(const char *name);
/**
* Destroy an IP lookup table
*
* @param table Handle of the ip lookup table to be destroyed
*
* @retval 0 Success
* @retval < 0 Failure
*/
int odph_iplookup_table_destroy(odph_table_t table);
/**
* Insert a key/value pair into an ip lookup table
*
* @param table Table into which value is to be stored
* @param key Address of an odph_iplookup_prefix_t to be used as key
* @param value Value to be associated with specified key
*
* @retval >= 0 Success
* @retval < 0 Failure
*/
int odph_iplookup_table_put_value(odph_table_t table, void *key, void *value);
/**
* Retrieve a value from an iplookup table
*
* @param table Table from which value is to be retrieved
* @param key Address of an odph_iplookup_prefix_t to be used as key
* @param[out] buffer Address of buffer to receive resulting value
* @param buffer_size Size of supplied buffer
*
* @retval 0 Success
* @retval 1 Success
* @retval < 0 Failure
*/
int odph_iplookup_table_get_value(odph_table_t table, void *key,
void *buffer, uint32_t buffer_size);
/**
* Remove a value from an iplookup table
*
* @param table Table from which value is to be removed
* @param key Address of odph_iplookup_prefix_t to be used as key
*
* @retval >= 0 Success
* @retval < 0 Failure
*
*/
int odph_iplookup_table_remove_value(odph_table_t table, void *key);
extern odph_table_ops_t odph_iplookup_table_ops; /**< @internal */
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* ODPH_IPLOOKUP_TABLE_H_ */
|