print-regdom.c 1.5 KB
Newer Older
1 2 3 4
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <arpa/inet.h>
5 6 7

#include "nl80211.h"

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
#include "reglib.h"

static void print_reg_rule(struct ieee80211_reg_rule *rule)
{
	struct ieee80211_freq_range *freq;
	struct ieee80211_power_rule *power;

	freq  = &rule->freq_range;
	power = &rule->power_rule;

	printf("\t(%.3f - %.3f @ %.3f), ",
	       ((float)(freq->start_freq_khz))/1000.0,
	       ((float)(freq->end_freq_khz))/1000.0,
	       ((float)(freq->max_bandwidth_khz))/1000.0);

	printf("(");

	if (power->max_antenna_gain)
		printf("%.2f, ", ((float)(power->max_antenna_gain)/100.0));
	else
		printf("N/A, ");

	if (power->max_eirp)
		printf("%.2f)", ((float)(power->max_eirp)/100.0));
	else
		printf("N/A)");

35
	if (rule->flags & NL80211_RRF_NO_OFDM)
36
		printf(", NO-OFDM");
37
	if (rule->flags & NL80211_RRF_NO_CCK)
38
		printf(", NO-CCK");
39
	if (rule->flags & NL80211_RRF_NO_INDOOR)
40
		printf(", NO-INDOOR");
41
	if (rule->flags & NL80211_RRF_NO_OUTDOOR)
42
		printf(", NO-OUTDOOR");
43
	if (rule->flags & NL80211_RRF_DFS)
44
		printf(", DFS");
45
	if (rule->flags & NL80211_RRF_PTP_ONLY)
46
		printf(", PTP-ONLY");
47
	if (rule->flags & NL80211_RRF_PTMP_ONLY)
48
		printf(", PTMP-ONLY");
49
	if (rule->flags & NL80211_RRF_PASSIVE_SCAN)
50
		printf(", PASSIVE-SCAN");
51
	if (rule->flags & NL80211_RRF_NO_IBSS)
52 53 54 55 56 57 58 59 60 61 62 63 64
		printf(", NO-IBSS");

	printf("\n");
}

void print_regdom(struct ieee80211_regdomain *rd)
{
	unsigned int i;
	printf("country %.2s:\n", rd->alpha2);
	for (i = 0; i < rd->n_reg_rules; i++)
		print_reg_rule(&rd->reg_rules[i]);
	printf("\n");
}