X-Git-Url: https://git.rohieb.name/openwrt.git/blobdiff_plain/5e220c57cca550851d9e1c9990d2bb9df323a1bb..c38283c4869eaa426735e08186218815cab2cf9e:/package/nvram/src/wl.c?ds=inline diff --git a/package/nvram/src/wl.c b/package/nvram/src/wl.c index 5738e2cd0..c33610310 100644 --- a/package/nvram/src/wl.c +++ b/package/nvram/src/wl.c @@ -11,11 +11,68 @@ * * $Id$ */ +#include +#include #include +#include +#include +#include #include #include +int +wl_ioctl(char *name, int cmd, void *buf, int len) +{ + struct ifreq ifr; + wl_ioctl_t ioc; + int ret = 0; + int s; + + /* open socket to kernel */ + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + perror("socket"); + return errno; + } + + /* do it */ + ioc.cmd = cmd; + ioc.buf = buf; + ioc.len = len; + strncpy(ifr.ifr_name, name, IFNAMSIZ); + ifr.ifr_data = (caddr_t) &ioc; + if ((ret = ioctl(s, SIOCDEVPRIVATE, &ifr)) < 0) + if (cmd != WLC_GET_MAGIC) + perror(ifr.ifr_name); + + /* cleanup */ + close(s); + return ret; +} + +int +wl_hwaddr(char *name, unsigned char *hwaddr) +{ + struct ifreq ifr; + int ret = 0; + int s; + + /* open socket to kernel */ + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + perror("socket"); + return errno; + } + + /* do it */ + strncpy(ifr.ifr_name, name, IFNAMSIZ); + if ((ret = ioctl(s, SIOCGIFHWADDR, &ifr)) == 0) + memcpy(hwaddr, ifr.ifr_hwaddr.sa_data, ETHER_ADDR_LEN); + + /* cleanup */ + close(s); + return ret; +} + int wl_probe(char *name) {