mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-08 16:11:18 +00:00
add real life testing for PPPoE and VLANs
This commit is contained in:
1 parent
ba2abbc444
commit
9448625662
9 files changed
+251
-50
No files matched your search
+13
-14
@@ -366,10 +366,10 @@ static void ppp_handle_ipv6cp(struct mg_tcpip_if *ifp, uint8_t *ipv6cpp,
|
||||
find_opt(
|
||||
MG_PPP_IPV6CP_OPT_IFCID, 10, (const uint8_t *) (ipv6cp + 1),
|
||||
len - sizeof(*ipv6cp),
|
||||
(uint8_t *) &((struct mg_l2addr *) (ifp->gwmac))->addr.ieee64)) {
|
||||
if (((struct mg_l2addr *) (ifp->gwmac))->addr.ieee64 != 0) {
|
||||
(uint8_t *) &((struct mg_l2addr *) (ifp->gw6mac))->addr.ieee64)) {
|
||||
if (((struct mg_l2addr *) (ifp->gw6mac))->addr.ieee64 != 0) {
|
||||
MG_DEBUG(("IPV6CP cfg, GW IFCID: %M", mg_print_ieee64,
|
||||
&((struct mg_l2addr *) (ifp->gwmac))->addr.ieee64));
|
||||
&((struct mg_l2addr *) (ifp->gw6mac))->addr.ieee64));
|
||||
ipv6cp->code = MG_PPP_IPV6CP_CFG_ACK;
|
||||
ppp_tx_frame(ifp, MG_PPP_PROTO_IPV6CP, ipv6cpp, len);
|
||||
req[1] = id;
|
||||
@@ -393,22 +393,21 @@ static void ppp_handle_ipv6cp(struct mg_tcpip_if *ifp, uint8_t *ipv6cpp,
|
||||
// Our peer accepted our ifc id
|
||||
MG_VERBOSE(("got IPV6CP config ack"));
|
||||
break;
|
||||
case MG_PPP_IPV6CP_CFG_NACK:
|
||||
case MG_PPP_IPV6CP_CFG_NACK: {
|
||||
struct mg_l2addr l2;
|
||||
MG_VERBOSE(("got IPV6CP config nack"));
|
||||
// NACK contains our "suggested" IFC id, use it
|
||||
if (len >= 10 &&
|
||||
find_opt(
|
||||
MG_PPP_IPV6CP_OPT_IFCID, 10, (const uint8_t *) (ipv6cp + 1),
|
||||
len - sizeof(*ipv6cp),
|
||||
(uint8_t *) &((struct mg_l2addr *) (ifp->mac))->addr.ieee64)) {
|
||||
MG_DEBUG(("IPV6CP cfg, IFCID: %M", mg_print_ieee64,
|
||||
&((struct mg_l2addr *) (ifp->mac))->addr.ieee64));
|
||||
find_opt(MG_PPP_IPV6CP_OPT_IFCID, 10, (const uint8_t *) (ipv6cp + 1),
|
||||
len - sizeof(*ipv6cp), (uint8_t *) &l2.addr.ieee64)) {
|
||||
MG_DEBUG(("IPV6CP cfg, IFCID: %M", mg_print_ieee64, &l2.addr.ieee64));
|
||||
ifp->ip6ll[1] = l2.addr.ieee64; // RFC-5072 5, signal L3 we're ready
|
||||
ipv6cp->code = MG_PPP_IPV6CP_CFG_REQ;
|
||||
ppp_tx_frame(ifp, MG_PPP_PROTO_IPV6CP, ipv6cpp, len);
|
||||
} else {
|
||||
MG_ERROR(("Peer is not able to offer an interface id"));
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
case MG_PPP_IPV6CP_CFG_REJECT:
|
||||
MG_ERROR(("Peer rejected our interface id"));
|
||||
break;
|
||||
@@ -573,10 +572,10 @@ bool mg_l2_pppoe_rx(struct mg_tcpip_if *ifp, enum mg_l2proto *proto,
|
||||
uint8_t *p = (uint8_t *) (pppoe + 1);
|
||||
uint16_t taglen;
|
||||
while (len >= 4) { // parse tags for a possible AC-Cookie
|
||||
uint16_t curtag = *((uint16_t *) p);
|
||||
taglen = mg_ntohs(*(((uint16_t *) p) + 1));
|
||||
uint16_t curtag = MG_LOAD_BE16(p);
|
||||
taglen = MG_LOAD_BE16(p + 2);
|
||||
if (taglen > len - 4) return false; // truncated / malformed
|
||||
if (curtag == mg_htons(0x0104)) {
|
||||
if (curtag == 0x0104) {
|
||||
has_cookie = true;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user