static void print_all_mesh_param_descr(void)
{
- int i;
+ unsigned int i;
printf("Possible mesh parameters are:\n");
static const struct mesh_param_descr *find_mesh_param(const char *name)
{
- int i;
+ unsigned int i;
/* Find out what mesh parameter we want to change. */
for (i = 0; i < ARRAY_SIZE(_mesh_param_descrs); i++) {
return _mesh_param_descrs + i;
}
- print_all_mesh_param_descr();
return NULL;
}
if (!container)
return -ENOBUFS;
- if (!argc)
+ if (!argc) {
+ print_all_mesh_param_descr();
return 1;
+ }
while (argc) {
const char *name;
}
mdescr = find_mesh_param(name);
- if (!mdescr)
+ if (!mdescr) {
+ printf("Could not find the parameter %s.\n", name);
+ print_all_mesh_param_descr();
return 2;
+ }
/* Parse the new value */
ret = mdescr->parse_fn(value, &any);
return -EINVAL;
if (!mdescr) {
- int i;
+ unsigned int i;
for (i = 0; i < ARRAY_SIZE(_mesh_param_descrs); i++) {
mdescr = &_mesh_param_descrs[i];
{
const struct mesh_param_descr *mdescr = NULL;
- if (argc > 1)
+ if (argc == 0) {
+ print_all_mesh_param_descr();
return 1;
-
- if (argc == 1) {
+ } else if (argc == 1) {
mdescr = find_mesh_param(argv[0]);
- if (!mdescr)
+ if (!mdescr) {
+ printf("Could not find the parameter %s.\n", argv[0]);
+ print_all_mesh_param_descr();
return 2;
+ }
+ } else {
+ return 1;
}
register_handler(print_mesh_param_handler, (void *)mdescr);
struct nlattr *container;
float rate;
unsigned char rates[NL80211_MAX_SUPP_RATES];
- int bintval, dtim_period, i, n_rates = 0;
+ int bintval, dtim_period, n_rates = 0;
char *end, *value = NULL, *sptr = NULL;
- unsigned long freq = 0;
- static const struct {
- const char *name;
- unsigned int width;
- int freq1_diff;
- int chantype; /* for older kernel */
- } *chanmode_selected = NULL, chanmode[] = {
- { .name = "HT20",
- .width = NL80211_CHAN_WIDTH_20,
- .freq1_diff = 0,
- .chantype = NL80211_CHAN_HT20 },
- { .name = "HT40+",
- .width = NL80211_CHAN_WIDTH_40,
- .freq1_diff = 10,
- .chantype = NL80211_CHAN_HT40PLUS },
- { .name = "HT40-",
- .width = NL80211_CHAN_WIDTH_40,
- .freq1_diff = -10,
- .chantype = NL80211_CHAN_HT40MINUS },
- { .name = "NOHT",
- .width = NL80211_CHAN_WIDTH_20_NOHT,
- .freq1_diff = 0,
- .chantype = NL80211_CHAN_NO_HT },
- };
if (argc < 1)
return 1;
/* freq */
if (argc > 1 && strcmp(argv[0], "freq") == 0) {
- argv++;
- argc--;
-
- freq = strtoul(argv[0], &end, 10);
- if (*end != '\0')
- return 1;
- NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq);
+ struct chandef chandef;
+ int err, parsed;
- argv++;
- argc--;
- }
-
- /* channel type */
- if (argc) {
- for (i = 0; i < ARRAY_SIZE(chanmode); i++) {
- if (strcasecmp(chanmode[i].name, argv[0]) == 0) {
- chanmode_selected = &chanmode[i];
- break;
- }
- }
+ err = parse_freqchan(&chandef, false, argc - 1, argv + 1,
+ &parsed);
+ if (err)
+ return err;
- if (chanmode_selected) {
- NLA_PUT_U32(msg, NL80211_ATTR_CHANNEL_WIDTH,
- chanmode_selected->width);
- NLA_PUT_U32(msg, NL80211_ATTR_CENTER_FREQ1,
- freq + chanmode_selected->freq1_diff);
- if (chanmode_selected->chantype != -1)
- NLA_PUT_U32(msg,
- NL80211_ATTR_WIPHY_CHANNEL_TYPE,
- chanmode_selected->chantype);
+ argv += parsed + 1;
+ argc -= parsed + 1;
- argv++;
- argc--;
- }
+ put_chandef(msg, &chandef);
+ if (err)
+ return err;
}
/* basic rates */
nla_put_failure:
return -ENOBUFS;
}
-COMMAND(mesh, join, "<mesh ID> [[freq <freq in MHz> <HT20|HT40+|HT40-|NOHT>]"
+COMMAND(mesh, join, "<mesh ID> [[freq <freq in MHz> <NOHT|HT20|HT40+|HT40-|80MHz>]"
" [basic-rates <rate in Mbps,rate2,...>]], [mcast-rate <rate in Mbps>]"
" [beacon-interval <time in TUs>] [dtim-period <value>]"
" [vendor_sync on|off] [<param>=<value>]*",