purposes: keep a database of world-wide regulatory information and
tell the Linux kernel what to enforce.
- REQUIREMENTS
-==============
+ HOST REQUIREMENTS
+===================
+
+CRDA is provided as a binary file so all the host needs is libc/uclibc.
+
+ BUILD REQUIREMENTS
+====================
+
+The package build requirements currently are:
-The package requirements currently are:
* python and the m2crypto package (python-m2crypto)
* libgcrypt or libssl (openssl) header files
* MoinMoin (http://moinmo.in) for the web viewer
+ CALLING CRDA -- UDEV
+======================
+
+Distributions can set up a udev rule to allow the kernel's regulatory
+domain change request to be reviewed by CRDA so CRDA can pass an
+appropriate regulatory domain. An example regulatory rule is provided
+with this package as regulatory.rules
+
OVERVIEW
==========
#include <errno.h>
#include <stdio.h>
+#include <stdlib.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
struct regdb_file_reg_country *countries;
int dblen, siglen, num_countries, i, j, r;
char alpha2[2];
+ char *env_country;
struct nl80211_state nlstate;
struct nl_cb *cb = NULL;
struct nl_msg *msg;
#endif
char *regdb = "/usr/lib/crda/regulatory.bin";
- if (argc != 2) {
- fprintf(stderr, "Usage: %s <ISO-3166 alpha2 country code>\n", argv[0]);
+ if (argc != 1) {
+ fprintf(stderr, "Usage: %s\n", argv[0]);
return -EINVAL;
}
+
+ env_country = getenv("COUNTRY");
+ if (!env_country) {
+ fprintf(stderr, "COUNTRY environment variable not set.\n");
+ return -EINVAL;
+ }
+
- if (!is_alpha2(argv[1]) && !is_world_regdom(argv[1])) {
- fprintf(stderr, "Invalid alpha2\n");
+ if (!is_alpha2(env_country) && !is_world_regdom(env_country)) {
+ fprintf(stderr, "Invalid alpha2 set in COUNTRY\n");
return -EINVAL;
}
- memcpy(alpha2, argv[1], 2);
+ memcpy(alpha2, env_country, 2);
r = nl80211_init(&nlstate);
if (r)
--- /dev/null
+# Runs CRDA for kernel wireless regulatory events.
+# For more information see:
+# http://wireless.kernel.org/en/developers/Regulatory/CRDA
+
+KERNEL=="regulatory*", ACTION=="change", SUBSYSTEM=="platform", RUN+="/sbin/crda"