From 19ce039cee78a1787df9dfc0cde25aa1b2838e4c Mon Sep 17 00:00:00 2001 From: MissValeska Date: Mon, 26 May 2014 20:21:17 -0700 Subject: [PATCH] I added a lot of stuff! I fully set up exclude_interface to ignore inactive interfaces, and optarg, Along with a small list of other interfaces. I did some bug fixing, And looked into how netsukuku sets it's interfaces by default, And added some stuff to deal with that too. I, Also, Figured out that, The entire exclude_interface function is probably unnecessary, And can be fully replaced with just check_excluded, Which would be much simpler, Easier, And elegant. Along with the fact that, It will probably just work. --- src/netsukuku.c | 51 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/src/netsukuku.c b/src/netsukuku.c index ff79cc4..cf3dc28 100644 --- a/src/netsukuku.c +++ b/src/netsukuku.c @@ -324,37 +324,55 @@ void free_server_opt(void) xfree(server_opt.ifs[i]); } +// Checks and removes any existing interface which is intended to be excluded + void check_excluded(void) { + int i; + printf("Number of Interfaces in Use: %d\n", server_opt.ifs_n); printf("Interface names in Use: %s", server_opt.ifs); + for(i=0; iifa_addr && tmp->ifa_addr->sa_family == AF_PACKET && tmp->ifa_flags & IFF_UP && (strncmp(ifs, "lo", 2) == 0 || strncmp(ifs, "tunl0", 5) == 0 || strncmp(ifs, "tunl1", 5) == 0 || strcmp(optarg, ifs) == 0)) + if(tmp && tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_PACKET && tmp->ifa_flags & IFF_UP && !(tmp->ifa_flags & IFF_LOOPBACK) (strncmp(tmp->ifa_name, "tunl0", 5) != 0 || strncmp(tmp->ifa_name, "tunl1", 5) != 0 || strcmp(optarg, tmp->ifa_name) != 0)) { ifs = tmp->ifa_name; - - else if(tmp && strcmp(old_tmp1, ifs) == 0) { - tmp = tmp->ifa_next; - goto Re_Check; + ifs_n++; } printf("Good ifs is: %s\n", ifs); @@ -368,7 +386,13 @@ int exclude_interface(void) { tmp = tmp->ifa_next; server_opt.ifs[server_opt.ifs_n++]=xstrndup(ifs, IFNAMSIZ-1); printf("Using Interface: %s\n", ifs); + + ifs_a[ifs_n].dev_idx = (int)tmp->ifa_flags; + + strncpy(ifs_a[ifs_n].dev_name, ifs, (int)strlen(ifs)); + check_excluded(); + } freeifaddrs(addrs); @@ -416,7 +440,10 @@ void parse_options(int argc, char **argv) exit(0); break; case 'e': - exclude_interface(); + //int prevent_doubles = -1; + //prevent_doubles++; + //exclude_interface(prevent_doubles); + check_excluded(); break; case 'k': if(is_ntkd_already_running() == 1){