mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-15 19:13:18 +00:00
Merge pull request #2860 from cesanta/l2r
fix ARP resolution when remote host is the gw
This commit is contained in:
2 files changed
+6
-4
No files matched your search
+3
-2
@@ -5117,7 +5117,7 @@ static void onstatechange(struct mg_tcpip_if *ifp) {
|
|||||||
MG_INFO(("READY, IP: %M", mg_print_ip4, &ifp->ip));
|
MG_INFO(("READY, IP: %M", mg_print_ip4, &ifp->ip));
|
||||||
MG_INFO((" GW: %M", mg_print_ip4, &ifp->gw));
|
MG_INFO((" GW: %M", mg_print_ip4, &ifp->gw));
|
||||||
MG_INFO((" MAC: %M", mg_print_mac, &ifp->mac));
|
MG_INFO((" MAC: %M", mg_print_mac, &ifp->mac));
|
||||||
arp_ask(ifp, ifp->gw);
|
arp_ask(ifp, ifp->gw); // unsolicited GW ARP request
|
||||||
} else if (ifp->state == MG_TCPIP_STATE_UP) {
|
} else if (ifp->state == MG_TCPIP_STATE_UP) {
|
||||||
MG_ERROR(("Link up"));
|
MG_ERROR(("Link up"));
|
||||||
srand((unsigned int) mg_millis());
|
srand((unsigned int) mg_millis());
|
||||||
@@ -5966,7 +5966,8 @@ void mg_connect_resolved(struct mg_connection *c) {
|
|||||||
if (c->is_udp && (rem_ip == 0xffffffff || rem_ip == (ifp->ip | ~ifp->mask))) {
|
if (c->is_udp && (rem_ip == 0xffffffff || rem_ip == (ifp->ip | ~ifp->mask))) {
|
||||||
struct connstate *s = (struct connstate *) (c + 1);
|
struct connstate *s = (struct connstate *) (c + 1);
|
||||||
memset(s->mac, 0xFF, sizeof(s->mac)); // global or local broadcast
|
memset(s->mac, 0xFF, sizeof(s->mac)); // global or local broadcast
|
||||||
} else if (ifp->ip && ((rem_ip & ifp->mask) == (ifp->ip & ifp->mask))) {
|
} else if (ifp->ip && ((rem_ip & ifp->mask) == (ifp->ip & ifp->mask)) &&
|
||||||
|
rem_ip != ifp->gw) { // skip if gw (onstatechange -> READY -> ARP)
|
||||||
// If we're in the same LAN, fire an ARP lookup.
|
// If we're in the same LAN, fire an ARP lookup.
|
||||||
MG_DEBUG(("%lu ARP lookup...", c->id));
|
MG_DEBUG(("%lu ARP lookup...", c->id));
|
||||||
arp_ask(ifp, rem_ip);
|
arp_ask(ifp, rem_ip);
|
||||||
|
|||||||
+3
-2
@@ -204,7 +204,7 @@ static void onstatechange(struct mg_tcpip_if *ifp) {
|
|||||||
MG_INFO(("READY, IP: %M", mg_print_ip4, &ifp->ip));
|
MG_INFO(("READY, IP: %M", mg_print_ip4, &ifp->ip));
|
||||||
MG_INFO((" GW: %M", mg_print_ip4, &ifp->gw));
|
MG_INFO((" GW: %M", mg_print_ip4, &ifp->gw));
|
||||||
MG_INFO((" MAC: %M", mg_print_mac, &ifp->mac));
|
MG_INFO((" MAC: %M", mg_print_mac, &ifp->mac));
|
||||||
arp_ask(ifp, ifp->gw);
|
arp_ask(ifp, ifp->gw); // unsolicited GW ARP request
|
||||||
} else if (ifp->state == MG_TCPIP_STATE_UP) {
|
} else if (ifp->state == MG_TCPIP_STATE_UP) {
|
||||||
MG_ERROR(("Link up"));
|
MG_ERROR(("Link up"));
|
||||||
srand((unsigned int) mg_millis());
|
srand((unsigned int) mg_millis());
|
||||||
@@ -1053,7 +1053,8 @@ void mg_connect_resolved(struct mg_connection *c) {
|
|||||||
if (c->is_udp && (rem_ip == 0xffffffff || rem_ip == (ifp->ip | ~ifp->mask))) {
|
if (c->is_udp && (rem_ip == 0xffffffff || rem_ip == (ifp->ip | ~ifp->mask))) {
|
||||||
struct connstate *s = (struct connstate *) (c + 1);
|
struct connstate *s = (struct connstate *) (c + 1);
|
||||||
memset(s->mac, 0xFF, sizeof(s->mac)); // global or local broadcast
|
memset(s->mac, 0xFF, sizeof(s->mac)); // global or local broadcast
|
||||||
} else if (ifp->ip && ((rem_ip & ifp->mask) == (ifp->ip & ifp->mask))) {
|
} else if (ifp->ip && ((rem_ip & ifp->mask) == (ifp->ip & ifp->mask)) &&
|
||||||
|
rem_ip != ifp->gw) { // skip if gw (onstatechange -> READY -> ARP)
|
||||||
// If we're in the same LAN, fire an ARP lookup.
|
// If we're in the same LAN, fire an ARP lookup.
|
||||||
MG_DEBUG(("%lu ARP lookup...", c->id));
|
MG_DEBUG(("%lu ARP lookup...", c->id));
|
||||||
arp_ask(ifp, rem_ip);
|
arp_ask(ifp, rem_ip);
|
||||||
|
|||||||
Reference in new issue
Block a user