summaryrefslogtreecommitdiff
path: root/IPCode.c
diff options
context:
space:
mode:
authorDave Hibberd <d@vehibberd.com>2024-01-16 20:42:28 +0000
committerDave Hibberd <d@vehibberd.com>2024-01-16 20:42:28 +0000
commit2634d16f4159b217417724b0cf2a834d5a816346 (patch)
treed5b509788f352dab301acfb916828ceba8808d86 /IPCode.c
parent7a61c594e1bf9fd62e156d3d8db772fe7c4bfd03 (diff)
New upstream version 6.0.24.27upstream/6.0.24.27
Diffstat (limited to 'IPCode.c')
-rw-r--r--IPCode.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/IPCode.c b/IPCode.c
index efc4d91..7958b73 100644
--- a/IPCode.c
+++ b/IPCode.c
@@ -4539,6 +4539,50 @@ void OpenTAP()
return;
}
+ // Fix from github user isavitsky
+
+ /*
+ * After some research I found that on most of my
+ * systems, including Raspberry Pi IV, a slight delay
+ * is needed before considering the TAP device
+ * up and running. Otherwise the interface structures
+ * do not initialise properly and later in the code
+ * around the line 4700 when we initialise our ARP
+ * structure:
+ *
+ * memcpy(Arp->HWADDR, xbuffer.ifr_hwaddr.sa_data, 6);
+ *
+ * the MAC address is getting filled in with random
+ * value which makes the communication via our TAP
+ * device using the configured IPADDR virtually
+ * impossible.
+ *
+ */
+
+ Debugprintf("Waiting for the TAP to become UP and RUNNING");
+
+ for (int i=10; i>0; i--)
+ {
+ Sleep(10);
+
+ if ((err = ioctl(sockfd, SIOCGIFFLAGS, &ifr)) < 0)
+ {
+ perror("SIOCGIFFLAGS");
+ return;
+ }
+
+ if((ifr.ifr_flags & IFF_UP) && (ifr.ifr_flags & IFF_RUNNING))
+ {
+ Debugprintf("TAP is UP and RUNNING");
+ break;
+ }
+ else if (i == 1)
+ {
+ Debugprintf("TAP is still not UP and RUNNING");
+ return;
+ }
+ }
+
printf("TAP brought up\n");
// Set MTU to 256