MCPcopy Create free account
hub / github.com/F-Stack/f-stack / set80211chanlist

Function set80211chanlist

tools/ifconfig/ifieee80211.c:1121–1171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1119}
1120
1121static void
1122set80211chanlist(const char *val, int d, int s, const struct afswtch *rafp)
1123{
1124 struct ieee80211req_chanlist chanlist;
1125 char *temp, *cp, *tp;
1126
1127 temp = malloc(strlen(val) + 1);
1128 if (temp == NULL)
1129 errx(1, "malloc failed");
1130 strcpy(temp, val);
1131 memset(&chanlist, 0, sizeof(chanlist));
1132 cp = temp;
1133 for (;;) {
1134 int first, last, f, c;
1135
1136 tp = strchr(cp, ',');
1137 if (tp != NULL)
1138 *tp++ = '\0';
1139 switch (sscanf(cp, "%u-%u", &first, &last)) {
1140 case 1:
1141 if (first > IEEE80211_CHAN_MAX)
1142 errx(-1, "channel %u out of range, max %u",
1143 first, IEEE80211_CHAN_MAX);
1144 setbit(chanlist.ic_channels, first);
1145 break;
1146 case 2:
1147 if (first > IEEE80211_CHAN_MAX)
1148 errx(-1, "channel %u out of range, max %u",
1149 first, IEEE80211_CHAN_MAX);
1150 if (last > IEEE80211_CHAN_MAX)
1151 errx(-1, "channel %u out of range, max %u",
1152 last, IEEE80211_CHAN_MAX);
1153 if (first > last)
1154 errx(-1, "void channel range, %u > %u",
1155 first, last);
1156 for (f = first; f <= last; f++)
1157 setbit(chanlist.ic_channels, f);
1158 break;
1159 }
1160 if (tp == NULL)
1161 break;
1162 c = *tp;
1163 while (isspace(c))
1164 tp++;
1165 if (!isdigit(c))
1166 break;
1167 cp = tp;
1168 }
1169 set80211(s, IEEE80211_IOC_CHANLIST, 0, sizeof(chanlist), &chanlist);
1170 free(temp);
1171}
1172
1173static void
1174set80211bssid(const char *val, int d, int s, const struct afswtch *rafp)

Callers

nothing calls this directly

Calls 8

mallocFunction · 0.85
memsetFunction · 0.85
strchrFunction · 0.85
sscanfFunction · 0.85
isspaceFunction · 0.85
isdigitFunction · 0.85
set80211Function · 0.85
freeFunction · 0.50

Tested by

no test coverage detected