libnl 1.1
include/netlink/route/route.h
00001 /*
00002  * netlink/route/route.h        Routes
00003  *
00004  *      This library is free software; you can redistribute it and/or
00005  *      modify it under the terms of the GNU Lesser General Public
00006  *      License as published by the Free Software Foundation version 2.1
00007  *      of the License.
00008  *
00009  * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
00010  */
00011 
00012 #ifndef NETLINK_ROUTE_H_
00013 #define NETLINK_ROUTE_H_
00014 
00015 #include <netlink/netlink.h>
00016 #include <netlink/cache.h>
00017 #include <netlink/addr.h>
00018 #include <netlink/data.h>
00019 #include <netlink/route/nexthop.h>
00020 
00021 #ifdef __cplusplus
00022 extern "C" {
00023 #endif
00024 
00025 struct rtnl_route;
00026 
00027 struct rtnl_rtcacheinfo
00028 {
00029         uint32_t        rtci_clntref;
00030         uint32_t        rtci_last_use;
00031         uint32_t        rtci_expires;
00032         int32_t         rtci_error;
00033         uint32_t        rtci_used;
00034         uint32_t        rtci_id;
00035         uint32_t        rtci_ts;
00036         uint32_t        rtci_tsage;
00037 };
00038 
00039 extern struct nl_object_ops route_obj_ops;
00040 
00041 /* General */
00042 extern struct rtnl_route *      rtnl_route_alloc(void);
00043 extern void                     rtnl_route_put(struct rtnl_route *);
00044 extern struct nl_cache *        rtnl_route_alloc_cache(struct nl_handle *);
00045 
00046 extern void             rtnl_route_get(struct rtnl_route *);
00047 extern void             rtnl_route_put(struct rtnl_route *);
00048 
00049 extern struct nl_msg *rtnl_route_build_add_request(struct rtnl_route *, int);
00050 extern int rtnl_route_add(struct nl_handle *, struct rtnl_route *, int);
00051 extern struct nl_msg *rtnl_route_build_del_request(struct rtnl_route *, int);
00052 extern int rtnl_route_del(struct nl_handle *, struct rtnl_route *, int);
00053 
00054 extern void             rtnl_route_set_table(struct rtnl_route *, int);
00055 extern int              rtnl_route_get_table(struct rtnl_route *);
00056 extern void             rtnl_route_set_scope(struct rtnl_route *, int);
00057 extern int              rtnl_route_get_scope(struct rtnl_route *);
00058 extern void             rtnl_route_set_tos(struct rtnl_route *, int);
00059 extern int              rtnl_route_get_tos(struct rtnl_route *);
00060 extern void             rtnl_route_set_realms(struct rtnl_route *, realm_t);
00061 extern realm_t          rtnl_route_get_realms(struct rtnl_route *);
00062 extern void             rtnl_route_set_protocol(struct rtnl_route *, int);
00063 extern int              rtnl_route_get_protocol(struct rtnl_route *);
00064 extern void             rtnl_route_set_prio(struct rtnl_route *, int);
00065 extern int              rtnl_route_get_prio(struct rtnl_route *);
00066 extern void             rtnl_route_set_family(struct rtnl_route *, int);
00067 extern int              rtnl_route_get_family(struct rtnl_route *);
00068 extern void             rtnl_route_set_type(struct rtnl_route *, int);
00069 extern int              rtnl_route_get_type(struct rtnl_route *);
00070 extern void             rtnl_route_set_flags(struct rtnl_route *,
00071                                              unsigned int);
00072 extern void             rtnl_route_unset_flags(struct rtnl_route *,
00073                                                unsigned int);
00074 extern unsigned int     rtnl_route_get_flags(struct rtnl_route *);
00075 extern int              rtnl_route_set_metric(struct rtnl_route *, int,
00076                                               unsigned int);
00077 extern int              rtnl_route_unset_metric(struct rtnl_route *, int);
00078 extern unsigned int     rtnl_route_get_metric(struct rtnl_route *, int);
00079 extern int              rtnl_route_set_dst(struct rtnl_route *,
00080                                            struct nl_addr *);
00081 extern struct nl_addr * rtnl_route_get_dst(struct rtnl_route *);
00082 extern int              rtnl_route_set_src(struct rtnl_route *,
00083                                            struct nl_addr *);
00084 extern struct nl_addr * rtnl_route_get_src(struct rtnl_route *);
00085 extern int              rtnl_route_set_gateway(struct rtnl_route *,
00086                                                struct nl_addr *);
00087 extern struct nl_addr * rtnl_route_get_gateway(struct rtnl_route *);
00088 extern int              rtnl_route_set_pref_src(struct rtnl_route *,
00089                                                 struct nl_addr *);
00090 extern struct nl_addr * rtnl_route_get_pref_src(struct rtnl_route *);
00091 extern void             rtnl_route_set_oif(struct rtnl_route *, int);
00092 extern int              rtnl_route_get_oif(struct rtnl_route *);
00093 extern void             rtnl_route_set_iif(struct rtnl_route *, const char *);
00094 extern char *           rtnl_route_get_iif(struct rtnl_route *);
00095 extern int              rtnl_route_get_dst_len(struct rtnl_route *);
00096 extern int              rtnl_route_get_src_len(struct rtnl_route *);
00097 
00098 extern void             rtnl_route_add_nexthop(struct rtnl_route *,
00099                                                struct rtnl_nexthop *);
00100 extern void             rtnl_route_remove_nexthop(struct rtnl_nexthop *);
00101 extern struct nl_list_head *    rtnl_route_get_nexthops(struct rtnl_route *);
00102 extern void             rtnl_route_set_cacheinfo(struct rtnl_route *,
00103                                                  struct rtnl_rtcacheinfo *);
00104 extern uint32_t         rtnl_route_get_mp_algo(struct rtnl_route *);
00105 extern void             rtnl_route_set_mp_algo(struct rtnl_route *, uint32_t);
00106 
00107 extern char *           rtnl_route_table2str(int, char *, size_t);
00108 extern int              rtnl_route_str2table(const char *);
00109 extern int              rtnl_route_read_table_names(const char *);
00110 
00111 extern char *           rtnl_route_proto2str(int, char *, size_t);
00112 extern int              rtnl_route_str2proto(const char *);
00113 extern int              rtnl_route_read_protocol_names(const char *);
00114 
00115 extern char *           rtnl_route_metric2str(int, char *, size_t);
00116 extern int              rtnl_route_str2metric(const char *);
00117 
00118 extern char *           rtnl_route_nh_flags2str(int, char *, size_t);
00119 extern int              rtnl_route_nh_str2flags(const char *);
00120 
00121 #ifdef __cplusplus
00122 }
00123 #endif
00124 
00125 #endif