2 * Wireless network adapter utilities (linux-specific)
4 * Copyright 2005, Broadcom Corporation
7 * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8 * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9 * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10 * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
12 * $Id: wl_linux.c,v 1.1.1.8 2005/03/07 07:31:20 kanki Exp $
19 #include <sys/ioctl.h>
22 typedef u_int64_t u64
;
23 typedef u_int32_t u32
;
24 typedef u_int16_t u16
;
26 #include <linux/types.h>
27 #include <linux/sockios.h>
28 #include <linux/ethtool.h>
34 // xref: nas,wlconf,httpd,rc,
35 int wl_ioctl(char *name
, int cmd
, void *buf
, int len
)
42 /* open socket to kernel */
43 if ((s
= socket(AF_INET
, SOCK_DGRAM
, 0)) < 0) {
53 /* initializing the remaining fields */
58 strncpy(ifr
.ifr_name
, name
, IFNAMSIZ
);
59 ifr
.ifr_data
= (caddr_t
) &ioc
;
60 ret
= ioctl(s
, SIOCDEVPRIVATE
, &ifr
);
62 if ((ret = ioctl(s, SIOCDEVPRIVATE, &ifr)) < 0)
63 if (cmd != WLC_GET_MAGIC)
71 // xref: wl.c:wl_probe()
72 int wl_get_dev_type(char *name
, void *buf
, int len
)
77 struct ethtool_drvinfo info
;
79 /* open socket to kernel */
80 if ((s
= socket(AF_INET
, SOCK_DGRAM
, 0)) < 0) {
86 memset(&info
, 0, sizeof(info
));
87 info
.cmd
= ETHTOOL_GDRVINFO
;
88 ifr
.ifr_data
= (caddr_t
)&info
;
89 strlcpy(ifr
.ifr_name
, name
, IFNAMSIZ
);
90 if ((ret
= ioctl(s
, SIOCETHTOOL
, &ifr
)) < 0) {
94 strlcpy(buf
, info
.driver
, len
);
102 int wl_hwaddr(char *name
, unsigned char *hwaddr
)
108 /* open socket to kernel */
109 if ((s
= socket(AF_INET
, SOCK_DGRAM
, 0)) < 0) {
115 strlcpy(ifr
.ifr_name
, name
, IFNAMSIZ
);
116 if ((ret
= ioctl(s
, SIOCGIFHWADDR
, &ifr
)) == 0)
117 memcpy(hwaddr
, ifr
.ifr_hwaddr
.sa_data
, ETHER_ADDR_LEN
);