Move last helpers to crda.h, forgot to add crda.h to git too
authorLuis R. Rodriguez <lrodriguez@atheros.com>
Tue, 28 Oct 2008 00:41:54 +0000 (17:41 -0700)
committerLuis R. Rodriguez <lrodriguez@atheros.com>
Tue, 28 Oct 2008 00:41:54 +0000 (17:41 -0700)
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
crda.c
crda.h [new file with mode: 0644]

diff --git a/crda.c b/crda.c
index 97e1f53..0930c69 100644 (file)
--- a/crda.c
+++ b/crda.c
@@ -94,28 +94,6 @@ static int error_handler(struct sockaddr_nl __attribute__((unused)) *nla,
        exit(err->error);
 }
 
-/* Avoid stdlib */
-static int is_len_2(const char *alpha2)
-{
-        if (alpha2[0] == '\0' || (alpha2[1] == '\0'))
-                return 0;
-        if (alpha2[2] == '\0')
-                return 1;
-        return 0;
-}
-
-static int is_valid_regdom(const char *alpha2)
-{
-       if (!is_len_2(alpha2))
-               return 0;
-
-       if (!is_alpha2(alpha2) && !is_world_regdom(alpha2))
-               return 0;
-
-       return 1;
-}
-
-
 static int put_reg_rule(__u8 *db, int dblen, __be32 ruleptr, struct nl_msg *msg)
 {
        struct regdb_file_reg_rule *rule;
diff --git a/crda.h b/crda.h
new file mode 100644 (file)
index 0000000..eec4ec4
--- /dev/null
+++ b/crda.h
@@ -0,0 +1,49 @@
+#include <stdlib.h>
+#include <linux/types.h>
+
+/* Common regulatory functions and helpers */
+
+void *crda_get_file_ptr(__u8 *db, int dblen, int structlen, __be32 ptr);
+int crda_verify_db_signature(__u8 *db, int dblen, int siglen);
+
+static inline int is_world_regdom(const char *alpha2)
+{
+       if (alpha2[0] == '0' && alpha2[1] == '0')
+               return 1;
+       return 0;
+}
+
+static inline int isalpha_upper(char letter)
+{
+       if (letter >= 'A' && letter <= 'Z')
+               return 1;
+       return 0;
+}
+
+static inline int is_alpha2(const char *alpha2)
+{
+       if (isalpha_upper(alpha2[0]) && isalpha_upper(alpha2[1]))
+               return 1;
+       return 0;
+}
+
+/* Avoid stdlib */
+static inline int is_len_2(const char *alpha2)
+{
+        if (alpha2[0] == '\0' || (alpha2[1] == '\0'))
+                return 0;
+        if (alpha2[2] == '\0')
+                return 1;
+        return 0;
+}
+
+static inline int is_valid_regdom(const char *alpha2)
+{
+       if (!is_len_2(alpha2))
+               return 0;
+
+       if (!is_alpha2(alpha2) && !is_world_regdom(alpha2))
+               return 0;
+
+       return 1;
+}