1/* 2 * netlink/route/route.h Routes 3 * 4 * This library is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU Lesser General Public 6 * License as published by the Free Software Foundation version 2.1 7 * of the License. 8 * 9 * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch> 10 */ 11 12#ifndef NETLINK_ROUTE_H_ 13#define NETLINK_ROUTE_H_ 14 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> 22 23#ifdef __cplusplus 24extern "C" { 25#endif 26 27/* flags */ 28#define ROUTE_CACHE_CONTENT 1 29 30struct rtnl_route; 31 32struct rtnl_rtcacheinfo 33{ 34 uint32_t rtci_clntref; 35 uint32_t rtci_last_use; 36 uint32_t rtci_expires; 37 int32_t rtci_error; 38 uint32_t rtci_used; 39 uint32_t rtci_id; 40 uint32_t rtci_ts; 41 uint32_t rtci_tsage; 42}; 43 44extern struct nl_object_ops route_obj_ops; 45 46extern struct rtnl_route * rtnl_route_alloc(void); 47extern void rtnl_route_put(struct rtnl_route *); 48extern int rtnl_route_alloc_cache(struct nl_sock *, int, int, 49 struct nl_cache **); 50 51extern void rtnl_route_get(struct rtnl_route *); 52extern void rtnl_route_put(struct rtnl_route *); 53 54extern int rtnl_route_parse(struct nlmsghdr *, struct rtnl_route **); 55extern int rtnl_route_build_msg(struct nl_msg *, struct rtnl_route *); 56 57extern int rtnl_route_build_add_request(struct rtnl_route *, int, 58 struct nl_msg **); 59extern int rtnl_route_add(struct nl_sock *, struct rtnl_route *, int); 60extern int rtnl_route_build_del_request(struct rtnl_route *, int, 61 struct nl_msg **); 62extern int rtnl_route_delete(struct nl_sock *, struct rtnl_route *, int); 63 64extern void rtnl_route_set_table(struct rtnl_route *, uint32_t); 65extern uint32_t rtnl_route_get_table(struct rtnl_route *); 66extern void rtnl_route_set_scope(struct rtnl_route *, uint8_t); 67extern uint8_t rtnl_route_get_scope(struct rtnl_route *); 68extern void rtnl_route_set_tos(struct rtnl_route *, uint8_t); 69extern uint8_t rtnl_route_get_tos(struct rtnl_route *); 70extern void rtnl_route_set_protocol(struct rtnl_route *, uint8_t); 71extern uint8_t rtnl_route_get_protocol(struct rtnl_route *); 72extern void rtnl_route_set_priority(struct rtnl_route *, uint32_t); 73extern uint32_t rtnl_route_get_priority(struct rtnl_route *); 74extern int rtnl_route_set_family(struct rtnl_route *, uint8_t); 75extern uint8_t rtnl_route_get_family(struct rtnl_route *); 76extern int rtnl_route_set_type(struct rtnl_route *, uint8_t); 77extern uint8_t rtnl_route_get_type(struct rtnl_route *); 78extern void rtnl_route_set_flags(struct rtnl_route *, uint32_t); 79extern void rtnl_route_unset_flags(struct rtnl_route *, uint32_t); 80extern uint32_t rtnl_route_get_flags(struct rtnl_route *); 81extern int rtnl_route_set_metric(struct rtnl_route *, int, unsigned int); 82extern int rtnl_route_unset_metric(struct rtnl_route *, int); 83extern int rtnl_route_get_metric(struct rtnl_route *, int, uint32_t *); 84extern int rtnl_route_set_dst(struct rtnl_route *, struct nl_addr *); 85extern struct nl_addr *rtnl_route_get_dst(struct rtnl_route *); 86extern int rtnl_route_set_src(struct rtnl_route *, struct nl_addr *); 87extern struct nl_addr *rtnl_route_get_src(struct rtnl_route *); 88extern int rtnl_route_set_pref_src(struct rtnl_route *, struct nl_addr *); 89extern struct nl_addr *rtnl_route_get_pref_src(struct rtnl_route *); 90extern void rtnl_route_set_iif(struct rtnl_route *, int); 91extern int rtnl_route_get_iif(struct rtnl_route *); 92extern int rtnl_route_get_src_len(struct rtnl_route *); 93 94extern void rtnl_route_add_nexthop(struct rtnl_route *, 95 struct rtnl_nexthop *); 96extern void rtnl_route_remove_nexthop(struct rtnl_route *, 97 struct rtnl_nexthop *); 98extern struct nl_list_head *rtnl_route_get_nexthops(struct rtnl_route *); 99extern int rtnl_route_get_nnexthops(struct rtnl_route *); 100 101extern void rtnl_route_foreach_nexthop(struct rtnl_route *r, 102 void (*cb)(struct rtnl_nexthop *, void *), 103 void *arg); 104 105extern struct rtnl_nexthop * rtnl_route_nexthop_n(struct rtnl_route *r, int n); 106 107extern int rtnl_route_guess_scope(struct rtnl_route *); 108 109extern char * rtnl_route_table2str(int, char *, size_t); 110extern int rtnl_route_str2table(const char *); 111extern int rtnl_route_read_table_names(const char *); 112 113extern char * rtnl_route_proto2str(int, char *, size_t); 114extern int rtnl_route_str2proto(const char *); 115extern int rtnl_route_read_protocol_names(const char *); 116 117extern char * rtnl_route_metric2str(int, char *, size_t); 118extern int rtnl_route_str2metric(const char *); 119 120#ifdef __cplusplus 121} 122#endif 123 124#endif 125