我试图扩展'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及其使用有一个很好的文档?有人能发现我的问题吗?
发布于 2014-07-24 07:10:03
从netlink套接字的另一端的内核代码(在linux/net/wireless/nl80211.c -我使用的是3.13.0-30)来看,似乎有几个原因可以得到“无效参数”(-EINVAL)响应。
首先,您需要给它一个有效的接口,并且设备需要处于AP或P2P_GO模式。您还需要提供所有TXQ参数,而不仅仅是争用窗口值。如果您想确切地了解消息的处理方式,请参阅nl80211.c中的nl80211_set_wiphy()和parse_txq_params()函数。
但是,您确实对参数使用了正确的类型:u8 80211_TXQ_ATTR_QUEUE/u8 80211_TXQ_ATTR_AC(取决于版本)和NL80211_TXQ_ATTR_AIFS是u8,其他三种(NL80211_TXQ_ATTR_TXOP、NL80211_TXQ_ATTR_CWMIN和NL80211_TXQ_ATTR_CWMAX)是u16。
https://stackoverflow.com/questions/24289775
复制相似问题