diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2013-10-30 16:00:45 +0400 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2013-10-30 16:00:45 +0400 |
commit | 68b7256c31e4efcb613854d73571edcca13fcd6e (patch) | |
tree | eb06b79d7578fd794fa9b730323ca937b8a1b85d /accel-pppd/ctrl | |
parent | 7499d96d719042e4b8a89dbbacf2fa9138d700cc (diff) | |
parent | f1adc930c84f02ff845dce3013c05bc027a8bda4 (diff) | |
download | accel-ppp-xebd-68b7256c31e4efcb613854d73571edcca13fcd6e.tar.gz accel-ppp-xebd-68b7256c31e4efcb613854d73571edcca13fcd6e.zip |
Merge branch 'master' of ssh://git.code.sf.net/p/accel-ppp/code
Diffstat (limited to 'accel-pppd/ctrl')
-rw-r--r-- | accel-pppd/ctrl/ipoe/ipoe.c | 38 | ||||
-rw-r--r-- | accel-pppd/ctrl/l2tp/l2tp.c | 12 |
2 files changed, 35 insertions, 15 deletions
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index 8ec4980..d9d71de 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.c +++ b/accel-pppd/ctrl/ipoe/ipoe.c @@ -132,6 +132,7 @@ static int conf_verbose; static const char *conf_agent_remote_id; static int conf_proto; static LIST_HEAD(conf_offer_delay); +static const char *conf_vlan_name; static unsigned int stat_starting; static unsigned int stat_active; @@ -1846,6 +1847,32 @@ static int get_offer_delay() return 0; } +static int make_vlan_name(const char *parent, int vid, char *name) +{ + char *ptr1 = name, *endptr = name + IFNAMSIZ - 1; + const char *ptr2 = conf_vlan_name; + char num[5], *ptr3 = num; + + sprintf(num, "%i", vid); + + while (ptr1 < endptr && *ptr2) { + if (ptr2[0] == '%' && ptr2[1] == 'I') { + while (ptr1 < endptr && *parent) + *ptr1++ = *parent++; + ptr2 += 2; + } else if (ptr2[0] == '%' && ptr2[1] == 'N') { + while (ptr1 < endptr && *ptr3) + *ptr1++ = *ptr3++; + ptr2 += 2; + } else + *ptr1++ = *ptr2++; + } + + *ptr1 = 0; + + return ptr1 == endptr; +} + void ipoe_vlan_notify(int ifindex, int vid) { struct conf_sect_t *sect = conf_get_section("ipoe"); @@ -1857,6 +1884,7 @@ void ipoe_vlan_notify(int ifindex, int vid) const char *pcre_err; char *pattern; int pcre_offset; + char ifname[IFNAMSIZ]; if (!sect) return; @@ -1868,12 +1896,12 @@ void ipoe_vlan_notify(int ifindex, int vid) return; } - if (strlen(ifr.ifr_name) + 5 >= sizeof(ifr.ifr_name)) { + if (make_vlan_name(ifr.ifr_name, vid, ifname)) { log_error("ipoe: vlan-mon: %s.%i: interface name is too long\n", ifr.ifr_name, vid); return; } - - sprintf(ifr.ifr_name + strlen(ifr.ifr_name), ".%i", vid); + + strcpy(ifr.ifr_name, ifname); len = strlen(ifr.ifr_name); log_info2("ipoe: create vlan %s\n", ifr.ifr_name); @@ -2857,6 +2885,10 @@ static void load_config(void) conf_offer_timeout = 10; conf_ip_pool = conf_get_opt("ipoe", "ip-pool"); + + conf_vlan_name = conf_get_opt("ipoe", "vlan-name"); + if (!conf_vlan_name) + conf_vlan_name = "%I.%N"; #ifdef RADIUS if (triton_module_loaded("radius")) diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c index e14bab8..3b2e3f2 100644 --- a/accel-pppd/ctrl/l2tp/l2tp.c +++ b/accel-pppd/ctrl/l2tp/l2tp.c @@ -1822,12 +1822,6 @@ static int l2tp_send_ICCN(struct l2tp_sess_t *sess) return -1; } - if (l2tp_packet_add_int16(pack, Assigned_Session_ID, - sess->sid, 1) < 0) { - log_session(log_error, sess, "impossible to send ICCN:" - " adding data to packet failed\n"); - goto out_err; - } if (l2tp_packet_add_int32(pack, TX_Speed, 1000, 1) < 0) { log_session(log_error, sess, "impossible to send ICCN:" " adding data to packet failed\n"); @@ -3786,12 +3780,6 @@ static int l2tp_create_tunnel_exec(const char *cmd, char * const *fields, return CLI_CMD_SYNTAX; } - if (iprange_client_check(peer.sin_addr.s_addr) < 0) { - cli_sendv(client, "peer address %s out of IP range\r\n", - fields[peer_indx]); - return CLI_CMD_INVAL; - } - conn = l2tp_tunnel_alloc(&peer, &host, 3, lns_mode, 0, hide_avps); if (conn == NULL) { cli_send(client, "tunnel allocation failed\r\n"); |