5 #include <netlink/genl/genl.h>
6 #include <netlink/genl/family.h>
7 #include <netlink/genl/ctrl.h>
8 #include <netlink/msg.h>
9 #include <netlink/attr.h>
16 static int read_file(FILE *file
, char *buf
, size_t size
)
20 while ((data
= fgetc(file
)) != EOF
) {
30 static int read_hex(int argc
, char **argv
, char *buf
, size_t size
)
38 for (i
= 0; i
< argc
; i
++) {
39 res
= sscanf(argv
[i
], "0x%x", &data
);
40 if (res
!= 1 || data
> 0xff)
48 static int handle_vendor(struct nl80211_state
*state
, struct nl_cb
*cb
,
49 struct nl_msg
*msg
, int argc
, char **argv
,
61 res
= sscanf(argv
[0], "0x%x", &oui
);
65 res
= sscanf(argv
[1], "0x%x", &subcmd
);
69 if (!strcmp(argv
[2], "-"))
72 file
= fopen(argv
[2], "r");
74 NLA_PUT_U32(msg
, NL80211_ATTR_VENDOR_ID
, oui
);
75 NLA_PUT_U32(msg
, NL80211_ATTR_VENDOR_SUBCMD
, subcmd
);
78 count
= read_file(file
, buf
, sizeof(buf
));
81 count
= read_hex(argc
- 2, &argv
[2], buf
, sizeof(buf
));
87 NLA_PUT(msg
, NL80211_ATTR_VENDOR_DATA
, count
, buf
);
95 COMMAND(vendor
, send
, "<oui> <subcmd> <filename|-|hex data>", NL80211_CMD_VENDOR
, 0, CIB_NETDEV
, handle_vendor
, "");