CNDP  22.08.0
cnet_route4.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2016-2022 Intel Corporation
3  */
4 
5 #ifndef __CNET_ROUTE4_H
6 #define __CNET_ROUTE4_H
7 
13 #include <net/ethernet.h> // for ether_addr
14 #include <stdint.h> // for uint16_t, uint8_t, uint32_t
15 #include <sys/queue.h> // for TAILQ_ENTRY
16 
17 #include "cne_common.h" // for __cne_cache_aligned
18 #include "cnet_const.h" // for match_t, rt_attach_t, vfunc_t
19 #include "cne_inet.h" // for in_caddr
20 #include "cnet_stk.h" // for this_stk
21 #include "cnet_route.h"
22 
23 struct netif;
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #define RT4_NEXT_INDEX_SHIFT 24UL /* use the upper 8 bits for next index value */
29 
30 /* Routing Table entry for Internet protocol addresses */
31 struct rt4_entry {
32  struct in_addr nexthop;
33  struct in_addr netmask;
34  struct in_addr gateway;
35  struct in_addr subnet;
36  uint32_t flags;
37  uint16_t netif_idx;
38  uint16_t timo;
39  uint16_t metric;
40 } __cne_cache_aligned;
41 
54 CNDP_API int cnet_route4_create(struct cnet *cnet, uint32_t num_rules, uint32_t num_tbl8s);
55 
64 CNDP_API int cnet_route4_destroy(struct cnet *cnet);
65 
72 CNDP_API struct rt4_entry *cnet_route4_alloc(void);
73 
84 CNDP_API int cnet_route4_alloc_bulk(struct rt4_entry **rt, int n);
85 
94 CNDP_API void cnet_route4_free(struct rt4_entry *entry);
95 
106 CNDP_API void cnet_route4_free_bulk(struct rt4_entry **entry, int n);
107 
114 CNDP_API void cne_route4_timer(void);
115 
122 CNDP_API int cne_route4_notify(void);
123 
142 CNDP_API int cnet_route4_insert(int netif_idx, struct in_addr *dst, struct in_addr *netmask,
143  struct in_addr *gate, uint8_t metric, uint16_t timo);
144 
153 CNDP_API int cnet_route4_delete(struct in_addr *ipaddr);
154 
167 CNDP_API int cnet_route4_get_bulk(uint64_t *nh, struct rt4_entry **rt, int n);
168 
177 CNDP_API struct rt4_entry *cnet_route4_get(uint64_t nh);
178 
185 CNDP_API int cnet_route4_show(void);
186 
187 #ifdef __cplusplus
188 }
189 #endif
190 
191 #endif /* __CNET_ROUTE4_H */
CNDP_API int cnet_route4_insert(int netif_idx, struct in_addr *dst, struct in_addr *netmask, struct in_addr *gate, uint8_t metric, uint16_t timo)
Insert IPv4 route into the routing table.
CNDP_API void cnet_route4_free(struct rt4_entry *entry)
Free a IPv4 route entry.
CNDP_API struct rt4_entry * cnet_route4_get(uint64_t nh)
Return a single route entry given the nexthop index value.
CNDP_API int cnet_route4_delete(struct in_addr *ipaddr)
Delete a IPv4 route entry.
CNDP_API struct rt4_entry * cnet_route4_alloc(void)
Allocate a IPv4 route entry.
CNDP_API int cne_route4_notify(void)
Routine to call when a route notification is received.
CNDP_API int cnet_route4_get_bulk(uint64_t *nh, struct rt4_entry **rt, int n)
Get a bulk of route entries using the nexthop index values.
CNDP_API int cnet_route4_alloc_bulk(struct rt4_entry **rt, int n)
Allocate a number of IPv4 route entries.
CNDP_API int cnet_route4_create(struct cnet *cnet, uint32_t num_rules, uint32_t num_tbl8s)
Create a IPv4 route instance.
CNDP_API int cnet_route4_show(void)
Display the IPvr route entries.
CNDP_API int cnet_route4_destroy(struct cnet *cnet)
Destroy the IPv4 routing instance.
CNDP_API void cne_route4_timer(void)
Enable a IPv4 route entry timer to age entries.
CNDP_API void cnet_route4_free_bulk(struct rt4_entry **entry, int n)
Free a bulk of IPv4 route entries.