summaryrefslogtreecommitdiff
path: root/accel-pppd/ctrl/ipoe
diff options
context:
space:
mode:
authorKozlov Dmitry <xeb@mail.ru>2013-06-04 15:37:57 +0400
committerKozlov Dmitry <xeb@mail.ru>2013-06-04 15:37:57 +0400
commit45156b684e0bd404215183d1368ad8694f29075e (patch)
tree28b2cb7abdebf9f1763968ddf0820647b894b2b2 /accel-pppd/ctrl/ipoe
parentb267b9c39ed7177b466db6c8b5b3f8c3dc6d7758 (diff)
parentcf27bf49df5243237acb15389fb5544f5a863685 (diff)
downloadaccel-ppp-45156b684e0bd404215183d1368ad8694f29075e.tar.gz
accel-ppp-45156b684e0bd404215183d1368ad8694f29075e.zip
Merge branch 'master' of ssh://git.code.sf.net/p/accel-ppp/code
Diffstat (limited to 'accel-pppd/ctrl/ipoe')
-rw-r--r--accel-pppd/ctrl/ipoe/ipoe.c35
-rw-r--r--accel-pppd/ctrl/ipoe/ipoe.h1
2 files changed, 25 insertions, 11 deletions
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c
index 4c3c585..a2991f4 100644
--- a/accel-pppd/ctrl/ipoe/ipoe.c
+++ b/accel-pppd/ctrl/ipoe/ipoe.c
@@ -49,6 +49,7 @@ static int conf_up = 0;
static int conf_mode = 0;
static int conf_shared = 1;
static int conf_ifcfg = 1;
+static int conf_nat = 0;
//static int conf_dhcpv6;
static int conf_username;
static int conf_unit_cache;
@@ -372,8 +373,9 @@ static void ipoe_session_start(struct ipoe_session *ses)
return;
}
}
-
- ses->ses.ipv4 = ipdb_get_ipv4(&ses->ses);
+
+ if (ses->serv->opt_nat)
+ ses->ses.ipv4 = ipdb_get_ipv4(&ses->ses);
if (ses->serv->opt_shared == 0 && (!ses->ses.ipv4 || ses->ses.ipv4->peer_addr == ses->yiaddr)) {
strncpy(ses->ses.ifname, ses->serv->ifname, AP_IFNAME_LEN);
@@ -432,14 +434,18 @@ static void __ipoe_session_start(struct ipoe_session *ses)
ses->dhcp_addr = 1;
}
+ if (!ses->yiaddr && !ses->serv->opt_nat)
+ ses->ses.ipv4 = ipdb_get_ipv4(&ses->ses);
+
+ if (!ses->mask)
+ ses->mask = conf_netmask;
+
if (ses->ses.ipv4) {
if (conf_gw_address)
ses->ses.ipv4->addr = conf_gw_address;
- if (conf_netmask)
- ses->ses.ipv4->mask = conf_netmask;
- else if (!ses->ses.ipv4->mask)
- ses->ses.ipv4->mask = 24;
+ if (!ses->mask)
+ ses->mask = ses->ses.ipv4->mask;
if (!ses->yiaddr)
ses->yiaddr = ses->ses.ipv4->peer_addr;
@@ -550,7 +556,7 @@ static void ipoe_ifcfg_add(struct ipoe_session *ses)
}
if (iproute_add(serv->ifindex, ses->siaddr, ses->yiaddr))
log_ppp_warn("ipoe: failed to add route to interface '%s'\n", serv->ifname);
- } else if (iproute_add(serv->ifindex, 0, ses->yiaddr))
+ } else if (iproute_add(serv->ifindex, ses->siaddr, ses->yiaddr))
log_ppp_warn("ipoe: failed to add route to interface '%s'\n", serv->ifname);
ses->ifcfg = 1;
@@ -564,9 +570,6 @@ static void ipoe_ifcfg_del(struct ipoe_session *ses)
log_ppp_warn("ipoe: failed to delete route from interface '%s'\n", serv->ifname);
if (ses->serv->opt_ifcfg) {
- if (iproute_del(serv->ifindex, ses->yiaddr))
- log_ppp_warn("ipoe: failed to delete route from interface '%s'\n", serv->ifname);
-
if (ses->serv->opt_shared) {
ipoe_serv_del_addr(ses->serv, ses->siaddr);
} else {
@@ -1414,6 +1417,7 @@ static void add_interface(const char *ifname, int ifindex, const char *opt)
int opt_up = 0;
int opt_mode = conf_mode;
int opt_ifcfg = conf_ifcfg;
+ int opt_nat = conf_nat;
const char *opt_relay = conf_relay;
const char *opt_giaddr = NULL;
in_addr_t relay_addr = 0;
@@ -1466,6 +1470,8 @@ static void add_interface(const char *ifname, int ifindex, const char *opt)
} else if (strcmp(str, "giaddr") == 0) {
opt_giaddr = ptr1;
giaddr = inet_addr(ptr1);
+ } else if (strcmp(str, "nat") == 0) {
+ opt_nat = atoi(ptr1);
}
if (end)
@@ -1521,7 +1527,7 @@ static void add_interface(const char *ifname, int ifindex, const char *opt)
serv->opt_up = opt_up;
serv->opt_mode = opt_mode;
serv->opt_ifcfg = opt_ifcfg;
-
+ serv->opt_nat = opt_nat;
if (str0)
_free(str0);
@@ -1539,6 +1545,7 @@ static void add_interface(const char *ifname, int ifindex, const char *opt)
serv->opt_up = opt_up;
serv->opt_mode = opt_mode;
serv->opt_ifcfg = opt_ifcfg;
+ serv->opt_nat = opt_nat;
serv->active = 1;
INIT_LIST_HEAD(&serv->sessions);
INIT_LIST_HEAD(&serv->addr_list);
@@ -1844,6 +1851,12 @@ static void load_config(void)
else
conf_ifcfg = 1;
+ opt = conf_get_opt("ipoe", "nat");
+ if (opt)
+ conf_nat = atoi(opt);
+ else
+ conf_nat = 0;
+
opt = conf_get_opt("ipoe", "mode");
if (opt) {
if (!strcmp(opt, "L2"))
diff --git a/accel-pppd/ctrl/ipoe/ipoe.h b/accel-pppd/ctrl/ipoe/ipoe.h
index 96920a3..034092e 100644
--- a/accel-pppd/ctrl/ipoe/ipoe.h
+++ b/accel-pppd/ctrl/ipoe/ipoe.h
@@ -26,6 +26,7 @@ struct ipoe_serv
int opt_dhcpv4:1;
int opt_up:1;
int opt_ifcfg:1;
+ int opt_nat:1;
int need_close:1;
};