36eb3af3f5158acec1a9e52d43b6b35e20a20335
[openwrt-10.03/.git] / package / nvram / src / include / wlutils.h
1 /*
2  * Broadcom wireless network adapter utility functions
3  *
4  * Copyright 2004, Broadcom Corporation
5  * All Rights Reserved.
6  * 
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.
11  *
12  * $Id$
13  */
14
15 #ifndef _wlutils_h_
16 #define _wlutils_h_
17
18 #include <typedefs.h>
19
20 /* check this magic number */
21 #define WLC_IOCTL_MAGIC         0x14e46c77
22
23 /* maximum length buffer required */
24 #define WLC_IOCTL_SMLEN         256
25
26 #define WLC_IOCTL_VERSION       1
27
28 #define WLC_GET_MAGIC                           0
29 #define WLC_GET_VERSION                         1
30 #define WLC_GET_VAR                             262     /* get value of named variable */
31 #define WLC_SET_VAR                             263     /* set named variable to value */
32
33 /* Linux network driver ioctl encoding */
34 typedef struct wl_ioctl {
35         uint cmd;       /* common ioctl definition */
36         void *buf;      /* pointer to user buffer */
37         uint len;       /* length of user buffer */
38         bool set;       /* get or set request (optional) */
39         uint used;      /* bytes read or written (optional) */
40         uint needed;    /* bytes needed (optional) */
41 } wl_ioctl_t;
42
43
44 /*
45  * Pass a wlioctl request to the specified interface.
46  * @param       name    interface name
47  * @param       cmd     WLC_GET_MAGIC <= cmd < WLC_LAST
48  * @param       buf     buffer for passing in and/or receiving data
49  * @param       len     length of buf
50  * @return      >= 0 if successful or < 0 otherwise
51  */
52 extern int wl_ioctl(char *name, int cmd, void *buf, int len);
53
54 /*
55  * Get the MAC (hardware) address of the specified interface.
56  * @param       name    interface name
57  * @param       hwaddr  6-byte buffer for receiving address
58  * @return      >= 0 if successful or < 0 otherwise
59  */
60 extern int wl_hwaddr(char *name, unsigned char *hwaddr);
61
62 /*
63  * Probe the specified interface.
64  * @param       name    interface name
65  * @return      >= 0 if a Broadcom wireless device or < 0 otherwise
66  */
67 extern int wl_probe(char *name);
68
69 /*
70  * Set/Get named variable.
71  * @param       name    interface name
72  * @param       var     variable name
73  * @param       val     variable value/buffer
74  * @param       len     variable value/buffer length
75  * @return      success == 0, failure != 0
76  */
77 extern int wl_set_val(char *name, char *var, void *val, int len);
78 extern int wl_get_val(char *name, char *var, void *val, int len);
79 extern int wl_set_int(char *name, char *var, int val);
80 extern int wl_get_int(char *name, char *var, int *val);
81
82 #endif /* _wlutils_h_ */