#include #include #include #include #include #include // If this programs // - receives an ipv4 address in its arguments: // → it will executes iptables with the same arguments in place. // // - receives an ipv6 address in its arguments: // → it will executes ip6tables with the same arguments in place. // // - doesn't receive an ipv4 or ipv6 address in its arguments: // → it will executes both, with the same arguments in place. int isIPv4(char *tab) { int i,len; // IPv4 addresses are at least 7 chars long len = strlen(tab); if (len < 7 || !isdigit(tab[0]) || !isdigit(tab[len-1])) { return 0; } // Each char must be a digit or a dot between 2 digits for (i=1; i= 'a' && tab[i] <= 'f') && !(tab[i] >= 'A' && tab[i] <= 'F')) { return 0; } } return 1; } int guess_type(int len, char *tab[]) { int i; for (i=0; i