summaryrefslogtreecommitdiff
path: root/accel-pppd/ctrl/ipoe
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2013-06-11 23:01:28 +0400
committerDmitry Kozlov <xeb@mail.ru>2013-06-11 23:01:28 +0400
commit338e86560f0bb991852f977ff5376a2d9fb71b20 (patch)
tree433992e7dbfae9ffd041a6b0216612b06cdd7855 /accel-pppd/ctrl/ipoe
parent23ef56423c127464216d534fe12a206c807a53d1 (diff)
downloadaccel-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
Diffstat (limited to 'accel-pppd/ctrl/ipoe')
-rw-r--r--accel-pppd/ctrl/ipoe/ipoe.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c
index e9edd9b..ac971c4 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);
}
}