diff options
author | Felix Fietkau <nbd@openwrt.org> | 2007-01-22 14:46:37 +0000 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2007-01-22 14:46:37 +0000 |
commit | 88436e8d37d4c6f60809f0ac6f190515673618a1 (patch) | |
tree | b4f29b0681c4c20011f19a34530acf2315923d92 /package/nvram/src/wl.c | |
parent | e8caa3c42b3772092fc0c645d646a95dff2a4311 (diff) | |
download | upstream-88436e8d37d4c6f60809f0ac6f190515673618a1.tar.gz upstream-88436e8d37d4c6f60809f0ac6f190515673618a1.tar.bz2 upstream-88436e8d37d4c6f60809f0ac6f190515673618a1.zip |
remove lots of useless junk from the nvram package
SVN-Revision: 6177
Diffstat (limited to 'package/nvram/src/wl.c')
-rw-r--r-- | package/nvram/src/wl.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/package/nvram/src/wl.c b/package/nvram/src/wl.c index 5738e2cd04..c33610310c 100644 --- a/package/nvram/src/wl.c +++ b/package/nvram/src/wl.c @@ -11,12 +11,69 @@ * * $Id$ */ +#include <stdio.h> +#include <unistd.h> #include <string.h> +#include <errno.h> +#include <sys/ioctl.h> +#include <net/if.h> #include <typedefs.h> #include <wlutils.h> 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) { int ret, val; |