]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/commitdiff
misc-progs: Move network stuff to own header file.
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 12 Oct 2013 16:22:51 +0000 (18:22 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 12 Oct 2013 16:22:51 +0000 (18:22 +0200)
src/misc-progs/ipsecctrl.c
src/misc-progs/netutil.h [new file with mode: 0644]
src/misc-progs/openvpnctrl.c
src/misc-progs/rebuildhosts.c
src/misc-progs/setaliases.c
src/misc-progs/setuid.h
src/misc-progs/syslogdctrl.c
src/misc-progs/wirelessctrl.c

index 365807c9e4ab336a5f208a30592e3a8b70a208f7..570fdebab4583e3c10f6d8f2a56df42d3cfbed57 100644 (file)
@@ -13,7 +13,9 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <signal.h>
+
 #include "setuid.h"
+#include "netutil.h"
 
 /*
     This module is responsible for start stop of the vpn system.
diff --git a/src/misc-progs/netutil.h b/src/misc-progs/netutil.h
new file mode 100644 (file)
index 0000000..e96eb5d
--- /dev/null
@@ -0,0 +1,48 @@
+
+#ifndef NETUTIL_H
+#define NETUTIL_H 1
+
+#include <stdlib.h>
+
+#define LETTERS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+#define NUMBERS "0123456789"
+#define LETTERS_NUMBERS LETTERS NUMBERS
+#define IP_NUMBERS "./" NUMBERS
+#define PORT_NUMBERS ":-" NUMBERS
+#define VALID_FQDN LETTERS_NUMBERS ".-"
+
+#define VALID_IP(ip) (strlen(ip) > 6 \
+               && strlen(ip) < 16 \
+               && strspn(ip, NUMBERS ".") == strlen(ip))
+
+#define VALID_IP_AND_MASK(ip) (strlen(ip) > 6 \
+               && strlen(ip) < 32 \
+               && strspn(ip, IP_NUMBERS) == strlen(ip))
+
+#define VALID_PORT(port) (strlen(port) \
+               && strlen(port) < 6 \
+               && strspn(port, NUMBERS) == strlen(port))
+
+#define VALID_PORT_RANGE(port) (strlen(port) \
+               && strlen(port) < 12 \
+               && strspn(port, PORT_NUMBERS) == strlen(port))
+
+#define VALID_SHORT_MASK(ip) (strlen(ip) > 1 \
+               && strlen(ip) < 3 \
+               && strspn(ip, NUMBERS) == strlen(ip))
+
+/* Can't find any info on valid characters/length hopefully these are
+ * reasonable guesses */
+#define VALID_DEVICE(dev) (strlen(dev) \
+               && strlen(dev) < 16 \
+               && strspn(dev, LETTERS_NUMBERS ":.") == strlen(dev))
+
+/* Again, can't find any hard and fast rules for protocol names, these
+ * restrictions are based on the keywords currently listed in
+ * <http://www.iana.org/assignments/protocol-numbers>
+ * though currently the ipcop cgis will only pass tcp, udp or gre anyway */
+#define VALID_PROTOCOL(prot) (strlen(prot) \
+               &&  strlen(prot) <16 \
+               &&  strspn(prot, LETTERS_NUMBERS "-") == strlen(prot))
+
+#endif
index 4c1d1c3bbb30a9bee58e49f024949acd240ab870..257778892a1868bdb302614de2a1fcc970b3d619 100644 (file)
@@ -8,6 +8,7 @@
 #include <netinet/in.h>
 #include <fcntl.h>
 #include "setuid.h"
+#include "netutil.h"
 #include "libsmooth.h"
 
 #define noovpndebug
index e831858819e18d98c5e11404953bad65580cf4b6..21c523600c75b5223106d6aeb284db40f30e9531 100644 (file)
@@ -19,7 +19,9 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <signal.h>
+
 #include "setuid.h"
+#include "netutil.h"
 
 FILE *fd = NULL;
 FILE *hosts = NULL;
index ea4bc11dbec4e3016ac6b0d64f77cbe0e5b4ce97..93af1cb0a4ecd1e7832aad8b6943c9d903695680 100644 (file)
@@ -13,8 +13,6 @@
  *
  */
 
-#include "libsmooth.h"
-#include "setuid.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 
+#include "libsmooth.h"
+#include "setuid.h"
+#include "netutil.h"
+
 struct keyvalue *kv = NULL;
 FILE *file = NULL;
 
index 1e0aed2a08f0747243fc68c6433cf53760383707..d1155c5e8dedac0f426808888941136281f9fc6d 100644 (file)
 #ifndef STRING_SIZE
 #define STRING_SIZE 256
 #endif
-#define LETTERS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
-#define NUMBERS "0123456789"
-#define LETTERS_NUMBERS LETTERS NUMBERS
-#define IP_NUMBERS "./" NUMBERS
-#define PORT_NUMBERS ":-" NUMBERS
-#define VALID_FQDN LETTERS_NUMBERS ".-"
-
-
-#define VALID_IP(ip) (strlen(ip) > 6 \
-                   && strlen(ip) < 16 \
-                   && strspn(ip, NUMBERS ".") == strlen(ip))
-
-#define VALID_IP_AND_MASK(ip) (strlen(ip) > 6 \
-                            && strlen(ip) < 32 \
-                            && strspn(ip, IP_NUMBERS) == strlen(ip))
-
-#define VALID_PORT(port) (strlen(port) \
-                       && strlen(port) < 6 \
-                       && strspn(port, NUMBERS) == strlen(port))
-
-#define VALID_PORT_RANGE(port) (strlen(port) \
-                             && strlen(port) < 12 \
-                             && strspn(port, PORT_NUMBERS) == strlen(port))
-
-#define VALID_SHORT_MASK(ip) (strlen(ip) > 1 \
-                             && strlen(ip) < 3 \
-                             && strspn(ip, NUMBERS) == strlen(ip))
-
-/* Can't find any info on valid characters/length hopefully these are
- * reasonable guesses */
-#define VALID_DEVICE(dev) (strlen(dev) \
-                        && strlen(dev) < 16 \
-                        && strspn(dev, LETTERS_NUMBERS ":.") == strlen(dev))
-
-/* Again, can't find any hard and fast rules for protocol names, these
- * restrictions are based on the keywords currently listed in
- * <http://www.iana.org/assignments/protocol-numbers>
- * though currently the ipcop cgis will only pass tcp, udp or gre anyway */
-#define VALID_PROTOCOL(prot) (strlen(prot) \
-                          &&  strlen(prot) <16 \
-                          &&  strspn(prot, LETTERS_NUMBERS "-") == strlen(prot))
 
 extern char * trusted_env[4];
 
index 993cc938d98357b7a6e3fc72e9db9fec974b9c63..8111c84c56ac696084ff7af046e8db866c16fa1c 100644 (file)
 #include <fcntl.h>
 #include <signal.h>
 #include <errno.h>
+
 #include "libsmooth.h"
 #include "setuid.h"
+#include "netutil.h"
 
 #define ERR_ANY 1
 #define ERR_SETTINGS 2    /* error in settings file */
index 8ca7a81ae77572aac6a522629857bb08203f1a1a..e3a1107c2bff927bb2aa6e6b4d49bcb0e51ff8db 100644 (file)
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <signal.h>
-#include "setuid.h"
 #include <errno.h>
 
+#include "setuid.h"
+#include "netutil.h"
+
 FILE *fd = NULL;
 char blue_dev[STRING_SIZE] = "";
 char command[STRING_SIZE];