3 #include <sys/socket.h>
7 #include "wireless-lite.h"
9 /* returns 0 on success. */
10 int set_channel(const char* iface
, int channel
) {
12 if((s
= socket(AF_INET
, SOCK_DGRAM
, 0)) < 0) {
17 struct iwreq req
= {.u
.freq
.m
= channel
, .u
.freq
.flags
= IW_FREQ_FIXED
};
18 snprintf(req
.ifr_name
, IFNAMSIZ
, "%s", iface
);
21 if((ret
= ioctl(s
, SIOCSIWFREQ
, &req
) < 0)) {
31 static int usage(char* argv0
) {
32 dprintf(2, "usage: %s interface channel\n", argv0
);
36 int main(int argc
, char** argv
) {
37 if(argc
!= 3) return usage(argv
[0]);
38 return set_channel(argv
[1], atoi(argv
[2]));