5 #include <netlink/genl/genl.h>
6 #include <netlink/genl/family.h>
7 #include <netlink/genl/ctrl.h>
8 #include <netlink/msg.h>
9 #include <netlink/attr.h>
14 static int handle_name(struct nl80211_state
*state
,
17 int argc
, char **argv
)
22 NLA_PUT_STRING(msg
, NL80211_ATTR_WIPHY_NAME
, *argv
);
28 COMMAND(set
, name
, "<new name>", NL80211_CMD_SET_WIPHY
, 0, CIB_PHY
, handle_name
);
30 static int handle_freqchan(struct nl_msg
*msg
, bool chan
,
31 int argc
, char **argv
)
37 { .name
= "HT20", .val
= NL80211_CHAN_HT20
, },
38 { .name
= "HT40+", .val
= NL80211_CHAN_HT40PLUS
, },
39 { .name
= "HT40-", .val
= NL80211_CHAN_HT40MINUS
, },
41 unsigned int htval
= NL80211_CHAN_NO_HT
;
45 if (!argc
|| argc
> 2)
49 for (i
= 0; i
< ARRAY_SIZE(htmap
); i
++) {
50 if (strcasecmp(htmap
[i
].name
, argv
[1]) == 0) {
55 if (htval
== NL80211_CHAN_NO_HT
)
59 freq
= strtoul(argv
[0], NULL
, 10);
61 freq
= ieee80211_channel_to_frequency(freq
);
63 NLA_PUT_U32(msg
, NL80211_ATTR_WIPHY_FREQ
, freq
);
64 NLA_PUT_U32(msg
, NL80211_ATTR_WIPHY_CHANNEL_TYPE
, htval
);
71 static int handle_freq(struct nl80211_state
*state
,
72 struct nl_cb
*cb
, struct nl_msg
*msg
,
73 int argc
, char **argv
)
75 return handle_freqchan(msg
, false, argc
, argv
);
77 COMMAND(set
, freq
, "<freq> [HT20|HT40+|HT40-]",
78 NL80211_CMD_SET_WIPHY
, 0, CIB_PHY
, handle_freq
);
79 COMMAND(set
, freq
, "<freq> [HT20|HT40+|HT40-]",
80 NL80211_CMD_SET_WIPHY
, 0, CIB_NETDEV
, handle_freq
);
82 static int handle_chan(struct nl80211_state
*state
,
83 struct nl_cb
*cb
, struct nl_msg
*msg
,
84 int argc
, char **argv
)
86 return handle_freqchan(msg
, true, argc
, argv
);
88 COMMAND(set
, channel
, "<channel> [HT20|HT40+|HT40-]",
89 NL80211_CMD_SET_WIPHY
, 0, CIB_PHY
, handle_chan
);
90 COMMAND(set
, channel
, "<channel> [HT20|HT40+|HT40-]",
91 NL80211_CMD_SET_WIPHY
, 0, CIB_NETDEV
, handle_chan
);