]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/misc-progs/netutil.h
7 #define LETTERS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
8 #define NUMBERS "0123456789"
9 #define LETTERS_NUMBERS LETTERS NUMBERS
10 #define IP_NUMBERS "./" NUMBERS
11 #define PORT_NUMBERS ":-" NUMBERS
12 #define VALID_FQDN LETTERS_NUMBERS ".-"
14 #define VALID_IP(ip) (strlen(ip) > 6 \
16 && strspn(ip, NUMBERS ".") == strlen(ip))
18 #define VALID_IP_AND_MASK(ip) (strlen(ip) > 6 \
20 && strspn(ip, IP_NUMBERS) == strlen(ip))
22 #define VALID_PORT(port) (strlen(port) \
24 && strspn(port, NUMBERS) == strlen(port))
26 #define VALID_PORT_RANGE(port) (strlen(port) \
27 && strlen(port) < 12 \
28 && strspn(port, PORT_NUMBERS) == strlen(port))
30 #define VALID_SHORT_MASK(ip) (strlen(ip) > 1 \
32 && strspn(ip, NUMBERS) == strlen(ip))
34 /* Can't find any info on valid characters/length hopefully these are
35 * reasonable guesses */
36 #define VALID_DEVICE(dev) (strlen(dev) \
38 && strspn(dev, LETTERS_NUMBERS ":.") == strlen(dev))
40 /* Again, can't find any hard and fast rules for protocol names, these
41 * restrictions are based on the keywords currently listed in
42 * <http://www.iana.org/assignments/protocol-numbers>
43 * though currently the ipcop cgis will only pass tcp, udp or gre anyway */
44 #define VALID_PROTOCOL(prot) (strlen(prot) \
46 && strspn(prot, LETTERS_NUMBERS "-") == strlen(prot))