summaryrefslogtreecommitdiff
path: root/accel-pppd/ctrl/ipoe/ipoe.c
diff options
context:
space:
mode:
authorKozlov Dmitry <xeb@mail.ru>2013-06-11 15:48:11 +0400
committerKozlov Dmitry <xeb@mail.ru>2013-06-11 15:49:47 +0400
commitca0729a15bd271d9cb85c5e493e98d3b5b6f7fea (patch)
tree4934ee15cf18839713d92c497a9386627a9642ce /accel-pppd/ctrl/ipoe/ipoe.c
parentc4e0859d53d9626eb7be3805d3a796011eac1869 (diff)
parent33d1277b396622f58303c89930a3ca648efebfff (diff)
downloadaccel-ppp-xebd-ca0729a15bd271d9cb85c5e493e98d3b5b6f7fea.tar.gz
accel-ppp-xebd-ca0729a15bd271d9cb85c5e493e98d3b5b6f7fea.zip
Merge branch 'master' of ssh://git.code.sf.net/p/accel-ppp/code
Diffstat (limited to 'accel-pppd/ctrl/ipoe/ipoe.c')
-rw-r--r--accel-pppd/ctrl/ipoe/ipoe.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c
index 18965d8..3e3a3e8 100644
--- a/accel-pppd/ctrl/ipoe/ipoe.c
+++ b/accel-pppd/ctrl/ipoe/ipoe.c
@@ -50,6 +50,8 @@ static int conf_mode = 0;
static int conf_shared = 1;
static int conf_ifcfg = 1;
static int conf_nat = 0;
+static uint32_t conf_src;
+
//static int conf_dhcpv6;
static int conf_username;
static int conf_unit_cache;
@@ -531,6 +533,9 @@ static void __ipoe_session_start(struct ipoe_session *ses)
if (!ses->siaddr && ses->router != ses->yiaddr)
ses->siaddr = ses->router;
+ if (!ses->siaddr)
+ ses->siaddr = ses->serv->opt_src;
+
if (!ses->siaddr && ses->serv->dhcpv4_relay)
ses->siaddr = ses->serv->dhcpv4_relay->giaddr;
@@ -618,9 +623,9 @@ static void ipoe_ifcfg_add(struct ipoe_session *ses)
log_ppp_warn("ipoe: failed to add addess to interface '%s'\n", serv->ifname);
pthread_mutex_unlock(&serv->lock);
}
- if (iproute_add(serv->ifindex, ses->siaddr, ses->yiaddr))
+ if (iproute_add(serv->ifindex, ses->serv->opt_src ? ses->serv->opt_src : ses->router, ses->yiaddr))
log_ppp_warn("ipoe: failed to add route to interface '%s'\n", serv->ifname);
- } else if (iproute_add(serv->ifindex, ses->siaddr, ses->yiaddr))
+ } else if (iproute_add(serv->ifindex, ses->serv->opt_src ? ses->serv->opt_src : ses->router, ses->yiaddr))
log_ppp_warn("ipoe: failed to add route to interface '%s'\n", serv->ifname);
ses->ifcfg = 1;
@@ -1563,6 +1568,7 @@ static void add_interface(const char *ifname, int ifindex, const char *opt)
const char *opt_giaddr = NULL;
in_addr_t relay_addr = 0;
in_addr_t giaddr = 0;
+ in_addr_t opt_src = conf_src;
str0 = strchr(opt, ',');
if (str0) {
@@ -1613,6 +1619,8 @@ static void add_interface(const char *ifname, int ifindex, const char *opt)
giaddr = inet_addr(ptr1);
} else if (strcmp(str, "nat") == 0) {
opt_nat = atoi(ptr1);
+ } else if (strcmp(str, "src") == 0) {
+ opt_src = inet_addr(ptr1);
}
if (end)
@@ -1669,6 +1677,7 @@ static void add_interface(const char *ifname, int ifindex, const char *opt)
serv->opt_mode = opt_mode;
serv->opt_ifcfg = opt_ifcfg;
serv->opt_nat = opt_nat;
+ serv->opt_src = opt_src;
if (str0)
_free(str0);
@@ -1687,6 +1696,7 @@ static void add_interface(const char *ifname, int ifindex, const char *opt)
serv->opt_mode = opt_mode;
serv->opt_ifcfg = opt_ifcfg;
serv->opt_nat = opt_nat;
+ serv->opt_src = opt_src;
serv->active = 1;
INIT_LIST_HEAD(&serv->sessions);
INIT_LIST_HEAD(&serv->addr_list);
@@ -2031,6 +2041,12 @@ static void load_config(void)
conf_nat = atoi(opt);
else
conf_nat = 0;
+
+ opt = conf_get_opt("ipoe", "src");
+ if (opt)
+ conf_src = inet_addr(opt);
+ else
+ conf_src = 0;
opt = conf_get_opt("ipoe", "mode");
if (opt) {