Friday, 15 February 2013

c - libnl 'invalid argument (-22) while trying using nl80211 -



c - libnl 'invalid argument (-22) while trying using nl80211 -

i tried extend 'iw' utility allow set maximum , minimum size of 802.11 contention window. i'm getting 'invalid argument (-22)' returned.

i edited phy.c of iw-3.15 source , appended

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) homecoming 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); homecoming 0; nla_put_failure: homecoming -enobufs; } command(set, txq, "<cw_min> <cw_max>", nl80211_cmd_set_wiphy, 0, cib_netdev, handle_txq, "set contention window minimum , maximum size.\n" "valid values: 1 - 32767 in form 2^n-1"); command(set, txq, "<cw_min> <cw_max>", nl80211_cmd_set_wiphy, 0, cib_phy, handle_txq, "set contention window minimum , maximum size.\n" "valid values: 1 - 32767 in form 2^n-1");

i couldn't find documentation of nl80211 or it's usage through netlink except header file itself. not sure if contruct nested message according specification , using u16 attributes educated guess (they uint_16 in matching cfg80211).

from understanding of netlink message assembly should correct, since error i'm wrong... have documentation nl80211 , usage? can spot problem?

from kernel code on other end of netlink socket (in linux/net/wireless/nl80211.c - using 3.13.0-30), seems there few reasons can "invalid argument" (-einval) response.

firstly, need give valid interface , device needs in ap or p2p_go mode. need provide txq params, not contention window values. see nl80211_set_wiphy() , parse_txq_params() functions in nl80211.c if want see how message beingness handled.

you appear using right types parameters though: nl80211_txq_attr_queue/nl80211_txq_attr_ac (depending on version) , nl80211_txq_attr_aifs u8, , other 3 (nl80211_txq_attr_txop, nl80211_txq_attr_cwmin , nl80211_txq_attr_cwmax) u16.

c linux-kernel wireless netlink

No comments:

Post a Comment