diff options
| author | Felix Fietkau <nbd@openwrt.org> | 2005-07-24 19:58:14 +0000 |
|---|---|---|
| committer | Felix Fietkau <nbd@openwrt.org> | 2005-07-24 19:58:14 +0000 |
| commit | 910f49d7b9c08f9745bd5eb60cfb800c940899c3 (patch) | |
| tree | 2127b232ba8b642de1105e7cc7f0d1c60563c4bf /openwrt/package/nvram/src/wl_linux.c | |
| parent | 725321d472f211acae0b67a1f041a7144a86fe9d (diff) | |
| download | mtk-20170518-910f49d7b9c08f9745bd5eb60cfb800c940899c3.zip mtk-20170518-910f49d7b9c08f9745bd5eb60cfb800c940899c3.tar.gz mtk-20170518-910f49d7b9c08f9745bd5eb60cfb800c940899c3.tar.bz2 | |
move wificonf and nvram stuff back to package/, remove build_mipsel/root, run install part of package/ for every board/kernel - fixes dependency mess
SVN-Revision: 1540
Diffstat (limited to 'openwrt/package/nvram/src/wl_linux.c')
| -rw-r--r-- | openwrt/package/nvram/src/wl_linux.c | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/openwrt/package/nvram/src/wl_linux.c b/openwrt/package/nvram/src/wl_linux.c new file mode 100644 index 0000000..126a40b --- /dev/null +++ b/openwrt/package/nvram/src/wl_linux.c @@ -0,0 +1,77 @@ +/* + * Wireless network adapter utilities (linux-specific) + * + * Copyright 2004, Broadcom Corporation + * All Rights Reserved. + * + * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY + * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM + * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE. + * + * $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 <wlioctl.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; +} + |
