Lines Matching +full:in +full:- +full:band
1 /*-
5 * Redistribution and use in source and binary forms, with or without
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
76 if (++mt->level == MAXLEVEL) { in start_element()
80 mt->sbuf[mt->level] = sbuf_new_auto(); in start_element()
90 printf("%*.*s[%s = %s]\n", mt->level + 1, in start_element()
91 mt->level + 1, "", attr[i], attr[i+1]); in start_element()
93 if (iseq(name, "rd") && mt->rd == NULL) { in start_element()
94 if (mt->country == NULL) { in start_element()
95 mt->rd = calloc(1, sizeof(struct regdomain)); in start_element()
96 mt->rd->name = strdup(id); in start_element()
97 mt->nident++; in start_element()
98 LIST_INSERT_HEAD(&mt->rdp->domains, mt->rd, next); in start_element()
100 mt->country->rd = (void *)strdup(ref); in start_element()
103 if (iseq(name, "defcc") && mt->rd != NULL) { in start_element()
104 mt->rd->cc = (void *)strdup(ref); in start_element()
107 if (iseq(name, "netband") && mt->curband == NULL && mt->rd != NULL) { in start_element()
110 XML_GetCurrentLineNumber(mt->parser)); in start_element()
114 mt->curband = &mt->rd->bands_11b; in start_element()
116 mt->curband = &mt->rd->bands_11g; in start_element()
118 mt->curband = &mt->rd->bands_11a; in start_element()
120 mt->curband = &mt->rd->bands_11ng; in start_element()
122 mt->curband = &mt->rd->bands_11na; in start_element()
124 mt->curband = &mt->rd->bands_11ac; in start_element()
126 mt->curband = &mt->rd->bands_11acg; in start_element()
130 XML_GetCurrentLineNumber(mt->parser)); in start_element()
133 if (iseq(name, "band") && mt->netband == NULL) { in start_element()
134 if (mt->curband == NULL) { in start_element()
135 warnx("band without enclosing netband at line %ld", in start_element()
136 XML_GetCurrentLineNumber(mt->parser)); in start_element()
139 mt->netband = calloc(1, sizeof(struct netband)); in start_element()
140 LIST_INSERT_HEAD(mt->curband, mt->netband, next); in start_element()
143 if (iseq(name, "freqband") && mt->freqband == NULL && mt->netband != NULL) { in start_element()
145 if (mt->netband->band != NULL) { in start_element()
147 XML_GetCurrentLineNumber(mt->parser)); in start_element()
150 mt->netband->band = (void *)strdup(ref); in start_element()
154 if (iseq(name, "country") && mt->country == NULL) { in start_element()
155 mt->country = calloc(1, sizeof(struct country)); in start_element()
156 mt->country->isoname = strdup(id); in start_element()
157 mt->country->code = NO_COUNTRY; in start_element()
158 mt->nident++; in start_element()
159 LIST_INSERT_HEAD(&mt->rdp->countries, mt->country, next); in start_element()
163 if (iseq(name, "freqband") && mt->freqband == NULL) { in start_element()
164 mt->freqband = calloc(1, sizeof(struct freqband)); in start_element()
165 mt->freqband->id = strdup(id); in start_element()
166 mt->nident++; in start_element()
167 LIST_INSERT_HEAD(&mt->rdp->freqbands, mt->freqband, next); in start_element()
182 #define FLAG(x) { #x, sizeof(#x)-1, x } in decode_flag()
194 * 80MHz chan logic in net80211 / ifconfig. in decode_flag()
231 len, p, XML_GetCurrentLineNumber(mt->parser)); in decode_flag()
245 sbuf_finish(mt->sbuf[mt->level]); in end_element()
246 p = sbuf_data(mt->sbuf[mt->level]); in end_element()
247 len = sbuf_len(mt->sbuf[mt->level]); in end_element()
250 if (iseq(name, "freqstart") && mt->freqband != NULL) { in end_element()
251 mt->freqband->freqStart = strtoul(p, NULL, 0); in end_element()
254 if (iseq(name, "freqend") && mt->freqband != NULL) { in end_element()
255 mt->freqband->freqEnd = strtoul(p, NULL, 0); in end_element()
258 if (iseq(name, "chanwidth") && mt->freqband != NULL) { in end_element()
259 mt->freqband->chanWidth = strtoul(p, NULL, 0); in end_element()
262 if (iseq(name, "chansep") && mt->freqband != NULL) { in end_element()
263 mt->freqband->chanSep = strtoul(p, NULL, 0); in end_element()
267 if (mt->freqband != NULL) in end_element()
268 mt->freqband->flags |= decode_flag(mt, p, len); in end_element()
269 else if (mt->netband != NULL) in end_element()
270 mt->netband->flags |= decode_flag(mt, p, len); in end_element()
273 XML_GetCurrentLineNumber(mt->parser)); in end_element()
279 if (iseq(name, "name") && mt->rd != NULL) { in end_element()
280 mt->rd->name = strdup(p); in end_element()
283 if (iseq(name, "sku") && mt->rd != NULL) { in end_element()
284 mt->rd->sku = strtoul(p, NULL, 0); in end_element()
287 if (iseq(name, "netband") && mt->rd != NULL) { in end_element()
288 mt->curband = NULL; in end_element()
292 /* <band> ... </band> */ in end_element()
293 if (iseq(name, "freqband") && mt->netband != NULL) { in end_element()
297 if (iseq(name, "maxpower") && mt->netband != NULL) { in end_element()
298 mt->netband->maxPower = strtoul(p, NULL, 0); in end_element()
301 if (iseq(name, "maxpowerdfs") && mt->netband != NULL) { in end_element()
302 mt->netband->maxPowerDFS = strtoul(p, NULL, 0); in end_element()
305 if (iseq(name, "maxantgain") && mt->netband != NULL) { in end_element()
306 mt->netband->maxAntGain = strtoul(p, NULL, 0); in end_element()
311 if (iseq(name, "isocc") && mt->country != NULL) { in end_element()
312 mt->country->code = strtoul(p, NULL, 0); in end_element()
315 if (iseq(name, "name") && mt->country != NULL) { in end_element()
316 mt->country->name = strdup(p); in end_element()
322 name, p, XML_GetCurrentLineNumber(mt->parser)); in end_element()
326 if (iseq(name, "freqband") && mt->freqband != NULL) { in end_element()
329 mt->freqband = NULL; in end_element()
333 if (iseq(name, "rd") && mt->rd != NULL) { in end_element()
334 mt->rd = NULL; in end_element()
337 /* </band> */ in end_element()
338 if (iseq(name, "band") && mt->netband != NULL) { in end_element()
339 if (mt->netband->band == NULL) { in end_element()
340 warnx("no freqbands for band at line %ld", in end_element()
341 XML_GetCurrentLineNumber(mt->parser)); in end_element()
343 if (mt->netband->maxPower == 0) { in end_element()
344 warnx("no maxpower for band at line %ld", in end_element()
345 XML_GetCurrentLineNumber(mt->parser)); in end_element()
348 if (mt->netband->maxPowerDFS == 0) in end_element()
349 mt->netband->maxPowerDFS = mt->netband->maxPower; in end_element()
350 mt->netband = NULL; in end_element()
354 if (iseq(name, "netband") && mt->netband != NULL) { in end_element()
355 mt->curband = NULL; in end_element()
359 if (iseq(name, "country") && mt->country != NULL) { in end_element()
360 /* XXX NO_COUNTRY should be in the net80211 country enum */ in end_element()
361 if ((int) mt->country->code == NO_COUNTRY) { in end_element()
363 XML_GetCurrentLineNumber(mt->parser)); in end_element()
365 if (mt->country->name == NULL) { in end_element()
367 XML_GetCurrentLineNumber(mt->parser)); in end_element()
369 if (mt->country->rd == NULL) { in end_element()
371 XML_GetCurrentLineNumber(mt->parser)); in end_element()
373 mt->country = NULL; in end_element()
377 sbuf_delete(mt->sbuf[mt->level]); in end_element()
378 mt->sbuf[mt->level--] = NULL; in end_element()
391 e = s + len-1; in char_data()
397 sbuf_bcat(mt->sbuf[mt->level], b, e-b+1); in char_data()
405 for (ip = rdp->ident; ip->id != NULL; ip++) in findid()
406 if ((int) ip->type == type && strcasecmp(ip->id, id) == 0) in findid()
407 return ip->p; in findid()
430 mt->rdp = rdp; in lib80211_regdomain_readconfig()
431 mt->parser = XML_ParserCreate(NULL); in lib80211_regdomain_readconfig()
432 XML_SetUserData(mt->parser, mt); in lib80211_regdomain_readconfig()
433 XML_SetElementHandler(mt->parser, start_element, end_element); in lib80211_regdomain_readconfig()
434 XML_SetCharacterDataHandler(mt->parser, char_data); in lib80211_regdomain_readconfig()
435 if (XML_Parse(mt->parser, p, len, 1) != XML_STATUS_OK) { in lib80211_regdomain_readconfig()
437 XML_ErrorString(XML_GetErrorCode(mt->parser)), in lib80211_regdomain_readconfig()
438 XML_GetCurrentLineNumber(mt->parser)); in lib80211_regdomain_readconfig()
439 return -1; in lib80211_regdomain_readconfig()
441 XML_ParserFree(mt->parser); in lib80211_regdomain_readconfig()
444 rdp->ident = calloc(mt->nident + 1, sizeof(struct ident)); in lib80211_regdomain_readconfig()
445 if (rdp->ident == NULL) in lib80211_regdomain_readconfig()
451 LIST_FOREACH(dp, &rdp->domains, next) { in lib80211_regdomain_readconfig()
452 rdp->ident[i].id = dp->name; in lib80211_regdomain_readconfig()
453 rdp->ident[i].p = dp; in lib80211_regdomain_readconfig()
454 rdp->ident[i].type = DOMAIN; in lib80211_regdomain_readconfig()
457 LIST_FOREACH(fp, &rdp->freqbands, next) { in lib80211_regdomain_readconfig()
458 rdp->ident[i].id = fp->id; in lib80211_regdomain_readconfig()
459 rdp->ident[i].p = fp; in lib80211_regdomain_readconfig()
460 rdp->ident[i].type = FREQBAND; in lib80211_regdomain_readconfig()
463 LIST_FOREACH(cp, &rdp->countries, next) { in lib80211_regdomain_readconfig()
464 rdp->ident[i].id = cp->isoname; in lib80211_regdomain_readconfig()
465 rdp->ident[i].p = cp; in lib80211_regdomain_readconfig()
466 rdp->ident[i].type = COUNTRY; in lib80211_regdomain_readconfig()
471 LIST_FOREACH(dp, &rdp->domains, next) { in lib80211_regdomain_readconfig()
472 if (dp->cc != NULL) { in lib80211_regdomain_readconfig()
473 id = dp->cc; in lib80211_regdomain_readconfig()
474 dp->cc = findid(rdp, id, COUNTRY); in lib80211_regdomain_readconfig()
475 if (dp->cc == NULL) { in lib80211_regdomain_readconfig()
482 LIST_FOREACH(nb, &dp->bands_11b, next) { in lib80211_regdomain_readconfig()
483 id = findid(rdp, nb->band, FREQBAND); in lib80211_regdomain_readconfig()
485 warnx("undefined 11b band \"%s\"", in lib80211_regdomain_readconfig()
486 __DECONST(char *, nb->band)); in lib80211_regdomain_readconfig()
489 nb->band = id; in lib80211_regdomain_readconfig()
491 LIST_FOREACH(nb, &dp->bands_11g, next) { in lib80211_regdomain_readconfig()
492 id = findid(rdp, nb->band, FREQBAND); in lib80211_regdomain_readconfig()
494 warnx("undefined 11g band \"%s\"", in lib80211_regdomain_readconfig()
495 __DECONST(char *, nb->band)); in lib80211_regdomain_readconfig()
498 nb->band = id; in lib80211_regdomain_readconfig()
500 LIST_FOREACH(nb, &dp->bands_11a, next) { in lib80211_regdomain_readconfig()
501 id = findid(rdp, nb->band, FREQBAND); in lib80211_regdomain_readconfig()
503 warnx("undefined 11a band \"%s\"", in lib80211_regdomain_readconfig()
504 __DECONST(char *, nb->band)); in lib80211_regdomain_readconfig()
507 nb->band = id; in lib80211_regdomain_readconfig()
509 LIST_FOREACH(nb, &dp->bands_11ng, next) { in lib80211_regdomain_readconfig()
510 id = findid(rdp, nb->band, FREQBAND); in lib80211_regdomain_readconfig()
512 warnx("undefined 11ng band \"%s\"", in lib80211_regdomain_readconfig()
513 __DECONST(char *, nb->band)); in lib80211_regdomain_readconfig()
516 nb->band = id; in lib80211_regdomain_readconfig()
518 LIST_FOREACH(nb, &dp->bands_11na, next) { in lib80211_regdomain_readconfig()
519 id = findid(rdp, nb->band, FREQBAND); in lib80211_regdomain_readconfig()
521 warnx("undefined 11na band \"%s\"", in lib80211_regdomain_readconfig()
522 __DECONST(char *, nb->band)); in lib80211_regdomain_readconfig()
525 nb->band = id; in lib80211_regdomain_readconfig()
527 LIST_FOREACH(nb, &dp->bands_11ac, next) { in lib80211_regdomain_readconfig()
528 id = findid(rdp, nb->band, FREQBAND); in lib80211_regdomain_readconfig()
530 warnx("undefined 11ac band \"%s\"", in lib80211_regdomain_readconfig()
531 __DECONST(char *, nb->band)); in lib80211_regdomain_readconfig()
534 nb->band = id; in lib80211_regdomain_readconfig()
536 LIST_FOREACH(nb, &dp->bands_11acg, next) { in lib80211_regdomain_readconfig()
537 id = findid(rdp, nb->band, FREQBAND); in lib80211_regdomain_readconfig()
539 warnx("undefined 11acg band \"%s\"", in lib80211_regdomain_readconfig()
540 __DECONST(char *, nb->band)); in lib80211_regdomain_readconfig()
543 nb->band = id; in lib80211_regdomain_readconfig()
546 LIST_FOREACH(cp, &rdp->countries, next) { in lib80211_regdomain_readconfig()
547 id = cp->rd; in lib80211_regdomain_readconfig()
548 cp->rd = findid(rdp, id, DOMAIN); in lib80211_regdomain_readconfig()
549 if (cp->rd == NULL) { in lib80211_regdomain_readconfig()
581 free(rdp->ident); in lib80211_regdomain_cleanup()
582 rdp->ident = NULL; in lib80211_regdomain_cleanup()
584 struct regdomain *dp = LIST_FIRST(&rdp->domains); in lib80211_regdomain_cleanup()
588 cleanup_bands(&dp->bands_11b); in lib80211_regdomain_cleanup()
589 cleanup_bands(&dp->bands_11g); in lib80211_regdomain_cleanup()
590 cleanup_bands(&dp->bands_11a); in lib80211_regdomain_cleanup()
591 cleanup_bands(&dp->bands_11ng); in lib80211_regdomain_cleanup()
592 cleanup_bands(&dp->bands_11na); in lib80211_regdomain_cleanup()
593 cleanup_bands(&dp->bands_11ac); in lib80211_regdomain_cleanup()
594 cleanup_bands(&dp->bands_11acg); in lib80211_regdomain_cleanup()
595 if (dp->name != NULL) in lib80211_regdomain_cleanup()
596 free(__DECONST(char *, dp->name)); in lib80211_regdomain_cleanup()
599 struct country *cp = LIST_FIRST(&rdp->countries); in lib80211_regdomain_cleanup()
603 if (cp->name != NULL) in lib80211_regdomain_cleanup()
604 free(__DECONST(char *, cp->name)); in lib80211_regdomain_cleanup()
608 struct freqband *fp = LIST_FIRST(&rdp->freqbands); in lib80211_regdomain_cleanup()
681 LIST_FOREACH(dp, &rdp->domains, next) { in lib80211_regdomain_findbysku()
682 if (dp->sku == sku) in lib80211_regdomain_findbysku()
696 LIST_FOREACH(dp, &rdp->domains, next) { in lib80211_regdomain_findbyname()
697 if (strcasecmp(dp->name, name) == 0) in lib80211_regdomain_findbyname()
711 LIST_FOREACH(cp, &rdp->countries, next) { in lib80211_country_findbycc()
712 if (cp->code == cc) in lib80211_country_findbycc()
728 LIST_FOREACH(cp, &rdp->countries, next) { in lib80211_country_findbyname()
729 if (strcasecmp(cp->isoname, name) == 0) in lib80211_country_findbyname()
732 LIST_FOREACH(cp, &rdp->countries, next) { in lib80211_country_findbyname()
733 if (strncasecmp(cp->name, name, len) == 0) in lib80211_country_findbyname()