Exclude would work, If there wasn't a segmentation fault.

This commit is contained in:
MissValeska 2014-05-13 17:45:00 -07:00
parent 7333da2f7c
commit e06db959e8

View File

@ -325,48 +325,39 @@ void free_server_opt(void)
} }
void exclude_interface(void) { void exclude_interface(void) {
printf("optarg: %s\n", optarg);
char *a_ifs; char *a_ifs;
char *old_tmp;
struct ifaddrs *addrs,*tmp; struct ifaddrs *addrs,*tmp;
getifaddrs(&addrs); getifaddrs(&addrs);
tmp = addrs; tmp = addrs;
int i; int run_c = 1;
if(tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_PACKET) printf("omg\n");
a_ifs = tmp->ifa_name; while(tmp) {
char *first_tmp = tmp; old_tmp = a_ifs;
tmp->ifa_next;
int ifs_c = 1; if(tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_PACKET)
while(tmp != first_tmp){ a_ifs = tmp->ifa_name;
//if(tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_PACKET)
//tmp->ifa_name; printf("wtf\n");
tmp->ifa_next;
ifs_c++;
}
ifs_c += 1;
if(ifs_c > MAX_INTERFACES){
printf("ERROR: Max Number of interfaces is: %i", MAX_INTERFACES);
exit(1);
}
printf("ifs_c is: %i\n", ifs_c);
for(i=0; i<ifs_c; i++) {
//if(tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_PACKET)
//a_ifs = tmp->ifa_name;
if(strncmp(a_ifs, "lo", 2) == 0 || strncmp(a_ifs, "tunl0", 5) == 0 || strncmp(a_ifs, "tunl1", 5) == 0 || strcmp(a_ifs, optarg) == 0) { if(strncmp(a_ifs, "lo", 2) == 0 || strncmp(a_ifs, "tunl0", 5) == 0 || strncmp(a_ifs, "tunl1", 5) == 0 || strcmp(a_ifs, optarg) == 0) {
a_ifs = tmp->ifa_next; tmp = tmp->ifa_next;
printf("Bad Case Interface Name Increment: %s\n", a_ifs); if(tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_PACKET)
//if(tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_PACKET) a_ifs = tmp->ifa_name;
//a_ifs = tmp->ifa_name; printf("dun be meanie\n");
} }
else { printf("weirdness\n");
//tmp = tmp->ifa_next; tmp = tmp->ifa_next;
printf("Normal Interface Name Increment: %s\n", a_ifs); run_c++;
} if(strcmp(old_tmp, a_ifs) == 0) {
printf("a_ifs is: %s\n", a_ifs); printf("True\n");
server_opt.ifs[server_opt.ifs_n++]=xstrndup(a_ifs, IFNAMSIZ-1); break;
a_ifs = tmp->ifa_next; }
} printf("why so mean? D:\n");
freeifaddrs(addrs); server_opt.ifs[server_opt.ifs_n++]=xstrndup(a_ifs, IFNAMSIZ-1);
}
freeifaddrs(addrs);
} }
void parse_options(int argc, char **argv) void parse_options(int argc, char **argv)
@ -411,6 +402,7 @@ void parse_options(int argc, char **argv)
exit(0); exit(0);
break; break;
case 'e': case 'e':
printf("hey\n");
exclude_interface(); exclude_interface();
break; break;
case 'k': case 'k':