12 #ifndef NETLINK_ROUTE_H_
13 #define NETLINK_ROUTE_H_
15 #include <netlink/netlink.h>
16 #include <netlink/cache.h>
17 #include <netlink/addr.h>
18 #include <netlink/data.h>
19 #include <netlink/route/nexthop.h>
20 #include <netlink/route/rtnl.h>
21 #include <linux/in_route.h>
33 #define ROUTE_CACHE_CONTENT 1
39 uint32_t rtci_clntref;
40 uint32_t rtci_last_use;
41 uint32_t rtci_expires;
51 extern struct rtnl_route * rtnl_route_alloc(
void);
52 extern void rtnl_route_put(
struct rtnl_route *);
56 extern void rtnl_route_get(
struct rtnl_route *);
57 extern void rtnl_route_put(
struct rtnl_route *);
59 extern int rtnl_route_parse(
struct nlmsghdr *,
struct rtnl_route **);
60 extern int rtnl_route_build_msg(
struct nl_msg *,
struct rtnl_route *);
62 extern int rtnl_route_build_add_request(
struct rtnl_route *,
int,
64 extern int rtnl_route_add(
struct nl_sock *,
struct rtnl_route *,
int);
65 extern int rtnl_route_build_del_request(
struct rtnl_route *,
int,
67 extern int rtnl_route_delete(
struct nl_sock *,
struct rtnl_route *,
int);
69 extern void rtnl_route_set_table(
struct rtnl_route *, uint32_t);
70 extern uint32_t rtnl_route_get_table(
struct rtnl_route *);
71 extern void rtnl_route_set_scope(
struct rtnl_route *, uint8_t);
72 extern uint8_t rtnl_route_get_scope(
struct rtnl_route *);
73 extern void rtnl_route_set_tos(
struct rtnl_route *, uint8_t);
74 extern uint8_t rtnl_route_get_tos(
struct rtnl_route *);
75 extern void rtnl_route_set_protocol(
struct rtnl_route *, uint8_t);
76 extern uint8_t rtnl_route_get_protocol(
struct rtnl_route *);
77 extern void rtnl_route_set_priority(
struct rtnl_route *, uint32_t);
78 extern uint32_t rtnl_route_get_priority(
struct rtnl_route *);
79 extern int rtnl_route_set_family(
struct rtnl_route *, uint8_t);
80 extern uint8_t rtnl_route_get_family(
struct rtnl_route *);
81 extern int rtnl_route_set_type(
struct rtnl_route *, uint8_t);
82 extern uint8_t rtnl_route_get_type(
struct rtnl_route *);
83 extern void rtnl_route_set_flags(
struct rtnl_route *, uint32_t);
84 extern void rtnl_route_unset_flags(
struct rtnl_route *, uint32_t);
85 extern uint32_t rtnl_route_get_flags(
struct rtnl_route *);
86 extern int rtnl_route_set_metric(
struct rtnl_route *,
int,
unsigned int);
87 extern int rtnl_route_unset_metric(
struct rtnl_route *,
int);
88 extern int rtnl_route_get_metric(
struct rtnl_route *,
int, uint32_t *);
89 extern int rtnl_route_set_dst(
struct rtnl_route *,
struct nl_addr *);
90 extern struct nl_addr *rtnl_route_get_dst(
struct rtnl_route *);
91 extern int rtnl_route_set_src(
struct rtnl_route *,
struct nl_addr *);
92 extern struct nl_addr *rtnl_route_get_src(
struct rtnl_route *);
93 extern int rtnl_route_set_pref_src(
struct rtnl_route *,
struct nl_addr *);
94 extern struct nl_addr *rtnl_route_get_pref_src(
struct rtnl_route *);
95 extern void rtnl_route_set_iif(
struct rtnl_route *,
int);
96 extern int rtnl_route_get_iif(
struct rtnl_route *);
97 extern int rtnl_route_get_src_len(
struct rtnl_route *);
99 extern void rtnl_route_add_nexthop(
struct rtnl_route *,
100 struct rtnl_nexthop *);
101 extern void rtnl_route_remove_nexthop(
struct rtnl_route *,
102 struct rtnl_nexthop *);
103 extern struct nl_list_head *rtnl_route_get_nexthops(
struct rtnl_route *);
104 extern int rtnl_route_get_nnexthops(
struct rtnl_route *);
106 extern void rtnl_route_foreach_nexthop(
struct rtnl_route *r,
107 void (*cb)(
struct rtnl_nexthop *,
void *),
110 extern struct rtnl_nexthop * rtnl_route_nexthop_n(
struct rtnl_route *r,
int n);
114 extern char * rtnl_route_table2str(
int,
char *,
size_t);
115 extern int rtnl_route_str2table(
const char *);
116 extern int rtnl_route_read_table_names(
const char *);
118 extern char * rtnl_route_proto2str(
int,
char *,
size_t);
119 extern int rtnl_route_str2proto(
const char *);
120 extern int rtnl_route_read_protocol_names(
const char *);
122 extern char * rtnl_route_metric2str(
int,
char *,
size_t);
123 extern int rtnl_route_str2metric(
const char *);