| 491 | } |
| 492 | |
| 493 | static void |
| 494 | setregdomain_cb(int s, void *arg) |
| 495 | { |
| 496 | struct ieee80211_regdomain_req *req; |
| 497 | struct ieee80211_regdomain *rd = arg; |
| 498 | struct ieee80211_devcaps_req *dc; |
| 499 | struct regdata *rdp = getregdata(); |
| 500 | |
| 501 | if (rd->country != NO_COUNTRY) { |
| 502 | const struct country *cc; |
| 503 | /* |
| 504 | * Check current country seting to make sure it's |
| 505 | * compatible with the new regdomain. If not, then |
| 506 | * override it with any default country for this |
| 507 | * SKU. If we cannot arrange a match, then abort. |
| 508 | */ |
| 509 | cc = lib80211_country_findbycc(rdp, rd->country); |
| 510 | if (cc == NULL) |
| 511 | errx(1, "unknown ISO country code %d", rd->country); |
| 512 | if (cc->rd->sku != rd->regdomain) { |
| 513 | const struct regdomain *rp; |
| 514 | /* |
| 515 | * Check if country is incompatible with regdomain. |
| 516 | * To enable multiple regdomains for a country code |
| 517 | * we permit a mismatch between the regdomain and |
| 518 | * the country's associated regdomain when the |
| 519 | * regdomain is setup w/o a default country. For |
| 520 | * example, US is bound to the FCC regdomain but |
| 521 | * we allow US to be combined with FCC3 because FCC3 |
| 522 | * has not default country. This allows bogus |
| 523 | * combinations like FCC3+DK which are resolved when |
| 524 | * constructing the channel list by deferring to the |
| 525 | * regdomain to construct the channel list. |
| 526 | */ |
| 527 | rp = lib80211_regdomain_findbysku(rdp, rd->regdomain); |
| 528 | if (rp == NULL) |
| 529 | errx(1, "country %s (%s) is not usable with " |
| 530 | "regdomain %d", cc->isoname, cc->name, |
| 531 | rd->regdomain); |
| 532 | else if (rp->cc != NULL && rp->cc != cc) |
| 533 | errx(1, "country %s (%s) is not usable with " |
| 534 | "regdomain %s", cc->isoname, cc->name, |
| 535 | rp->name); |
| 536 | } |
| 537 | } |
| 538 | /* |
| 539 | * Fetch the device capabilities and calculate the |
| 540 | * full set of netbands for which we request a new |
| 541 | * channel list be constructed. Once that's done we |
| 542 | * push the regdomain info + channel list to the kernel. |
| 543 | */ |
| 544 | dc = malloc(IEEE80211_DEVCAPS_SIZE(MAXCHAN)); |
| 545 | if (dc == NULL) |
| 546 | errx(1, "no space for device capabilities"); |
| 547 | dc->dc_chaninfo.ic_nchans = MAXCHAN; |
| 548 | getdevcaps(s, dc); |
| 549 | #if 0 |
| 550 | if (verbose) { |
no test coverage detected