return NL_SKIP;
}
-static int handle_info(struct nl_cb *cb,
+static int handle_info(struct nl80211_state *state,
+ struct nl_cb *cb,
struct nl_msg *msg,
int argc, char **argv)
{
return -1;
}
-static int handle_interface_add(struct nl_cb *cb,
+static int handle_interface_add(struct nl80211_state *state,
+ struct nl_cb *cb,
struct nl_msg *msg,
int argc, char **argv)
{
COMMAND(interface, add, "<name> type <type> [mesh_id <meshid>] [flags ...]",
NL80211_CMD_NEW_INTERFACE, 0, CIB_NETDEV, handle_interface_add);
-static int handle_interface_del(struct nl_cb *cb,
+static int handle_interface_del(struct nl80211_state *state,
+ struct nl_cb *cb,
struct nl_msg *msg,
int argc, char **argv)
{
return NL_SKIP;
}
-static int handle_interface_info(struct nl_cb *cb,
+static int handle_interface_info(struct nl80211_state *state,
+ struct nl_cb *cb,
struct nl_msg *msg,
int argc, char **argv)
{
}
TOPLEVEL(info, NULL, NL80211_CMD_GET_INTERFACE, 0, CIB_NETDEV, handle_interface_info);
-static int handle_interface_set(struct nl_cb *cb,
+static int handle_interface_set(struct nl80211_state *state,
+ struct nl_cb *cb,
struct nl_msg *msg,
int argc, char **argv)
{
COMMAND(set, monitor, "<flag> [...]",
NL80211_CMD_SET_INTERFACE, 0, CIB_NETDEV, handle_interface_set);
-static int handle_interface_meshid(struct nl_cb *cb,
+static int handle_interface_meshid(struct nl80211_state *state,
+ struct nl_cb *cb,
struct nl_msg *msg,
int argc, char **argv)
{
fprintf(stderr, "\tphy <phyname> ");
break;
case CIB_NETDEV:
+ case CIB_NETDEV_RAW:
fprintf(stderr, "\tdev <devname> ");
break;
}
return NL_STOP;
}
-enum id_input {
- II_NONE,
- II_NETDEV,
- II_PHY_NAME,
- II_PHY_IDX,
-};
-
-static int handle_cmd(struct nl80211_state *state,
- enum id_input idby,
- int argc, char **argv)
+int handle_cmd(struct nl80211_state *state, enum id_input idby,
+ int argc, char **argv)
{
struct cmd *cmd;
- struct nl_cb *cb = NULL;
+ struct nl_cb *cb;
struct nl_msg *msg;
int devidx = 0;
int err;
if (cmd >= &__stop___cmd)
return 1;
+ if (cmd->idby == CIB_NETDEV_RAW) {
+ argc++;
+ argv--;
+ return cmd->handler(state, NULL, NULL, argc, argv);
+ }
+
msg = nlmsg_alloc();
if (!msg) {
fprintf(stderr, "failed to allocate netlink message\n");
break;
}
- err = cmd->handler(cb, msg, argc, argv);
+ err = cmd->handler(state, cb, msg, argc, argv);
if (err)
goto out;
CIB_NONE,
CIB_PHY,
CIB_NETDEV,
+ CIB_NETDEV_RAW,
+};
+
+enum id_input {
+ II_NONE,
+ II_NETDEV,
+ II_PHY_NAME,
+ II_PHY_IDX,
};
struct cmd {
* zero on success, 1 if the arguments were wrong
* and the usage message should and 2 otherwise.
*/
- int (*handler)(struct nl_cb *cb,
+ int (*handler)(struct nl80211_state *state,
+ struct nl_cb *cb,
struct nl_msg *msg,
int argc, char **argv);
};
extern struct cmd __start___cmd;
extern struct cmd __stop___cmd;
+
+int handle_cmd(struct nl80211_state *state, enum id_input idby,
+ int argc, char **argv);
+
+
int mac_addr_a2n(unsigned char *mac_addr, char *arg);
int mac_addr_n2a(char *mac_addr, unsigned char *arg);
}
/* Setter */
-static int set_interface_meshparam(struct nl_cb *cb,
- struct nl_msg *msg,
- int argc, char **argv)
+static int set_interface_meshparam(struct nl80211_state *state,
+ struct nl_cb *cb,
+ struct nl_msg *msg,
+ int argc, char **argv)
{
int err;
uint32_t ret;
return NL_SKIP;
}
-static int get_interface_meshparam(struct nl_cb *cb,
- struct nl_msg *msg,
- int argc, char **argv)
+static int get_interface_meshparam(struct nl80211_state *state,
+ struct nl_cb *cb,
+ struct nl_msg *msg,
+ int argc, char **argv)
{
const struct mesh_param_descr *mdescr;
return NL_SKIP;
}
-static int handle_mpath_get(struct nl_cb *cb,
+static int handle_mpath_get(struct nl80211_state *state,
+ struct nl_cb *cb,
struct nl_msg *msg,
int argc, char **argv)
{
COMMAND(mpath, del, "<MAC address>",
NL80211_CMD_DEL_MPATH, 0, CIB_NETDEV, handle_mpath_get);
-static int handle_mpath_set(struct nl_cb *cb,
+static int handle_mpath_set(struct nl80211_state *state,
+ struct nl_cb *cb,
struct nl_msg *msg,
int argc, char **argv)
{
COMMAND(mpath, set, "<destination MAC address> next_hop <next hop MAC address>",
NL80211_CMD_SET_MPATH, 0, CIB_NETDEV, handle_mpath_set);
-static int handle_mpath_dump(struct nl_cb *cb,
+static int handle_mpath_dump(struct nl80211_state *state,
+ struct nl_cb *cb,
struct nl_msg *msg,
int argc, char **argv)
{
#include "nl80211.h"
#include "iw.h"
-static int handle_name(struct nl_cb *cb,
+static int handle_name(struct nl80211_state *state,
+ struct nl_cb *cb,
struct nl_msg *msg,
int argc, char **argv)
{
return -ENOBUFS;
}
-static int handle_freq(struct nl_cb *cb, struct nl_msg *msg,
+static int handle_freq(struct nl80211_state *state,
+ struct nl_cb *cb, struct nl_msg *msg,
int argc, char **argv)
{
return handle_freqchan(msg, false, argc, argv);
COMMAND(set, freq, "<freq> [HT20|HT40+|HT40-]",
NL80211_CMD_SET_WIPHY, 0, CIB_NETDEV, handle_freq);
-static int handle_chan(struct nl_cb *cb, struct nl_msg *msg,
+static int handle_chan(struct nl80211_state *state,
+ struct nl_cb *cb, struct nl_msg *msg,
int argc, char **argv)
{
return handle_freqchan(msg, true, argc, argv);
}
}
-static int handle_reg_set(struct nl_cb *cb,
+static int handle_reg_set(struct nl80211_state *state,
+ struct nl_cb *cb,
struct nl_msg *msg,
int argc, char **argv)
{
#undef PARSE_FLAG
}
-static int handle_reg_get(struct nl_cb *cb,
+static int handle_reg_get(struct nl80211_state *state,
+ struct nl_cb *cb,
struct nl_msg *msg,
int argc, char **argv)
{
bool unknown;
};
-static int handle_scan(struct nl_cb *cb,
+static int handle_scan(struct nl80211_state *state,
+ struct nl_cb *cb,
struct nl_msg *msg,
int argc, char **argv)
{
static struct scan_params scan_params;
-static int handle_scan_dump(struct nl_cb *cb,
+static int handle_scan_dump(struct nl80211_state *state,
+ struct nl_cb *cb,
struct nl_msg *msg,
int argc, char **argv)
{
return NL_SKIP;
}
-static int handle_station_get(struct nl_cb *cb,
+static int handle_station_get(struct nl80211_state *state,
+ struct nl_cb *cb,
struct nl_msg *msg,
int argc, char **argv)
{
COMMAND(station, del, "<MAC address>",
NL80211_CMD_DEL_STATION, 0, CIB_NETDEV, handle_station_get);
-static int handle_station_set(struct nl_cb *cb,
+static int handle_station_set(struct nl80211_state *state,
+ struct nl_cb *cb,
struct nl_msg *msg,
int argc, char **argv)
{
COMMAND(station, set, "<MAC address> plink_action <open|block>",
NL80211_CMD_SET_STATION, 0, CIB_NETDEV, handle_station_set);
-static int handle_station_dump(struct nl_cb *cb,
+static int handle_station_dump(struct nl80211_state *state,
+ struct nl_cb *cb,
struct nl_msg *msg,
int argc, char **argv)
{