diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2013-06-11 23:01:28 +0400 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2013-06-11 23:01:28 +0400 |
commit | 338e86560f0bb991852f977ff5376a2d9fb71b20 (patch) | |
tree | 433992e7dbfae9ffd041a6b0216612b06cdd7855 | |
parent | 23ef56423c127464216d534fe12a206c807a53d1 (diff) | |
download | accel-ppp-338e86560f0bb991852f977ff5376a2d9fb71b20.tar.gz accel-ppp-338e86560f0bb991852f977ff5376a2d9fb71b20.zip |
ipoe: fixed mask calculation for gw-ip-address
ipoe: pass router=siaddr if router was not configured by other way
-rw-r--r-- | accel-pppd/ctrl/ipoe/ipoe.c | 11 | ||||
-rw-r--r-- | accel-pppd/session.c | 2 |
2 files changed, 9 insertions, 4 deletions
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index e9edd9be..ac971c40 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.c +++ b/accel-pppd/ctrl/ipoe/ipoe.c @@ -112,6 +112,7 @@ struct gw_addr { struct list_head entry; in_addr_t addr; int mask; + int mask1; }; static pthread_mutex_t uc_lock = PTHREAD_MUTEX_INITIALIZER; @@ -481,14 +482,11 @@ static void find_gw_addr(struct ipoe_session *ses) struct gw_addr *a; list_for_each_entry(a, &conf_gw_addr, entry) { -#if __BYTE_ORDER == __LITTLE_ENDIAN - if ((ses->yiaddr & ((1<<a->mask) - 1)) == (a->addr & ((1<<a->mask) - 1))) { + if ((ntohl(ses->yiaddr) & (a->mask1)) == (ntohl(a->addr) & (a->mask1))) { ses->siaddr = a->addr; ses->mask = a->mask; return; } -#else -#endif } } @@ -547,6 +545,9 @@ static void __ipoe_session_start(struct ipoe_session *ses) ap_session_terminate(&ses->ses, TERM_NAS_ERROR, 0); return; } + + if (!ses->router) + ses->router = ses->siaddr; if (!ses->mask) ses->mask = 32; @@ -1919,6 +1920,8 @@ static void load_gw_addr(struct conf_sect_t *sect) _free(a); continue; } + + a->mask1 = ((1 << a->mask) - 1) << (32 - a->mask); list_add_tail(&a->entry, &conf_gw_addr); } } diff --git a/accel-pppd/session.c b/accel-pppd/session.c index 380552a7..f60c3802 100644 --- a/accel-pppd/session.c +++ b/accel-pppd/session.c @@ -42,7 +42,9 @@ int __export sock6_fd; int __export urandom_fd; int __export ap_shutdown; +#if __WORDSIZE == 32 static spinlock_t seq_lock; +#endif static long long unsigned seq; static struct timespec seq_ts; |