1 #include <errno.h> 2 3 #include <netlink/genl/genl.h> 4 #include <netlink/genl/family.h> 5 #include <netlink/genl/ctrl.h> 6 #include <netlink/msg.h> 7 #include <netlink/attr.h> 8 9 #include "nl80211.h" 10 #include "iw.h" 11 12 static int offchannel(struct nl80211_state *state, struct nl_cb *cb, 13 struct nl_msg *msg, int argc, char **argv, 14 enum id_input id) 15 { 16 char *end; 17 18 /* freq */ 19 NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, 20 strtoul(argv[0], &end, 10)); 21 if (*end != '\0') 22 return 1; 23 argv++; 24 argc--; 25 26 /* duration */ 27 NLA_PUT_U32(msg, NL80211_ATTR_DURATION, 28 strtoul(argv[0], &end, 10)); 29 if (*end != '\0') 30 return 1; 31 argv++; 32 argc--; 33 34 if (argc) 35 return 1; 36 37 return 0; 38 nla_put_failure: 39 return -ENOSPC; 40 } 41 42 TOPLEVEL(offchannel, "<freq> <duration>", NL80211_CMD_REMAIN_ON_CHANNEL, 0, 43 CIB_NETDEV, offchannel, 44 "Leave operating channel and go to the given channel for a while."); 45