summaryrefslogtreecommitdiff
path: root/accel-pppd/ctrl
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2014-11-22 08:56:40 +0300
committerDmitry Kozlov <xeb@mail.ru>2014-11-22 08:56:40 +0300
commit81ca3923a29ea9b67f7291be23b210019546aa5f (patch)
treefcebf0d426665b4f06e01168f27cd8f9ab8c50d8 /accel-pppd/ctrl
parent830c399cf126f6bf1e8dfa1ad919a3ce8e346c5d (diff)
downloadaccel-ppp-81ca3923a29ea9b67f7291be23b210019546aa5f.tar.gz
accel-ppp-81ca3923a29ea9b67f7291be23b210019546aa5f.zip
remove trailing whitespaces
Diffstat (limited to 'accel-pppd/ctrl')
-rw-r--r--accel-pppd/ctrl/ipoe/arp.c2
-rw-r--r--accel-pppd/ctrl/ipoe/backup.c22
-rw-r--r--accel-pppd/ctrl/ipoe/dhcpv4.c110
-rw-r--r--accel-pppd/ctrl/ipoe/dhcpv4.h2
-rw-r--r--accel-pppd/ctrl/ipoe/dhcpv4_options.c8
-rw-r--r--accel-pppd/ctrl/ipoe/ipoe.c452
-rw-r--r--accel-pppd/ctrl/ipoe/ipoe_netlink.c52
-rw-r--r--accel-pppd/ctrl/ipoe/lua.c18
-rw-r--r--accel-pppd/ctrl/ipoe/lua_lpack.c4
-rw-r--r--accel-pppd/ctrl/l2tp/dict.c12
-rw-r--r--accel-pppd/ctrl/l2tp/l2tp.c4
-rw-r--r--accel-pppd/ctrl/l2tp/netlink.c14
-rw-r--r--accel-pppd/ctrl/l2tp/packet.c8
-rw-r--r--accel-pppd/ctrl/pppoe/cli.c30
-rw-r--r--accel-pppd/ctrl/pppoe/dpado.c6
-rw-r--r--accel-pppd/ctrl/pppoe/mac_filter.c4
-rw-r--r--accel-pppd/ctrl/pppoe/pppoe.c104
-rw-r--r--accel-pppd/ctrl/pptp/pptp.c30
18 files changed, 441 insertions, 441 deletions
diff --git a/accel-pppd/ctrl/ipoe/arp.c b/accel-pppd/ctrl/ipoe/arp.c
index 10ea138..ebf05c7 100644
--- a/accel-pppd/ctrl/ipoe/arp.c
+++ b/accel-pppd/ctrl/ipoe/arp.c
@@ -50,7 +50,7 @@ static int arp_read(struct triton_md_handler_t *h)
dst.sll_family = AF_PACKET;
dst.sll_ifindex = s->ipoe->ifindex;
dst.sll_protocol = htons(ETH_P_ARP);
-
+
ah2.ar_hrd = htons(ARPHRD_ETHER);
ah2.ar_pro = htons(ETH_P_IP);
ah2.ar_hln = ETH_ALEN;
diff --git a/accel-pppd/ctrl/ipoe/backup.c b/accel-pppd/ctrl/ipoe/backup.c
index 9633bf7..b272731 100644
--- a/accel-pppd/ctrl/ipoe/backup.c
+++ b/accel-pppd/ctrl/ipoe/backup.c
@@ -51,16 +51,16 @@ static int session_save(struct ap_session *ses, struct backup_mod *m)
if (conn->ifcfg)
flags |= IPOE_FLAG_IFCFG;
-
+
if (conn->dhcp_addr)
flags |= IPOE_FLAG_DHCP_ADDR;
-
+
if (conn->relay_addr)
flags |= IPOE_FLAG_RELAY_ADDR;
-
+
if (conn->l4_redirect)
flags |= IPOE_FLAG_L4_REDIR;
-
+
if (conn->l4_redirect_set)
flags |= IPOE_FLAG_L4_REDIR_SET;
@@ -82,7 +82,7 @@ static int session_save(struct ap_session *ses, struct backup_mod *m)
if (conn->relay_agent)
add_tag(IPOE_TAG_RELAY_AGENT, conn->relay_agent->data, conn->relay_agent->len);
-
+
add_tag_i(IPOE_TAG_IFINDEX, &conn->ifindex, 4);
return 0;
@@ -98,7 +98,7 @@ static int session_restore(struct ap_session *ses, struct backup_mod *m)
static void set_dhcpv4_opt(struct dhcpv4_option **opt, struct backup_tag *t, uint8_t **ptr)
{
- *opt = (struct dhcpv4_option *)(*ptr);
+ *opt = (struct dhcpv4_option *)(*ptr);
(*opt)->len = t->size;
memcpy((*opt)->data, t->data, t->size);
(*ptr) += sizeof(**opt) + t->size;
@@ -200,23 +200,23 @@ static struct ap_session *ctrl_restore(struct backup_mod *m)
if (flags & IPOE_FLAG_IFCFG)
ses->ifcfg = 1;
-
+
if (flags & IPOE_FLAG_DHCP_ADDR) {
dhcpv4_reserve_ip(ses->serv->dhcpv4, ses->yiaddr);
ses->dhcp_addr = 1;
}
-
+
if (flags & IPOE_FLAG_RELAY_ADDR)
ses->relay_addr = 1;
-
+
if (flags & IPOE_FLAG_L4_REDIR)
ses->l4_redirect = 1;
-
+
if (flags & IPOE_FLAG_L4_REDIR_SET && m->data->internal)
ses->l4_redirect = 1;
ses->serv = serv;
-
+
triton_context_register(&ses->ctx, &ses->ses);
triton_context_wakeup(&ses->ctx);
diff --git a/accel-pppd/ctrl/ipoe/dhcpv4.c b/accel-pppd/ctrl/ipoe/dhcpv4.c
index 936b50e..18dea80 100644
--- a/accel-pppd/ctrl/ipoe/dhcpv4.c
+++ b/accel-pppd/ctrl/ipoe/dhcpv4.c
@@ -57,10 +57,10 @@ static int open_raw_sock(void)
log_error("dhcpv4: socket(AF_PACKET, SOCK_RAW): %s\n", strerror(errno));
return -1;
}
-
+
fcntl(raw_sock, F_SETFL, O_NONBLOCK);
fcntl(raw_sock, F_SETFD, fcntl(raw_sock, F_GETFD) | FD_CLOEXEC);
-
+
pthread_setspecific(raw_sock_key, (void *)(long)raw_sock);
}
@@ -78,7 +78,7 @@ static struct dhcpv4_iprange *parse_range(const char *str)
struct dhcpv4_iprange *r;
n = sscanf(str, "%u.%u.%u.%u/%u", &f1, &f2, &f3, &f4, &m);
-
+
if (n != 5)
goto parse_err;
if (f1 > 255)
@@ -91,7 +91,7 @@ static struct dhcpv4_iprange *parse_range(const char *str)
goto parse_err;
if (m == 0 || m > 30)
goto parse_err;
-
+
start = (f1 << 24) | (f2 << 16) | (f3 << 8) | f4;
mask = ~((1 << (32 - m)) - 1);
start = start & mask;
@@ -145,10 +145,10 @@ struct dhcpv4_serv *dhcpv4_create(struct triton_context_t *ctx, const char *ifna
addr.sin_addr.s_addr = htonl(INADDR_ANY);
sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
-
+
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &f, sizeof(f)))
log_error("setsockopt(SO_REUSEADDR): %s\n", strerror(errno));
-
+
if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &f, sizeof(f))) {
log_error("setsockopt(SO_BROADCAST): %s\n", strerror(errno));
@@ -164,15 +164,15 @@ struct dhcpv4_serv *dhcpv4_create(struct triton_context_t *ctx, const char *ifna
log_error("setsockopt(SO_BINDTODEVICE): %s\n", strerror(errno));
goto out_err;
}
-
+
if (ioctl(sock, SIOCGIFHWADDR, &ifr)) {
log_error("dhcpv4(%s): ioctl(SIOCGIFHWADDR): %s\n", ifname, strerror(errno));
goto out_err;
}
-
+
fcntl(sock, F_SETFL, O_NONBLOCK);
fcntl(sock, F_SETFD, fcntl(sock, F_GETFD) | FD_CLOEXEC);
-
+
serv = _malloc(sizeof(*serv));
memset(serv, 0, sizeof(*serv));
@@ -186,13 +186,13 @@ struct dhcpv4_serv *dhcpv4_create(struct triton_context_t *ctx, const char *ifna
if (opt && *opt) {
str0 = _strdup(opt);
str = str0;
-
+
while (1) {
for (ptr1 = str + 1; *ptr1 && *ptr1 != '='; ptr1++);
if (!*ptr1)
break;
-
+
*ptr1 = 0;
for (ptr2 = ++ptr1; *ptr2 && *ptr2 != ','; ptr2++);
@@ -213,7 +213,7 @@ struct dhcpv4_serv *dhcpv4_create(struct triton_context_t *ctx, const char *ifna
str = ptr2 + 1;
}
-
+
_free(str0);
}
@@ -301,10 +301,10 @@ static int dhcpv4_parse_packet(struct dhcpv4_packet *pack, int len)
log_warn("dhcpv4: short packet received\n");
return -1;
}
-
+
if (pack->hdr->htype != 1)
return -1;
-
+
if (pack->hdr->hlen != 6)
return -1;
@@ -318,7 +318,7 @@ static int dhcpv4_parse_packet(struct dhcpv4_packet *pack, int len)
ptr++;
continue;
}
-
+
if (*ptr == 0xff) {
ptr++;
break;
@@ -357,9 +357,9 @@ static int dhcpv4_parse_packet(struct dhcpv4_packet *pack, int len)
if (dhcpv4_check_options(pack))
return -1;
-
+
pack->ptr = ptr;
-
+
/*if (conf_verbose) {
log_info2("recv ");
print_packet(pack, log_info2);
@@ -465,7 +465,7 @@ int dhcpv4_packet_insert_opt82(struct dhcpv4_packet *pack, const char *agent_cir
r = dhcpv4_packet_add_opt(pack, 82, data, 4 + len1 + len2);
_free(data);
-
+
*pack->ptr++ = 255;
return r;
@@ -500,7 +500,7 @@ static int dhcpv4_read(struct triton_md_handler_t *h)
dhcpv4_packet_free(pack);
continue;
}
-
+
if (pack->hdr->op != DHCP_OP_REQUEST) {
dhcpv4_packet_free(pack);
continue;
@@ -510,7 +510,7 @@ static int dhcpv4_read(struct triton_md_handler_t *h)
if (serv->recv)
serv->recv(serv, pack);
-
+
dhcpv4_packet_free(pack);
}
}
@@ -542,7 +542,7 @@ static int dhcpv4_relay_read(struct triton_md_handler_t *h)
dhcpv4_packet_free(pack);
continue;
}
-
+
if (pack->hdr->op != DHCP_OP_REPLY) {
dhcpv4_packet_free(pack);
continue;
@@ -564,17 +564,17 @@ uint16_t ip_csum(uint16_t *buf, int len)
{
uint32_t sum=0;
int i;
-
+
for (i=0; i < len; i += 2)
sum += *buf++;
-
+
// take only 16 bits out of the 32 bit sum and add up the carries
while (sum >> 16)
sum = (sum & 0xffff) + (sum >> 16);
// one's complement the result
sum = ~sum;
-
+
return sum & 0xffff;
}
@@ -591,7 +591,7 @@ static int dhcpv4_send_raw(struct dhcpv4_serv *serv, struct dhcpv4_packet *pack,
struct sockaddr_ll ll_addr;
struct msghdr msg;
int sock = open_raw_sock();
-
+
memset(&ll_addr, 0, sizeof(ll_addr));
ll_addr.sll_family = AF_PACKET;
ll_addr.sll_ifindex = serv->ifindex;
@@ -638,7 +638,7 @@ static int dhcpv4_send_raw(struct dhcpv4_serv *serv, struct dhcpv4_packet *pack,
printf("%i %i\n", errno, serv->ifindex);
return -1;
}
-
+
return 0;
}
@@ -656,7 +656,7 @@ static int dhcpv4_send_udp(struct dhcpv4_serv *serv, struct dhcpv4_packet *pack,
n = sendto(serv->hnd.fd, pack->data, len, 0, (struct sockaddr *)&addr, sizeof(addr));
if (n != len)
return -1;
-
+
return 0;
}
@@ -674,7 +674,7 @@ int dhcpv4_packet_add_opt(struct dhcpv4_packet *pack, int type, const void *data
opt->type = type;
opt->len = len;
- opt->data = pack->ptr;
+ opt->data = pack->ptr;
pack->ptr += len;
memcpy(opt->data, data, len);
@@ -697,7 +697,7 @@ int dhcpv4_send_reply(int msg_type, struct dhcpv4_serv *serv, struct dhcpv4_pack
} dns;
int dns_avail = 0;
struct dhcpv4_option *opt;
-
+
pack = dhcpv4_packet_alloc();
if (!pack) {
log_emerg("out of memory\n");
@@ -717,17 +717,17 @@ int dhcpv4_send_reply(int msg_type, struct dhcpv4_serv *serv, struct dhcpv4_pack
if (dhcpv4_packet_add_opt(pack, 53, &msg_type, 1))
goto out_err;
-
+
if (dhcpv4_packet_add_opt(pack, 54, &siaddr, 4))
goto out_err;
-
+
val = ntohl(lease_time);
if (dhcpv4_packet_add_opt(pack, 51, &val, 4))
goto out_err;
if (router && dhcpv4_packet_add_opt(pack, 3, &router, 4))
goto out_err;
-
+
val = htonl(~((1 << (32 - mask)) - 1));
if (dhcpv4_packet_add_opt(pack, 1, &val, 4))
goto out_err;
@@ -742,7 +742,7 @@ int dhcpv4_send_reply(int msg_type, struct dhcpv4_serv *serv, struct dhcpv4_pack
goto out_err;
}
}
-
+
if (!dns_avail) {
if (conf_dns1 && conf_dns2) {
dns.dns1 = conf_dns1;
@@ -783,7 +783,7 @@ int dhcpv4_send_nak(struct dhcpv4_serv *serv, struct dhcpv4_packet *req)
{
struct dhcpv4_packet *pack;
int val, r;
-
+
pack = dhcpv4_packet_alloc();
if (!pack) {
log_emerg("out of memory\n");
@@ -801,7 +801,7 @@ int dhcpv4_send_nak(struct dhcpv4_serv *serv, struct dhcpv4_packet *req)
val = DHCPNAK;
if (dhcpv4_packet_add_opt(pack, 53, &val, 1))
goto out_err;
-
+
*pack->ptr++ = 255;
if (conf_verbose) {
@@ -837,7 +837,7 @@ struct dhcpv4_relay *dhcpv4_relay_create(const char *_addr, in_addr_t giaddr, st
int sock = -1;
int f = 1;
struct dhcpv4_relay_ctx *c;
-
+
ptr = strchr(_addr, ':');
if (ptr) {
memcpy(str, _addr, ptr - _addr);
@@ -846,7 +846,7 @@ struct dhcpv4_relay *dhcpv4_relay_create(const char *_addr, in_addr_t giaddr, st
port = atoi(ptr + 1);
} else
addr = inet_addr(_addr);
-
+
memset(&raddr, 0, sizeof(raddr));
raddr.sin_family = AF_INET;
raddr.sin_addr.s_addr = addr;
@@ -862,7 +862,7 @@ struct dhcpv4_relay *dhcpv4_relay_create(const char *_addr, in_addr_t giaddr, st
if (r->addr == addr && r->giaddr == giaddr)
goto found;
}
-
+
r = _malloc(sizeof(*r));
memset(r, 0, sizeof(*r));
INIT_LIST_HEAD(&r->ctx_list);
@@ -877,7 +877,7 @@ struct dhcpv4_relay *dhcpv4_relay_create(const char *_addr, in_addr_t giaddr, st
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &f, sizeof(f)))
log_error("dhcpv4: setsockopt(SO_REUSEADDR): %s\n", strerror(errno));
-
+
if (bind(sock, &laddr, sizeof(laddr))) {
log_error("dhcpv4: relay: %s: bind: %s\n", _addr, strerror(errno));
goto out_err_unlock;
@@ -887,7 +887,7 @@ struct dhcpv4_relay *dhcpv4_relay_create(const char *_addr, in_addr_t giaddr, st
log_error("dhcpv4: relay: %s: connect: %s\n", _addr, strerror(errno));
goto out_err_unlock;
}
-
+
fcntl(sock, F_SETFL, O_NONBLOCK);
fcntl(sock, F_SETFD, fcntl(sock, F_GETFD) | FD_CLOEXEC);
@@ -908,7 +908,7 @@ found:
c->ctx = ctx;
c->recv = recv;
list_add_tail(&c->entry, &r->ctx_list);
-
+
pthread_mutex_unlock(&relay_lock);
return r;
@@ -965,11 +965,11 @@ int dhcpv4_relay_send(struct dhcpv4_relay *relay, struct dhcpv4_packet *request,
if (server_id) {
opt = dhcpv4_packet_find_opt(request, 54);
if (opt) {
- _server_id = *(uint32_t *)opt->data;
+ _server_id = *(uint32_t *)opt->data;
*(uint32_t *)opt->data = server_id;
}
}
-
+
if (conf_verbose) {
log_ppp_info2("send ");
dhcpv4_print_packet(request, 1, log_ppp_info2);
@@ -982,10 +982,10 @@ int dhcpv4_relay_send(struct dhcpv4_relay *relay, struct dhcpv4_packet *request,
if (opt)
*(uint32_t *)opt->data = _server_id;
-
+
if (n != len)
return -1;
-
+
return 0;
}
@@ -1019,7 +1019,7 @@ int dhcpv4_relay_send_release(struct dhcpv4_relay *relay, uint8_t *chaddr, uint3
if (client_id && dhcpv4_packet_add_opt(pack, 61, client_id->data, client_id->len))
goto out_err;
-
+
if (relay_agent && dhcpv4_packet_add_opt(pack, 82, relay_agent->data, relay_agent->len))
goto out_err;
else if (!relay_agent) {
@@ -1028,18 +1028,18 @@ int dhcpv4_relay_send_release(struct dhcpv4_relay *relay, uint8_t *chaddr, uint3
goto out_err;
pack->ptr--;
}
-
+
*pack->ptr++ = 255;
len = pack->ptr - pack->data;
-
+
if (conf_verbose) {
log_ppp_info2("send ");
dhcpv4_print_packet(pack, 1, log_ppp_info2);
}
n = write(relay->hnd.fd, pack->data, len);
-
+
dhcpv4_packet_free(pack);
return n == len ? 0 : -1;
@@ -1055,7 +1055,7 @@ int dhcpv4_get_ip(struct dhcpv4_serv *serv, uint32_t *yiaddr, uint32_t *siaddr,
if (!serv->range)
return 0;
-
+
pthread_mutex_lock(&serv->range->lock);
while (1) {
@@ -1074,7 +1074,7 @@ int dhcpv4_get_ip(struct dhcpv4_serv *serv, uint32_t *yiaddr, uint32_t *siaddr,
if (serv->range->pos == 0)
break;
-
+
serv->range->pos = 0;
}
@@ -1097,7 +1097,7 @@ void dhcpv4_put_ip(struct dhcpv4_serv *serv, uint32_t ip)
void dhcpv4_reserve_ip(struct dhcpv4_serv *serv, uint32_t ip)
{
int n = ntohl(ip) - serv->range->startip;
-
+
if (n <= 0 || n / (8 * sizeof(long)) >= serv->range->len)
return;
@@ -1108,7 +1108,7 @@ void dhcpv4_reserve_ip(struct dhcpv4_serv *serv, uint32_t ip)
static void load_config()
{
- const char *opt;
+ const char *opt;
opt = conf_get_opt("ipoe", "verbose");
if (opt)
@@ -1117,7 +1117,7 @@ static void load_config()
opt = conf_get_opt("dns", "dns1");
if (opt)
conf_dns1 = inet_addr(opt);
-
+
opt = conf_get_opt("dns", "dns2");
if (opt)
conf_dns2 = inet_addr(opt);
@@ -1127,7 +1127,7 @@ static void init()
{
pack_pool = mempool_create(BUF_SIZE + sizeof(struct dhcpv4_packet));
opt_pool = mempool_create(sizeof(struct dhcpv4_option));
-
+
pthread_key_create(&raw_sock_key, close_raw_sock);
load_config();
diff --git a/accel-pppd/ctrl/ipoe/dhcpv4.h b/accel-pppd/ctrl/ipoe/dhcpv4.h
index 15db8ed..163c084 100644
--- a/accel-pppd/ctrl/ipoe/dhcpv4.h
+++ b/accel-pppd/ctrl/ipoe/dhcpv4.h
@@ -80,7 +80,7 @@ struct dhcpv4_iprange {
int len;
pthread_mutex_t lock;
unsigned long free[0];
-};
+};
struct dhcpv4_serv {
struct triton_context_t *ctx;
diff --git a/accel-pppd/ctrl/ipoe/dhcpv4_options.c b/accel-pppd/ctrl/ipoe/dhcpv4_options.c
index f233e7c..b5f2b3b 100644
--- a/accel-pppd/ctrl/ipoe/dhcpv4_options.c
+++ b/accel-pppd/ctrl/ipoe/dhcpv4_options.c
@@ -131,7 +131,7 @@ static void print_ip(const struct dhcpv4_option *opt, int elem_size, void (*prin
{
int i, n = opt->len / elem_size;
uint32_t ip;
-
+
for (i = 0; i < n; i++) {
ip = ntohl(*(uint32_t *)(opt->data + i*elem_size));
@@ -172,10 +172,10 @@ static void print_route(const struct dhcpv4_option *opt, int elem_size, void (*p
for (i = 0; i < n; i++) {
ip = ntohl(*(uint32_t *)(opt->data + i*8));
gw = ntohl(*(uint32_t *)(opt->data + i*8 + 4));
-
+
if (i)
print(",");
-
+
print("%i.%i.%i.%i via %i.%i.%i.%i",
(ip >> 24) & 0xff,
(ip >> 16) & 0xff,
@@ -275,7 +275,7 @@ static void print_classless_route(const struct dhcpv4_option *opt, int elem_size
ptr += 4;
gw = ntohl(*(uint32_t *)ptr);
ptr += 4;
-
+
print("%i.%i.%i.%i/%i via %i.%i.%i.%i",
(ip >> 24) & 0xff,
(ip >> 16) & 0xff,
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c
index cdb8fb0..cca2096 100644
--- a/accel-pppd/ctrl/ipoe/ipoe.c
+++ b/accel-pppd/ctrl/ipoe/ipoe.c
@@ -186,7 +186,7 @@ static int ipoe_rad_send_request(struct rad_plugin_t *rad, struct rad_packet_t *
static struct ipoe_session *ipoe_session_lookup(struct ipoe_serv *serv, struct dhcpv4_packet *pack, struct ipoe_session **opt82_ses)
{
struct ipoe_session *ses, *res = NULL;
-
+
uint8_t *agent_circuit_id = NULL;
uint8_t *agent_remote_id = NULL;
int opt82_match;
@@ -201,27 +201,27 @@ static struct ipoe_session *ipoe_session_lookup(struct ipoe_serv *serv, struct d
list_for_each_entry(ses, &serv->sessions, entry) {
opt82_match = pack->relay_agent != NULL;
-
+
if (agent_circuit_id && !ses->agent_circuit_id)
opt82_match = 0;
-
+
if (opt82_match && agent_remote_id && !ses->agent_remote_id)
opt82_match = 0;
-
+
if (opt82_match && !agent_circuit_id && ses->agent_circuit_id)
opt82_match = 0;
-
+
if (opt82_match && !agent_remote_id && ses->agent_remote_id)
opt82_match = 0;
-
+
if (opt82_match && agent_circuit_id) {
if (*agent_circuit_id != *ses->agent_circuit_id)
opt82_match = 0;
-
+
if (memcmp(agent_circuit_id + 1, ses->agent_circuit_id + 1, *agent_circuit_id))
opt82_match = 0;
}
-
+
if (opt82_match && agent_remote_id) {
if (*agent_remote_id != *ses->agent_remote_id)
opt82_match = 0;
@@ -232,19 +232,19 @@ static struct ipoe_session *ipoe_session_lookup(struct ipoe_serv *serv, struct d
if (opt82_match && opt82_ses)
*opt82_ses = ses;
-
+
if (memcmp(pack->hdr->chaddr, ses->hwaddr, ETH_ALEN))
continue;
-
+
res = ses;
break;
-
+
/*if (pack->client_id && !ses->client_id)
continue;
-
+
if (!pack->client_id && ses->client_id)
continue;
-
+
if (pack->client_id) {
if (pack->client_id->len != ses->client_id->len)
continue;
@@ -262,28 +262,28 @@ static struct ipoe_session *ipoe_session_lookup(struct ipoe_serv *serv, struct d
if (!res || !pack->relay_agent || !opt82_ses || *opt82_ses)
return res;
-
+
list_for_each_entry(ses, &serv->sessions, entry) {
if (agent_circuit_id && !ses->agent_circuit_id)
continue;
-
+
if (opt82_match && agent_remote_id && !ses->agent_remote_id)
continue;
-
+
if (opt82_match && !agent_circuit_id && ses->agent_circuit_id)
continue;
-
+
if (opt82_match && !agent_remote_id && ses->agent_remote_id)
continue;
-
+
if (opt82_match && agent_circuit_id) {
if (*agent_circuit_id != *ses->agent_circuit_id)
continue;
-
+
if (memcmp(agent_circuit_id + 1, ses->agent_circuit_id + 1, *agent_circuit_id))
continue;
}
-
+
if (opt82_match && agent_remote_id) {
if (*agent_remote_id != *ses->agent_remote_id)
continue;
@@ -295,7 +295,7 @@ static struct ipoe_session *ipoe_session_lookup(struct ipoe_serv *serv, struct d
*opt82_ses = ses;
break;
}
-
+
return res;
}
@@ -367,7 +367,7 @@ static void l4_redirect_list_add(in_addr_t addr)
memset(n, 0, sizeof(*n));
n->addr = addr;
n->timeout = ts.tv_sec + conf_l4_redirect_on_reject;
-
+
ipoe_nl_add_exclude(addr, 32);
if (conf_l4_redirect_table)
@@ -377,13 +377,13 @@ static void l4_redirect_list_add(in_addr_t addr)
ipset_add(conf_l4_redirect_ipset, addr);
pthread_rwlock_wrlock(&l4_list_lock);
-
+
list_add_tail(&n->entry, &l4_redirect_list);
-
+
if (!l4_redirect_timer.tpd)
triton_timer_add(&l4_redirect_ctx, &l4_redirect_timer, 0);
- pthread_rwlock_unlock(&l4_list_lock);
+ pthread_rwlock_unlock(&l4_list_lock);
}
static int l4_redirect_list_check(in_addr_t addr)
@@ -417,10 +417,10 @@ static void l4_redirect_list_timer(struct triton_timer_t *t)
if (conf_l4_redirect_table)
iprule_del(n->addr, conf_l4_redirect_table);
-
+
if (conf_l4_redirect_ipset)
ipset_del(conf_l4_redirect_ipset, n->addr);
-
+
ipoe_nl_del_exclude(n->addr);
_free(n);
@@ -438,12 +438,12 @@ static void l4_redirect_list_timer(struct triton_timer_t *t)
static void ipoe_change_l4_redirect(struct ipoe_session *ses, int del)
{
in_addr_t addr;
-
+
if (ses->ses.ipv4)
addr = ses->ses.ipv4->peer_addr;
else
addr = ses->yiaddr;
-
+
if (ses->l4_redirect_table) {
if (del) {
iprule_del(addr, ses->l4_redirect_table);
@@ -560,7 +560,7 @@ cont:
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);
ses->ses.ifindex = ses->serv->ifindex;
@@ -586,18 +586,18 @@ static void ipoe_session_start(struct ipoe_session *ses)
int r;
char *passwd;
char *username;
-
+
if (ses->dhcpv4_request && conf_verbose) {
log_ppp_info2("recv ");
dhcpv4_print_packet(ses->dhcpv4_request, 0, log_ppp_info2);
}
__sync_add_and_fetch(&stat_starting, 1);
-
+
assert(!ses->ses.username);
strncpy(ses->ses.ifname, ses->serv->ifname, AP_IFNAME_LEN);
-
+
username = ipoe_session_get_username(ses);
if (!username) {
@@ -606,13 +606,13 @@ static void ipoe_session_start(struct ipoe_session *ses)
}
ses->ses.unit_idx = ses->serv->ifindex;
-
+
triton_event_fire(EV_CTRL_STARTING, &ses->ses);
triton_event_fire(EV_CTRL_STARTED, &ses->ses);
ap_session_starting(&ses->ses);
-
- if (conf_noauth)
+
+ if (conf_noauth)
r = PWDB_SUCCESS;
else {
if (ses->serv->opt_shared && ipoe_create_interface(ses))
@@ -628,7 +628,7 @@ static void ipoe_session_start(struct ipoe_session *ses)
ses->username = username;
r = pwdb_check(&ses->ses, (pwdb_callback)auth_result, ses, username, PPP_PAP, conf_password ? conf_password : username);
-
+
if (r == PWDB_WAIT)
return;
@@ -642,7 +642,7 @@ static void ipoe_session_start(struct ipoe_session *ses)
}
}
}
-
+
auth_result(ses, r);
}
@@ -659,7 +659,7 @@ static void find_gw_addr(struct ipoe_session *ses)
}
}
-static void __ipoe_session_start(struct ipoe_session *ses)
+static void __ipoe_session_start(struct ipoe_session *ses)
{
if (!ses->yiaddr) {
dhcpv4_get_ip(ses->serv->dhcpv4, &ses->yiaddr, &ses->router, &ses->mask);
@@ -676,7 +676,7 @@ static void __ipoe_session_start(struct ipoe_session *ses)
if (!ses->yiaddr)
ses->yiaddr = ses->ses.ipv4->peer_addr;
-
+
if (!ses->router)
ses->router = ses->ses.ipv4->addr;
} /*else if (ses->yiaddr) {
@@ -686,7 +686,7 @@ static void __ipoe_session_start(struct ipoe_session *ses)
ses->ipv4.mask = ses->mask;
ses->ipv4.owner = NULL;
}*/
-
+
if (ses->dhcpv4_request) {
if (!ses->yiaddr) {
log_ppp_error("no free IPv4 address\n");
@@ -696,13 +696,13 @@ static void __ipoe_session_start(struct ipoe_session *ses)
if (!ses->router)
find_gw_addr(ses);
-
+
if (!ses->mask)
ses->mask = conf_netmask;
-
+
if (!ses->mask)
ses->mask = 32;
-
+
if (ses->dhcpv4_request->hdr->giaddr) {
/*uint32_t mask = ses->mask == 32 ? 0xffffffff : (((1 << ses->mask) - 1) << (32 - ses->mask));
@@ -719,18 +719,18 @@ static void __ipoe_session_start(struct ipoe_session *ses)
ses->router = ses->dhcpv4_request->hdr->giaddr;
}
}
-
+
if (!ses->router) {
log_ppp_error("can't determine router address\n");
ap_session_terminate(&ses->ses, TERM_NAS_REQUEST, 0);
return;
- }
-
+ }
+
if (!ses->siaddr && ses->router != ses->yiaddr)
ses->siaddr = ses->router;
-
+
if (!ses->siaddr)
- ses->siaddr = ses->serv->opt_src;
+ ses->siaddr = ses->serv->opt_src;
if (!ses->siaddr && ses->serv->dhcpv4_relay)
ses->siaddr = ses->serv->dhcpv4_relay->giaddr;
@@ -748,7 +748,7 @@ static void __ipoe_session_start(struct ipoe_session *ses)
dhcpv4_packet_free(ses->dhcpv4_request);
ses->dhcpv4_request = NULL;
-
+
ses->timer.expire = ipoe_session_timeout;
ses->timer.period = 0;
ses->timer.expire_tv.tv_sec = conf_offer_timeout;
@@ -756,7 +756,7 @@ static void __ipoe_session_start(struct ipoe_session *ses)
} else {
if (!ses->siaddr)
find_gw_addr(ses);
-
+
if (!ses->siaddr)
ses->siaddr = ses->serv->opt_src;
@@ -768,7 +768,7 @@ static void __ipoe_session_start(struct ipoe_session *ses)
ap_session_terminate(&ses->ses, TERM_NAS_ERROR, 0);
return;
}
-
+
if (ses->ses.ipv4 && !ses->ses.ipv4->addr)
ses->ses.ipv4->addr = ses->siaddr;
@@ -781,7 +781,7 @@ static void ipoe_serv_add_addr(struct ipoe_serv *serv, in_addr_t addr, int mask)
struct ifaddr *a;
pthread_mutex_lock(&serv->lock);
-
+
if (serv->opt_shared) {
list_for_each_entry(a, &serv->addr_list, entry) {
if (a->addr == addr) {
@@ -823,7 +823,7 @@ static void ipoe_serv_del_addr(struct ipoe_serv *serv, in_addr_t addr, int lock)
break;
}
}
-
+
if (lock)
pthread_mutex_unlock(&serv->lock);
}
@@ -834,7 +834,7 @@ static void ipoe_ifcfg_add(struct ipoe_session *ses)
if (ses->serv->opt_ifcfg)
ipoe_serv_add_addr(ses->serv, ses->siaddr, conf_ip_unnumbered ? 32 : ses->mask);
-
+
if (conf_ip_unnumbered) {
if (iproute_add(serv->ifindex, ses->serv->opt_src ? ses->serv->opt_src : ses->router, ses->yiaddr, 0, conf_proto))
log_ppp_warn("ipoe: failed to add route to interface '%s'\n", serv->ifname);
@@ -846,7 +846,7 @@ static void ipoe_ifcfg_add(struct ipoe_session *ses)
static void ipoe_ifcfg_del(struct ipoe_session *ses, int lock)
{
struct ipoe_serv *serv = ses->serv;
-
+
if (conf_ip_unnumbered) {
if (iproute_del(serv->ifindex, ses->yiaddr, conf_proto))
log_ppp_warn("ipoe: failed to delete route from interface '%s'\n", serv->ifname);
@@ -862,7 +862,7 @@ static void __ipoe_session_activate(struct ipoe_session *ses)
if (ses->terminating)
return;
-
+
if (ses->ifindex != -1) {
addr = 0;
if (!ses->ses.ipv4) {
@@ -889,29 +889,29 @@ static void __ipoe_session_activate(struct ipoe_session *ses)
return;
}
}
-
+
if (!ses->ses.ipv4) {
ses->ses.ipv4 = &ses->ipv4;
ses->ipv4.owner = NULL;
ses->ipv4.peer_addr = ses->yiaddr;
ses->ipv4.addr = ses->siaddr;
}
-
+
if (ses->ifindex == -1) {
if (ses->serv->opt_ifcfg || (ses->serv->opt_mode == MODE_L2))
ipoe_ifcfg_add(ses);
-
+
ipoe_nl_add_exclude(ses->yiaddr, 32);
iproute_add(ses->serv->ifindex, ses->siaddr, ses->yiaddr, 0, conf_proto);
-
+
ses->ctrl.dont_ifcfg = 1;
} else if (ses->ctrl.dont_ifcfg && ses->serv->opt_mode == MODE_L2)
ipaddr_add(ses->ifindex, ses->siaddr, ses->mask);
-
+
if (ses->l4_redirect)
ipoe_change_l4_redirect(ses, 0);
-
+
if (ses->serv->opt_mode == MODE_L2 && ses->serv->opt_ipv6 && sock6_fd != -1) {
ses->ses.ipv6 = ipdb_get_ipv6(&ses->ses);
if (!ses->ses.ipv6)
@@ -935,7 +935,7 @@ static void __ipoe_session_activate(struct ipoe_session *ses)
dhcpv4_packet_free(ses->dhcpv4_request);
ses->dhcpv4_request = NULL;
}
-
+
ses->timer.expire = ipoe_session_timeout;
ses->timer.period = 0;
ses->timer.expire_tv.tv_sec = conf_lease_timeout ? conf_lease_timeout : ses->lease_time;
@@ -946,7 +946,7 @@ static void __ipoe_session_activate(struct ipoe_session *ses)
static void ipoe_session_activate(struct dhcpv4_packet *pack)
{
struct ipoe_session *ses = container_of(triton_context_self(), typeof(*ses), ctx);
-
+
if (ses->ses.state == AP_STATE_ACTIVE) {
ipoe_session_keepalive(pack);
return;
@@ -954,7 +954,7 @@ static void ipoe_session_activate(struct dhcpv4_packet *pack)
if (ses->dhcpv4_request)
dhcpv4_packet_free(ses->dhcpv4_request);
-
+
ses->dhcpv4_request = pack;
if (ses->serv->dhcpv4_relay)
@@ -969,14 +969,14 @@ static void ipoe_session_keepalive(struct dhcpv4_packet *pack)
if (ses->dhcpv4_request)
dhcpv4_packet_free(ses->dhcpv4_request);
-
+
ses->dhcpv4_request = pack;
if (ses->timer.tpd)
triton_timer_mod(&ses->timer, 0);
ses->xid = ses->dhcpv4_request->hdr->xid;
-
+
if (/*ses->ses.state == AP_STATE_ACTIVE &&*/ ses->serv->dhcpv4_relay) {
dhcpv4_relay_send(ses->serv->dhcpv4_relay, ses->dhcpv4_request, ses->relay_server_id, ses->serv->ifname, conf_agent_remote_id);
return;
@@ -990,7 +990,7 @@ static void ipoe_session_keepalive(struct dhcpv4_packet *pack)
dhcpv4_packet_free(ses->dhcpv4_request);
ses->dhcpv4_request = NULL;
}
-
+
static void ipoe_session_decline(struct dhcpv4_packet *pack)
{
struct ipoe_session *ses = container_of(triton_context_self(), typeof(*ses), ctx);
@@ -999,7 +999,7 @@ static void ipoe_session_decline(struct dhcpv4_packet *pack)
log_ppp_info2("recv ");
dhcpv4_print_packet(pack, 0, log_ppp_info2);
}
-
+
if (pack->msg_type == DHCPDECLINE && ses->serv->dhcpv4_relay)
dhcpv4_relay_send(ses->serv->dhcpv4_relay, pack, 0, ses->serv->ifname, conf_agent_remote_id);
@@ -1011,12 +1011,12 @@ static void ipoe_session_decline(struct dhcpv4_packet *pack)
static void ipoe_session_started(struct ap_session *s)
{
struct ipoe_session *ses = container_of(s, typeof(*ses), ses);
-
+
log_ppp_info1("ipoe: session started\n");
if (ses->timer.tpd)
triton_timer_mod(&ses->timer, 0);
-
+
if (ses->ifindex != -1 && ses->xid) {
ses->dhcpv4 = dhcpv4_create(ses->ctrl.ctx, ses->ses.ifname, "");
if (!ses->dhcpv4) {
@@ -1033,33 +1033,33 @@ static void ipoe_session_free(struct ipoe_session *ses)
__sync_sub_and_fetch(&stat_active, 1);
else
__sync_sub_and_fetch(&stat_starting, 1);
-
+
if (ses->timer.tpd)
triton_timer_del(&ses->timer);
-
+
if (ses->l4_redirect_timer.tpd)
triton_timer_del(&ses->timer);
if (ses->dhcpv4_request)
dhcpv4_packet_free(ses->dhcpv4_request);
-
+
if (ses->dhcpv4_relay_reply)
dhcpv4_packet_free(ses->dhcpv4_relay_reply);
-
+
if (ses->ctrl.called_station_id)
_free(ses->ctrl.called_station_id);
-
+
if (ses->ctrl.calling_station_id)
_free(ses->ctrl.calling_station_id);
-
+
if (ses->l4_redirect_ipset)
_free(ses->l4_redirect_ipset);
triton_context_unregister(&ses->ctx);
-
+
if (ses->data)
_free(ses->data);
-
+
mempool_free(ses);
}
@@ -1097,12 +1097,12 @@ static void ipoe_session_finished(struct ap_session *s)
if (ses->ifcfg)
ipoe_ifcfg_del(ses, 1);
-
+
if (ses->dhcpv4)
dhcpv4_free(ses->dhcpv4);
triton_event_fire(EV_CTRL_FINISHED, s);
-
+
triton_context_call(&ses->ctx, (triton_event_func)ipoe_session_free, ses);
}
@@ -1120,7 +1120,7 @@ static void ipoe_session_terminate(struct ap_session *s, int hard)
static void ipoe_session_close(struct triton_context_t *ctx)
{
struct ipoe_session *ses = container_of(ctx, typeof(*ses), ctx);
-
+
if (ses->ses.state)
ap_session_terminate(&ses->ses, TERM_ADMIN_RESET, 1);
else
@@ -1132,7 +1132,7 @@ static struct ipoe_session *ipoe_session_create_dhcpv4(struct ipoe_serv *serv, s
struct ipoe_session *ses;
int dlen = 0;
uint8_t *ptr = NULL;
-
+
ses = ipoe_session_alloc();
if (!ses)
return NULL;
@@ -1140,7 +1140,7 @@ static struct ipoe_session *ipoe_session_create_dhcpv4(struct ipoe_serv *serv, s
ses->serv = serv;
ses->dhcpv4_request = pack;
strncpy(ses->ses.ifname, serv->ifname, AP_IFNAME_LEN);
-
+
ses->xid = pack->hdr->xid;
memcpy(ses->hwaddr, pack->hdr->chaddr, 6);
ses->giaddr = pack->hdr->giaddr;
@@ -1148,10 +1148,10 @@ static struct ipoe_session *ipoe_session_create_dhcpv4(struct ipoe_serv *serv, s
if (pack->client_id)
dlen += sizeof(struct dhcpv4_option) + pack->client_id->len;
-
+
if (pack->relay_agent)
dlen += sizeof(struct dhcpv4_option) + pack->relay_agent->len;
-
+
if (dlen) {
ses->data = _malloc(dlen);
if (!ses->data) {
@@ -1169,7 +1169,7 @@ static struct ipoe_session *ipoe_session_create_dhcpv4(struct ipoe_serv *serv, s
memcpy(ses->client_id->data, pack->client_id->data, pack->client_id->len);
ptr += sizeof(struct dhcpv4_option) + pack->client_id->len;
}
-
+
if (pack->relay_agent) {
ses->relay_agent = (struct dhcpv4_option *)ptr;
ses->relay_agent->len = pack->relay_agent->len;
@@ -1181,14 +1181,14 @@ static struct ipoe_session *ipoe_session_create_dhcpv4(struct ipoe_serv *serv, s
}
ses->ctrl.dont_ifcfg = 1;
-
+
ses->ctrl.calling_station_id = _malloc(19);
ses->ctrl.called_station_id = _strdup(serv->ifname);
-
+
ptr = ses->hwaddr;
sprintf(ses->ctrl.calling_station_id, "%02x:%02x:%02x:%02x:%02x:%02x",
ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5]);
-
+
ses->ses.ctrl = &ses->ctrl;
ses->ses.chan_name = ses->ctrl.calling_station_id;
@@ -1202,10 +1202,10 @@ static struct ipoe_session *ipoe_session_create_dhcpv4(struct ipoe_serv *serv, s
//pthread_mutex_lock(&serv->lock);
list_add_tail(&ses->entry, &serv->sessions);
//pthread_mutex_unlock(&serv->lock);
-
+
if (serv->timer.tpd)
triton_timer_del(&serv->timer);
-
+
dhcpv4_packet_ref(pack);
triton_context_call(&ses->ctx, (triton_event_func)ipoe_session_start, ses);
@@ -1227,7 +1227,7 @@ static void ipoe_ses_recv_dhcpv4(struct dhcpv4_serv *dhcpv4, struct dhcpv4_packe
if (ap_shutdown)
return;
-
+
if (conf_verbose) {
log_ppp_info2("recv ");
dhcpv4_print_packet(pack, 0, log_ppp_info2);
@@ -1239,27 +1239,27 @@ static void ipoe_ses_recv_dhcpv4(struct dhcpv4_serv *dhcpv4, struct dhcpv4_packe
}
opt82_match = pack->relay_agent != NULL;
-
+
if (agent_circuit_id && !ses->agent_circuit_id)
opt82_match = 0;
-
+
if (opt82_match && agent_remote_id && !ses->agent_remote_id)
opt82_match = 0;
-
+
if (opt82_match && !agent_circuit_id && ses->agent_circuit_id)
opt82_match = 0;
-
+
if (opt82_match && !agent_remote_id && ses->agent_remote_id)
opt82_match = 0;
-
+
if (opt82_match && agent_circuit_id) {
if (*agent_circuit_id != *ses->agent_circuit_id)
opt82_match = 0;
-
+
if (memcmp(agent_circuit_id + 1, ses->agent_circuit_id + 1, *agent_circuit_id))
opt82_match = 0;
}
-
+
if (opt82_match && agent_remote_id) {
if (*agent_remote_id != *ses->agent_remote_id)
opt82_match = 0;
@@ -1295,7 +1295,7 @@ static void ipoe_ses_recv_dhcpv4(struct dhcpv4_serv *dhcpv4, struct dhcpv4_packe
dhcpv4_send_nak(dhcpv4, pack);
else if (ses->serv->dhcpv4_relay)
dhcpv4_relay_send(ses->serv->dhcpv4_relay, pack, 0, ses->serv->ifname, conf_agent_remote_id);
-
+
triton_context_call(ses->ctrl.ctx, (triton_event_func)__ipoe_session_terminate, &ses->ses);
} else {
dhcpv4_packet_ref(pack);
@@ -1315,10 +1315,10 @@ static void ipoe_ses_recv_dhcpv4_discover(struct dhcpv4_packet *pack)
log_ppp_info2("recv ");
dhcpv4_print_packet(pack, 0, log_ppp_info2);
}
-
+
if (ses->yiaddr)
dhcpv4_send_reply(DHCPOFFER, ses->serv->dhcpv4, pack, ses->yiaddr, ses->siaddr, ses->router, ses->mask, ses->lease_time, ses->dhcpv4_relay_reply);
-
+
dhcpv4_packet_free(pack);
}
@@ -1327,12 +1327,12 @@ static void ipoe_ses_recv_dhcpv4_request(struct dhcpv4_packet *pack)
struct ipoe_session *ses = container_of(triton_context_self(), typeof(*ses), ctx);
ses->xid = pack->hdr->xid;
-
+
if (conf_verbose) {
log_ppp_info2("recv ");
dhcpv4_print_packet(pack, 0, log_ppp_info2);
}
-
+
if ((pack->server_id && (pack->server_id != ses->siaddr || pack->request_ip != ses->yiaddr)) ||
(pack->hdr->ciaddr && (pack->hdr->ciaddr != ses->yiaddr))) {
@@ -1361,10 +1361,10 @@ static void ipoe_serv_disc_timer(struct triton_timer_t *t)
int delay, offer_delay;
clock_gettime(CLOCK_MONOTONIC, &ts);
-
- while (!list_empty(&serv->disc_list)) {
+
+ while (!list_empty(&serv->disc_list)) {
d = list_entry(serv->disc_list.next, typeof(*d), entry);
-
+
delay = (ts.tv_sec - d->ts.tv_sec) * 1000 + (ts.tv_nsec - d->ts.tv_nsec) / 1000000;
offer_delay = get_offer_delay();
@@ -1375,7 +1375,7 @@ static void ipoe_serv_disc_timer(struct triton_timer_t *t)
triton_timer_mod(t, 0);
return;
}
-
+
__ipoe_recv_dhcpv4(serv->dhcpv4, d->pack, 1);
list_del(&d->entry);
@@ -1394,14 +1394,14 @@ static void ipoe_serv_add_disc(struct ipoe_serv *serv, struct dhcpv4_packet *pac
if (!d)
return;
-
+
__sync_add_and_fetch(&stat_delayed_offer, 1);
-
+
dhcpv4_packet_ref(pack);
d->pack = pack;
clock_gettime(CLOCK_MONOTONIC, &d->ts);
list_add_tail(&d->entry, &serv->disc_list);
-
+
if (!serv->disc_timer.tpd) {
serv->disc_timer.expire_tv.tv_sec = offer_delay / 1000;
serv->disc_timer.expire_tv.tv_usec = (offer_delay % 1000) * 1000;
@@ -1419,13 +1419,13 @@ static void ipoe_serv_check_disc(struct ipoe_serv *serv, struct dhcpv4_packet *p
if (memcmp(d->pack->hdr->chaddr, pack->hdr->chaddr, ETH_ALEN))
continue;
-
+
list_del(&d->entry);
dhcpv4_packet_free(d->pack);
mempool_free(d);
-
+
__sync_sub_and_fetch(&stat_delayed_offer, 1);
-
+
break;
}
}
@@ -1456,7 +1456,7 @@ static int ipoe_serv_request_check(struct ipoe_serv *serv, uint32_t xid)
mempool_free(r);
}
}
-
+
r = mempool_alloc(req_item_pool);
r->xid = xid;
r->expire = ts.tv_sec + 30;
@@ -1481,7 +1481,7 @@ static void port_change_detected(struct dhcpv4_packet *pack)
ap_session_terminate(&ses->ses, TERM_USER_REQUEST, 0);
}
-
+
static void mac_change_detected(struct dhcpv4_packet *pack)
{
struct ipoe_session *ses = container_of(triton_context_self(), typeof(*ses), ctx);
@@ -1490,11 +1490,11 @@ static void mac_change_detected(struct dhcpv4_packet *pack)
log_ppp_info2("recv ");
dhcpv4_print_packet(pack, 0, log_ppp_info2);
}
-
+
dhcpv4_packet_free(pack);
-
+
log_ppp_warn("mac change detected\n");
-
+
ap_session_terminate(&ses->ses, TERM_USER_REQUEST, 0);
}
@@ -1510,7 +1510,7 @@ static void __ipoe_recv_dhcpv4(struct dhcpv4_serv *dhcpv4, struct dhcpv4_packet
if (ap_shutdown)
return;
-
+
if (connlimit_loaded && pack->msg_type == DHCPDISCOVER && connlimit_check(serv->opt_shared ? cl_key_from_mac(pack->hdr->chaddr) : serv->ifindex))
return;
@@ -1543,13 +1543,13 @@ static void __ipoe_recv_dhcpv4(struct dhcpv4_serv *dhcpv4, struct dhcpv4_packet
triton_context_call(&opt82_ses->ctx, (triton_event_func)__ipoe_session_terminate, &opt82_ses->ses);
goto out;
}
-
+
dhcpv4_packet_ref(pack);
triton_context_call(&ses->ctx, (triton_event_func)ipoe_ses_recv_dhcpv4_discover, pack);
}
} else if (pack->msg_type == DHCPREQUEST) {
ipoe_serv_check_disc(serv, pack);
-
+
ses = ipoe_session_lookup(serv, pack, &opt82_ses);
if (!ses) {
@@ -1576,7 +1576,7 @@ static void __ipoe_recv_dhcpv4(struct dhcpv4_serv *dhcpv4, struct dhcpv4_packet
triton_context_call(&opt82_ses->ctx, (triton_event_func)__ipoe_session_terminate, &opt82_ses->ses);
goto out;
}
-
+
if (serv->opt_shared == 0)
ipoe_drop_sessions(serv, ses);
@@ -1617,7 +1617,7 @@ static void ipoe_ses_recv_dhcpv4_relay(struct dhcpv4_packet *pack)
if (ses->dhcpv4_relay_reply)
dhcpv4_packet_free(ses->dhcpv4_relay_reply);
-
+
if (!ses->dhcpv4_request) {
ses->dhcpv4_relay_reply = NULL;
return;
@@ -1667,7 +1667,7 @@ static void ipoe_ses_recv_dhcpv4_relay(struct dhcpv4_packet *pack)
ap_session_terminate(&ses->ses, TERM_NAS_REQUEST, 0);
return;
}
-
+
dhcpv4_packet_free(ses->dhcpv4_relay_reply);
ses->dhcpv4_relay_reply = NULL;
}
@@ -1694,7 +1694,7 @@ static void ipoe_recv_dhcpv4_relay(struct dhcpv4_packet *pack)
found = 1;
break;
}
-
+
if (found) {
triton_context_call(&ses->ctx, (triton_event_func)ipoe_ses_recv_dhcpv4_relay, pack);
} else
@@ -1710,10 +1710,10 @@ static struct ipoe_session *ipoe_session_create_up(struct ipoe_serv *serv, struc
if (ap_shutdown)
return NULL;
-
+
if (l4_redirect_list_check(iph->saddr))
return NULL;
-
+
ses = ipoe_session_alloc();
if (!ses)
return NULL;
@@ -1726,12 +1726,12 @@ static struct ipoe_session *ipoe_session_create_up(struct ipoe_serv *serv, struc
ses->ctrl.called_station_id = _strdup(serv->ifname);
u_inet_ntoa(iph->saddr, ses->ctrl.calling_station_id);
-
+
ses->ses.chan_name = ses->ctrl.calling_station_id;
-
+
if (conf_ip_pool)
ses->ses.ipv4_pool_name = _strdup(conf_ip_pool);
-
+
triton_context_register(&ses->ctx, &ses->ses);
triton_context_wakeup(&ses->ctx);
@@ -1763,7 +1763,7 @@ struct ipoe_session *ipoe_session_alloc(void)
ap_session_init(&ses->ses);
ses->ifindex = -1;
-
+
ses->ctx.before_switch = log_switch;
ses->ctx.close = ipoe_session_close;
ses->ctrl.ctx = &ses->ctx;
@@ -1775,7 +1775,7 @@ struct ipoe_session *ipoe_session_alloc(void)
ses->l4_redirect_table = conf_l4_redirect_table;
ses->ses.ctrl = &ses->ctrl;
-
+
return ses;
}
@@ -1790,7 +1790,7 @@ void ipoe_recv_up(int ifindex, struct ethhdr *eth, struct iphdr *iph)
if (!serv->opt_up)
return;
-
+
pthread_mutex_lock(&serv->lock);
list_for_each_entry(ses, &serv->sessions, entry) {
if (ses->yiaddr == iph->saddr) {
@@ -1799,7 +1799,7 @@ void ipoe_recv_up(int ifindex, struct ethhdr *eth, struct iphdr *iph)
}
}
pthread_mutex_unlock(&serv->lock);
-
+
ipoe_session_create_up(serv, eth, iph);
break;
@@ -1853,10 +1853,10 @@ static void ev_radius_coa(struct ev_radius_t *ev)
struct ipoe_session *ses = container_of(ev->ses, typeof(*ses), ses);
struct rad_attr_t *attr;
int l4_redirect;
-
+
if (ev->ses->ctrl->type != CTRL_TYPE_IPOE)
return;
-
+
l4_redirect = ses->l4_redirect;
list_for_each_entry(attr, &ev->request->attrs, entry) {
@@ -1883,8 +1883,8 @@ static int ipoe_rad_send_request(struct rad_plugin_t *rad, struct rad_packet_t *
if (!ses->relay_agent)
return 0;
-
- return rad_packet_add_octets(pack, NULL, conf_attr_dhcp_opt82, ses->relay_agent->data, ses->relay_agent->len);
+
+ return rad_packet_add_octets(pack, NULL, conf_attr_dhcp_opt82, ses->relay_agent->data, ses->relay_agent->len);
}
#endif
@@ -1906,7 +1906,7 @@ static void ipoe_serv_release(struct ipoe_serv *serv)
return;
}
-
+
log_info2("ipoe: stop interface %s\n", serv->ifname);
pthread_mutex_lock(&serv_lock);
@@ -1915,7 +1915,7 @@ static void ipoe_serv_release(struct ipoe_serv *serv)
if (serv->dhcpv4)
dhcpv4_free(serv->dhcpv4);
-
+
if (serv->dhcpv4_relay) {
ipoe_serv_del_addr(serv, serv->dhcpv4_relay->giaddr, 0);
dhcpv4_relay_free(serv->dhcpv4_relay, &serv->ctx);
@@ -1931,7 +1931,7 @@ static void ipoe_serv_release(struct ipoe_serv *serv)
mempool_free(d);
__sync_sub_and_fetch(&stat_delayed_offer, 1);
}
-
+
while (!list_empty(&serv->req_list)) {
struct request_item *r = list_first_entry(&serv->req_list, typeof(*r), entry);
list_del(&r->entry);
@@ -1940,7 +1940,7 @@ static void ipoe_serv_release(struct ipoe_serv *serv)
if (serv->disc_timer.tpd)
triton_timer_del(&serv->disc_timer);
-
+
if (serv->timer.tpd)
triton_timer_del(&serv->timer);
@@ -1982,19 +1982,19 @@ static void l4_redirect_ctx_close(struct triton_context_t *ctx)
if (conf_l4_redirect_table)
iprule_del(n->addr, conf_l4_redirect_table);
-
+
if (conf_l4_redirect_ipset)
ipset_del(conf_l4_redirect_ipset, n->addr);
-
+
ipoe_nl_del_exclude(n->addr);
-
+
_free(n);
}
pthread_rwlock_unlock(&l4_list_lock);
if (l4_redirect_timer.tpd)
triton_timer_del(&l4_redirect_timer);
-
+
triton_context_unregister(&l4_redirect_ctx);
}
@@ -2066,7 +2066,7 @@ static int get_offer_delay()
if (prev)
return prev->delay;
-
+
return 0;
}
@@ -2118,12 +2118,12 @@ void ipoe_vlan_notify(int ifindex, int vid)
log_error("ipoe: vlan-mon: failed to get interface name, ifindex=%i\n", ifindex);
return;
}
-
+
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;
}
-
+
log_info2("ipoe: create vlan %s parent %s\n", ifname, ifr.ifr_name);
strcpy(ifr.ifr_name, ifname);
@@ -2133,11 +2133,11 @@ void ipoe_vlan_notify(int ifindex, int vid)
log_warn("ipoe: vlan-mon: %s: failed to add vlan\n", ifr.ifr_name);
return;
}
-
+
ioctl(sock_fd, SIOCGIFFLAGS, &ifr, sizeof(ifr));
ifr.ifr_flags |= IFF_UP;
ioctl(sock_fd, SIOCSIFFLAGS, &ifr, sizeof(ifr));
-
+
if (ioctl(sock_fd, SIOCGIFINDEX, &ifr, sizeof(ifr))) {
log_error("ipoe: vlan-mon: %s: failed to get interface index\n", ifr.ifr_name);
return;
@@ -2148,7 +2148,7 @@ void ipoe_vlan_notify(int ifindex, int vid)
continue;
if (!opt->val)
continue;
-
+
ptr = strchr(opt->val, ',');
if (!ptr)
ptr = strchr(opt->val, 0);
@@ -2157,20 +2157,20 @@ void ipoe_vlan_notify(int ifindex, int vid)
pattern = _malloc(ptr - (opt->val + 3) + 1);
memcpy(pattern, opt->val + 3, ptr - (opt->val + 3));
pattern[ptr - (opt->val + 3)] = 0;
-
+
re = pcre_compile2(pattern, 0, NULL, &pcre_err, &pcre_offset, NULL);
-
+
_free(pattern);
-
+
if (!re)
continue;
r = pcre_exec(re, NULL, ifr.ifr_name, len, 0, 0, NULL, 0);
pcre_free(re);
-
+
if (r < 0)
continue;
-
+
add_interface(ifr.ifr_name, ifr.ifr_ifindex, opt->val, ifindex, vid);
} else if (ptr - opt->val == len && memcmp(opt->val, ifr.ifr_name, len) == 0)
add_interface(ifr.ifr_name, ifr.ifr_ifindex, opt->val, ifindex, vid);
@@ -2182,7 +2182,7 @@ static void ipoe_serv_timeout(struct triton_timer_t *t)
struct ipoe_serv *serv = container_of(t, typeof(*serv), timer);
serv->need_close = 1;
-
+
ipoe_serv_release(serv);
}
@@ -2213,13 +2213,13 @@ static void add_interface(const char *ifname, int ifindex, const char *opt, int
if (str0) {
str0 = _strdup(str0 + 1);
str = str0;
-
+
while (1) {
for (ptr1 = str + 1; *ptr1 && *ptr1 != '='; ptr1++);
if (!*ptr1)
goto parse_err;
-
+
*ptr1 = 0;
for (ptr2 = ++ptr1; *ptr2 && *ptr2 != ','; ptr2++);
@@ -2270,7 +2270,7 @@ static void add_interface(const char *ifname, int ifindex, const char *opt, int
else if (strlen(ptr1) > 4 && memcmp(ptr1, "lua:", 4) == 0) {
opt_username = USERNAME_LUA;
opt_lua_username_func = _strdup(ptr1 + 4);
- }
+ }
#endif
else
log_error("ipoe: unknown username value '%s'\n", ptr1);
@@ -2297,14 +2297,14 @@ static void add_interface(const char *ifname, int ifindex, const char *opt, int
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = relay_addr;
addr.sin_port = htons(DHCP_SERV_PORT);
-
+
sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
-
+
if (connect(sock, &addr, sizeof(addr))) {
log_error("dhcpv4: relay: %s: connect: %s\n", opt_relay, strerror(errno));
goto out_err;
}
-
+
getsockname(sock, &addr, &len);
opt_giaddr = addr.sin_addr.s_addr;
@@ -2321,7 +2321,7 @@ static void add_interface(const char *ifname, int ifindex, const char *opt, int
serv->active = 1;
serv->ifindex = ifindex;
-
+
if ((opt_shared && !serv->opt_shared) || (!opt_shared && serv->opt_shared)) {
ipoe_drop_sessions(serv, NULL);
serv->opt_shared = opt_shared;
@@ -2336,7 +2336,7 @@ static void add_interface(const char *ifname, int ifindex, const char *opt, int
serv->dhcpv4 = NULL;
}
- if (serv->dhcpv4_relay &&
+ if (serv->dhcpv4_relay &&
(serv->dhcpv4_relay->addr != relay_addr || serv->dhcpv4_relay->giaddr != opt_giaddr)) {
if (serv->opt_ifcfg)
ipoe_serv_del_addr(serv, serv->dhcpv4_relay->giaddr, 0);
@@ -2355,7 +2355,7 @@ static void add_interface(const char *ifname, int ifindex, const char *opt, int
serv->arp = NULL;
} else if (!serv->arp && conf_arp)
serv->arp = arpd_start(serv);
-
+
serv->opt_up = opt_up;
serv->opt_mode = opt_mode;
serv->opt_ifcfg = opt_ifcfg;
@@ -2369,7 +2369,7 @@ static void add_interface(const char *ifname, int ifindex, const char *opt, int
_free(serv->opt_lua_username_func);
serv->opt_lua_username_func = NULL;
}
-
+
if (!serv->opt_lua_username_func && opt_lua_username_func)
serv->opt_lua_username_func = opt_lua_username_func;
else if (opt_lua_username_func)
@@ -2392,14 +2392,14 @@ static void add_interface(const char *ifname, int ifindex, const char *opt, int
memset(&ifr, 0, sizeof(ifr));
strcpy(ifr.ifr_name, ifname);
-
+
if (ioctl(sock_fd, SIOCGIFHWADDR, &ifr)) {
log_error("ipoe: '%s': ioctl(SIOCGIFHWADDR): %s\n", ifname, strerror(errno));
return;
}
-
+
ioctl(sock_fd, SIOCGIFFLAGS, &ifr);
-
+
if (!(ifr.ifr_flags & IFF_UP)) {
ifr.ifr_flags |= IFF_UP;
@@ -2435,14 +2435,14 @@ static void add_interface(const char *ifname, int ifindex, const char *opt, int
INIT_LIST_HEAD(&serv->req_list);
memcpy(serv->hwaddr, ifr.ifr_hwaddr.sa_data, ETH_ALEN);
serv->disc_timer.expire = ipoe_serv_disc_timer;
-
+
triton_context_register(&serv->ctx, NULL);
if (serv->opt_dhcpv4) {
serv->dhcpv4 = dhcpv4_create(&serv->ctx, serv->ifname, opt);
if (serv->dhcpv4)
serv->dhcpv4->recv = ipoe_recv_dhcpv4;
-
+
if (opt_relay) {
if (opt_ifcfg)
ipoe_serv_add_addr(serv, opt_giaddr, 32);
@@ -2452,7 +2452,7 @@ static void add_interface(const char *ifname, int ifindex, const char *opt, int
if (serv->opt_arp)
serv->arp = arpd_start(serv);
-
+
if (vid) {
serv->timer.expire = ipoe_serv_timeout;
serv->timer.expire_tv.tv_sec = conf_vlan_timeout;
@@ -2488,12 +2488,12 @@ static void load_interface(const char *opt)
memcpy(ifr.ifr_name, opt, ptr - opt);
ifr.ifr_name[ptr - opt] = 0;
-
+
if (ioctl(sock_fd, SIOCGIFINDEX, &ifr)) {
log_error("ipoe: '%s': ioctl(SIOCGIFINDEX): %s\n", ifr.ifr_name, strerror(errno));
return;
}
-
+
add_interface(ifr.ifr_name, ifr.ifr_ifindex, opt, 0, 0);
}
@@ -2517,13 +2517,13 @@ static void load_interface_re(const char *opt)
struct iplink_arg arg;
for (ptr = opt; *ptr && *ptr != ','; ptr++);
-
+
pattern = _malloc(ptr - (opt + 3) + 1);
memcpy(pattern, opt + 3, ptr - (opt + 3));
pattern[ptr - (opt + 3)] = 0;
-
+
re = pcre_compile2(pattern, 0, NULL, &pcre_err, &pcre_offset, NULL);
-
+
if (!re) {
log_error("ipoe: '%s': %s at %i\r\n", pattern, pcre_err, pcre_offset);
return;
@@ -2559,7 +2559,7 @@ static void load_interfaces(struct conf_sect_t *sect)
else
load_interface(opt->val);
}
-
+
list_for_each_entry(serv, &serv_list, entry) {
if (!serv->active && !serv->vid) {
ipoe_drop_sessions(serv, NULL);
@@ -2664,7 +2664,7 @@ static void parse_conf_rad_attr(const char *opt, int *val)
struct rad_dict_attr_t *attr;
opt = conf_get_opt("ipoe", opt);
-
+
*val = 0;
if (opt) {
@@ -2798,11 +2798,11 @@ static int parse_vlan_mon(const char *opt, long *mask)
log_error("ipoe: vlan-mon=%s: invalid vlan %i\n", opt, vid2);
return -1;
}
-
+
for (; vid < vid2; vid++)
mask[vid / (8*sizeof(long))] &= ~(1lu << (vid % (8*sizeof(long))));
}
-
+
mask[vid / (8*sizeof(long))] &= ~(1lu << (vid % (8*sizeof(long))));
if (*ptr2 == 0)
@@ -2815,7 +2815,7 @@ static int parse_vlan_mon(const char *opt, long *mask)
}
return 0;
-
+
out_err:
log_error("ipoe: vlan-mon=%s: failed to parse\n", opt);
return -1;
@@ -2828,16 +2828,16 @@ static void add_vlan_mon(const char *opt, long *mask)
int ifindex;
long mask1[4096/8/sizeof(long)];
struct ipoe_serv *serv;
-
+
for (ptr = opt; *ptr && *ptr != ','; ptr++);
-
+
if (ptr - opt >= sizeof(ifr.ifr_name)) {
log_error("ipoe: vlan-mon=%s: interface name is too long\n", opt);
return;
}
memset(&ifr, 0, sizeof(ifr));
-
+
memcpy(ifr.ifr_name, opt, ptr - opt);
ifr.ifr_name[ptr - opt] = 0;
@@ -2847,9 +2847,9 @@ static void add_vlan_mon(const char *opt, long *mask)
}
ifindex = ifr.ifr_ifindex;
-
+
ioctl(sock_fd, SIOCGIFFLAGS, &ifr);
-
+
if (!(ifr.ifr_flags & IFF_UP)) {
ifr.ifr_flags |= IFF_UP;
@@ -2876,15 +2876,15 @@ static int __load_vlan_mon_re(int index, int flags, const char *name, struct ipl
memset(&ifr, 0, sizeof(ifr));
strcpy(ifr.ifr_name, name);
-
+
ioctl(sock_fd, SIOCGIFFLAGS, &ifr);
-
+
if (!(ifr.ifr_flags & IFF_UP)) {
ifr.ifr_flags |= IFF_UP;
ioctl(sock_fd, SIOCSIFFLAGS, &ifr);
}
-
+
memcpy(mask1, arg->arg1, sizeof(mask1));
list_for_each_entry(serv, &serv_list, entry) {
if (serv->vid && serv->parent_ifindex == index)
@@ -2906,13 +2906,13 @@ static void load_vlan_mon_re(const char *opt, long *mask, int len)
struct iplink_arg arg;
for (ptr = opt; *ptr && *ptr != ','; ptr++);
-
+
pattern = _malloc(ptr - (opt + 3) + 1);
memcpy(pattern, opt + 3, ptr - (opt + 3));
pattern[ptr - (opt + 3)] = 0;
-
+
re = pcre_compile2(pattern, 0, NULL, &pcre_err, &pcre_offset, NULL);
-
+
if (!re) {
log_error("ipoe: '%s': %s at %i\r\n", pattern, pcre_err, pcre_offset);
return;
@@ -2942,7 +2942,7 @@ static void load_vlan_mon(struct conf_sect_t *sect)
if (!opt->val)
continue;
-
+
if (parse_vlan_mon(opt->val, mask))
continue;
@@ -2977,7 +2977,7 @@ static void load_config(void)
log_emerg("ipoe: unknown username value '%s'\n", opt);
} else
conf_username = USERNAME_UNSET;
-
+
opt = conf_get_opt("ipoe", "password");
if (opt) {
if (!strcmp(opt, "username"))
@@ -2998,7 +2998,7 @@ static void load_config(void)
}
} else
conf_netmask = 0;
-
+
opt = conf_get_opt("ipoe", "verbose");
if (opt)
conf_verbose = atoi(opt);
@@ -3008,49 +3008,49 @@ static void load_config(void)
conf_lease_time = atoi(opt);
else
conf_lease_time = 600;
-
+
opt = conf_get_opt("ipoe", "max-lease-time");
if (opt)
conf_lease_timeout = atoi(opt);
else
conf_lease_timeout = 660;
-
+
opt = conf_get_opt("ipoe", "unit-cache");
if (opt)
conf_unit_cache = atoi(opt);
-
+
opt = conf_get_opt("ipoe", "l4-redirect-table");
if (opt && atoi(opt) > 0)
conf_l4_redirect_table = atoi(opt);
else
conf_l4_redirect_table = 0;
-
+
conf_l4_redirect_ipset = conf_get_opt("ipoe", "l4-redirect-ipset");
-
+
opt = conf_get_opt("ipoe", "l4-redirect-on-reject");
if (opt) {
conf_l4_redirect_on_reject = atoi(opt);
} else
conf_l4_redirect_on_reject = 0;
-
+
if (conf_l4_redirect_on_reject) {
l4_redirect_timer.period = conf_l4_redirect_on_reject / 10 * 1000;
if (l4_redirect_timer.tpd)
triton_timer_mod(&l4_redirect_timer, 0);
}
-
+
opt = conf_get_opt("ipoe", "shared");
if (opt)
conf_shared = atoi(opt);
else
conf_shared = 1;
-
+
opt = conf_get_opt("ipoe", "ifcfg");
if (opt)
conf_ifcfg = atoi(opt);
else
conf_ifcfg = 1;
-
+
opt = conf_get_opt("ipoe", "nat");
if (opt)
conf_nat = atoi(opt);
@@ -3068,12 +3068,12 @@ static void load_config(void)
conf_arp = atoi(opt);
else
conf_arp = 0;
-
+
if (conf_arp < 0 || conf_arp > 2) {
log_error("ipoe: arp=%s: invalid value\n", opt);
conf_arp = 0;
}
-
+
opt = conf_get_opt("ipoe", "mode");
if (opt) {
if (!strcmp(opt, "L2"))
@@ -3084,7 +3084,7 @@ static void load_config(void)
log_emerg("ipoe: failed to parse 'mode=%s'\n", opt);
} else
conf_mode = MODE_L2;
-
+
conf_relay = conf_get_opt("ipoe", "relay");
opt = conf_get_opt("ipoe", "relay-timeout");
@@ -3092,25 +3092,25 @@ static void load_config(void)
conf_relay_timeout = atoi(opt);
else
conf_relay_timeout = 3;
-
+
opt = conf_get_opt("ipoe", "relay-retransmit");
if (opt && atoi(opt) > 0)
conf_relay_retransmit = atoi(opt);
else
conf_relay_retransmit = 3;
-
+
opt = conf_get_opt("ipoe", "agent-remote-id");
if (opt)
conf_agent_remote_id = opt;
else
conf_agent_remote_id = "accel-pppd";
-
+
opt = conf_get_opt("ipoe", "ipv6");
if (opt)
conf_ipv6 = atoi(opt);
else
conf_ipv6 = 0;
-
+
opt = conf_get_opt("ipoe", "noauth");
if (opt)
conf_noauth = atoi(opt);
@@ -3131,45 +3131,45 @@ static void load_config(void)
if (!conf_dhcpv4 && !conf_up)
conf_dhcpv4 = 1;
-
+
opt = conf_get_opt("ipoe", "proto");
if (opt && atoi(opt) > 0)
conf_proto = atoi(opt);
else
conf_proto = 3;
-
+
opt = conf_get_opt("ipoe", "vlan-timeout");
if (opt && atoi(opt) > 0)
conf_vlan_timeout = atoi(opt);
else
conf_vlan_timeout = 60;
-
+
opt = conf_get_opt("ipoe", "offer-timeout");
if (opt && atoi(opt) > 0)
conf_offer_timeout = atoi(opt);
else
conf_offer_timeout = 10;
-
+
conf_ip_pool = conf_get_opt("ipoe", "ip-pool");
conf_l4_redirect_pool = conf_get_opt("ipoe", "l4-redirect-ip-pool");
conf_vlan_name = conf_get_opt("ipoe", "vlan-name");
if (!conf_vlan_name)
conf_vlan_name = "%I.%N";
-
+
opt = conf_get_opt("ipoe", "ip-unnumbered");
if (opt)
conf_ip_unnumbered = atoi(opt);
else
conf_ip_unnumbered = 1;
-
+
#ifdef RADIUS
if (triton_module_loaded("radius"))
load_radius_attrs();
#endif
parse_offer_delay(conf_get_opt("ipoe", "offer-delay"));
-
+
load_interfaces(s);
load_local_nets(s);
load_vlan_mon(s);
@@ -3200,7 +3200,7 @@ static void ipoe_init(void)
ipset_flush(conf_l4_redirect_ipset);
cli_register_simple_cmd2(show_stat_exec, NULL, 2, "show", "stat");
-
+
triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config);
#ifdef RADIUS
@@ -3209,7 +3209,7 @@ static void ipoe_init(void)
triton_event_register_handler(EV_RADIUS_COA, (triton_event_func)ev_radius_coa);
}
#endif
-
+
connlimit_loaded = triton_module_loaded("connlimit");
radius_loaded = triton_module_loaded("radius");
}
diff --git a/accel-pppd/ctrl/ipoe/ipoe_netlink.c b/accel-pppd/ctrl/ipoe/ipoe_netlink.c
index 7643961..c061036 100644
--- a/accel-pppd/ctrl/ipoe/ipoe_netlink.c
+++ b/accel-pppd/ctrl/ipoe/ipoe_netlink.c
@@ -63,7 +63,7 @@ void ipoe_nl_add_net(uint32_t addr, int mask)
struct nlmsghdr n;
char buf[1024];
} req;
-
+
if (rth.fd == -1)
return;
@@ -74,7 +74,7 @@ void ipoe_nl_add_net(uint32_t addr, int mask)
ghdr = NLMSG_DATA(&req.n);
ghdr->cmd = IPOE_CMD_ADD_NET;
-
+
mask = ((1 << mask) - 1) << (32 - mask);
addattr32(nlh, 1024, IPOE_ATTR_ADDR, addr);
@@ -94,12 +94,12 @@ int ipoe_nl_add_exclude(uint32_t addr, int mask)
char buf[1024];
} req;
int ret = 0;
-
+
if (rtnl_open_byproto(&rth, 0, NETLINK_GENERIC)) {
log_ppp_error("ipoe: cannot open generic netlink socket\n");
return -1;
}
-
+
nlh = &req.n;
nlh->nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN);
nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
@@ -115,9 +115,9 @@ int ipoe_nl_add_exclude(uint32_t addr, int mask)
log_ppp_error("ipoe: nl_add_net: error talking to kernel\n");
ret = -1;
}
-
+
rtnl_close(&rth);
-
+
return ret;
}
@@ -130,7 +130,7 @@ void ipoe_nl_del_exclude(uint32_t addr)
struct nlmsghdr n;
char buf[1024];
} req;
-
+
if (rtnl_open_byproto(&rth, 0, NETLINK_GENERIC)) {
log_ppp_error("ipoe: cannot open generic netlink socket\n");
return;
@@ -148,7 +148,7 @@ void ipoe_nl_del_exclude(uint32_t addr)
if (rtnl_talk(&rth, nlh, 0, 0, nlh, NULL, NULL, 0) < 0 )
log_ppp_error("ipoe: nl_add_net: error talking to kernel\n");
-
+
rtnl_close(&rth);
}
@@ -186,7 +186,7 @@ void ipoe_nl_add_interface(int ifindex)
struct nlmsghdr n;
char buf[1024];
} req;
-
+
if (rth.fd == -1)
return;
@@ -238,10 +238,10 @@ int ipoe_nl_create(uint32_t peer_addr, uint32_t addr, const char *ifname, uint8_
if (peer_addr)
addattr32(nlh, 1024, IPOE_ATTR_PEER_ADDR, peer_addr);
-
+
if (addr)
addattr32(nlh, 1024, IPOE_ATTR_ADDR, addr);
-
+
if (hwaddr) {
memcpy(u.hwaddr, hwaddr, 6);
addattr_l(nlh, 1024, IPOE_ATTR_HWADDR, &u.u64, 8);
@@ -252,7 +252,7 @@ int ipoe_nl_create(uint32_t peer_addr, uint32_t addr, const char *ifname, uint8_
if (rtnl_talk(&rth, nlh, 0, 0, nlh, NULL, NULL, 0) < 0 )
log_ppp_error("ipoe: nl_create: error talking to kernel\n");
-
+
if (nlh->nlmsg_type != ipoe_genl_id) {
log_ppp_error("ipoe: not a IPoE message %d\n", nlh->nlmsg_type);
goto out;
@@ -281,7 +281,7 @@ int ipoe_nl_create(uint32_t peer_addr, uint32_t addr, const char *ifname, uint8_
}
ret = *(uint32_t *)(RTA_DATA(tb[IPOE_ATTR_IFINDEX]));
-
+
out:
rtnl_close(&rth);
@@ -319,7 +319,7 @@ int ipoe_nl_modify(int ifindex, uint32_t peer_addr, uint32_t addr, const char *i
addattr32(nlh, 1024, IPOE_ATTR_IFINDEX, ifindex);
addattr32(nlh, 1024, IPOE_ATTR_PEER_ADDR, peer_addr);
addattr32(nlh, 1024, IPOE_ATTR_ADDR, addr);
-
+
if (hwaddr) {
memcpy(u.hwaddr, hwaddr, 6);
addattr_l(nlh, 1024, IPOE_ATTR_HWADDR, &u.u64, 8);
@@ -332,7 +332,7 @@ int ipoe_nl_modify(int ifindex, uint32_t peer_addr, uint32_t addr, const char *i
log_ppp_error("ipoe: nl_create: error talking to kernel\n");
ret = -1;
}
-
+
rtnl_close(&rth);
return ret;
@@ -399,7 +399,7 @@ void ipoe_nl_get_sessions(struct list_head *list)
if (rth.fd == -1)
return;
-
+
nlh = &req.n;
nlh->nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN);
nlh->nlmsg_flags = NLM_F_ROOT | NLM_F_MATCH | NLM_F_REQUEST;
@@ -456,7 +456,7 @@ int ipoe_nl_add_vlan_mon(int ifindex, long *mask, int len)
struct nlmsghdr n;
char buf[1024];
} req;
-
+
if (rth.fd == -1)
return -1;
@@ -489,12 +489,12 @@ int ipoe_nl_add_vlan_mon_vid(int ifindex, int vid)
char buf[1024];
} req;
int r = 0;
-
+
if (rtnl_open_byproto(&rth, 0, NETLINK_GENERIC)) {
log_error("ipoe: cannot open generic netlink socket\n");
return -1;
}
-
+
nlh = &req.n;
nlh->nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN);
nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
@@ -510,7 +510,7 @@ int ipoe_nl_add_vlan_mon_vid(int ifindex, int vid)
log_error("ipoe: nl_add_vlan_mon_vid: error talking to kernel\n");
r = -1;
}
-
+
rtnl_close(&rth);
return r;
@@ -525,7 +525,7 @@ int ipoe_nl_del_vlan_mon(int ifindex)
struct nlmsghdr n;
char buf[1024];
} req;
-
+
if (rth.fd == -1)
return -1;
@@ -575,7 +575,7 @@ static void ipoe_up_handler(const struct sockaddr_nl *addr, struct nlmsghdr *h)
break;
parse_rtattr_nested(tb2, IPOE_ATTR_MAX, tb[i]);
-
+
if (!tb2[IPOE_ATTR_ETH_HDR] || !tb2[IPOE_ATTR_IP_HDR] || !tb2[IPOE_ATTR_IFINDEX])
continue;
@@ -612,7 +612,7 @@ static void ipoe_vlan_mon_handler(const struct sockaddr_nl *addr, struct nlmsghd
break;
parse_rtattr_nested(tb2, IPOE_ATTR_MAX, tb[i]);
-
+
if (!tb2[IPOE_ATTR_IFINDEX] || !tb2[IPOE_ATTR_ADDR])
continue;
@@ -657,7 +657,7 @@ static int ipoe_mc_read(struct triton_md_handler_t *h)
continue;
return 0;
}
-
+
if (status == 0) {
log_error("ipoe: EOF on netlink\n");
return 0;
@@ -728,13 +728,13 @@ static void init(void)
rth.fd = -1;
return;
}
-
+
if (rtnl_open_byproto(&rth, 1 << (mcg_id - 1), NETLINK_GENERIC)) {
log_error("ipoe: cannot open generic netlink socket\n");
rth.fd = -1;
return;
}
-
+
fcntl(rth.fd, F_SETFL, O_NONBLOCK);
fcntl(rth.fd, F_SETFD, fcntl(rth.fd, F_GETFD) | FD_CLOEXEC);
diff --git a/accel-pppd/ctrl/ipoe/lua.c b/accel-pppd/ctrl/ipoe/lua.c
index 46c8594..abc3d0d 100644
--- a/accel-pppd/ctrl/ipoe/lua.c
+++ b/accel-pppd/ctrl/ipoe/lua.c
@@ -70,7 +70,7 @@ static int packet4_hdr(lua_State *L)
if (!ses || !ses->dhcpv4_request)
return 0;
-
+
if (!strcmp(name, "xid"))
lua_pushinteger(L, ses->dhcpv4_request->hdr->xid);
else if (!strcmp(name, "ciaddr")) {
@@ -95,9 +95,9 @@ static int packet4_ifname(lua_State *L)
if (!ses)
return 0;
-
+
lua_pushstring(L, ses->serv->ifname);
-
+
return 1;
}
@@ -129,7 +129,7 @@ static int packet4_options(lua_State *L)
if (!ses || !ses->dhcpv4_request)
return 0;
-
+
lua_newtable(L);
list_for_each_entry(opt, &ses->dhcpv4_request->options, entry) {
@@ -146,12 +146,12 @@ static int packet4_agent_circuit_id(lua_State *L)
if (!ses || !ses->dhcpv4_request)
return 0;
-
+
if (ses->agent_circuit_id)
lua_pushlstring(L, (char *)(ses->agent_circuit_id + 1), *ses->agent_circuit_id);
else
lua_pushnil(L);
-
+
return 1;
}
@@ -161,12 +161,12 @@ static int packet4_agent_remote_id(lua_State *L)
if (!ses || !ses->dhcpv4_request)
return 0;
-
+
if (ses->agent_remote_id)
lua_pushlstring(L, (char *)(ses->agent_remote_id + 1), *ses->agent_remote_id);
else
lua_pushnil(L);
-
+
return 1;
}
@@ -264,7 +264,7 @@ char *ipoe_lua_get_username(struct ipoe_session *ses, const char *func)
lua_settop(L, 0);
return r;
-
+
out_err:
file_error = 1;
lua_close(L);
diff --git a/accel-pppd/ctrl/ipoe/lua_lpack.c b/accel-pppd/ctrl/ipoe/lua_lpack.c
index 0dc3046..feb0a5a 100644
--- a/accel-pppd/ctrl/ipoe/lua_lpack.c
+++ b/accel-pppd/ctrl/ipoe/lua_lpack.c
@@ -109,7 +109,7 @@ static int l_unpack(lua_State *L) /** unpack(s,f,[init]) */
{
int c=*f++;
int N=1;
- if (isdigit(*f))
+ if (isdigit(*f))
{
N=0;
while (isdigit(*f)) N=10*N+(*f++)-'0';
@@ -204,7 +204,7 @@ static int l_pack(lua_State *L) /** pack(f,...) */
{
int c=*f++;
int N=1;
- if (isdigit(*f))
+ if (isdigit(*f))
{
N=0;
while (isdigit(*f)) N=10*N+(*f++)-'0';
diff --git a/accel-pppd/ctrl/l2tp/dict.c b/accel-pppd/ctrl/l2tp/dict.c
index f145449..b636c87 100644
--- a/accel-pppd/ctrl/l2tp/dict.c
+++ b/accel-pppd/ctrl/l2tp/dict.c
@@ -70,7 +70,7 @@ const struct l2tp_dict_value_t *l2tp_dict_find_value(const struct l2tp_dict_attr
static char *skip_word(char *ptr)
{
for(; *ptr; ptr++)
- if (*ptr == ' ' || *ptr == '\t' || *ptr == '\n')
+ if (*ptr == ' ' || *ptr == '\t' || *ptr == '\n')
break;
return ptr;
}
@@ -91,9 +91,9 @@ static int split(char *buf, char **ptr)
buf = skip_word(buf);
if (!*buf)
return i;
-
+
*buf = 0;
-
+
buf = skip_space(buf + 1);
if (!*buf)
return i;
@@ -153,12 +153,12 @@ static int dict_load(const char *fname)
} else if (!strcmp(buf, "ATTRIBUTE")) {
if (r < 3)
goto out_syntax;
-
+
attr = malloc(sizeof(*attr));
memset(attr, 0, sizeof(*attr));
list_add_tail(&attr->entry, items);
INIT_LIST_HEAD(&attr->values);
-
+
attr->name = strdup(ptr[0]);
attr->id = strtol(ptr[1], &endptr, 10);
if (*endptr != 0)
@@ -197,7 +197,7 @@ static int dict_load(const char *fname)
} else if (!strcmp(buf, "VALUE")) {
if (r != 3)
goto out_syntax;
-
+
attr = l2tp_dict_find_attr_by_name(ptr[0]);
if (!attr) {
log_emerg("l2tp:%s:%i: attribute not found\n", fname, n);
diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c
index 2a52d69..befe0c9 100644
--- a/accel-pppd/ctrl/l2tp/l2tp.c
+++ b/accel-pppd/ctrl/l2tp/l2tp.c
@@ -4552,7 +4552,7 @@ static int start_udp_server(void)
err_hnd:
triton_md_unregister_handler(&udp_serv.hnd, 1);
triton_context_unregister(&udp_serv.ctx);
-
+
return -1;
err_fd:
@@ -4888,7 +4888,7 @@ static void load_config(void)
opt = conf_get_opt("l2tp", "dir300_quirk");
if (opt)
conf_dir300_quirk = atoi(opt);
-
+
conf_mppe = MPPE_UNSET;
opt = conf_get_opt("l2tp", "mppe");
if (opt) {
diff --git a/accel-pppd/ctrl/l2tp/netlink.c b/accel-pppd/ctrl/l2tp/netlink.c
index c8dce89..3de6e06 100644
--- a/accel-pppd/ctrl/l2tp/netlink.c
+++ b/accel-pppd/ctrl/l2tp/netlink.c
@@ -11,7 +11,7 @@ void l2tp_nl_delete_tunnel(int tid)
{
struct nl_sock *nl_sock;
struct nl_msg *msg;
-
+
nl_sock = nl_socket_alloc();
msg = nlmsg_alloc();
@@ -32,10 +32,10 @@ void l2tp_nl_create_tunnel(int fd, int tid, int peer_tid)
{
struct nl_sock *nl_sock;
struct nl_msg *msg;
-
+
nl_sock = nl_socket_alloc();
msg = nlmsg_alloc();
-
+
genl_connect(nl_sock);
genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, family, 0, NLM_F_REQUEST, L2TP_CMD_TUNNEL_CREATE, L2TP_GENL_VERSION);
@@ -58,10 +58,10 @@ void l2tp_nl_create_session(int tid, int sid, int peer_sid)
{
struct nl_sock *nl_sock;
struct nl_msg *msg;
-
+
nl_sock = nl_socket_alloc();
msg = nlmsg_alloc();
-
+
genl_connect(nl_sock);
genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, family, 0, NLM_F_REQUEST, L2TP_CMD_SESSION_CREATE, L2TP_GENL_VERSION);
@@ -83,11 +83,11 @@ void l2tp_nl_create_session(int tid, int sid, int peer_sid)
static void init(void)
{
struct nl_sock *nl_sock = nl_socket_alloc();
-
+
genl_connect(nl_sock);
family = genl_ctrl_resolve(nl_sock, L2TP_GENL_NAME);
-
+
nl_close(nl_sock);
nl_socket_free(nl_sock);
}
diff --git a/accel-pppd/ctrl/l2tp/packet.c b/accel-pppd/ctrl/l2tp/packet.c
index 78e0789..34e4bb6 100644
--- a/accel-pppd/ctrl/l2tp/packet.c
+++ b/accel-pppd/ctrl/l2tp/packet.c
@@ -69,7 +69,7 @@ struct l2tp_packet_t *l2tp_packet_alloc(int ver, int msg_type,
struct l2tp_packet_t *pack = mempool_alloc(pack_pool);
if (!pack)
return NULL;
-
+
memset(pack, 0, sizeof(*pack));
INIT_LIST_HEAD(&pack->attrs);
pack->hdr.ver = ver;
@@ -250,16 +250,16 @@ int l2tp_recv(int fd, struct l2tp_packet_t **p, struct in_pktinfo *pkt_info,
memset(&msg, 0, sizeof(msg));
msg.msg_control = msg_control;
msg.msg_controllen = 128;
-
+
n = recvmsg(fd, &msg, MSG_PEEK);
-
+
if (n < 0) {
if (errno == EAGAIN)
return -1;
log_error("l2tp: recvmsg: %s\n", strerror(errno));
return 0;
}
-
+
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
if (cmsg->cmsg_level == IPPROTO_IP && cmsg->cmsg_type == IP_PKTINFO) {
memcpy(pkt_info, CMSG_DATA(cmsg), sizeof(*pkt_info));
diff --git a/accel-pppd/ctrl/pppoe/cli.c b/accel-pppd/ctrl/pppoe/cli.c
index ad577c1..c79a5f1 100644
--- a/accel-pppd/ctrl/pppoe/cli.c
+++ b/accel-pppd/ctrl/pppoe/cli.c
@@ -77,7 +77,7 @@ static int intf_exec(const char *cmd, char * const *fields, int fields_cnt, void
pppoe_server_stop(fields[3]);
else
goto help;
-
+
return CLI_CMD_OK;
help:
intf_help(fields, fields_cnt, client);
@@ -149,9 +149,9 @@ static int show_verbose_exec(const char *cmd, char * const *f, int f_cnt, void *
{
if (f_cnt != 3)
return CLI_CMD_SYNTAX;
-
+
cli_sendv(cli, "%i\r\n", conf_verbose);
-
+
return CLI_CMD_OK;
}
@@ -159,9 +159,9 @@ static int show_pado_delay_exec(const char *cmd, char * const *f, int f_cnt, voi
{
if (f_cnt != 3)
return CLI_CMD_SYNTAX;
-
+
cli_sendv(cli, "%s\r\n", conf_pado_delay);
-
+
return CLI_CMD_OK;
}
@@ -169,12 +169,12 @@ static int show_service_name_exec(const char *cmd, char * const *f, int f_cnt, v
{
if (f_cnt != 3)
return CLI_CMD_SYNTAX;
-
+
if (conf_service_name)
cli_sendv(cli, "%s\r\n", conf_service_name);
else
cli_sendv(cli, "*\r\n");
-
+
return CLI_CMD_OK;
}
@@ -182,9 +182,9 @@ static int show_ac_name_exec(const char *cmd, char * const *f, int f_cnt, void *
{
if (f_cnt != 3)
return CLI_CMD_SYNTAX;
-
+
cli_sendv(cli, "%s\r\n", conf_ac_name);
-
+
return CLI_CMD_OK;
}
@@ -192,14 +192,14 @@ static int set_verbose_exec(const char *cmd, char * const *f, int f_cnt, void *c
{
if (f_cnt != 4)
return CLI_CMD_SYNTAX;
-
+
if (!strcmp(f[3], "0"))
conf_verbose = 0;
else if (!strcmp(f[3], "1"))
conf_verbose = 1;
else
return CLI_CMD_INVAL;
-
+
return CLI_CMD_OK;
}
@@ -218,7 +218,7 @@ static int set_service_name_exec(const char *cmd, char * const *f, int f_cnt, vo
{
if (f_cnt != 4)
return CLI_CMD_SYNTAX;
-
+
if (conf_service_name)
_free(conf_service_name);
@@ -226,7 +226,7 @@ static int set_service_name_exec(const char *cmd, char * const *f, int f_cnt, vo
conf_service_name = NULL;
else
conf_service_name = _strdup(f[3]);
-
+
return CLI_CMD_OK;
}
@@ -234,10 +234,10 @@ static int set_ac_name_exec(const char *cmd, char * const *f, int f_cnt, void *c
{
if (f_cnt != 4)
return CLI_CMD_SYNTAX;
-
+
_free(conf_ac_name);
conf_ac_name = _strdup(f[3]);
-
+
return CLI_CMD_OK;
}
//===================================
diff --git a/accel-pppd/ctrl/pppoe/dpado.c b/accel-pppd/ctrl/pppoe/dpado.c
index 3f56519..c7992bc 100644
--- a/accel-pppd/ctrl/pppoe/dpado.c
+++ b/accel-pppd/ctrl/pppoe/dpado.c
@@ -37,7 +37,7 @@ void dpado_check_next(int conn_cnt)
dpado_range_next = list_entry(dpado_range_next->entry.next, typeof(*dpado_range_next), entry);
else
dpado_range_next = NULL;
- /*printf("active=%i, prev=%i:%i, next=%i:%i, pado_delay=%i\n", stat_active,
+ /*printf("active=%i, prev=%i:%i, next=%i:%i, pado_delay=%i\n", stat_active,
dpado_range_prev?dpado_range_prev->pado_delay:0,dpado_range_prev?dpado_range_prev->conn_cnt:0,
dpado_range_next?dpado_range_next->pado_delay:0,dpado_range_next?dpado_range_next->conn_cnt:0,
pado_delay);*/
@@ -52,7 +52,7 @@ void dpado_check_prev(int conn_cnt)
dpado_range_next = dpado_range_prev;
dpado_range_prev = list_entry(dpado_range_prev->entry.prev, typeof(*dpado_range_prev), entry);
pado_delay = dpado_range_prev->pado_delay;
- /*printf("active=%i, prev=%i:%i, next=%i:%i, pado_delay=%i\n", stat_active,
+ /*printf("active=%i, prev=%i:%i, next=%i:%i, pado_delay=%i\n", stat_active,
dpado_range_prev?dpado_range_prev->pado_delay:0,dpado_range_prev?dpado_range_prev->conn_cnt:0,
dpado_range_next?dpado_range_next->pado_delay:0,dpado_range_next?dpado_range_next->conn_cnt:0,
pado_delay);*/
@@ -144,7 +144,7 @@ int dpado_parse(const char *str)
if (conf_pado_delay)
_free(conf_pado_delay);
conf_pado_delay = _strdup(str);
- /*printf("active=%i, prev=%i:%i, next=%i:%i, pado_delay=%i\n", stat_active,
+ /*printf("active=%i, prev=%i:%i, next=%i:%i, pado_delay=%i\n", stat_active,
dpado_range_prev?dpado_range_prev->pado_delay:0,dpado_range_prev?dpado_range_prev->conn_cnt:0,
dpado_range_next?dpado_range_next->pado_delay:0,dpado_range_next?dpado_range_next->conn_cnt:0,
pado_delay);*/
diff --git a/accel-pppd/ctrl/pppoe/mac_filter.c b/accel-pppd/ctrl/pppoe/mac_filter.c
index b55cbf2..d1e104e 100644
--- a/accel-pppd/ctrl/pppoe/mac_filter.c
+++ b/accel-pppd/ctrl/pppoe/mac_filter.c
@@ -73,7 +73,7 @@ static int mac_filter_load(const char *opt)
log_emerg("pppoe: open '%s': %s\n", name, strerror(errno));
goto err;
}
-
+
conf_mac_filter = opt;
pthread_rwlock_wrlock(&lock);
@@ -274,7 +274,7 @@ static void init(void)
const char *opt = conf_get_opt("pppoe", "mac-filter");
if (!opt || mac_filter_load(opt))
type = -1;
-
+
cli_register_simple_cmd2(cmd_exec, cmd_help, 2, "pppoe", "mac-filter");
}
diff --git a/accel-pppd/ctrl/pppoe/pppoe.c b/accel-pppd/ctrl/pppoe/pppoe.c
index 5037f5a..12c274b 100644
--- a/accel-pppd/ctrl/pppoe/pppoe.c
+++ b/accel-pppd/ctrl/pppoe/pppoe.c
@@ -49,7 +49,7 @@ struct pppoe_conn_t {
struct pppoe_tag *service_name;
struct pppoe_tag *tr101;
uint8_t cookie[COOKIE_LENGTH - 4];
-
+
struct ap_ctrl ctrl;
struct ppp_t ppp;
#ifdef RADIUS
@@ -153,7 +153,7 @@ static void disconnect(struct pppoe_conn_t *conn)
pppoe_server_free(conn->serv);
} else
pthread_mutex_unlock(&conn->serv->lock);
-
+
pthread_mutex_lock(&sid_lock);
sid_map[conn->sid/(8*sizeof(long))] |= 1 << (conn->sid % (8*sizeof(long)));
pthread_mutex_unlock(&sid_lock);
@@ -209,7 +209,7 @@ static int pppoe_rad_send_access_request(struct rad_plugin_t *rad, struct rad_pa
if (conn->tr101)
return tr101_send_access_request(conn->tr101, pack);
-
+
return 0;
}
@@ -219,11 +219,11 @@ static int pppoe_rad_send_accounting_request(struct rad_plugin_t *rad, struct ra
if (conn->tr101)
return tr101_send_accounting_request(conn->tr101, pack);
-
+
return 0;
}
#endif
-
+
static struct pppoe_conn_t *allocate_channel(struct pppoe_serv_t *serv, const uint8_t *addr, const struct pppoe_tag *host_uniq, const struct pppoe_tag *relay_sid, const struct pppoe_tag *service_name, const struct pppoe_tag *tr101, const uint8_t *cookie)
{
struct pppoe_conn_t *conn;
@@ -241,18 +241,18 @@ static struct pppoe_conn_t *allocate_channel(struct pppoe_serv_t *serv, const ui
old_sid_ptr = sid_ptr;
while (1) {
int bit = ffsl(*sid_ptr) - 1;
-
+
if (bit != -1) {
conn->sid = sid_idx*8*sizeof(long) + bit;
*sid_ptr &= ~(1lu << bit);
}
-
+
if (++sid_idx == SID_MAX/8/sizeof(long)) {
sid_ptr = sid_map;
sid_idx = 0;
} else
sid_ptr++;
-
+
if (bit != -1)
break;
@@ -349,7 +349,7 @@ static struct pppoe_conn_t *allocate_channel(struct pppoe_serv_t *serv, const ui
else
sprintf(conn->ctrl.calling_station_id, "%02x:%02x:%02x:%02x:%02x:%02x",
addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
-
+
ppp_init(&conn->ppp);
conn->ppp.ses.ctrl = &conn->ctrl;
@@ -357,16 +357,16 @@ static struct pppoe_conn_t *allocate_channel(struct pppoe_serv_t *serv, const ui
if (conf_ip_pool)
conn->ppp.ses.ipv4_pool_name = _strdup(conf_ip_pool);
-
+
conn->disc_sock = dup(serv->hnd.fd);
-
+
triton_context_register(&conn->ctx, &conn->ppp.ses);
pthread_mutex_lock(&serv->lock);
list_add_tail(&conn->entry, &serv->conn_list);
serv->conn_cnt++;
pthread_mutex_unlock(&serv->lock);
-
+
return conn;
}
@@ -374,7 +374,7 @@ static void connect_channel(struct pppoe_conn_t *conn)
{
int sock;
struct sockaddr_pppox sp;
-
+
triton_event_fire(EV_CTRL_STARTING, &conn->ppp.ses);
triton_event_fire(EV_CTRL_STARTED, &conn->ppp.ses);
@@ -383,7 +383,7 @@ static void connect_channel(struct pppoe_conn_t *conn)
log_error("pppoe: socket(PPPOX): %s\n", strerror(errno));
goto out_err;
}
-
+
fcntl(sock, F_SETFD, fcntl(sock, F_GETFD) | FD_CLOEXEC);
memset(&sp, 0, sizeof(sp));
@@ -403,7 +403,7 @@ static void connect_channel(struct pppoe_conn_t *conn)
if (establish_ppp(&conn->ppp))
goto out_err_close;
-
+
#ifdef RADIUS
if (conn->tr101 && triton_module_loaded("radius")) {
conn->radius.send_access_request = pppoe_rad_send_access_request;
@@ -413,9 +413,9 @@ static void connect_channel(struct pppoe_conn_t *conn)
#endif
conn->ppp_started = 1;
-
+
dpado_check_next(__sync_add_and_fetch(&stat_active, 1));
-
+
return;
out_err_close:
@@ -478,8 +478,8 @@ static void print_packet(uint8_t *pack)
log_info2("PADT");
break;
}
-
- log_info2(" %02x:%02x:%02x:%02x:%02x:%02x => %02x:%02x:%02x:%02x:%02x:%02x",
+
+ log_info2(" %02x:%02x:%02x:%02x:%02x:%02x => %02x:%02x:%02x:%02x:%02x:%02x",
ethhdr->h_source[0], ethhdr->h_source[1], ethhdr->h_source[2], ethhdr->h_source[3], ethhdr->h_source[4], ethhdr->h_source[5],
ethhdr->h_dest[0], ethhdr->h_dest[1], ethhdr->h_dest[2], ethhdr->h_dest[3], ethhdr->h_dest[4], ethhdr->h_dest[5]);
@@ -577,7 +577,7 @@ static void generate_cookie(struct pppoe_serv_t *serv, const uint8_t *src, uint8
u1.raw[16 + i] = buf[i] ^ buf[i + 4] ^ buf[i + 8] ^ buf[i + 12];
} else
memset(u1.raw + 16, 0, 4);
-
+
*(uint32_t *)(u1.raw + 20) = ts.tv_sec + conf_cookie_timeout;
for (i = 0; i < 3; i++)
@@ -585,7 +585,7 @@ static void generate_cookie(struct pppoe_serv_t *serv, const uint8_t *src, uint8
for (i = 0; i < 3; i++)
DES_ecb_encrypt(&u2.b[i], &u1.b[i], &serv->des_ks, DES_ENCRYPT);
-
+
memcpy(cookie, u1.raw, 24);
}
@@ -593,7 +593,7 @@ static int check_cookie(struct pppoe_serv_t *serv, const uint8_t *src, const uin
{
MD5_CTX ctx;
DES_cblock key;
- DES_key_schedule ks;
+ DES_key_schedule ks;
int i;
union {
DES_cblock b[3];
@@ -602,7 +602,7 @@ static int check_cookie(struct pppoe_serv_t *serv, const uint8_t *src, const uin
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
-
+
memcpy(key, serv->hwaddr, 6);
key[6] = src[4];
key[7] = src[5];
@@ -612,13 +612,13 @@ static int check_cookie(struct pppoe_serv_t *serv, const uint8_t *src, const uin
for (i = 0; i < 3; i++)
DES_ecb_encrypt(&u1.b[i], &u2.b[i], &serv->des_ks, DES_DECRYPT);
-
+
for (i = 0; i < 3; i++)
DES_ecb_encrypt(&u2.b[i], &u1.b[i], &ks, DES_DECRYPT);
-
+
if (*(uint32_t *)(u1.raw + 20) < ts.tv_sec)
return 1;
-
+
MD5_Init(&ctx);
MD5_Update(&ctx, serv->secret, SECRET_LENGTH);
MD5_Update(&ctx, serv->hwaddr, ETH_ALEN);
@@ -664,7 +664,7 @@ static void add_tag2(uint8_t *pack, const struct pppoe_tag *t)
struct pppoe_tag *tag = (struct pppoe_tag *)(pack + ETH_HLEN + sizeof(*hdr) + ntohs(hdr->length));
memcpy(tag, t, sizeof(*t) + ntohs(t->tag_len));
-
+
hdr->length = htons(ntohs(hdr->length) + sizeof(*tag) + ntohs(t->tag_len));
}
@@ -695,14 +695,14 @@ static void pppoe_send_PADO(struct pppoe_serv_t *serv, const uint8_t *addr, cons
if (service_name)
add_tag2(pack, service_name);
-
+
generate_cookie(serv, addr, cookie, host_uniq, relay_sid);
add_tag(pack, TAG_AC_COOKIE, cookie, COOKIE_LENGTH);
if (host_uniq)
add_tag2(pack, host_uniq);
-
+
if (relay_sid)
add_tag2(pack, relay_sid);
@@ -726,7 +726,7 @@ static void pppoe_send_err(struct pppoe_serv_t *serv, const uint8_t *addr, const
if (host_uniq)
add_tag2(pack, host_uniq);
-
+
if (relay_sid)
add_tag2(pack, relay_sid);
@@ -745,12 +745,12 @@ static void pppoe_send_PADS(struct pppoe_conn_t *conn)
setup_header(pack, conn->serv->hwaddr, conn->addr, CODE_PADS, conn->sid);
add_tag(pack, TAG_AC_NAME, (uint8_t *)conf_ac_name, strlen(conf_ac_name));
-
+
add_tag2(pack, conn->service_name);
if (conn->host_uniq)
add_tag2(pack, conn->host_uniq);
-
+
if (conn->relay_sid)
add_tag2(pack, conn->relay_sid);
@@ -831,13 +831,13 @@ static int check_padi_limit(struct pppoe_serv_t *serv, uint8_t *addr)
} else
break;
}
-
+
if (serv->padi_cnt == serv->padi_limit)
return -1;
-
+
if (conf_padi_limit && total_padi_cnt >= conf_padi_limit)
return -1;
-
+
list_for_each_entry(padi, &serv->padi_list, entry) {
if (memcmp(padi->addr, addr, ETH_ALEN) == 0)
return -1;
@@ -846,7 +846,7 @@ static int check_padi_limit(struct pppoe_serv_t *serv, uint8_t *addr)
padi = mempool_alloc(padi_pool);
if (!padi)
return -1;
-
+
padi->ts = ts;
memcpy(padi->addr, addr, ETH_ALEN);
list_add_tail(&padi->entry, &serv->padi_list);
@@ -990,13 +990,13 @@ static void pppoe_recv_PADR(struct pppoe_serv_t *serv, uint8_t *pack, int size)
if (ap_shutdown)
return;
-
+
if (!memcmp(ethhdr->h_dest, bc_addr, ETH_ALEN)) {
if (conf_verbose)
log_warn("pppoe: discard PADR (destination address is broadcast)\n");
return;
}
-
+
if (hdr->sid) {
if (conf_verbose)
log_warn("pppoe: discarding PADR packet (sid is not zero)\n");
@@ -1007,7 +1007,7 @@ static void pppoe_recv_PADR(struct pppoe_serv_t *serv, uint8_t *pack, int size)
log_info2("recv ");
print_packet(pack);
}
-
+
for (n = 0; n < ntohs(hdr->length); n += sizeof(*tag) + ntohs(tag->tag_len)) {
tag = (struct pppoe_tag *)(pack + ETH_HLEN + sizeof(*hdr) + n);
@@ -1110,13 +1110,13 @@ static void pppoe_recv_PADT(struct pppoe_serv_t *serv, uint8_t *pack)
struct pppoe_hdr *hdr = (struct pppoe_hdr *)(pack + ETH_HLEN);
struct pppoe_conn_t *conn;
uint16_t sid = ntohs(hdr->sid);
-
+
if (!memcmp(ethhdr->h_dest, bc_addr, ETH_ALEN)) {
if (conf_verbose)
log_warn("pppoe: discard PADT (destination address is broadcast)\n");
return;
}
-
+
if (conf_verbose) {
log_info2("recv ");
print_packet(pack);
@@ -1191,7 +1191,7 @@ static int pppoe_serv_read(struct triton_md_handler_t *h)
log_warn("pppoe: discarding packet (unsupported version %i)\n", hdr->ver);
continue;
}
-
+
if (hdr->type != 1) {
if (conf_verbose)
log_warn("pppoe: discarding packet (unsupported type %i)\n", hdr->type);
@@ -1266,13 +1266,13 @@ static void pppoe_add_interface_re(const char *opt, void *cli)
struct iplink_arg arg;
for (ptr = opt; *ptr && *ptr != ','; ptr++);
-
+
pattern = _malloc(ptr - (opt + 3) + 1);
memcpy(pattern, opt + 3, ptr - (opt + 3));
pattern[ptr - (opt + 3)] = 0;
-
+
re = pcre_compile2(pattern, 0, NULL, &pcre_err, &pcre_offset, NULL);
-
+
if (!re) {
log_error("pppoe: %s at %i\r\n", pcre_err, pcre_offset);
return;
@@ -1352,7 +1352,7 @@ static void __pppoe_server_start(const char *ifname, const char *opt, void *cli)
_free(serv);
return;
}
-
+
fcntl(sock, F_SETFD, fcntl(sock, F_GETFD) | FD_CLOEXEC);
if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &f, sizeof(f))) {
@@ -1398,7 +1398,7 @@ static void __pppoe_server_start(const char *ifname, const char *opt, void *cli)
cli_sendv(cli, "interface %s has MTU of %i, should be %i\r\n", ifname, ifr.ifr_mtu, ETH_DATA_LEN);
log_error("pppoe: interface %s has MTU of %i, should be %i\n", ifname, ifr.ifr_mtu, ETH_DATA_LEN);
}
-
+
if (ioctl(sock, SIOCGIFINDEX, &ifr)) {
if (cli)
cli_sendv(cli, "ioctl(SIOCGIFINDEX): %s\r\n", strerror(errno));
@@ -1464,7 +1464,7 @@ static void _server_stop(struct pppoe_serv_t *serv)
if (serv->stopping)
return;
-
+
serv->stopping = 1;
triton_md_disable_handler(&serv->hnd, MD_MODE_READ | MD_MODE_WRITE);
@@ -1578,11 +1578,11 @@ static void load_config(void)
opt = conf_get_opt("pppoe", "PADO-Delay");
if (opt)
dpado_parse(opt);
-
+
opt = conf_get_opt("pppoe", "tr101");
if (opt)
conf_tr101 = atoi(opt);
-
+
opt = conf_get_opt("pppoe", "padi-limit");
if (opt)
conf_padi_limit = atoi(opt);
@@ -1590,7 +1590,7 @@ static void load_config(void)
opt = conf_get_opt("pppoe", "sid-uppercase");
if (opt)
conf_sid_uppercase = atoi(opt);
-
+
opt = conf_get_opt("pppoe", "cookie-timeout");
if (opt)
conf_cookie_timeout = atoi(opt);
@@ -1665,7 +1665,7 @@ static void pppoe_init(void)
log_error("pppoe: no configuration, disabled...\n");
return;
}
-
+
load_config();
connlimit_loaded = triton_module_loaded("connlimit");
diff --git a/accel-pppd/ctrl/pptp/pptp.c b/accel-pppd/ctrl/pptp/pptp.c
index 19deb3d..94cfd7f 100644
--- a/accel-pppd/ctrl/pptp/pptp.c
+++ b/accel-pppd/ctrl/pptp/pptp.c
@@ -78,7 +78,7 @@ static void disconnect(struct pptp_conn_t *conn)
log_ppp_debug("pptp: disconnect\n");
triton_md_unregister_handler(&conn->hnd, 1);
-
+
if (conn->timeout_timer.tpd)
triton_timer_del(&conn->timeout_timer);
@@ -93,14 +93,14 @@ static void disconnect(struct pptp_conn_t *conn)
__sync_sub_and_fetch(&stat_starting, 1);
triton_event_fire(EV_CTRL_FINISHED, &conn->ppp.ses);
-
+
log_ppp_info1("disconnected\n");
triton_context_unregister(&conn->ctx);
if (conn->ppp.ses.chan_name)
_free(conn->ppp.ses.chan_name);
-
+
_free(conn->in_buf);
_free(conn->out_buf);
_free(conn->ctrl.calling_station_id);
@@ -178,7 +178,7 @@ static int pptp_stop_ctrl_conn_rqst(struct pptp_conn_t *conn)
}
static int pptp_stop_ctrl_conn_rply(struct pptp_conn_t *conn)
-{
+{
struct pptp_stop_ctrl_conn *msg = (struct pptp_stop_ctrl_conn*)conn->in_buf;
if (conf_verbose)
log_ppp_info2("recv [PPTP Stop-Ctrl-Conn-Reply <Result %i> <Error %i>]\n", msg->reason_result, msg->error_code);
@@ -342,7 +342,7 @@ static int pptp_out_call_rqst(struct pptp_conn_t *conn)
conn->state = STATE_PPP;
__sync_sub_and_fetch(&stat_starting, 1);
__sync_add_and_fetch(&stat_active, 1);
-
+
if (conn->timeout_timer.tpd)
triton_timer_del(&conn->timeout_timer);
@@ -366,7 +366,7 @@ static int send_pptp_call_disconnect_notify(struct pptp_conn_t *conn, int result
if (conf_verbose)
log_ppp_info2("send [PPTP Call-Disconnect-Notify <Call-ID %x> <Result %i> <Error %i> <Cause %i>]\n", ntohs(msg.call_id), msg.result_code, msg.error_code, msg.cause_code);
-
+
return post_msg(conn, &msg, sizeof(msg));
}
@@ -409,7 +409,7 @@ static int pptp_echo_rqst(struct pptp_conn_t *conn)
static int pptp_echo_rply(struct pptp_conn_t *conn)
{
struct pptp_echo_rply *msg = (struct pptp_echo_rply *)conn->in_buf;
-
+
if (conf_verbose)
log_ppp_debug("recv [PPTP Echo-Reply <Identifier %x>]\n", msg->identifier);
@@ -678,13 +678,13 @@ static int pptp_connect(struct triton_md_handler_t *h)
conn->ctrl.ppp = 1;
conn->ctrl.name = "pptp";
conn->ctrl.mppe = conf_mppe;
-
+
conn->ctrl.calling_station_id = _malloc(17);
conn->ctrl.called_station_id = _malloc(17);
u_inet_ntoa(addr.sin_addr.s_addr, conn->ctrl.calling_station_id);
getsockname(sock, &addr, &size);
u_inet_ntoa(addr.sin_addr.s_addr, conn->ctrl.called_station_id);
-
+
ppp_init(&conn->ppp);
conn->ppp.ses.ctrl = &conn->ctrl;
@@ -739,7 +739,7 @@ static void load_config(void)
opt = conf_get_opt("pptp", "timeout");
if (opt && atoi(opt) > 0)
conf_timeout = atoi(opt);
-
+
opt = conf_get_opt("pptp", "echo-interval");
if (opt && atoi(opt) >= 0)
conf_echo_interval = atoi(opt);
@@ -787,7 +787,7 @@ static void pptp_init(void)
}
fcntl(serv.hnd.fd, F_SETFD, fcntl(serv.hnd.fd, F_GETFD) | FD_CLOEXEC);
-
+
addr.sin_family = AF_INET;
opt = conf_get_opt("pptp", "bind");
@@ -801,8 +801,8 @@ static void pptp_init(void)
addr.sin_port = htons(atoi(opt));
else
addr.sin_port = htons(PPTP_PORT);
-
- setsockopt(serv.hnd.fd, SOL_SOCKET, SO_REUSEADDR, &serv.hnd.fd, 4);
+
+ setsockopt(serv.hnd.fd, SOL_SOCKET, SO_REUSEADDR, &serv.hnd.fd, 4);
if (bind (serv.hnd.fd, (struct sockaddr *) &addr, sizeof (addr)) < 0) {
log_emerg("pptp: failed to bind socket: %s\n", strerror(errno));
close(serv.hnd.fd);
@@ -820,7 +820,7 @@ static void pptp_init(void)
close(serv.hnd.fd);
return;
}
-
+
conn_pool = mempool_create(sizeof(struct pptp_conn_t));
load_config();
@@ -831,7 +831,7 @@ static void pptp_init(void)
triton_context_wakeup(&serv.ctx);
cli_register_simple_cmd2(show_stat_exec, NULL, 2, "show", "stat");
-
+
triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config);
}