MCPcopy Index your code
hub / github.com/F-Stack/f-stack / getmodeflags

Function getmodeflags

tools/ifconfig/ifieee80211.c:1492–1548  ·  view source on GitHub ↗

* Parse an optional trailing specification of which netbands * to apply a parameter to. This is basically the same syntax * as used for channels but you can concatenate to specify * multiple. For example: * 14:abg apply to 11a, 11b, and 11g * 6:ht apply to 11na and 11ng * We don't make a big effort to catch silly things; this is * really a convenience mechanism. */

Source from the content-addressed store, hash-verified

1490 * really a convenience mechanism.
1491 */
1492static int
1493getmodeflags(const char *val)
1494{
1495 const char *cp;
1496 int flags;
1497
1498 flags = 0;
1499
1500 cp = strchr(val, ':');
1501 if (cp != NULL) {
1502 for (cp++; isalpha((int) *cp); cp++) {
1503 /* accept mixed case */
1504 int c = *cp;
1505 if (isupper(c))
1506 c = tolower(c);
1507 switch (c) {
1508 case 'a': /* 802.11a */
1509 flags |= IEEE80211_CHAN_A;
1510 break;
1511 case 'b': /* 802.11b */
1512 flags |= IEEE80211_CHAN_B;
1513 break;
1514 case 'g': /* 802.11g */
1515 flags |= IEEE80211_CHAN_G;
1516 break;
1517 case 'n': /* 802.11n */
1518 flags |= IEEE80211_CHAN_HT;
1519 break;
1520 case 'd': /* dt = Atheros Dynamic Turbo */
1521 flags |= IEEE80211_CHAN_TURBO;
1522 break;
1523 case 't': /* ht, dt, st, t */
1524 /* dt and unadorned t specify Dynamic Turbo */
1525 if ((flags & (IEEE80211_CHAN_STURBO|IEEE80211_CHAN_HT)) == 0)
1526 flags |= IEEE80211_CHAN_TURBO;
1527 break;
1528 case 's': /* st = Atheros Static Turbo */
1529 flags |= IEEE80211_CHAN_STURBO;
1530 break;
1531 case 'h': /* 1/2-width channels */
1532 flags |= IEEE80211_CHAN_HALF;
1533 break;
1534 case 'q': /* 1/4-width channels */
1535 flags |= IEEE80211_CHAN_QUARTER;
1536 break;
1537 case 'v':
1538 /* XXX set HT too? */
1539 flags |= IEEE80211_CHAN_VHT;
1540 break;
1541 default:
1542 errx(-1, "%s: Invalid mode attribute %c\n",
1543 val, *cp);
1544 }
1545 }
1546 }
1547 return flags;
1548}
1549

Callers 1

ifieee80211.cFile · 0.85

Calls 4

strchrFunction · 0.85
isalphaFunction · 0.85
isupperFunction · 0.85
tolowerFunction · 0.85

Tested by

no test coverage detected