我尝试扩展“iw”实用程序以允许它设置 802.11 争用窗口的最大和最小大小。但我总是得到一个“无效的参数(-22)”返回。
我编辑了 iw-3.15 源的 phy.c 并附加了
static int handle_txq(struct nl80211_state *state,
struct nl_cb *cb,
struct nl_msg *msg,
int argc, char **argv,
enum id_input id)
{
unsigned int cw_min, cw_max;
printf("HANDLE TXQ");
if (argc != 2)
return 1;
cw_min = atoi(argv[0]);
cw_max = atoi(argv[1]);
printf("setting contention window to: %d - %d\n",cw_min,cw_max);
//create nested txq array
struct nlattr *nested;
nested = nla_nest_start(msg,NL80211_ATTR_WIPHY_TXQ_PARAMS);
NLA_PUT_U16(msg,NL80211_TXQ_ATTR_CWMIN,cw_min);
NLA_PUT_U16(msg,NL80211_TXQ_ATTR_CWMAX,cw_max);
nla_nest_end(msg,nested);
return 0;
nla_put_failure:
return -ENOBUFS;
}
COMMAND(set, txq, "<cw_min> <cw_max>",
NL80211_CMD_SET_WIPHY, 0, CIB_NETDEV, handle_txq,
"Set contention window minimum and maximum size.\n"
"Valid values: 1 - 32767 in the form 2^n-1");
COMMAND(set, txq, "<cw_min> <cw_max>",
NL80211_CMD_SET_WIPHY, 0, CIB_PHY, handle_txq,
"Set contention window minimum and maximum size.\n"
"Valid values: 1 - 32767 in the form 2^n-1");
除了头文件本身之外,我找不到 nl80211 的任何好的文档或通过 netlink 使用它。我不确定我是否根据规范构造嵌套消息并且使用 U16 作为属性是有根据的猜测(它们在匹配的 cfg80211 中是 uint_16)。
根据我对 netlink 的理解,我的消息程序集应该是正确的,但由于我收到错误,我可能错了……有人有关于 nl80211 及其用法的良好文档吗?谁能发现我的问题?