Browse Source

Oh, My, GOD! You may think I was just doing afk the past week or so, But, You'd be wrong, So, So, SO wrong. I've spent almost every day working as hard as I can on this commit here. It should work perfectly now, It should properly exclude interfaces, And, It should automatically exclude inactive ones. More testing is needed, Especially testing of running the -e argument multiple times, I.E -e eth0 -e wlan0. Anyway, Thank you for reading, And for downloading.

MissValeska 10 years ago
parent
commit
27f363f9b1
2 changed files with 44 additions and 16 deletions
  1. 1
    0
      Vagrant/Vagrantfile
  2. 43
    16
      src/netsukuku.c

+ 1
- 0
Vagrant/Vagrantfile View File

97
     sudo apt-get update
97
     sudo apt-get update
98
     sudo apt-get install nasm make build-essential grub qemu zip -y
98
     sudo apt-get install nasm make build-essential grub qemu zip -y
99
     sudo apt-get install git vde2 zlibc libgmp-dev openssl libssl-dev libgee-dev libpth-dev libgcrypt11-dev autoconf cmake autogen mawk gawk
99
     sudo apt-get install git vde2 zlibc libgmp-dev openssl libssl-dev libgee-dev libpth-dev libgcrypt11-dev autoconf cmake autogen mawk gawk
100
+    sudo vde_switch -t tap0 -t tap1 -d
100
   }
101
   }
101
 
102
 
102
   
103
   

+ 43
- 16
src/netsukuku.c View File

327
 void exclude_interface(void) {
327
 void exclude_interface(void) {
328
                       char *ifs = "null1";
328
                       char *ifs = "null1";
329
 		      char *old_tmp = "null2";
329
 		      char *old_tmp = "null2";
330
+                      char *old_tmp1 = "null3";
330
                       struct ifaddrs *addrs,*tmp;
331
                       struct ifaddrs *addrs,*tmp;
331
-                      struct ifreq *a_ifs;
332
-                      getifaddrs(&addrs);
332
+                      
333
+                      if (getifaddrs(&addrs) !=0) {
334
+                          printf("%s\n", strerror(errno));
335
+                          exit(1);
336
+                      }
333
                       tmp = addrs;
337
                       tmp = addrs;
334
                       while(tmp) {
338
                       while(tmp) {
339
+                          
335
 			    old_tmp = ifs;
340
 			    old_tmp = ifs;
336
                             
341
                             
337
-                            if(tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_PACKET)
338
-                                    ifs = tmp->ifa_name;
342
+                            Re_Check:
339
                             
343
                             
340
-                                if(strncmp(ifs, "lo", 2) == 0 || strncmp(ifs, "tunl0", 5) == 0 || strncmp(ifs, "tunl1", 5) == 0 || strcmp(ifs, optarg) == 0)
341
-                                    goto Check_Active;
342
-                                    
343
-                            Check_Active:
344
+                            old_tmp1 = ifs;
345
+                            if(tmp && tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_PACKET && tmp->ifa_flags & IFF_UP)
346
+                                 ifs = tmp->ifa_name;
347
+                                        
348
+                                else if(tmp && strcmp(old_tmp1, ifs) == 0) {
349
+                                    tmp = tmp->ifa_next;
350
+                                    goto Re_Check;
351
+                            }
352
+                            
353
+                            Re_Check1:
354
+                            
355
+                            printf("Possibly bad ifs is: %s\n", ifs);
344
                             
356
                             
345
-                            a_ifs = ifs;
346
-                            if(a_ifs->ifr_name != IFF_UP) {
347
-                                tmp = tmp->ifa_next;
348
-                                if(tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_PACKET)
349
-                                            ifs = tmp->ifa_name;
357
+                                if(tmp && (strncmp(ifs, "lo", 2) == 0 || strncmp(ifs, "tunl0", 5) == 0 || strncmp(ifs, "tunl1", 5) == 0 || strcmp(optarg, ifs) == 0)) {
358
+                                        printf("Bad Interface: %s\n", ifs);
359
+                                        tmp = tmp->ifa_next;
360
+                                        old_tmp1 = ifs;
361
+                                		if(tmp && tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_PACKET && tmp->ifa_flags & IFF_UP)
362
+                                            		ifs = tmp->ifa_name;
363
+                                        
364
+                                                    if(tmp && strcmp(old_tmp1, ifs) == 0) {
365
+                                                        tmp = tmp->ifa_next;
366
+                                                        
367
+                                                        if(tmp && tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_PACKET && tmp->ifa_flags & IFF_UP)
368
+                                                            ifs = tmp->ifa_name;
369
+                                                            goto Re_Check1;
370
+                                                    }
371
+                                }
372
+                            
373
+                            printf("Good ifs is: %s\n", ifs);
374
+                            
375
+                            if(strcmp(old_tmp, ifs) == 0) {
376
+                                printf("Loop finished: %s\n", ifs);
377
+                                break;
350
                             }
378
                             }
351
                             
379
                             
352
                             tmp = tmp->ifa_next;
380
                             tmp = tmp->ifa_next;
353
-			    if(strcmp(old_tmp, ifs) == 0)
354
-					break;
355
-			    server_opt.ifs[server_opt.ifs_n++]=xstrndup(ifs, IFNAMSIZ-1);
381
+                            server_opt.ifs[server_opt.ifs_n++]=xstrndup(ifs, IFNAMSIZ-1);
382
+                            printf("Using Interface: %s\n", ifs);
356
                           }
383
                           }
357
 
384
 
358
 freeifaddrs(addrs);
385
 freeifaddrs(addrs);

Loading…
Cancel
Save