File: intersect.c

package info (click to toggle)
crda 4.14%2Bgit20191112.9856751-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 568 kB
  • sloc: ansic: 2,599; makefile: 195; python: 130; sh: 6
file content (39 lines) | stat: -rw-r--r-- 802 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <arpa/inet.h> /* ntohl */
#include <string.h>

#include "reglib.h"

int main(int argc, char **argv)
{
	const struct reglib_regdb_ctx *ctx;
	const struct ieee80211_regdomain *rd;

	if (argc != 2) {
		fprintf(stderr, "Usage: %s <regulatory-binary-file>\n", argv[0]);
		return -EINVAL;
	}

	ctx = reglib_malloc_regdb_ctx(argv[1]);
	if (!ctx) {
		fprintf(stderr, "Invalid or empty regulatory file, note: "
			"a binary regulatory file should be used.\n");
		return -EINVAL;
	}

	rd = reglib_intersect_regdb(ctx);
	if (!rd) {
		fprintf(stderr, "Intersection not possible\n");
		reglib_free_regdb_ctx(ctx);
		return -ENOENT;
	}

	reglib_print_regdom(rd);

	free((struct ieee80211_regdomain *) rd);

	reglib_free_regdb_ctx(ctx);
	return 0;
}