diff options
author | Kozlov Dmitry <xeb@mail.ru> | 2012-07-19 19:09:24 +0400 |
---|---|---|
committer | Kozlov Dmitry <xeb@mail.ru> | 2012-07-19 19:09:24 +0400 |
commit | a60d08c8ca66de1844a430cc487a725e4c0e0d54 (patch) | |
tree | 2c05a0acafefbfd22c2d8cc4093ae7ba6946b8c1 /accel-pppd/libnetlink | |
parent | 09b155588131d8ed6f380aec467d0fa7749933b8 (diff) | |
download | accel-ppp-a60d08c8ca66de1844a430cc487a725e4c0e0d54.tar.gz accel-ppp-a60d08c8ca66de1844a430cc487a725e4c0e0d54.zip |
ipoe: implemented L4-Redirect radius attribute
ipoe: implemented client address, router address and mask to be passed via radius
Diffstat (limited to 'accel-pppd/libnetlink')
-rw-r--r-- | accel-pppd/libnetlink/iplink.c | 72 | ||||
-rw-r--r-- | accel-pppd/libnetlink/iplink.h | 3 |
2 files changed, 75 insertions, 0 deletions
diff --git a/accel-pppd/libnetlink/iplink.c b/accel-pppd/libnetlink/iplink.c index 779a8aeb..4b85afe2 100644 --- a/accel-pppd/libnetlink/iplink.c +++ b/accel-pppd/libnetlink/iplink.c @@ -14,6 +14,7 @@ //#include <linux/if_link.h> //#include <linux/if_addr.h> //#include <linux/rtnetlink.h> +#include <linux/fib_rules.h> #include "triton.h" #include "log.h" @@ -294,6 +295,77 @@ int __export iproute_del(int ifindex, in_addr_t dst) return 0; } +int __export iprule_add(uint32_t addr, int table) +{ + struct ipaddr_req { + struct nlmsghdr n; + struct rtmsg i; + char buf[1024]; + } req; + + if (!rth) + open_rth(); + + if (!rth) + return -1; + + memset(&req, 0, sizeof(req) - 1024); + + req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg)); + req.n.nlmsg_flags = NLM_F_REQUEST; + req.n.nlmsg_type = RTM_NEWRULE; + req.i.rtm_family = AF_INET; + req.i.rtm_table = table < 256 ? table : RT_TABLE_UNSPEC; + req.i.rtm_scope = RT_SCOPE_UNIVERSE; + req.i.rtm_protocol = RTPROT_BOOT; + req.i.rtm_type = RTN_UNICAST; + req.i.rtm_src_len = 32; + + addattr32(&req.n, sizeof(req), FRA_SRC, addr); + if (table >= 256) + addattr32(&req.n, sizeof(req), FRA_TABLE, table); + + if (rtnl_talk(rth, &req.n, 0, 0, NULL, NULL, NULL, 0) < 0) + return -1; + + return 0; +} + +int __export iprule_del(uint32_t addr, int table) +{ + struct ipaddr_req { + struct nlmsghdr n; + struct rtmsg i; + char buf[1024]; + } req; + + if (!rth) + open_rth(); + + if (!rth) + return -1; + + memset(&req, 0, sizeof(req) - 1024); + + req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg)); + req.n.nlmsg_flags = NLM_F_REQUEST; + req.n.nlmsg_type = RTM_DELRULE; + req.i.rtm_family = AF_INET; + req.i.rtm_table = table < 256 ? table : RT_TABLE_UNSPEC; + req.i.rtm_scope = RT_SCOPE_UNIVERSE; + req.i.rtm_protocol = RTPROT_BOOT; + req.i.rtm_type = RTN_UNICAST; + req.i.rtm_src_len = 32; + + addattr32(&req.n, sizeof(req), FRA_SRC, addr); + if (table >= 256) + addattr32(&req.n, sizeof(req), FRA_TABLE, table); + + if (rtnl_talk(rth, &req.n, 0, 0, NULL, NULL, NULL, 0) < 0) + return -1; + + return 0; +} static void init(void) diff --git a/accel-pppd/libnetlink/iplink.h b/accel-pppd/libnetlink/iplink.h index a6af6627..f9124343 100644 --- a/accel-pppd/libnetlink/iplink.h +++ b/accel-pppd/libnetlink/iplink.h @@ -13,4 +13,7 @@ int ipaddr_del(int ifindex, in_addr_t addr); int iproute_add(int ifindex, in_addr_t src, in_addr_t dst); int iproute_del(int ifindex, in_addr_t dst); + +int iprule_add(uint32_t addr, int table); +int iprule_del(uint32_t addr, int table); #endif |