update wlcompat for new ioctl interface (fixes #1357)
SVN-Revision: 7795
This commit is contained in:
parent
16ae1e57bc
commit
a977a42502
17 changed files with 2711 additions and 2106 deletions
|
@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
|
|||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=kmod-wlcompat
|
||||
PKG_RELEASE:=4
|
||||
PKG_RELEASE:=5
|
||||
|
||||
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
|
|
106
package/wlcompat/src/include/bcmdefs.h
Normal file
106
package/wlcompat/src/include/bcmdefs.h
Normal file
|
@ -0,0 +1,106 @@
|
|||
/*
|
||||
* Misc system wide definitions
|
||||
*
|
||||
* Copyright 2006, 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: bcmdefs.h,v 1.1.1.3 2006/04/08 06:13:39 honor Exp $
|
||||
*/
|
||||
|
||||
#ifndef _bcmdefs_h_
|
||||
#define _bcmdefs_h_
|
||||
|
||||
/*
|
||||
* One doesn't need to include this file explicitly, gets included automatically if
|
||||
* typedefs.h is included.
|
||||
*/
|
||||
|
||||
/* Reclaiming text and data :
|
||||
* The following macros specify special linker sections that can be reclaimed
|
||||
* after a system is considered 'up'.
|
||||
*/
|
||||
#if defined(__GNUC__) && defined(BCMRECLAIM)
|
||||
extern bool bcmreclaimed;
|
||||
#define BCMINITDATA(_data) __attribute__ ((__section__ (".dataini." #_data))) _data
|
||||
#define BCMINITFN(_fn) __attribute__ ((__section__ (".textini." #_fn))) _fn
|
||||
#else /* #if defined(__GNUC__) && defined(BCMRECLAIM) */
|
||||
#define BCMINITDATA(_data) _data
|
||||
#define BCMINITFN(_fn) _fn
|
||||
#define bcmreclaimed 0
|
||||
#endif /* #if defined(__GNUC__) && defined(BCMRECLAIM) */
|
||||
|
||||
/* Reclaim uninit functions if BCMNODOWN is defined */
|
||||
/* and if they are not already removed by -gc-sections */
|
||||
#ifdef BCMNODOWN
|
||||
#define BCMUNINITFN(_fn) BCMINITFN(_fn)
|
||||
#else
|
||||
#define BCMUNINITFN(_fn) _fn
|
||||
#endif
|
||||
|
||||
#ifdef BCMRECLAIM
|
||||
#define CONST
|
||||
#else
|
||||
#define CONST const
|
||||
#endif /* BCMRECLAIM */
|
||||
|
||||
/* Compatibility with old-style BCMRECLAIM */
|
||||
#define BCMINIT(_id) _id
|
||||
|
||||
|
||||
/* Put some library data/code into ROM to reduce RAM requirements */
|
||||
#if defined(__GNUC__) && defined(BCMROMOFFLOAD)
|
||||
#define BCMROMDATA(_data) __attribute__ ((__section__ (".datarom." #_data))) _data
|
||||
#define BCMROMFN(_fn) __attribute__ ((__section__ (".textrom." #_fn))) _fn
|
||||
#else
|
||||
#define BCMROMDATA(_data) _data
|
||||
#define BCMROMFN(_fn) _fn
|
||||
#endif
|
||||
|
||||
/* Bus types */
|
||||
#define SB_BUS 0 /* Silicon Backplane */
|
||||
#define PCI_BUS 1 /* PCI target */
|
||||
#define PCMCIA_BUS 2 /* PCMCIA target */
|
||||
#define SDIO_BUS 3 /* SDIO target */
|
||||
#define JTAG_BUS 4 /* JTAG */
|
||||
#define NO_BUS 0xFF /* Bus that does not support R/W REG */
|
||||
|
||||
/* Allows optimization for single-bus support */
|
||||
#ifdef BCMBUSTYPE
|
||||
#define BUSTYPE(bus) (BCMBUSTYPE)
|
||||
#else
|
||||
#define BUSTYPE(bus) (bus)
|
||||
#endif
|
||||
|
||||
/* Defines for DMA Address Width - Shared between OSL and HNDDMA */
|
||||
#define DMADDR_MASK_32 0x0 /* Address mask for 32-bits */
|
||||
#define DMADDR_MASK_30 0xc0000000 /* Address mask for 30-bits */
|
||||
#define DMADDR_MASK_0 0xffffffff /* Address mask for 0-bits (hi-part) */
|
||||
|
||||
#define DMADDRWIDTH_30 30 /* 30-bit addressing capability */
|
||||
#define DMADDRWIDTH_32 32 /* 32-bit addressing capability */
|
||||
#define DMADDRWIDTH_63 63 /* 64-bit addressing capability */
|
||||
#define DMADDRWIDTH_64 64 /* 64-bit addressing capability */
|
||||
|
||||
/* packet headroom necessary to accomodate the largest header in the system, (i.e TXOFF).
|
||||
* By doing, we avoid the need to allocate an extra buffer for the header when bridging to WL.
|
||||
* There is a compile time check in wlc.c which ensure that this value is at least as big
|
||||
* as TXOFF. This value is used in dma_rxfill (hnddma.c).
|
||||
*/
|
||||
#define BCMEXTRAHDROOM 160
|
||||
|
||||
/* Headroom required for dongle-to-host communication. Packets allocated
|
||||
* locally in the dongle (e.g. for CDC ioctls or RNDIS messages) should
|
||||
* leave this much room in front for low-level message headers which may
|
||||
* be needed to get across the dongle bus to the host. (These messages
|
||||
* don't go over the network, so room for the full WL header above would
|
||||
* be a waste.)
|
||||
*/
|
||||
#define BCMDONGLEHDRSZ 8
|
||||
|
||||
|
||||
|
||||
#endif /* _bcmdefs_h_ */
|
|
@ -1,148 +0,0 @@
|
|||
/*
|
||||
* NVRAM variable manipulation
|
||||
*
|
||||
* 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$
|
||||
*/
|
||||
|
||||
#ifndef _bcmnvram_h_
|
||||
#define _bcmnvram_h_
|
||||
|
||||
#ifndef _LANGUAGE_ASSEMBLY
|
||||
|
||||
#include <typedefs.h>
|
||||
|
||||
struct nvram_header {
|
||||
uint32 magic;
|
||||
uint32 len;
|
||||
uint32 crc_ver_init; /* 0:7 crc, 8:15 ver, 16:27 init, mem. test 28, 29-31 reserved */
|
||||
uint32 config_refresh; /* 0:15 config, 16:31 refresh */
|
||||
uint32 config_ncdl; /* ncdl values for memc */
|
||||
};
|
||||
|
||||
struct nvram_tuple {
|
||||
char *name;
|
||||
char *value;
|
||||
struct nvram_tuple *next;
|
||||
};
|
||||
|
||||
/*
|
||||
* Initialize NVRAM access. May be unnecessary or undefined on certain
|
||||
* platforms.
|
||||
*/
|
||||
extern int nvram_init(void *sbh);
|
||||
|
||||
/*
|
||||
* Disable NVRAM access. May be unnecessary or undefined on certain
|
||||
* platforms.
|
||||
*/
|
||||
extern void nvram_exit(void);
|
||||
|
||||
/*
|
||||
* Get the value of an NVRAM variable. The pointer returned may be
|
||||
* invalid after a set.
|
||||
* @param name name of variable to get
|
||||
* @return value of variable or NULL if undefined
|
||||
*/
|
||||
extern char * nvram_get(const char *name);
|
||||
|
||||
/*
|
||||
* Get the value of an NVRAM variable.
|
||||
* @param name name of variable to get
|
||||
* @return value of variable or NUL if undefined
|
||||
*/
|
||||
#define nvram_safe_get(name) (nvram_get(name) ? : "")
|
||||
|
||||
#define nvram_safe_unset(name) ({ \
|
||||
if(nvram_get(name)) \
|
||||
nvram_unset(name); \
|
||||
})
|
||||
|
||||
#define nvram_safe_set(name, value) ({ \
|
||||
if(!nvram_get(name) || strcmp(nvram_get(name), value)) \
|
||||
nvram_set(name, value); \
|
||||
})
|
||||
|
||||
/*
|
||||
* Match an NVRAM variable.
|
||||
* @param name name of variable to match
|
||||
* @param match value to compare against value of variable
|
||||
* @return TRUE if variable is defined and its value is string equal
|
||||
* to match or FALSE otherwise
|
||||
*/
|
||||
static INLINE int
|
||||
nvram_match(char *name, char *match) {
|
||||
const char *value = nvram_get(name);
|
||||
return (value && !strcmp(value, match));
|
||||
}
|
||||
|
||||
/*
|
||||
* Inversely match an NVRAM variable.
|
||||
* @param name name of variable to match
|
||||
* @param match value to compare against value of variable
|
||||
* @return TRUE if variable is defined and its value is not string
|
||||
* equal to invmatch or FALSE otherwise
|
||||
*/
|
||||
static INLINE int
|
||||
nvram_invmatch(char *name, char *invmatch) {
|
||||
const char *value = nvram_get(name);
|
||||
return (value && strcmp(value, invmatch));
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the value of an NVRAM variable. The name and value strings are
|
||||
* copied into private storage. Pointers to previously set values
|
||||
* may become invalid. The new value may be immediately
|
||||
* retrieved but will not be permanently stored until a commit.
|
||||
* @param name name of variable to set
|
||||
* @param value value of variable
|
||||
* @return 0 on success and errno on failure
|
||||
*/
|
||||
extern int nvram_set(const char *name, const char *value);
|
||||
|
||||
/*
|
||||
* Unset an NVRAM variable. Pointers to previously set values
|
||||
* remain valid until a set.
|
||||
* @param name name of variable to unset
|
||||
* @return 0 on success and errno on failure
|
||||
* NOTE: use nvram_commit to commit this change to flash.
|
||||
*/
|
||||
extern int nvram_unset(const char *name);
|
||||
|
||||
/*
|
||||
* Commit NVRAM variables to permanent storage. All pointers to values
|
||||
* may be invalid after a commit.
|
||||
* NVRAM values are undefined after a commit.
|
||||
* @return 0 on success and errno on failure
|
||||
*/
|
||||
extern int nvram_commit(void);
|
||||
|
||||
/*
|
||||
* Get all NVRAM variables (format name=value\0 ... \0\0).
|
||||
* @param buf buffer to store variables
|
||||
* @param count size of buffer in bytes
|
||||
* @return 0 on success and errno on failure
|
||||
*/
|
||||
extern int nvram_getall(char *buf, int count);
|
||||
|
||||
extern int file2nvram(char *filename, char *varname);
|
||||
extern int nvram2file(char *varname, char *filename);
|
||||
|
||||
#endif /* _LANGUAGE_ASSEMBLY */
|
||||
|
||||
#define NVRAM_MAGIC 0x48534C46 /* 'FLSH' */
|
||||
#define NVRAM_VERSION 1
|
||||
#define NVRAM_HEADER_SIZE 20
|
||||
#define NVRAM_SPACE 0x8000
|
||||
#define FLASH_BASE 0xbfc00000 /* Extif core */
|
||||
#define FLASH_MIN 0x00100000 /* Minimum flash size */
|
||||
#define FLASH_MAX 0x00400000 /* Maximum flash size with extif */
|
||||
|
||||
#endif /* _bcmnvram_h_ */
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Misc useful os-independent macros and functions.
|
||||
*
|
||||
* Copyright 2004, Broadcom Corporation
|
||||
* Copyright 2006, Broadcom Corporation
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
|
||||
|
@ -14,83 +14,157 @@
|
|||
#ifndef _bcmutils_h_
|
||||
#define _bcmutils_h_
|
||||
|
||||
/* ** driver/apps-shared section ** */
|
||||
|
||||
#define BCME_STRLEN 64 /* Max string length for BCM errors */
|
||||
#define VALID_BCMERROR(e) ((e <= 0) && (e >= BCME_LAST))
|
||||
|
||||
|
||||
/*
|
||||
* error codes could be added but the defined ones shouldn't be changed/deleted
|
||||
* these error codes are exposed to the user code
|
||||
* when ever a new error code is added to this list
|
||||
* please update errorstring table with the related error string and
|
||||
* update osl files with os specific errorcode map
|
||||
*/
|
||||
|
||||
#define BCME_OK 0 /* Success */
|
||||
#define BCME_ERROR -1 /* Error generic */
|
||||
#define BCME_BADARG -2 /* Bad Argument */
|
||||
#define BCME_BADOPTION -3 /* Bad option */
|
||||
#define BCME_NOTUP -4 /* Not up */
|
||||
#define BCME_NOTDOWN -5 /* Not down */
|
||||
#define BCME_NOTAP -6 /* Not AP */
|
||||
#define BCME_NOTSTA -7 /* Not STA */
|
||||
#define BCME_BADKEYIDX -8 /* BAD Key Index */
|
||||
#define BCME_RADIOOFF -9 /* Radio Off */
|
||||
#define BCME_NOTBANDLOCKED -10 /* Not band locked */
|
||||
#define BCME_NOCLK -11 /* No Clock */
|
||||
#define BCME_BADRATESET -12 /* BAD Rate valueset */
|
||||
#define BCME_BADBAND -13 /* BAD Band */
|
||||
#define BCME_BUFTOOSHORT -14 /* Buffer too short */
|
||||
#define BCME_BUFTOOLONG -15 /* Buffer too long */
|
||||
#define BCME_BUSY -16 /* Busy */
|
||||
#define BCME_NOTASSOCIATED -17 /* Not Associated */
|
||||
#define BCME_BADSSIDLEN -18 /* Bad SSID len */
|
||||
#define BCME_OUTOFRANGECHAN -19 /* Out of Range Channel */
|
||||
#define BCME_BADCHAN -20 /* Bad Channel */
|
||||
#define BCME_BADADDR -21 /* Bad Address */
|
||||
#define BCME_NORESOURCE -22 /* Not Enough Resources */
|
||||
#define BCME_UNSUPPORTED -23 /* Unsupported */
|
||||
#define BCME_BADLEN -24 /* Bad length */
|
||||
#define BCME_NOTREADY -25 /* Not Ready */
|
||||
#define BCME_EPERM -26 /* Not Permitted */
|
||||
#define BCME_NOMEM -27 /* No Memory */
|
||||
#define BCME_ASSOCIATED -28 /* Associated */
|
||||
#define BCME_RANGE -29 /* Not In Range */
|
||||
#define BCME_NOTFOUND -30 /* Not Found */
|
||||
#define BCME_WME_NOT_ENABLED -31 /* WME Not Enabled */
|
||||
#define BCME_TSPEC_NOTFOUND -32 /* TSPEC Not Found */
|
||||
#define BCME_ACM_NOTSUPPORTED -33 /* ACM Not Supported */
|
||||
#define BCME_NOT_WME_ASSOCIATION -34 /* Not WME Association */
|
||||
#define BCME_SDIO_ERROR -35 /* SDIO Bus Error */
|
||||
#define BCME_DONGLE_DOWN -36 /* Dongle Not Accessible */
|
||||
#define BCME_LAST BCME_DONGLE_DOWN
|
||||
|
||||
/* These are collection of BCME Error strings */
|
||||
#define BCMERRSTRINGTABLE { \
|
||||
"OK", \
|
||||
"Undefined error", \
|
||||
"Bad Argument", \
|
||||
"Bad Option", \
|
||||
"Not up", \
|
||||
"Not down", \
|
||||
"Not AP", \
|
||||
"Not STA", \
|
||||
"Bad Key Index", \
|
||||
"Radio Off", \
|
||||
"Not band locked", \
|
||||
"No clock", \
|
||||
"Bad Rate valueset", \
|
||||
"Bad Band", \
|
||||
"Buffer too short", \
|
||||
"Buffer too long", \
|
||||
"Busy", \
|
||||
"Not Associated", \
|
||||
"Bad SSID len", \
|
||||
"Out of Range Channel", \
|
||||
"Bad Channel", \
|
||||
"Bad Address", \
|
||||
"Not Enough Resources", \
|
||||
"Unsupported", \
|
||||
"Bad length", \
|
||||
"Not Ready", \
|
||||
"Not Permitted", \
|
||||
"No Memory", \
|
||||
"Associated", \
|
||||
"Not In Range", \
|
||||
"Not Found", \
|
||||
"WME Not Enabled", \
|
||||
"TSPEC Not Found", \
|
||||
"ACM Not Supported", \
|
||||
"Not WME Association", \
|
||||
"SDIO Bus Error", \
|
||||
"Dongle Not Accessible" \
|
||||
}
|
||||
|
||||
#ifndef ABS
|
||||
#define ABS(a) (((a) < 0)?-(a):(a))
|
||||
#endif /* ABS */
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) (((a)<(b))?(a):(b))
|
||||
#endif
|
||||
#define MIN(a, b) (((a) < (b))?(a):(b))
|
||||
#endif /* MIN */
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) (((a)>(b))?(a):(b))
|
||||
#endif
|
||||
#define MAX(a, b) (((a) > (b))?(a):(b))
|
||||
#endif /* MAX */
|
||||
|
||||
#define CEIL(x, y) (((x) + ((y)-1)) / (y))
|
||||
#define ROUNDUP(x, y) ((((ulong)(x)+((y)-1))/(y))*(y))
|
||||
#define ISALIGNED(a, x) (((uint)(a) & ((x)-1)) == 0)
|
||||
#define ISPOWEROF2(x) ((((x)-1)&(x))==0)
|
||||
#define OFFSETOF(type, member) ((uint) &((type *)0)->member)
|
||||
#define ROUNDUP(x, y) ((((x)+((y)-1))/(y))*(y))
|
||||
#define ISALIGNED(a, x) (((a) & ((x)-1)) == 0)
|
||||
#define ISPOWEROF2(x) ((((x)-1)&(x)) == 0)
|
||||
#define VALID_MASK(mask) !((mask) & ((mask) + 1))
|
||||
#define OFFSETOF(type, member) ((uint)(uintptr)&((type *)0)->member)
|
||||
#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
|
||||
|
||||
/* bit map related macros */
|
||||
#ifndef setbit
|
||||
#ifndef NBBY /* the BSD family defines NBBY */
|
||||
#define NBBY 8 /* 8 bits per byte */
|
||||
#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
|
||||
#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
|
||||
#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
|
||||
#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
|
||||
#endif
|
||||
#endif /* #ifndef NBBY */
|
||||
#define setbit(a, i) (((uint8 *)a)[(i)/NBBY] |= 1<<((i)%NBBY))
|
||||
#define clrbit(a, i) (((uint8 *)a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
|
||||
#define isset(a, i) (((uint8 *)a)[(i)/NBBY] & (1<<((i)%NBBY)))
|
||||
#define isclr(a, i) ((((uint8 *)a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
|
||||
#endif /* setbit */
|
||||
|
||||
#define NBITS(type) (sizeof (type) * 8)
|
||||
#define NBITS(type) (sizeof(type) * 8)
|
||||
#define NBITVAL(nbits) (1 << (nbits))
|
||||
#define MAXBITVAL(nbits) ((1 << (nbits)) - 1)
|
||||
#define NBITMASK(nbits) MAXBITVAL(nbits)
|
||||
#define MAXNBVAL(nbyte) MAXBITVAL((nbyte) * 8)
|
||||
|
||||
#define _BCM_U 0x01 /* upper */
|
||||
#define _BCM_L 0x02 /* lower */
|
||||
#define _BCM_D 0x04 /* digit */
|
||||
#define _BCM_C 0x08 /* cntrl */
|
||||
#define _BCM_P 0x10 /* punct */
|
||||
#define _BCM_S 0x20 /* white space (space/lf/tab) */
|
||||
#define _BCM_X 0x40 /* hex digit */
|
||||
#define _BCM_SP 0x80 /* hard space (0x20) */
|
||||
/* basic mux operation - can be optimized on several architectures */
|
||||
#define MUX(pred, true, false) ((pred) ? (true) : (false))
|
||||
|
||||
extern unsigned char bcm_ctype[];
|
||||
#define bcm_ismask(x) (bcm_ctype[(int)(unsigned char)(x)])
|
||||
/* modulo inc/dec - assumes x E [0, bound - 1] */
|
||||
#define MODDEC(x, bound) MUX((x) == 0, (bound) - 1, (x) - 1)
|
||||
#define MODINC(x, bound) MUX((x) == (bound) - 1, 0, (x) + 1)
|
||||
|
||||
#define bcm_isalnum(c) ((bcm_ismask(c)&(_BCM_U|_BCM_L|_BCM_D)) != 0)
|
||||
#define bcm_isalpha(c) ((bcm_ismask(c)&(_BCM_U|_BCM_L)) != 0)
|
||||
#define bcm_iscntrl(c) ((bcm_ismask(c)&(_BCM_C)) != 0)
|
||||
#define bcm_isdigit(c) ((bcm_ismask(c)&(_BCM_D)) != 0)
|
||||
#define bcm_isgraph(c) ((bcm_ismask(c)&(_BCM_P|_BCM_U|_BCM_L|_BCM_D)) != 0)
|
||||
#define bcm_islower(c) ((bcm_ismask(c)&(_BCM_L)) != 0)
|
||||
#define bcm_isprint(c) ((bcm_ismask(c)&(_BCM_P|_BCM_U|_BCM_L|_BCM_D|_BCM_SP)) != 0)
|
||||
#define bcm_ispunct(c) ((bcm_ismask(c)&(_BCM_P)) != 0)
|
||||
#define bcm_isspace(c) ((bcm_ismask(c)&(_BCM_S)) != 0)
|
||||
#define bcm_isupper(c) ((bcm_ismask(c)&(_BCM_U)) != 0)
|
||||
#define bcm_isxdigit(c) ((bcm_ismask(c)&(_BCM_D|_BCM_X)) != 0)
|
||||
/* modulo inc/dec, bound = 2^k */
|
||||
#define MODDEC_POW2(x, bound) (((x) - 1) & ((bound) - 1))
|
||||
#define MODINC_POW2(x, bound) (((x) + 1) & ((bound) - 1))
|
||||
|
||||
/*
|
||||
* Spin at most 'us' microseconds while 'exp' is true.
|
||||
* Caller should explicitly test 'exp' when this completes
|
||||
* and take appropriate error action if 'exp' is still true.
|
||||
*/
|
||||
#define SPINWAIT(exp, us) { \
|
||||
uint countdown = (us) + 9; \
|
||||
while ((exp) && (countdown >= 10)) {\
|
||||
OSL_DELAY(10); \
|
||||
countdown -= 10; \
|
||||
} \
|
||||
}
|
||||
/* modulo add/sub - assumes x, y E [0, bound - 1] */
|
||||
#define MODADD(x, y, bound) \
|
||||
MUX((x) + (y) >= (bound), (x) + (y) - (bound), (x) + (y))
|
||||
#define MODSUB(x, y, bound) \
|
||||
MUX(((int)(x)) - ((int)(y)) < 0, (x) - (y) + (bound), (x) - (y))
|
||||
|
||||
/* generic osl packet queue */
|
||||
struct pktq {
|
||||
void *head; /* first packet to dequeue */
|
||||
void *tail; /* last packet to dequeue */
|
||||
uint len; /* number of queued packets */
|
||||
uint maxlen; /* maximum number of queued packets */
|
||||
bool priority; /* enqueue by packet priority */
|
||||
};
|
||||
#define DEFAULT_QLEN 128
|
||||
|
||||
#define pktq_len(q) ((q)->len)
|
||||
#define pktq_avail(q) ((q)->maxlen - (q)->len)
|
||||
#define pktq_head(q) ((q)->head)
|
||||
#define pktq_full(q) ((q)->len >= (q)->maxlen)
|
||||
/* module add/sub, bound = 2^k */
|
||||
#define MODADD_POW2(x, y, bound) (((x) + (y)) & ((bound) - 1))
|
||||
#define MODSUB_POW2(x, y, bound) (((x) - (y)) & ((bound) - 1))
|
||||
|
||||
/* crc defines */
|
||||
#define CRC8_INIT_VALUE 0xff /* Initial CRC8 checksum value */
|
||||
|
@ -100,6 +174,12 @@ struct pktq {
|
|||
#define CRC32_INIT_VALUE 0xffffffff /* Initial CRC32 checksum value */
|
||||
#define CRC32_GOOD_VALUE 0xdebb20e3 /* Good final CRC32 checksum value */
|
||||
|
||||
/* bcm_format_flags() bit description structure */
|
||||
typedef struct bcm_bit_desc {
|
||||
uint32 bit;
|
||||
char* name;
|
||||
} bcm_bit_desc_t;
|
||||
|
||||
/* tag_ID/length/value_buffer tuple */
|
||||
typedef struct bcm_tlv {
|
||||
uint8 id;
|
||||
|
@ -108,50 +188,71 @@ typedef struct bcm_tlv {
|
|||
} bcm_tlv_t;
|
||||
|
||||
/* Check that bcm_tlv_t fits into the given buflen */
|
||||
#define bcm_valid_tlv(elt, buflen) ((buflen) >= 2 && (buflen) >= 2 + (elt)->len)
|
||||
#define bcm_valid_tlv(elt, buflen) ((buflen) >= 2 && (int)(buflen) >= (int)(2 + (elt)->len))
|
||||
|
||||
/* buffer length for ethernet address from bcm_ether_ntoa() */
|
||||
#define ETHER_ADDR_STR_LEN 18
|
||||
#define ETHER_ADDR_STR_LEN 18 /* 18-bytes of Ethernet address buffer length */
|
||||
|
||||
/*
|
||||
* load 32-bit value from unaligned byte array
|
||||
*/
|
||||
/* unaligned load and store macros */
|
||||
#ifdef IL_BIGENDIAN
|
||||
#define load32_ua(a) ((((uint8 *)(a))[0] << 24) + (((uint8 *)(a))[1] << 16) + \
|
||||
(((uint8 *)(a))[2] << 8) + ((uint8 *)(a))[3])
|
||||
static INLINE uint32
|
||||
load32_ua(uint8 *a)
|
||||
{
|
||||
return ((a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3]);
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
store32_ua(uint8 *a, uint32 v)
|
||||
{
|
||||
a[0] = (v >> 24) & 0xff;
|
||||
a[1] = (v >> 16) & 0xff;
|
||||
a[2] = (v >> 8) & 0xff;
|
||||
a[3] = v & 0xff;
|
||||
}
|
||||
|
||||
static INLINE uint16
|
||||
load16_ua(uint8 *a)
|
||||
{
|
||||
return ((a[0] << 8) | a[1]);
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
store16_ua(uint8 *a, uint16 v)
|
||||
{
|
||||
a[0] = (v >> 8) & 0xff;
|
||||
a[1] = v & 0xff;
|
||||
}
|
||||
|
||||
#else
|
||||
#define load32_ua(a) ((((uint8 *)(a))[3] << 24) + (((uint8 *)(a))[2] << 16) + \
|
||||
(((uint8 *)(a))[1] << 8) + ((uint8 *)(a))[0])
|
||||
#endif
|
||||
|
||||
/* externs */
|
||||
extern uint bcm_atoi(char *s);
|
||||
extern uchar bcm_toupper(uchar c);
|
||||
extern ulong bcm_strtoul(char *cp, char **endp, uint base);
|
||||
extern void deadbeef(char *p, uint len);
|
||||
extern void prhex(char *msg, uchar *buf, uint len);
|
||||
extern void prpkt(char *msg, void *drv, void *p0);
|
||||
extern uint pktcopy(void *drv, void *p, uint offset, int len, uchar *buf);
|
||||
extern uint pkttotlen(void *drv, void *);
|
||||
extern uchar *bcm_ether_ntoa(char *ea, char *buf);
|
||||
extern int bcm_ether_atoe(char *p, char *ea);
|
||||
extern void bcm_mdelay(uint ms);
|
||||
extern char *getvar(char *vars, char *name);
|
||||
extern int getintvar(char *vars, char *name);
|
||||
extern char *bcmstrstr(char *haystack, char *needle);
|
||||
static INLINE uint32
|
||||
load32_ua(uint8 *a)
|
||||
{
|
||||
return ((a[3] << 24) | (a[2] << 16) | (a[1] << 8) | a[0]);
|
||||
}
|
||||
|
||||
extern uint8 crc8(uint8 *p, uint nbytes, uint8 crc);
|
||||
extern uint16 crc16(uint8 *p, uint nbytes, uint16 crc);
|
||||
extern uint32 crc32(uint8 *p, uint nbytes, uint32 crc);
|
||||
extern bcm_tlv_t *bcm_next_tlv(bcm_tlv_t *elt, int *buflen);
|
||||
extern bcm_tlv_t *bcm_parse_tlvs(void *buf, int buflen, uint key);
|
||||
extern bcm_tlv_t *bcm_parse_ordered_tlvs(void *buf, int buflen, uint key);
|
||||
extern void pktq_init(struct pktq *q, uint maxlen, bool priority);
|
||||
extern bool pktenq(struct pktq *q, void *p, bool lifo);
|
||||
extern void *pktdeq(struct pktq *q);
|
||||
static INLINE void
|
||||
store32_ua(uint8 *a, uint32 v)
|
||||
{
|
||||
a[3] = (v >> 24) & 0xff;
|
||||
a[2] = (v >> 16) & 0xff;
|
||||
a[1] = (v >> 8) & 0xff;
|
||||
a[0] = v & 0xff;
|
||||
}
|
||||
|
||||
#define bcmlog(fmt, a1, a2)
|
||||
#define bcmdumplog(buf, size) *buf = '\0'
|
||||
#define bcmdumplogent(buf, idx) -1
|
||||
static INLINE uint16
|
||||
load16_ua(uint8 *a)
|
||||
{
|
||||
return ((a[1] << 8) | a[0]);
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
store16_ua(uint8 *a, uint16 v)
|
||||
{
|
||||
a[1] = (v >> 8) & 0xff;
|
||||
a[0] = v & 0xff;
|
||||
}
|
||||
|
||||
#endif /* IL_BIGENDIAN */
|
||||
|
||||
#endif /* _bcmutils_h_ */
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
|
||||
#define DNSMASQ_SUPPORT 1
|
||||
#define CONFIG_DNSMASQ y
|
||||
#define UDHCPD_SUPPORT 1
|
||||
#define CONFIG_UDHCPD y
|
||||
#define UDHCPC_SUPPORT 1
|
||||
#define CONFIG_UDHCPC y
|
||||
#define PPPOE_SUPPORT 1
|
||||
#define CONFIG_PPPOE y
|
||||
#define PPTP_SUPPORT 1
|
||||
#define CONFIG_PPTP y
|
||||
#define L2TP_SUPPORT 1
|
||||
#define CONFIG_L2TP y
|
||||
#define PPPD_SUPPORT 1
|
||||
#define CONFIG_PPPD y
|
||||
#define ZEBRA_SUPPORT 1
|
||||
#define CONFIG_ZEBRA y
|
||||
#define TFTPD_SUPPORT 1
|
||||
#define CONFIG_TFTPD y
|
||||
#define DDNS_SUPPORT 1
|
||||
#define CONFIG_DDNS y
|
||||
#define CRON_SUPPORT 1
|
||||
#define CONFIG_CRON y
|
||||
#define HTTPD_SUPPORT 1
|
||||
#define CONFIG_HTTPD y
|
||||
#define GET_POST_SUPPORT 1
|
||||
#define CONFIG_GET_POST y
|
||||
|
||||
#if 1
|
||||
#define HEARTBEAT_SUPPORT 1
|
||||
#define CONFIG_HEARTBEAT y
|
||||
#define MULTICAST_SUPPORT 1
|
||||
#define CONFIG_MULTICAST y
|
||||
#define SETUP_WIZARD_SUPPORT 1
|
||||
#define CONFIG_SETUP_WIZARD y
|
||||
#define PARENTAL_CONTROL_SUPPORT 1
|
||||
#define CONFIG_PARENTAL_CONTROL y
|
||||
#define HTTPS_SUPPORT 1
|
||||
#define CONFIG_HTTPS y
|
||||
#define EOU_SUPPORT 1
|
||||
#define CONFIG_EOU y
|
||||
#define EZC_SUPPORT 1
|
||||
#define CONFIG_EZC y
|
||||
#define WRITE_MAC_SUPPORT 1
|
||||
#define CONFIG_WRITE_MAC y
|
||||
#define DIAG_SUPPORT 1
|
||||
#define CONFIG_DIAG y
|
||||
#endif
|
||||
|
||||
#define SPEED_BOOSTER_SUPPORT 1
|
||||
#define CONFIG_SPEED_BOOSTER y
|
||||
#define XBOX_SUPPORT 1
|
||||
#define CONFIG_XBOX y
|
||||
|
||||
#if 0
|
||||
#define MPPPOE_SUPPORT 1
|
||||
#define CONFIG_MPPPOE y
|
||||
#define UNNUMBERIP_SUPPORT 1
|
||||
#define CONFIG_UNNUMBERIP y
|
||||
#endif
|
||||
|
||||
#define WL_STA_SUPPORT 1
|
||||
#define CONFIG_WL_STA y
|
||||
#define BACKUP_RESTORE_SUPPORT 1
|
||||
#define CONFIG_BACKUP_RESTORE y
|
||||
#define PORT_TRIGGER_SUPPORT 1
|
||||
#define CONFIG_PORT_TRIGGER y
|
||||
#define HW_QOS_SUPPORT 1
|
||||
#define CONFIG_HW_QOS y
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
* 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$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _epivers_h_
|
||||
#define _epivers_h_
|
||||
|
||||
#ifdef linux
|
||||
#include <linux/config.h>
|
||||
#endif
|
||||
|
||||
/* Vendor Name, ASCII, 32 chars max */
|
||||
#ifdef COMPANYNAME
|
||||
#define HPNA_VENDOR COMPANYNAME
|
||||
#else
|
||||
#define HPNA_VENDOR "Broadcom Corporation"
|
||||
#endif
|
||||
|
||||
/* Driver Date, ASCII, 32 chars max */
|
||||
#define HPNA_DRV_BUILD_DATE __DATE__
|
||||
|
||||
/* Hardware Manufacture Date, ASCII, 32 chars max */
|
||||
#define HPNA_HW_MFG_DATE "Not Specified"
|
||||
|
||||
/* See documentation for Device Type values, 32 values max */
|
||||
#ifndef HPNA_DEV_TYPE
|
||||
|
||||
#if defined(CONFIG_BRCM_VJ)
|
||||
#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_DISPLAY }
|
||||
|
||||
#elif defined(CONFIG_BCRM_93725)
|
||||
#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_CM_BRIDGE, CDCF_V0_DEVICE_DISPLAY }
|
||||
|
||||
#else
|
||||
#define HPNA_DEV_TYPE { CDCF_V0_DEVICE_PCINIC }
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* !HPNA_DEV_TYPE */
|
||||
|
||||
|
||||
#define EPI_MAJOR_VERSION 3
|
||||
|
||||
#define EPI_MINOR_VERSION 60
|
||||
|
||||
#define EPI_RC_NUMBER 13
|
||||
|
||||
#define EPI_INCREMENTAL_NUMBER 0
|
||||
|
||||
#define EPI_BUILD_NUMBER 0
|
||||
|
||||
#define EPI_VERSION 3,60,13,0
|
||||
|
||||
#define EPI_VERSION_NUM 0x033c0d00
|
||||
|
||||
/* Driver Version String, ASCII, 32 chars max */
|
||||
#define EPI_VERSION_STR "3.60.13.0"
|
||||
#define EPI_ROUTER_VERSION_STR "3.61.13.0"
|
||||
|
||||
#endif /* _epivers_h_ */
|
File diff suppressed because it is too large
Load diff
101
package/wlcompat/src/include/proto/bcmeth.h
Normal file
101
package/wlcompat/src/include/proto/bcmeth.h
Normal file
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* Broadcom Ethernettype protocol definitions
|
||||
*
|
||||
* Copyright 2006, 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: bcmeth.h,v 1.1.1.4 2006/02/27 03:43:16 honor Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* Broadcom Ethernet protocol defines
|
||||
*/
|
||||
|
||||
#ifndef _BCMETH_H_
|
||||
#define _BCMETH_H_
|
||||
|
||||
/* enable structure packing */
|
||||
#if defined(__GNUC__)
|
||||
#define PACKED __attribute__((packed))
|
||||
#else
|
||||
#pragma pack(1)
|
||||
#define PACKED
|
||||
#endif
|
||||
|
||||
/* ETHER_TYPE_BRCM is defined in ethernet.h */
|
||||
|
||||
/*
|
||||
* Following the 2byte BRCM ether_type is a 16bit BRCM subtype field
|
||||
* in one of two formats: (only subtypes 32768-65535 are in use now)
|
||||
*
|
||||
* subtypes 0-32767:
|
||||
* 8 bit subtype (0-127)
|
||||
* 8 bit length in bytes (0-255)
|
||||
*
|
||||
* subtypes 32768-65535:
|
||||
* 16 bit big-endian subtype
|
||||
* 16 bit big-endian length in bytes (0-65535)
|
||||
*
|
||||
* length is the number of additional bytes beyond the 4 or 6 byte header
|
||||
*
|
||||
* Reserved values:
|
||||
* 0 reserved
|
||||
* 5-15 reserved for iLine protocol assignments
|
||||
* 17-126 reserved, assignable
|
||||
* 127 reserved
|
||||
* 32768 reserved
|
||||
* 32769-65534 reserved, assignable
|
||||
* 65535 reserved
|
||||
*/
|
||||
|
||||
/*
|
||||
* While adding the subtypes and their specific processing code make sure
|
||||
* bcmeth_bcm_hdr_t is the first data structure in the user specific data structure definition
|
||||
*/
|
||||
|
||||
#define BCMILCP_SUBTYPE_RATE 1
|
||||
#define BCMILCP_SUBTYPE_LINK 2
|
||||
#define BCMILCP_SUBTYPE_CSA 3
|
||||
#define BCMILCP_SUBTYPE_LARQ 4
|
||||
#define BCMILCP_SUBTYPE_VENDOR 5
|
||||
#define BCMILCP_SUBTYPE_FLH 17
|
||||
|
||||
#define BCMILCP_SUBTYPE_VENDOR_LONG 32769
|
||||
#define BCMILCP_SUBTYPE_CERT 32770
|
||||
#define BCMILCP_SUBTYPE_SES 32771
|
||||
|
||||
|
||||
#define BCMILCP_BCM_SUBTYPE_RESERVED 0
|
||||
#define BCMILCP_BCM_SUBTYPE_EVENT 1
|
||||
#define BCMILCP_BCM_SUBTYPE_SES 2
|
||||
/*
|
||||
* The EAPOL type is not used anymore. Instead EAPOL messages are now embedded
|
||||
* within BCMILCP_BCM_SUBTYPE_EVENT type messages
|
||||
*/
|
||||
/* #define BCMILCP_BCM_SUBTYPE_EAPOL 3 */
|
||||
|
||||
#define BCMILCP_BCM_SUBTYPEHDR_MINLENGTH 8
|
||||
#define BCMILCP_BCM_SUBTYPEHDR_VERSION 0
|
||||
|
||||
/* These fields are stored in network order */
|
||||
typedef struct bcmeth_hdr
|
||||
{
|
||||
uint16 subtype; /* Vendor specific..32769 */
|
||||
uint16 length;
|
||||
uint8 version; /* Version is 0 */
|
||||
uint8 oui[3]; /* Broadcom OUI */
|
||||
/* user specific Data */
|
||||
uint16 usr_subtype;
|
||||
} PACKED bcmeth_hdr_t;
|
||||
|
||||
#undef PACKED
|
||||
#if !defined(__GNUC__)
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
#endif /* _BCMETH_H_ */
|
152
package/wlcompat/src/include/proto/bcmevent.h
Normal file
152
package/wlcompat/src/include/proto/bcmevent.h
Normal file
|
@ -0,0 +1,152 @@
|
|||
/*
|
||||
* Broadcom Event protocol definitions
|
||||
*
|
||||
* Copyright 2006, 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.
|
||||
*
|
||||
*
|
||||
* Dependencies: proto/bcmeth.h
|
||||
*
|
||||
* $Id: bcmevent.h,v 1.1.1.3 2006/02/27 03:43:16 honor Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Broadcom Ethernet Events protocol defines
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _BCMEVENT_H_
|
||||
#define _BCMEVENT_H_
|
||||
|
||||
/* enable structure packing */
|
||||
#if defined(__GNUC__)
|
||||
#define PACKED __attribute__((packed))
|
||||
#else
|
||||
#pragma pack(1)
|
||||
#define PACKED
|
||||
#endif /* defined(__GNUC__) */
|
||||
|
||||
#define BCM_EVENT_MSG_VERSION 1 /* wl_event_msg_t struct version */
|
||||
#define BCM_MSG_IFNAME_MAX 16 /* max length of interface name */
|
||||
|
||||
/* flags */
|
||||
#define WLC_EVENT_MSG_LINK 0x01 /* link is up */
|
||||
#define WLC_EVENT_MSG_FLUSHTXQ 0x02 /* flush tx queue on MIC error */
|
||||
#define WLC_EVENT_MSG_GROUP 0x04 /* group MIC error */
|
||||
|
||||
/* theses fields are stored in network order */
|
||||
typedef struct
|
||||
{
|
||||
uint16 version;
|
||||
uint16 flags; /* see flags below */
|
||||
uint32 event_type; /* Message (see below) */
|
||||
uint32 status; /* Status code (see below) */
|
||||
uint32 reason; /* Reason code (if applicable) */
|
||||
uint32 auth_type; /* WLC_E_AUTH */
|
||||
uint32 datalen; /* data buf */
|
||||
struct ether_addr addr; /* Station address (if applicable) */
|
||||
char ifname[BCM_MSG_IFNAME_MAX]; /* name of the packet incoming interface */
|
||||
} PACKED wl_event_msg_t;
|
||||
|
||||
/* used by driver msgs */
|
||||
typedef struct bcm_event {
|
||||
struct ether_header eth;
|
||||
bcmeth_hdr_t bcm_hdr;
|
||||
wl_event_msg_t event;
|
||||
/* data portion follows */
|
||||
} PACKED bcm_event_t;
|
||||
|
||||
#define BCM_MSG_LEN (sizeof(bcm_event_t) - sizeof(bcmeth_hdr_t) - sizeof(struct ether_header))
|
||||
|
||||
/* Event messages */
|
||||
#define WLC_E_SET_SSID 0 /* indicates status of set SSID */
|
||||
#define WLC_E_JOIN 1 /* differentiates join IBSS from found (WLC_E_START) IBSS */
|
||||
#define WLC_E_START 2 /* STA founded an IBSS or AP started a BSS */
|
||||
#define WLC_E_AUTH 3 /* 802.11 AUTH request */
|
||||
#define WLC_E_AUTH_IND 4 /* 802.11 AUTH indication */
|
||||
#define WLC_E_DEAUTH 5 /* 802.11 DEAUTH request */
|
||||
#define WLC_E_DEAUTH_IND 6 /* 802.11 DEAUTH indication */
|
||||
#define WLC_E_ASSOC 7 /* 802.11 ASSOC request */
|
||||
#define WLC_E_ASSOC_IND 8 /* 802.11 ASSOC indication */
|
||||
#define WLC_E_REASSOC 9 /* 802.11 REASSOC request */
|
||||
#define WLC_E_REASSOC_IND 10 /* 802.11 REASSOC indication */
|
||||
#define WLC_E_DISASSOC 11 /* 802.11 DISASSOC request */
|
||||
#define WLC_E_DISASSOC_IND 12 /* 802.11 DISASSOC indication */
|
||||
#define WLC_E_QUIET_START 13 /* 802.11h Quiet period started */
|
||||
#define WLC_E_QUIET_END 14 /* 802.11h Quiet period ended */
|
||||
#define WLC_E_BEACON_RX 15 /* BEACONS received/lost indication */
|
||||
#define WLC_E_LINK 16 /* generic link indication */
|
||||
#define WLC_E_MIC_ERROR 17 /* TKIP MIC error occurred */
|
||||
#define WLC_E_NDIS_LINK 18 /* NDIS style link indication */
|
||||
#define WLC_E_ROAM 19 /* roam attempt occurred: indicate status & reason */
|
||||
#define WLC_E_TXFAIL 20 /* change in dot11FailedCount (txfail) */
|
||||
#define WLC_E_PMKID_CACHE 21 /* WPA2 pmkid cache indication */
|
||||
#define WLC_E_RETROGRADE_TSF 22 /* current AP's TSF value went backward */
|
||||
#define WLC_E_PRUNE 23 /* AP was pruned from join list for reason */
|
||||
#define WLC_E_AUTOAUTH 24 /* report AutoAuth table entry match for join attempt */
|
||||
#define WLC_E_EAPOL_MSG 25 /* Event encapsulating an EAPOL message */
|
||||
#define WLC_E_SCAN_COMPLETE 26 /* Scan results are ready or scan was aborted */
|
||||
#define WLC_E_ADDTS_IND 27 /* indicate to host addts fail/success */
|
||||
#define WLC_E_DELTS_IND 28 /* indicate to host delts fail/success */
|
||||
#define WLC_E_BCNSENT_IND 29 /* indicate to host of beacon transmit */
|
||||
#define WLC_E_BCNRX_MSG 30 /* Send the received beacon up to the host */
|
||||
#define WLC_E_LAST 31 /* highest val + 1 for range checking */
|
||||
|
||||
/* Event status codes */
|
||||
#define WLC_E_STATUS_SUCCESS 0 /* operation was successful */
|
||||
#define WLC_E_STATUS_FAIL 1 /* operation failed */
|
||||
#define WLC_E_STATUS_TIMEOUT 2 /* operation timed out */
|
||||
#define WLC_E_STATUS_NO_NETWORKS 3 /* failed due to no matching network found */
|
||||
#define WLC_E_STATUS_ABORT 4 /* operation was aborted */
|
||||
#define WLC_E_STATUS_NO_ACK 5 /* protocol failure: packet not ack'd */
|
||||
#define WLC_E_STATUS_UNSOLICITED 6 /* AUTH or ASSOC packet was unsolicited */
|
||||
#define WLC_E_STATUS_ATTEMPT 7 /* attempt to assoc to an auto auth configuration */
|
||||
|
||||
/* roam reason codes */
|
||||
#define WLC_E_REASON_INITIAL_ASSOC 0 /* initial assoc */
|
||||
#define WLC_E_REASON_LOW_RSSI 1 /* roamed due to low RSSI */
|
||||
#define WLC_E_REASON_DEAUTH 2 /* roamed due to DEAUTH indication */
|
||||
#define WLC_E_REASON_DISASSOC 3 /* roamed due to DISASSOC indication */
|
||||
#define WLC_E_REASON_BCNS_LOST 4 /* roamed due to lost beacons */
|
||||
#define WLC_E_REASON_FAST_ROAM_FAILED 5 /* roamed due to fast roam failure */
|
||||
#define WLC_E_REASON_DIRECTED_ROAM 6 /* roamed due to request by AP */
|
||||
#define WLC_E_REASON_TSPEC_REJECTED 7 /* roamed due to TSPEC rejection */
|
||||
#define WLC_E_REASON_BETTER_AP 8 /* roamed due to finding better AP */
|
||||
|
||||
/* prune reason codes */
|
||||
#define WLC_E_PRUNE_ENCR_MISMATCH 1 /* ecryption mismatch */
|
||||
#define WLC_E_PRUNE_BCAST_BSSID 2 /* AP uses a broadcast BSSID */
|
||||
#define WLC_E_PRUNE_MAC_DENY 3 /* STA's MAC addr is in AP's MAC deny list */
|
||||
#define WLC_E_PRUNE_MAC_NA 4 /* STA's MAC addr is not in AP's MAC allow list */
|
||||
#define WLC_E_PRUNE_REG_PASSV 5 /* AP not allowed due to regulatory restriction */
|
||||
#define WLC_E_PRUNE_SPCT_MGMT 6 /* AP does not support STA locale spectrum mgmt */
|
||||
#define WLC_E_PRUNE_RADAR 7 /* AP is on a radar channel of STA locale */
|
||||
#define WLC_E_RSN_MISMATCH 8 /* STA does not support AP's RSN */
|
||||
#define WLC_E_PRUNE_NO_COMMON_RATES 9 /* No rates in common with AP */
|
||||
#define WLC_E_PRUNE_BASIC_RATES 10 /* STA does not support all basic rates of BSS */
|
||||
#define WLC_E_PRUNE_CCXFAST_PREVAP 11 /* CCX FAST ROAM: prune previous AP */
|
||||
#define WLC_E_PRUNE_CIPHER_NA 12 /* BSS's cipher not supported */
|
||||
#define WLC_E_PRUNE_KNOWN_STA 13 /* AP is already known to us as a STA */
|
||||
#define WLC_E_PRUNE_CCXFAST_DROAM 14 /* CCX FAST ROAM: prune unqulified AP */
|
||||
#define WLC_E_PRUNE_WDS_PEER 15 /* AP is already known to us as a WDS peer */
|
||||
#define WLC_E_PRUNE_QBSS_LOAD 16 /* QBSS LOAD - AAC is too low */
|
||||
#define WLC_E_PRUNE_HOME_AP 17 /* prune home AP */
|
||||
|
||||
/* WLC_SET_CALLBACK data type */
|
||||
typedef struct wlc_event_cb {
|
||||
void (*fn)(void *, bcm_event_t *); /* Callback function */
|
||||
void *context; /* Passed to callback function */
|
||||
} wlc_event_cb_t;
|
||||
|
||||
#undef PACKED
|
||||
#if !defined(__GNUC__)
|
||||
#pragma pack()
|
||||
#endif /* PACKED */
|
||||
|
||||
#endif /* _BCMEVENT_H_ */
|
|
@ -1,14 +1,16 @@
|
|||
/*******************************************************************************
|
||||
* $Id$
|
||||
* Copyright 2004, Broadcom Corporation
|
||||
/*
|
||||
* From FreeBSD 2.2.7: Fundamental constants relating to ethernet.
|
||||
*
|
||||
* Copyright 2006, 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.
|
||||
* From FreeBSD 2.2.7: Fundamental constants relating to ethernet.
|
||||
******************************************************************************/
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef _NET_ETHERNET_H_ /* use native BSD ethernet.h when available */
|
||||
#define _NET_ETHERNET_H_
|
||||
|
@ -17,111 +19,80 @@
|
|||
#include "typedefs.h"
|
||||
#endif
|
||||
|
||||
/* enable structure packing */
|
||||
#if defined(__GNUC__)
|
||||
#define PACKED __attribute__((packed))
|
||||
#else
|
||||
#pragma pack(1)
|
||||
#define PACKED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The number of bytes in an ethernet (MAC) address.
|
||||
*/
|
||||
#ifndef ETHER_ADDR_LEN
|
||||
#define ETHER_ADDR_LEN 6
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The number of bytes in the type field.
|
||||
*/
|
||||
#ifndef ETHER_TYPE_LEN
|
||||
#define ETHER_TYPE_LEN 2
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The number of bytes in the trailing CRC field.
|
||||
*/
|
||||
#ifndef ETHER_CRC_LEN
|
||||
#define ETHER_CRC_LEN 4
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The length of the combined header.
|
||||
*/
|
||||
#ifndef ETHER_HDR_LEN
|
||||
#define ETHER_HDR_LEN (ETHER_ADDR_LEN*2+ETHER_TYPE_LEN)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The minimum packet length.
|
||||
*/
|
||||
#ifndef ETHER_MIN_LEN
|
||||
#define ETHER_MIN_LEN 64
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The minimum packet user data length.
|
||||
*/
|
||||
#ifndef ETHER_MIN_DATA
|
||||
#define ETHER_MIN_DATA 46
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The maximum packet length.
|
||||
*/
|
||||
#ifndef ETHER_MAX_LEN
|
||||
#define ETHER_MAX_LEN 1518
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The maximum packet user data length.
|
||||
*/
|
||||
#define ETHER_MAX_DATA 1500
|
||||
|
||||
/*
|
||||
* Used to uniquely identify a 802.1q VLAN-tagged header.
|
||||
*/
|
||||
#define VLAN_TAG 0x8100
|
||||
|
||||
/*
|
||||
* Located after dest & src address in ether header.
|
||||
*/
|
||||
#define VLAN_FIELDS_OFFSET (ETHER_ADDR_LEN * 2)
|
||||
|
||||
/*
|
||||
* 4 bytes of vlan field info.
|
||||
*/
|
||||
#define VLAN_FIELDS_SIZE 4
|
||||
|
||||
/* location of bits in 16-bit vlan fields */
|
||||
#define VLAN_PRI_SHIFT 13 /* user priority */
|
||||
#define VLAN_CFI_SHIFT 12 /* canonical format indicator bit */
|
||||
|
||||
/* 3 bits of priority */
|
||||
#define VLAN_PRI_MASK 7
|
||||
/* 12 bits of vlan identfier (VID) */
|
||||
#define VLAN_VID_MASK 0xFFF /* VLAN identifier (VID) field */
|
||||
|
||||
struct vlan_tags {
|
||||
uint16 tag_type; /* 0x8100 for VLAN */
|
||||
uint16 tag_control; /* prio | cfi | vid */
|
||||
} PACKED ;
|
||||
|
||||
/* 802.1X ethertype */
|
||||
|
||||
/* ether types */
|
||||
#define ETHER_TYPE_IP 0x0800 /* IP */
|
||||
#define ETHER_TYPE_ARP 0x0806 /* ARP */
|
||||
#define ETHER_TYPE_8021Q 0x8100 /* 802.1Q */
|
||||
#define ETHER_TYPE_BRCM 0x886c /* Broadcom Corp. */
|
||||
#define ETHER_TYPE_802_1X 0x888e /* 802.1x */
|
||||
#ifdef BCMWPA2
|
||||
#define ETHER_TYPE_802_1X_PREAUTH 0x88c7 /* 802.1x preauthentication */
|
||||
#endif
|
||||
|
||||
#define ETHER_BRCM_SUBTYPE_LEN 4 /* Broadcom 4byte subtype follows ethertype */
|
||||
/* Broadcom subtype follows ethertype; First 2 bytes are reserved; Next 2 are subtype; */
|
||||
#define ETHER_BRCM_SUBTYPE_LEN 4 /* Broadcom 4 byte subtype */
|
||||
#define ETHER_BRCM_CRAM 0x1 /* Broadcom subtype cram protocol */
|
||||
|
||||
/* ether header */
|
||||
#define ETHER_DEST_OFFSET 0 /* dest address offset */
|
||||
#define ETHER_SRC_OFFSET 6 /* src address offset */
|
||||
#define ETHER_TYPE_OFFSET 12 /* ether type offset */
|
||||
|
||||
/*
|
||||
* A macro to validate a length with
|
||||
*/
|
||||
#define ETHER_IS_VALID_LEN(foo) \
|
||||
((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN)
|
||||
|
||||
#ifndef __NET_ETHERNET_H
|
||||
|
||||
#ifndef __INCif_etherh /* Quick and ugly hack for VxWorks */
|
||||
/*
|
||||
* Structure of a 10Mb/s Ethernet header.
|
||||
|
@ -130,16 +101,21 @@ struct ether_header {
|
|||
uint8 ether_dhost[ETHER_ADDR_LEN];
|
||||
uint8 ether_shost[ETHER_ADDR_LEN];
|
||||
uint16 ether_type;
|
||||
} PACKED ;
|
||||
} PACKED;
|
||||
|
||||
/*
|
||||
* Structure of a 48-bit Ethernet address.
|
||||
*/
|
||||
struct ether_addr {
|
||||
uint8 octet[ETHER_ADDR_LEN];
|
||||
} PACKED ;
|
||||
#endif
|
||||
#endif
|
||||
} PACKED;
|
||||
#endif /* !__INCif_etherh Quick and ugly hack for VxWorks */
|
||||
|
||||
/*
|
||||
* Takes a pointer, sets locally admininistered
|
||||
* address bit in the 48-bit Ethernet address.
|
||||
*/
|
||||
#define ETHER_SET_LOCALADDR(ea) (((uint8 *)(ea))[0] = (((uint8 *)(ea))[0] | 2))
|
||||
|
||||
/*
|
||||
* Takes a pointer, returns true if a 48-bit multicast address
|
||||
|
@ -147,6 +123,18 @@ struct ether_addr {
|
|||
*/
|
||||
#define ETHER_ISMULTI(ea) (((uint8 *)(ea))[0] & 1)
|
||||
|
||||
|
||||
/* compare two ethernet addresses - assumes the pointers can be referenced as shorts */
|
||||
#define ether_cmp(a, b) (!(((short*)a)[0] == ((short*)b)[0]) | \
|
||||
!(((short*)a)[1] == ((short*)b)[1]) | \
|
||||
!(((short*)a)[2] == ((short*)b)[2]))
|
||||
|
||||
/* copy an ethernet address - assumes the pointers can be referenced as shorts */
|
||||
#define ether_copy(s, d) { \
|
||||
((short*)d)[0] = ((short*)s)[0]; \
|
||||
((short*)d)[1] = ((short*)s)[1]; \
|
||||
((short*)d)[2] = ((short*)s)[2]; }
|
||||
|
||||
/*
|
||||
* Takes a pointer, returns true if a 48-bit broadcast (all ones)
|
||||
*/
|
||||
|
@ -169,11 +157,9 @@ static const struct ether_addr ether_bcast = {{255, 255, 255, 255, 255, 255}};
|
|||
((uint8 *)(ea))[4] | \
|
||||
((uint8 *)(ea))[5]) == 0)
|
||||
|
||||
/* Differentiated Services Codepoint - lower 6 bits of tos in iphdr */
|
||||
#define DSCP_PRI_MASK 0x3F /* bits 0-6 */
|
||||
#define DSCP_WME_PRI_MASK 0x38 /* bits 3-6 */
|
||||
#define DSCP_WME_PRI_SHIFT 3
|
||||
|
||||
#undef PACKED
|
||||
#if !defined(__GNUC__)
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
#endif /* _NET_ETHERNET_H_ */
|
||||
|
|
148
package/wlcompat/src/include/proto/wpa.h
Normal file
148
package/wlcompat/src/include/proto/wpa.h
Normal file
|
@ -0,0 +1,148 @@
|
|||
/*
|
||||
* Fundamental types and constants relating to WPA
|
||||
*
|
||||
* Copyright 2006, 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: wpa.h,v 1.1.1.4 2006/02/27 03:43:16 honor Exp $
|
||||
*/
|
||||
|
||||
#ifndef _proto_wpa_h_
|
||||
#define _proto_wpa_h_
|
||||
|
||||
#include <typedefs.h>
|
||||
#include <proto/ethernet.h>
|
||||
|
||||
/* enable structure packing */
|
||||
#if defined(__GNUC__)
|
||||
#define PACKED __attribute__((packed))
|
||||
#else
|
||||
#pragma pack(1)
|
||||
#define PACKED
|
||||
#endif
|
||||
|
||||
/* Reason Codes */
|
||||
|
||||
/* 10 and 11 are from TGh. */
|
||||
#define DOT11_RC_BAD_PC 10 /* Unacceptable power capability element */
|
||||
#define DOT11_RC_BAD_CHANNELS 11 /* Unacceptable supported channels element */
|
||||
/* 12 is unused */
|
||||
/* 13 through 23 taken from P802.11i/D3.0, November 2002 */
|
||||
#define DOT11_RC_INVALID_WPA_IE 13 /* Invalid info. element */
|
||||
#define DOT11_RC_MIC_FAILURE 14 /* Michael failure */
|
||||
#define DOT11_RC_4WH_TIMEOUT 15 /* 4-way handshake timeout */
|
||||
#define DOT11_RC_GTK_UPDATE_TIMEOUT 16 /* Group key update timeout */
|
||||
#define DOT11_RC_WPA_IE_MISMATCH 17 /* WPA IE in 4-way handshake differs from
|
||||
* (re-)assoc. request/probe response
|
||||
*/
|
||||
#define DOT11_RC_INVALID_MC_CIPHER 18 /* Invalid multicast cipher */
|
||||
#define DOT11_RC_INVALID_UC_CIPHER 19 /* Invalid unicast cipher */
|
||||
#define DOT11_RC_INVALID_AKMP 20 /* Invalid authenticated key management protocol */
|
||||
#define DOT11_RC_BAD_WPA_VERSION 21 /* Unsupported WPA version */
|
||||
#define DOT11_RC_INVALID_WPA_CAP 22 /* Invalid WPA IE capabilities */
|
||||
#define DOT11_RC_8021X_AUTH_FAIL 23 /* 802.1X authentication failure */
|
||||
|
||||
#define WPA2_PMKID_LEN 16
|
||||
|
||||
/* WPA IE fixed portion */
|
||||
typedef struct
|
||||
{
|
||||
uint8 tag; /* TAG */
|
||||
uint8 length; /* TAG length */
|
||||
uint8 oui[3]; /* IE OUI */
|
||||
uint8 oui_type; /* OUI type */
|
||||
struct {
|
||||
uint8 low;
|
||||
uint8 high;
|
||||
} PACKED version; /* IE version */
|
||||
} PACKED wpa_ie_fixed_t;
|
||||
#define WPA_IE_OUITYPE_LEN 4
|
||||
#define WPA_IE_FIXED_LEN 8
|
||||
#define WPA_IE_TAG_FIXED_LEN 6
|
||||
|
||||
#ifdef BCMWPA2
|
||||
typedef struct {
|
||||
uint8 tag; /* TAG */
|
||||
uint8 length; /* TAG length */
|
||||
struct {
|
||||
uint8 low;
|
||||
uint8 high;
|
||||
} PACKED version; /* IE version */
|
||||
} PACKED wpa_rsn_ie_fixed_t;
|
||||
#define WPA_RSN_IE_FIXED_LEN 4
|
||||
#define WPA_RSN_IE_TAG_FIXED_LEN 2
|
||||
typedef uint8 wpa_pmkid_t[WPA2_PMKID_LEN];
|
||||
#endif
|
||||
|
||||
/* WPA suite/multicast suite */
|
||||
typedef struct
|
||||
{
|
||||
uint8 oui[3];
|
||||
uint8 type;
|
||||
} PACKED wpa_suite_t, wpa_suite_mcast_t;
|
||||
#define WPA_SUITE_LEN 4
|
||||
|
||||
/* WPA unicast suite list/key management suite list */
|
||||
typedef struct
|
||||
{
|
||||
struct {
|
||||
uint8 low;
|
||||
uint8 high;
|
||||
} PACKED count;
|
||||
wpa_suite_t list[1];
|
||||
} PACKED wpa_suite_ucast_t, wpa_suite_auth_key_mgmt_t;
|
||||
#define WPA_IE_SUITE_COUNT_LEN 2
|
||||
#ifdef BCMWPA2
|
||||
typedef struct
|
||||
{
|
||||
struct {
|
||||
uint8 low;
|
||||
uint8 high;
|
||||
} PACKED count;
|
||||
wpa_pmkid_t list[1];
|
||||
} PACKED wpa_pmkid_list_t;
|
||||
#endif
|
||||
|
||||
/* WPA cipher suites */
|
||||
#define WPA_CIPHER_NONE 0 /* None */
|
||||
#define WPA_CIPHER_WEP_40 1 /* WEP (40-bit) */
|
||||
#define WPA_CIPHER_TKIP 2 /* TKIP: default for WPA */
|
||||
#define WPA_CIPHER_AES_OCB 3 /* AES (OCB) */
|
||||
#define WPA_CIPHER_AES_CCM 4 /* AES (CCM) */
|
||||
#define WPA_CIPHER_WEP_104 5 /* WEP (104-bit) */
|
||||
|
||||
#define IS_WPA_CIPHER(cipher) ((cipher) == WPA_CIPHER_NONE || \
|
||||
(cipher) == WPA_CIPHER_WEP_40 || \
|
||||
(cipher) == WPA_CIPHER_WEP_104 || \
|
||||
(cipher) == WPA_CIPHER_TKIP || \
|
||||
(cipher) == WPA_CIPHER_AES_OCB || \
|
||||
(cipher) == WPA_CIPHER_AES_CCM)
|
||||
|
||||
/* WPA TKIP countermeasures parameters */
|
||||
#define WPA_TKIP_CM_DETECT 60 /* multiple MIC failure window (seconds) */
|
||||
#define WPA_TKIP_CM_BLOCK 60 /* countermeasures active window (seconds) */
|
||||
|
||||
/* WPA capabilities defined in 802.11i */
|
||||
#define WPA_CAP_4_REPLAY_CNTRS 2
|
||||
#define WPA_CAP_16_REPLAY_CNTRS 3
|
||||
#define WPA_CAP_REPLAY_CNTR_SHIFT 2
|
||||
#define WPA_CAP_REPLAY_CNTR_MASK 0x000c
|
||||
|
||||
/* WPA Specific defines */
|
||||
#define WPA_CAP_LEN 2 /* Length of RSN capabilities in RSN IE (2 octets) */
|
||||
|
||||
#ifdef BCMWPA2
|
||||
#define WPA_CAP_WPA2_PREAUTH 1
|
||||
#endif /* BCMWPA2 */
|
||||
|
||||
#undef PACKED
|
||||
#if !defined(__GNUC__)
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
#endif /* _proto_wpa_h_ */
|
|
@ -1,200 +0,0 @@
|
|||
/*
|
||||
* Shell-like utility functions
|
||||
*
|
||||
* 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$
|
||||
*/
|
||||
|
||||
#ifndef _shutils_h_
|
||||
#define _shutils_h_
|
||||
#include <string.h>
|
||||
/*
|
||||
* Reads file and returns contents
|
||||
* @param fd file descriptor
|
||||
* @return contents of file or NULL if an error occurred
|
||||
*/
|
||||
extern char * fd2str(int fd);
|
||||
|
||||
/*
|
||||
* Reads file and returns contents
|
||||
* @param path path to file
|
||||
* @return contents of file or NULL if an error occurred
|
||||
*/
|
||||
extern char * file2str(const char *path);
|
||||
|
||||
/*
|
||||
* Waits for a file descriptor to become available for reading or unblocked signal
|
||||
* @param fd file descriptor
|
||||
* @param timeout seconds to wait before timing out or 0 for no timeout
|
||||
* @return 1 if descriptor changed status or 0 if timed out or -1 on error
|
||||
*/
|
||||
extern int waitfor(int fd, int timeout);
|
||||
|
||||
/*
|
||||
* Concatenates NULL-terminated list of arguments into a single
|
||||
* commmand and executes it
|
||||
* @param argv argument list
|
||||
* @param path NULL, ">output", or ">>output"
|
||||
* @param timeout seconds to wait before timing out or 0 for no timeout
|
||||
* @param ppid NULL to wait for child termination or pointer to pid
|
||||
* @return return value of executed command or errno
|
||||
*/
|
||||
extern int _eval(char *const argv[], char *path, int timeout, pid_t *ppid);
|
||||
|
||||
/*
|
||||
* Concatenates NULL-terminated list of arguments into a single
|
||||
* commmand and executes it
|
||||
* @param argv argument list
|
||||
* @return stdout of executed command or NULL if an error occurred
|
||||
*/
|
||||
extern char * _backtick(char *const argv[]);
|
||||
|
||||
/*
|
||||
* Kills process whose PID is stored in plaintext in pidfile
|
||||
* @param pidfile PID file
|
||||
* @return 0 on success and errno on failure
|
||||
*/
|
||||
extern int kill_pidfile(char *pidfile);
|
||||
|
||||
/*
|
||||
* fread() with automatic retry on syscall interrupt
|
||||
* @param ptr location to store to
|
||||
* @param size size of each element of data
|
||||
* @param nmemb number of elements
|
||||
* @param stream file stream
|
||||
* @return number of items successfully read
|
||||
*/
|
||||
extern int safe_fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
|
||||
|
||||
/*
|
||||
* fwrite() with automatic retry on syscall interrupt
|
||||
* @param ptr location to read from
|
||||
* @param size size of each element of data
|
||||
* @param nmemb number of elements
|
||||
* @param stream file stream
|
||||
* @return number of items successfully written
|
||||
*/
|
||||
extern int safe_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
|
||||
|
||||
/*
|
||||
* Convert Ethernet address string representation to binary data
|
||||
* @param a string in xx:xx:xx:xx:xx:xx notation
|
||||
* @param e binary data
|
||||
* @return TRUE if conversion was successful and FALSE otherwise
|
||||
*/
|
||||
extern int ether_atoe(const char *a, unsigned char *e);
|
||||
|
||||
/*
|
||||
* Convert Ethernet address binary data to string representation
|
||||
* @param e binary data
|
||||
* @param a string in xx:xx:xx:xx:xx:xx notation
|
||||
* @return a
|
||||
*/
|
||||
extern char * ether_etoa(const unsigned char *e, char *a);
|
||||
|
||||
/*
|
||||
* Concatenate two strings together into a caller supplied buffer
|
||||
* @param s1 first string
|
||||
* @param s2 second string
|
||||
* @param buf buffer large enough to hold both strings
|
||||
* @return buf
|
||||
*/
|
||||
static inline char * strcat_r(const char *s1, const char *s2, char *buf)
|
||||
{
|
||||
strcpy(buf, s1);
|
||||
strcat(buf, s2);
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* Check for a blank character; that is, a space or a tab */
|
||||
#define isblank(c) ((c) == ' ' || (c) == '\t')
|
||||
|
||||
/* Strip trailing CR/NL from string <s> */
|
||||
#define chomp(s) ({ \
|
||||
char *c = (s) + strlen((s)) - 1; \
|
||||
while ((c > (s)) && (*c == '\n' || *c == '\r' || *c == ' ')) \
|
||||
*c-- = '\0'; \
|
||||
s; \
|
||||
})
|
||||
|
||||
/* Simple version of _backtick() */
|
||||
#define backtick(cmd, args...) ({ \
|
||||
char *argv[] = { cmd, ## args, NULL }; \
|
||||
_backtick(argv); \
|
||||
})
|
||||
|
||||
/* Simple version of _eval() (no timeout and wait for child termination) */
|
||||
#define eval(cmd, args...) ({ \
|
||||
char *argv[] = { cmd, ## args, NULL }; \
|
||||
_eval(argv, ">/dev/console", 0, NULL); \
|
||||
})
|
||||
|
||||
/* Copy each token in wordlist delimited by space into word */
|
||||
#define foreach(word, wordlist, next) \
|
||||
for (next = &wordlist[strspn(wordlist, " ")], \
|
||||
strncpy(word, next, sizeof(word)), \
|
||||
word[strcspn(word, " ")] = '\0', \
|
||||
word[sizeof(word) - 1] = '\0', \
|
||||
next = strchr(next, ' '); \
|
||||
strlen(word); \
|
||||
next = next ? &next[strspn(next, " ")] : "", \
|
||||
strncpy(word, next, sizeof(word)), \
|
||||
word[strcspn(word, " ")] = '\0', \
|
||||
word[sizeof(word) - 1] = '\0', \
|
||||
next = strchr(next, ' '))
|
||||
|
||||
/* Return NUL instead of NULL if undefined */
|
||||
#define safe_getenv(s) (getenv(s) ? : "")
|
||||
|
||||
/* Print directly to the console */
|
||||
#define cprintf(fmt, args...) do { \
|
||||
FILE *fp = fopen("/dev/console", "w"); \
|
||||
if (fp) { \
|
||||
fprintf(fp, fmt, ## args); \
|
||||
fclose(fp); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* Debug print */
|
||||
#ifdef DEBUG
|
||||
#define dprintf(fmt, args...) cprintf("%s: " fmt, __FUNCTION__, ## args)
|
||||
#else
|
||||
#define dprintf(fmt, args...)
|
||||
#endif
|
||||
|
||||
#ifdef vxworks
|
||||
|
||||
#include <inetLib.h>
|
||||
#define inet_aton(a, n) ((inet_aton((a), (n)) == ERROR) ? 0 : 1)
|
||||
#define inet_ntoa(n) ({ char a[INET_ADDR_LEN]; inet_ntoa_b ((n), a); a; })
|
||||
|
||||
#include <typedefs.h>
|
||||
#include <bcmutils.h>
|
||||
#define ether_atoe(a, e) bcm_ether_atoe((a), (e))
|
||||
#define ether_etoa(e, a) bcm_ether_ntoa((e), (a))
|
||||
|
||||
/* These declarations are not available where you would expect them */
|
||||
extern int vsnprintf (char *, size_t, const char *, va_list);
|
||||
extern int snprintf(char *str, size_t count, const char *fmt, ...);
|
||||
extern char *strdup(const char *);
|
||||
extern char *strsep(char **stringp, char *delim);
|
||||
extern int strcasecmp(const char *s1, const char *s2);
|
||||
extern int strncasecmp(const char *s1, const char *s2, size_t n);
|
||||
|
||||
/* Neither are socket() and connect() */
|
||||
#include <sockLib.h>
|
||||
|
||||
#ifdef DEBUG
|
||||
#undef dprintf
|
||||
#define dprintf printf
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* _shutils_h_ */
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2004, Broadcom Corporation
|
||||
* Copyright 2006, Broadcom Corporation
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
|
||||
|
@ -12,33 +12,10 @@
|
|||
#ifndef _TYPEDEFS_H_
|
||||
#define _TYPEDEFS_H_
|
||||
|
||||
|
||||
/* Define 'SITE_TYPEDEFS' in the compile to include a site specific
|
||||
* typedef file "site_typedefs.h".
|
||||
*
|
||||
* If 'SITE_TYPEDEFS' is not defined, then the "Inferred Typedefs"
|
||||
* section of this file makes inferences about the compile environment
|
||||
* based on defined symbols and possibly compiler pragmas.
|
||||
*
|
||||
* Following these two sections is the "Default Typedefs"
|
||||
* section. This section is only prcessed if 'USE_TYPEDEF_DEFAULTS' is
|
||||
* defined. This section has a default set of typedefs and a few
|
||||
* proprocessor symbols (TRUE, FALSE, NULL, ...).
|
||||
*/
|
||||
|
||||
#ifdef SITE_TYPEDEFS
|
||||
|
||||
/*******************************************************************************
|
||||
* Site Specific Typedefs
|
||||
*******************************************************************************/
|
||||
|
||||
#include "site_typedefs.h"
|
||||
|
||||
#else
|
||||
|
||||
/*******************************************************************************
|
||||
/*
|
||||
* Inferred Typedefs
|
||||
*******************************************************************************/
|
||||
*
|
||||
*/
|
||||
|
||||
/* Infer the compile environment based on preprocessor symbols and pramas.
|
||||
* Override type definitions as needed, and include configuration dependent
|
||||
|
@ -55,40 +32,15 @@
|
|||
#define TRUE true
|
||||
#endif
|
||||
|
||||
#else /* ! __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* for Windows build, define bool as a uchar instead of the default int */
|
||||
#if defined(_WIN32)
|
||||
|
||||
#define TYPEDEF_BOOL
|
||||
typedef unsigned char bool;
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#endif /* ! __cplusplus */
|
||||
|
||||
#ifdef _MSC_VER /* Microsoft C */
|
||||
#define TYPEDEF_INT64
|
||||
#define TYPEDEF_UINT64
|
||||
typedef signed __int64 int64;
|
||||
typedef unsigned __int64 uint64;
|
||||
#if defined(_NEED_SIZE_T_)
|
||||
typedef long unsigned int size_t;
|
||||
#endif
|
||||
|
||||
#if defined(MACOSX) && defined(KERNEL)
|
||||
#define TYPEDEF_BOOL
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(linux)
|
||||
#define TYPEDEF_UINT
|
||||
#define TYPEDEF_USHORT
|
||||
#define TYPEDEF_ULONG
|
||||
#endif
|
||||
|
||||
#if !defined(linux) && !defined(_WIN32) && !defined(PMON) && !defined(_CFE_)
|
||||
#define TYPEDEF_UINT
|
||||
#define TYPEDEF_USHORT
|
||||
#endif
|
||||
|
||||
|
||||
/* Do not support the (u)int64 types with strict ansi for GNU C */
|
||||
|
@ -97,57 +49,29 @@ typedef unsigned __int64 uint64;
|
|||
#define TYPEDEF_UINT64
|
||||
#endif
|
||||
|
||||
/* ICL accepts unsigned 64 bit type only, and complains in ANSI mode
|
||||
* for singned or unsigned */
|
||||
#if defined(__ICL)
|
||||
|
||||
#define TYPEDEF_INT64
|
||||
|
||||
#if defined(__STDC__)
|
||||
#define TYPEDEF_UINT64
|
||||
#endif
|
||||
|
||||
#endif /* __ICL */
|
||||
|
||||
|
||||
#if !defined(_WIN32) && !defined(PMON) && !defined(_CFE_)
|
||||
|
||||
/* pick up ushort & uint from standard types.h */
|
||||
#if defined(linux) && defined(__KERNEL__)
|
||||
|
||||
#include <linux/types.h> /* sys/types.h and linux/types.h are oil and water */
|
||||
|
||||
#else
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* !_WIN32 && !PMON && !_CFE_ */
|
||||
|
||||
#if defined(MACOSX) && defined(KERNEL)
|
||||
#include <IOKit/IOTypes.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* use the default typedefs in the next section of this file */
|
||||
#define USE_TYPEDEF_DEFAULTS
|
||||
|
||||
#endif /* SITE_TYPEDEFS */
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
/*
|
||||
* Default Typedefs
|
||||
*******************************************************************************/
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef USE_TYPEDEF_DEFAULTS
|
||||
#undef USE_TYPEDEF_DEFAULTS
|
||||
|
||||
#ifndef TYPEDEF_BOOL
|
||||
typedef int bool;
|
||||
typedef /* @abstract@ */ unsigned char bool;
|
||||
#endif
|
||||
|
||||
/*----------------------- define uchar, ushort, uint, ulong ----------------*/
|
||||
/* define uchar, ushort, uint, ulong */
|
||||
|
||||
#ifndef TYPEDEF_UCHAR
|
||||
typedef unsigned char uchar;
|
||||
|
@ -165,7 +89,7 @@ typedef unsigned int uint;
|
|||
typedef unsigned long ulong;
|
||||
#endif
|
||||
|
||||
/*----------------------- define [u]int8/16/32/64 --------------------------*/
|
||||
/* define [u]int8/16/32/64, uintptr */
|
||||
|
||||
#ifndef TYPEDEF_UINT8
|
||||
typedef unsigned char uint8;
|
||||
|
@ -183,6 +107,10 @@ typedef unsigned int uint32;
|
|||
typedef unsigned long long uint64;
|
||||
#endif
|
||||
|
||||
#ifndef TYPEDEF_UINTPTR
|
||||
typedef unsigned int uintptr;
|
||||
#endif
|
||||
|
||||
#ifndef TYPEDEF_INT8
|
||||
typedef signed char int8;
|
||||
#endif
|
||||
|
@ -199,7 +127,7 @@ typedef signed int int32;
|
|||
typedef signed long long int64;
|
||||
#endif
|
||||
|
||||
/*----------------------- define float32/64, float_t -----------------------*/
|
||||
/* define float32/64, float_t */
|
||||
|
||||
#ifndef TYPEDEF_FLOAT32
|
||||
typedef float float32;
|
||||
|
@ -225,14 +153,14 @@ typedef float64 float_t;
|
|||
|
||||
#endif /* TYPEDEF_FLOAT_T */
|
||||
|
||||
/*----------------------- define macro values -----------------------------*/
|
||||
/* define macro values */
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#define TRUE 1 /* TRUE */
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
|
@ -244,13 +172,15 @@ typedef float64 float_t;
|
|||
#endif
|
||||
|
||||
#ifndef ON
|
||||
#define ON 1
|
||||
#define ON 1 /* ON = 1 */
|
||||
#endif
|
||||
|
||||
/*----------------------- define PTRSZ, INLINE ----------------------------*/
|
||||
#define AUTO (-1) /* Auto = -1 */
|
||||
|
||||
/* define PTRSZ, INLINE */
|
||||
|
||||
#ifndef PTRSZ
|
||||
#define PTRSZ sizeof (char*)
|
||||
#define PTRSZ sizeof(char*)
|
||||
#endif
|
||||
|
||||
#ifndef INLINE
|
||||
|
@ -280,6 +210,7 @@ typedef float64 float_t;
|
|||
#undef TYPEDEF_UINT16
|
||||
#undef TYPEDEF_UINT32
|
||||
#undef TYPEDEF_UINT64
|
||||
#undef TYPEDEF_UINTPTR
|
||||
#undef TYPEDEF_INT8
|
||||
#undef TYPEDEF_INT16
|
||||
#undef TYPEDEF_INT32
|
||||
|
@ -290,4 +221,10 @@ typedef float64 float_t;
|
|||
|
||||
#endif /* USE_TYPEDEF_DEFAULTS */
|
||||
|
||||
/*
|
||||
* Including the bcmdefs.h here, to make sure everyone including typedefs.h
|
||||
* gets this automatically
|
||||
*/
|
||||
#include <bcmdefs.h>
|
||||
|
||||
#endif /* _TYPEDEFS_H_ */
|
||||
|
|
|
@ -1,131 +0,0 @@
|
|||
#include <cy_conf.h>
|
||||
|
||||
extern int diag_led(int type, int act);
|
||||
extern int C_led(int i);
|
||||
extern int get_single_ip(char *ipaddr, int which);
|
||||
extern char *get_mac_from_ip(char *ip);
|
||||
extern struct dns_lists *get_dns_list(int no);
|
||||
extern int dns_to_resolv(void);
|
||||
extern char *get_wan_face(void);
|
||||
extern int check_wan_link(int num);
|
||||
extern char *get_complete_lan_ip(char *ip);
|
||||
extern int get_int_len(int num);
|
||||
extern int file_to_buf(char *path, char *buf, int len);
|
||||
extern int buf_to_file(char *path, char *buf);
|
||||
extern pid_t* find_pid_by_name( char* pidName);
|
||||
extern int find_pid_by_ps(char* pidName);
|
||||
extern int *find_all_pid_by_ps(char* pidName);
|
||||
extern char *find_name_by_proc(int pid);
|
||||
extern int get_ppp_pid(char *file);
|
||||
extern long convert_ver(char *ver);
|
||||
extern int check_flash(void);
|
||||
extern int check_action(void);
|
||||
extern int check_now_boot(void);
|
||||
extern int check_hw_type(void);
|
||||
extern int is_exist(char *filename);
|
||||
extern void set_ip_forward(char c);
|
||||
struct mtu_lists *get_mtu(char *proto);
|
||||
extern void set_host_domain_name(void);
|
||||
|
||||
extern void encode(char *buf, int len);
|
||||
extern void decode(char *buf, int len);
|
||||
|
||||
extern int sys_netdev_ioctl(int family, int socket, char *if_name, int cmd, struct ifreq *ifr);
|
||||
|
||||
int ct_openlog(const char *ident, int option, int facility, char *log_name);
|
||||
void ct_syslog(int level, int enable, const char *fmt,...);
|
||||
void ct_logger(int level, const char *fmt,...);
|
||||
struct wl_assoc_mac * get_wl_assoc_mac(int *c);
|
||||
|
||||
|
||||
|
||||
enum { DMZ, SESSION, DIAG , WL};
|
||||
|
||||
enum { START_LED, STOP_LED };
|
||||
|
||||
typedef enum { ACT_IDLE,
|
||||
ACT_TFTP_UPGRADE,
|
||||
ACT_WEB_UPGRADE,
|
||||
ACT_WEBS_UPGRADE,
|
||||
ACT_SW_RESTORE,
|
||||
ACT_HW_RESTORE } ACTION;
|
||||
|
||||
enum { UNKNOWN_BOOT = -1, PMON_BOOT, CFE_BOOT };
|
||||
|
||||
enum { BCM4702_CHIP, BCM4712_CHIP, BCM5325E_CHIP };
|
||||
|
||||
enum { FIRST, SECOND };
|
||||
|
||||
enum { SYSLOG_LOG=1, SYSLOG_DEBUG, CONSOLE_ONLY, LOG_CONSOLE, DEBUG_CONSOLE };
|
||||
|
||||
#define ACTION(cmd) buf_to_file(ACTION_FILE, cmd)
|
||||
|
||||
struct dns_lists {
|
||||
int num_servers;
|
||||
char dns_server[4][16];
|
||||
};
|
||||
|
||||
#define NOT_USING 0
|
||||
#define USING 1
|
||||
|
||||
struct wl_assoc_mac
|
||||
{
|
||||
char mac[18];
|
||||
};
|
||||
|
||||
struct mtu_lists {
|
||||
char *proto; /* protocol */
|
||||
char *min; /* min mtu */
|
||||
char *max; /* max mtu */
|
||||
};
|
||||
|
||||
|
||||
#define PPP_PSEUDO_IP "10.64.64.64"
|
||||
#define PPP_PSEUDO_NM "255.255.255.255"
|
||||
#define PPP_PSEUDO_GW "10.112.112.112"
|
||||
|
||||
#define PING_TMP "/tmp/ping.log"
|
||||
#define TRACEROUTE_TMP "/tmp/traceroute.log"
|
||||
#define MAX_BUF_LEN 254
|
||||
|
||||
#define RESOLV_FILE "/tmp/resolv.conf"
|
||||
#define HOSTS_FILE "/tmp/hosts"
|
||||
|
||||
#define LOG_FILE "/var/log/mess"
|
||||
|
||||
#define ACTION_FILE "/tmp/action"
|
||||
|
||||
|
||||
#define split(word, wordlist, next, delim) \
|
||||
for (next = wordlist, \
|
||||
strncpy(word, next, sizeof(word)), \
|
||||
word[(next=strstr(next, delim)) ? strstr(word, delim) - word : sizeof(word) - 1] = '\0', \
|
||||
next = next ? next + sizeof(delim) - 1 : NULL ; \
|
||||
strlen(word); \
|
||||
next = next ? : "", \
|
||||
strncpy(word, next, sizeof(word)), \
|
||||
word[(next=strstr(next, delim)) ? strstr(word, delim) - word : sizeof(word) - 1] = '\0', \
|
||||
next = next ? next + sizeof(delim) - 1 : NULL)
|
||||
|
||||
#define STRUCT_LEN(name) sizeof(name)/sizeof(name[0])
|
||||
|
||||
#define printHEX(str,len) { \
|
||||
int i; \
|
||||
for (i=0 ; i<len ; i++) { \
|
||||
printf("%02X ", (unsigned char)*(str+i)); \
|
||||
if(((i+1)%16) == 0) printf("- "); \
|
||||
if(((i+1)%32) == 0) printf("\n"); \
|
||||
} \
|
||||
printf("\n\n"); \
|
||||
}
|
||||
|
||||
|
||||
#define printASC(str,len) { \
|
||||
int i; \
|
||||
for (i=0 ; i<len ; i++) { \
|
||||
printf("%c", (unsigned char)*(str+i)); \
|
||||
if(((i+1)%16) == 0) printf("- "); \
|
||||
if(((i+1)%32) == 0) printf("\n"); \
|
||||
} \
|
||||
printf("\n\n"); \
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Broadcom wireless network adapter utility functions
|
||||
*
|
||||
* Copyright 2004, Broadcom Corporation
|
||||
* Copyright 2006, Broadcom Corporation
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
|
||||
|
@ -28,14 +28,6 @@
|
|||
*/
|
||||
extern int wl_ioctl(char *name, int cmd, void *buf, int len);
|
||||
|
||||
/*
|
||||
* Get the MAC (hardware) address of the specified interface.
|
||||
* @param name interface name
|
||||
* @param hwaddr 6-byte buffer for receiving address
|
||||
* @return >= 0 if successful or < 0 otherwise
|
||||
*/
|
||||
extern int wl_hwaddr(char *name, unsigned char *hwaddr);
|
||||
|
||||
/*
|
||||
* Probe the specified interface.
|
||||
* @param name interface name
|
||||
|
@ -43,17 +35,68 @@ extern int wl_hwaddr(char *name, unsigned char *hwaddr);
|
|||
*/
|
||||
extern int wl_probe(char *name);
|
||||
|
||||
extern int wl_iovar_set(char *ifname, char *iovar, void *param, int paramlen);
|
||||
extern int wl_iovar_get(char *ifname, char *iovar, void *bufptr, int buflen);
|
||||
/*
|
||||
* Set/Get named variable.
|
||||
* @param name interface name
|
||||
* @param var variable name
|
||||
* @param val variable value/buffer
|
||||
* @param len variable value/buffer length
|
||||
* @param ifname interface name
|
||||
* @param iovar variable name
|
||||
* @param param input param value/buffer
|
||||
* @param paramlen input param value/buffer length
|
||||
* @param bufptr io buffer
|
||||
* @param buflen io buffer length
|
||||
* @param val val or val pointer for int routines
|
||||
* @return success == 0, failure != 0
|
||||
*/
|
||||
extern int wl_set_val(char *name, char *var, void *val, int len);
|
||||
extern int wl_get_val(char *name, char *var, void *val, int len);
|
||||
extern int wl_set_int(char *name, char *var, int val);
|
||||
extern int wl_get_int(char *name, char *var, int *val);
|
||||
/*
|
||||
* set named driver variable to int value
|
||||
* calling example: wl_iovar_setint(ifname, "arate", rate)
|
||||
*/
|
||||
static inline int
|
||||
wl_iovar_setint(char *ifname, char *iovar, int val)
|
||||
{
|
||||
return wl_iovar_set(ifname, iovar, &val, sizeof(val));
|
||||
}
|
||||
|
||||
/*
|
||||
* get named driver variable to int value and return error indication
|
||||
* calling example: wl_iovar_getint(ifname, "arate", &rate)
|
||||
*/
|
||||
static inline int
|
||||
wl_iovar_getint(char *ifname, char *iovar, int *val)
|
||||
{
|
||||
return wl_iovar_get(ifname, iovar, val, sizeof(int));
|
||||
}
|
||||
|
||||
/*
|
||||
* Set/Get named variable indexed by BSS Configuration
|
||||
* @param ifname interface name
|
||||
* @param iovar variable name
|
||||
* @param bssidx bsscfg index
|
||||
* @param param input param value/buffer
|
||||
* @param paramlen input param value/buffer length
|
||||
* @param bufptr io buffer
|
||||
* @param buflen io buffer length
|
||||
* @param val val or val pointer for int routines
|
||||
* @return success == 0, failure != 0
|
||||
*/
|
||||
extern int wl_bssiovar_get(char *ifname, char *iovar, int bssidx, void *outbuf, int len);
|
||||
extern int wl_bssiovar_set(char *ifname, char *iovar, int bssidx, void *param, int paramlen);
|
||||
/*
|
||||
* set named & bss indexed driver variable to int value
|
||||
*/
|
||||
static inline int
|
||||
wl_bssiovar_setint(char *ifname, char *iovar, int bssidx, int val)
|
||||
{
|
||||
return wl_bssiovar_set(ifname, iovar, bssidx, &val, sizeof(int));
|
||||
}
|
||||
|
||||
static inline int
|
||||
wl_bssiovar_getint(char *ifname, char *iovar, int bssidx, int *val)
|
||||
{
|
||||
return wl_bssiovar_get(ifname, iovar, bssidx, val, sizeof(int));
|
||||
}
|
||||
|
||||
extern int wl_bssiovar_setint(char *ifname, char *iovar, int bssidx, int val);
|
||||
|
||||
#endif /* _wlutils_h_ */
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*
|
||||
* wlcompat.c
|
||||
*
|
||||
* Copyright (C) 2005 Mike Baker,
|
||||
* Felix Fietkau <openwrt@nbd.name>
|
||||
* Copyright (C) 2005 Mike Baker
|
||||
* Copyright (C) 2005-2007 Felix Fietkau <nbd@openwrt.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -27,18 +27,23 @@
|
|||
#include <linux/moduleparam.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/if_arp.h>
|
||||
#include <asm/uaccess.h>
|
||||
#include <linux/wireless.h>
|
||||
#include <linux/timer.h>
|
||||
|
||||
#include <linux/delay.h>
|
||||
#include <net/iw_handler.h>
|
||||
#include <asm/uaccess.h>
|
||||
|
||||
#include <typedefs.h>
|
||||
#include <bcmutils.h>
|
||||
#include <wlioctl.h>
|
||||
#include <proto/802.11.h>
|
||||
|
||||
static struct net_device *dev;
|
||||
static unsigned short bss_force;
|
||||
static struct iw_statistics wstats;
|
||||
#ifndef DEBUG
|
||||
static int random = 1;
|
||||
#endif
|
||||
static int last_mode = -1;
|
||||
static int scan_cur = 0;
|
||||
char buf[WLC_IOCTL_MAXLEN];
|
||||
|
||||
/* The frequency of each channel in MHz */
|
||||
|
@ -48,7 +53,8 @@ const long channel_frequency[] = {
|
|||
};
|
||||
#define NUM_CHANNELS ( sizeof(channel_frequency) / sizeof(channel_frequency[0]) )
|
||||
|
||||
#define RNG_POLL_FREQ 2
|
||||
#define SCAN_RETRY_MAX 5
|
||||
#define RNG_POLL_FREQ 1
|
||||
|
||||
typedef struct internal_wsec_key {
|
||||
uint8 index; // 0x00
|
||||
|
@ -61,10 +67,6 @@ typedef struct internal_wsec_key {
|
|||
} wkey;
|
||||
|
||||
|
||||
static int wlcompat_private_ioctl(struct net_device *dev,
|
||||
struct iw_request_info *info,
|
||||
union iwreq_data *wrqu,
|
||||
char *extra);
|
||||
#ifdef DEBUG
|
||||
void print_buffer(int len, unsigned char *buf);
|
||||
#endif
|
||||
|
@ -86,45 +88,187 @@ static int wl_ioctl(struct net_device *dev, int cmd, void *buf, int len)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int wl_set_val(struct net_device *dev, char *var, void *val, int len)
|
||||
static int
|
||||
wl_iovar_getbuf(struct net_device *dev, char *iovar, void *param, int paramlen, void *bufptr, int buflen)
|
||||
{
|
||||
char buf[128];
|
||||
int buf_len;
|
||||
int ret;
|
||||
int err;
|
||||
uint namelen;
|
||||
uint iolen;
|
||||
|
||||
namelen = strlen(iovar) + 1; /* length of iovar name plus null */
|
||||
iolen = namelen + paramlen;
|
||||
|
||||
/* check for overflow */
|
||||
if ((buf_len = strlen(var)) + 1 + len > sizeof(buf))
|
||||
return -1;
|
||||
if (iolen > buflen)
|
||||
return (BCME_BUFTOOSHORT);
|
||||
|
||||
strcpy(buf, var);
|
||||
buf_len += 1;
|
||||
memcpy(bufptr, iovar, namelen); /* copy iovar name including null */
|
||||
memcpy((int8*)bufptr + namelen, param, paramlen);
|
||||
|
||||
/* append int value onto the end of the name string */
|
||||
memcpy(&(buf[buf_len]), val, len);
|
||||
buf_len += len;
|
||||
err = wl_ioctl(dev, WLC_GET_VAR, bufptr, buflen);
|
||||
|
||||
return (err);
|
||||
}
|
||||
|
||||
static int
|
||||
wl_iovar_setbuf(struct net_device *dev, char *iovar, void *param, int paramlen, void *bufptr, int buflen)
|
||||
{
|
||||
uint namelen;
|
||||
uint iolen;
|
||||
|
||||
namelen = strlen(iovar) + 1; /* length of iovar name plus null */
|
||||
iolen = namelen + paramlen;
|
||||
|
||||
/* check for overflow */
|
||||
if (iolen > buflen)
|
||||
return (BCME_BUFTOOSHORT);
|
||||
|
||||
memcpy(bufptr, iovar, namelen); /* copy iovar name including null */
|
||||
memcpy((int8*)bufptr + namelen, param, paramlen);
|
||||
|
||||
return wl_ioctl(dev, WLC_SET_VAR, bufptr, iolen);
|
||||
}
|
||||
|
||||
static int
|
||||
wl_iovar_set(struct net_device *dev, char *iovar, void *param, int paramlen)
|
||||
{
|
||||
char smbuf[WLC_IOCTL_SMLEN];
|
||||
|
||||
return wl_iovar_setbuf(dev, iovar, param, paramlen, smbuf, sizeof(smbuf));
|
||||
}
|
||||
|
||||
static int
|
||||
wl_iovar_get(struct net_device *dev, char *iovar, void *bufptr, int buflen)
|
||||
{
|
||||
char smbuf[WLC_IOCTL_SMLEN];
|
||||
int ret;
|
||||
|
||||
/* use the return buffer if it is bigger than what we have on the stack */
|
||||
if (buflen > sizeof(smbuf)) {
|
||||
ret = wl_iovar_getbuf(dev, iovar, NULL, 0, bufptr, buflen);
|
||||
} else {
|
||||
ret = wl_iovar_getbuf(dev, iovar, NULL, 0, smbuf, sizeof(smbuf));
|
||||
if (ret == 0)
|
||||
memcpy(bufptr, smbuf, buflen);
|
||||
}
|
||||
|
||||
ret = wl_ioctl(dev, WLC_SET_VAR, buf, buf_len);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int wl_get_val(struct net_device *dev, char *var, void *val, int len)
|
||||
#ifdef notyet
|
||||
/*
|
||||
* format a bsscfg indexed iovar buffer
|
||||
*/
|
||||
static int
|
||||
wl_bssiovar_mkbuf(char *iovar, int bssidx, void *param, int paramlen, void *bufptr, int buflen,
|
||||
int *plen)
|
||||
{
|
||||
char buf[128];
|
||||
int buf_len;
|
||||
int ret;
|
||||
char *prefix = "bsscfg:";
|
||||
int8* p;
|
||||
uint prefixlen;
|
||||
uint namelen;
|
||||
uint iolen;
|
||||
|
||||
prefixlen = strlen(prefix); /* length of bsscfg prefix */
|
||||
namelen = strlen(iovar) + 1; /* length of iovar name + null */
|
||||
iolen = prefixlen + namelen + sizeof(int) + paramlen;
|
||||
|
||||
/* check for overflow */
|
||||
if ((buf_len = strlen(var)) + 1 > sizeof(buf) || len > sizeof(buf))
|
||||
return -1;
|
||||
if (buflen < 0 || iolen > (uint)buflen) {
|
||||
*plen = 0;
|
||||
return BCME_BUFTOOSHORT;
|
||||
}
|
||||
|
||||
strcpy(buf, var);
|
||||
if (ret = wl_ioctl(dev, WLC_GET_VAR, buf, buf_len + len))
|
||||
return ret;
|
||||
p = (int8*)bufptr;
|
||||
|
||||
memcpy(val, buf, len);
|
||||
/* copy prefix, no null */
|
||||
memcpy(p, prefix, prefixlen);
|
||||
p += prefixlen;
|
||||
|
||||
/* copy iovar name including null */
|
||||
memcpy(p, iovar, namelen);
|
||||
p += namelen;
|
||||
|
||||
/* bss config index as first param */
|
||||
memcpy(p, &bssidx, sizeof(int32));
|
||||
p += sizeof(int32);
|
||||
|
||||
/* parameter buffer follows */
|
||||
if (paramlen)
|
||||
memcpy(p, param, paramlen);
|
||||
|
||||
*plen = iolen;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* set named & bss indexed driver variable to buffer value
|
||||
*/
|
||||
static int
|
||||
wl_bssiovar_setbuf(struct net_device *dev, char *iovar, int bssidx, void *param, int paramlen, void *bufptr,
|
||||
int buflen)
|
||||
{
|
||||
int err;
|
||||
int iolen;
|
||||
|
||||
err = wl_bssiovar_mkbuf(iovar, bssidx, param, paramlen, bufptr, buflen, &iolen);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
return wl_ioctl(dev, WLC_SET_VAR, bufptr, iolen);
|
||||
}
|
||||
|
||||
/*
|
||||
* get named & bss indexed driver variable buffer value
|
||||
*/
|
||||
static int
|
||||
wl_bssiovar_getbuf(struct net_device *dev, char *iovar, int bssidx, void *param, int paramlen, void *bufptr,
|
||||
int buflen)
|
||||
{
|
||||
int err;
|
||||
int iolen;
|
||||
|
||||
err = wl_bssiovar_mkbuf(iovar, bssidx, param, paramlen, bufptr, buflen, &iolen);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
return wl_ioctl(dev, WLC_GET_VAR, bufptr, buflen);
|
||||
}
|
||||
|
||||
/*
|
||||
* set named & bss indexed driver variable to buffer value
|
||||
*/
|
||||
static int
|
||||
wl_bssiovar_set(struct net_device *dev, char *iovar, int bssidx, void *param, int paramlen)
|
||||
{
|
||||
char smbuf[WLC_IOCTL_SMLEN];
|
||||
|
||||
return wl_bssiovar_setbuf(dev, iovar, bssidx, param, paramlen, smbuf, sizeof(smbuf));
|
||||
}
|
||||
|
||||
/*
|
||||
* get named & bss indexed driver variable buffer value
|
||||
*/
|
||||
static int
|
||||
wl_bssiovar_get(struct net_device *dev, char *iovar, int bssidx, void *outbuf, int len)
|
||||
{
|
||||
char smbuf[WLC_IOCTL_SMLEN];
|
||||
int err;
|
||||
|
||||
/* use the return buffer if it is bigger than what we have on the stack */
|
||||
if (len > (int)sizeof(smbuf)) {
|
||||
err = wl_bssiovar_getbuf(dev, iovar, bssidx, NULL, 0, outbuf, len);
|
||||
} else {
|
||||
memset(smbuf, 0, sizeof(smbuf));
|
||||
err = wl_bssiovar_getbuf(dev, iovar, bssidx, NULL, 0, smbuf, sizeof(smbuf));
|
||||
if (err == 0)
|
||||
memcpy(outbuf, smbuf, len);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
#endif
|
||||
|
||||
int get_primary_key(struct net_device *dev)
|
||||
{
|
||||
int key, val;
|
||||
|
@ -145,7 +289,7 @@ static int wlcompat_ioctl_getiwrange(struct net_device *dev,
|
|||
struct iw_range *range;
|
||||
|
||||
range = (struct iw_range *) extra;
|
||||
bzero(extra, sizeof(struct iw_range));
|
||||
memset(extra, 0, sizeof(struct iw_range));
|
||||
|
||||
range->we_version_compiled = WIRELESS_EXT;
|
||||
range->we_version_source = WIRELESS_EXT;
|
||||
|
@ -180,12 +324,12 @@ static int wlcompat_ioctl_getiwrange(struct net_device *dev,
|
|||
range->max_qual.noise = 0;
|
||||
|
||||
range->min_rts = 0;
|
||||
if (wl_ioctl(dev, WLC_GET_RTS, &range->max_rts, sizeof(int)) < 0)
|
||||
if (wl_iovar_get(dev, "rtsthresh", &range->max_rts, sizeof(int)) < 0)
|
||||
range->max_rts = 2347;
|
||||
|
||||
range->min_frag = 256;
|
||||
|
||||
if (wl_ioctl(dev, WLC_GET_FRAG, &range->max_frag, sizeof(int)) < 0)
|
||||
if (wl_iovar_get(dev, "fragthresh", &range->max_frag, sizeof(int)) < 0)
|
||||
range->max_frag = 2346;
|
||||
|
||||
range->txpower_capa = IW_TXPOW_DBM;
|
||||
|
@ -199,7 +343,7 @@ static int wlcompat_set_scan(struct net_device *dev,
|
|||
union iwreq_data *wrqu,
|
||||
char *extra)
|
||||
{
|
||||
int ap = 0, oldap = 0;
|
||||
int ap = 0;
|
||||
wl_scan_params_t params;
|
||||
|
||||
memset(¶ms, 0, sizeof(params));
|
||||
|
@ -214,15 +358,31 @@ static int wlcompat_set_scan(struct net_device *dev,
|
|||
params.home_time = -1;
|
||||
|
||||
/* can only scan in STA mode */
|
||||
wl_ioctl(dev, WLC_GET_AP, &oldap, sizeof(oldap));
|
||||
if (oldap > 0)
|
||||
wl_ioctl(dev, WLC_GET_AP, &last_mode, sizeof(last_mode));
|
||||
if (last_mode > 0) {
|
||||
/* switch to ap mode, scan result query will switch back */
|
||||
wl_ioctl(dev, WLC_SET_AP, &ap, sizeof(ap));
|
||||
|
||||
if (wl_ioctl(dev, WLC_SCAN, ¶ms, 64) < 0)
|
||||
/* wait 250 msec after mode change */
|
||||
set_current_state(TASK_INTERRUPTIBLE);
|
||||
schedule_timeout(msecs_to_jiffies(250));
|
||||
}
|
||||
|
||||
scan_cur = SCAN_RETRY_MAX;
|
||||
while (scan_cur-- && (wl_ioctl(dev, WLC_SCAN, ¶ms, 64) < 0)) {
|
||||
/* sometimes the driver takes a few tries... */
|
||||
set_current_state(TASK_INTERRUPTIBLE);
|
||||
schedule_timeout(msecs_to_jiffies(250));
|
||||
}
|
||||
|
||||
if (!scan_cur)
|
||||
return -EINVAL;
|
||||
|
||||
if (oldap > 0)
|
||||
wl_ioctl(dev, WLC_SET_AP, &oldap, sizeof(oldap));
|
||||
scan_cur = 0;
|
||||
|
||||
/* wait at least 2 seconds for results */
|
||||
set_current_state(TASK_INTERRUPTIBLE);
|
||||
schedule_timeout(msecs_to_jiffies(2000));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -230,7 +390,7 @@ static int wlcompat_set_scan(struct net_device *dev,
|
|||
|
||||
struct iw_statistics *wlcompat_get_wireless_stats(struct net_device *dev)
|
||||
{
|
||||
wl_bss_info_t *bss_info = (wl_bss_info_t *) buf;
|
||||
struct wl_bss_info *bss_info = (struct wl_bss_info *) buf;
|
||||
get_pktcnt_t pkt;
|
||||
unsigned int rssi, noise, ap;
|
||||
|
||||
|
@ -283,15 +443,18 @@ static int wlcompat_get_scan(struct net_device *dev,
|
|||
int i, j;
|
||||
int rssi, noise;
|
||||
|
||||
memset(buf, 0, WLC_IOCTL_MAXLEN);
|
||||
results->buflen = WLC_IOCTL_MAXLEN - sizeof(wl_scan_results_t);
|
||||
|
||||
if (wl_ioctl(dev, WLC_SCAN_RESULTS, buf, WLC_IOCTL_MAXLEN) < 0)
|
||||
return -EAGAIN;
|
||||
|
||||
if ((results->count <= 0) && (scan_cur++ < SCAN_RETRY_MAX))
|
||||
return -EAGAIN;
|
||||
|
||||
bss_info = &(results->bss_info[0]);
|
||||
info_ptr = (char *) bss_info;
|
||||
for (i = 0; i < results->count; i++) {
|
||||
|
||||
/* send the cell address (must be sent first) */
|
||||
iwe.cmd = SIOCGIWAP;
|
||||
iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
|
||||
|
@ -319,7 +482,7 @@ static int wlcompat_get_scan(struct net_device *dev,
|
|||
/* send frequency/channel info */
|
||||
iwe.cmd = SIOCGIWFREQ;
|
||||
iwe.u.freq.e = 0;
|
||||
iwe.u.freq.m = bss_info->channel;
|
||||
iwe.u.freq.m = bss_info->chanspec;
|
||||
current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
|
||||
|
||||
/* add quality statistics */
|
||||
|
@ -362,6 +525,10 @@ static int wlcompat_get_scan(struct net_device *dev,
|
|||
wrqu->data.length = (current_ev - extra);
|
||||
wrqu->data.flags = 0;
|
||||
|
||||
if (last_mode > 0)
|
||||
/* switch back to ap mode */
|
||||
wl_ioctl(dev, WLC_SET_AP, &last_mode, sizeof(last_mode));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -430,20 +597,9 @@ static int wlcompat_ioctl(struct net_device *dev,
|
|||
if (wl_ioctl(dev, WLC_GET_INFRA, &infra, sizeof(infra)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
if (!infra) {
|
||||
if (!infra)
|
||||
wl_ioctl(dev, WLC_SET_BSSID, wrqu->ap_addr.sa_data, 6);
|
||||
|
||||
reg.size = 4;
|
||||
reg.byteoff = 0x184;
|
||||
reg.val = bss_force << 16 | bss_force;
|
||||
wl_ioctl(dev, WLC_W_REG, ®, sizeof(reg));
|
||||
|
||||
reg.byteoff = 0x180;
|
||||
wl_ioctl(dev, WLC_R_REG, ®, sizeof(reg));
|
||||
reg.val = bss_force << 16;
|
||||
wl_ioctl(dev, WLC_W_REG, ®, sizeof(reg));
|
||||
}
|
||||
|
||||
if (wl_ioctl(dev, ((ap || !infra) ? WLC_SET_BSSID : WLC_REASSOC), wrqu->ap_addr.sa_data, 6) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
|
@ -451,20 +607,6 @@ static int wlcompat_ioctl(struct net_device *dev,
|
|||
}
|
||||
case SIOCGIWAP:
|
||||
{
|
||||
#ifdef DEBUG
|
||||
rw_reg_t reg;
|
||||
memset(®, 0, sizeof(reg));
|
||||
|
||||
reg.size = 4;
|
||||
reg.byteoff = 0x184;
|
||||
wl_ioctl(dev, WLC_R_REG, ®, sizeof(reg));
|
||||
printk("bss time = 0x%08x", reg.val);
|
||||
|
||||
reg.byteoff = 0x180;
|
||||
wl_ioctl(dev, WLC_R_REG, ®, sizeof(reg));
|
||||
printk("%08x\n", reg.val);
|
||||
#endif
|
||||
|
||||
wrqu->ap_addr.sa_family = ARPHRD_ETHER;
|
||||
if (wl_ioctl(dev,WLC_GET_BSSID,wrqu->ap_addr.sa_data,6) < 0)
|
||||
return -EINVAL;
|
||||
|
@ -487,8 +629,8 @@ static int wlcompat_ioctl(struct net_device *dev,
|
|||
wlc_ssid_t ssid;
|
||||
memset(&ssid, 0, sizeof(ssid));
|
||||
ssid.SSID_len = strlen(extra);
|
||||
if (ssid.SSID_len > WLC_ESSID_MAX_SIZE)
|
||||
ssid.SSID_len = WLC_ESSID_MAX_SIZE;
|
||||
if (ssid.SSID_len > 32)
|
||||
ssid.SSID_len = 32;
|
||||
memcpy(ssid.SSID, extra, ssid.SSID_len);
|
||||
if (wl_ioctl(dev, WLC_SET_SSID, &ssid, sizeof(ssid)) < 0)
|
||||
return -EINVAL;
|
||||
|
@ -496,25 +638,25 @@ static int wlcompat_ioctl(struct net_device *dev,
|
|||
}
|
||||
case SIOCGIWRTS:
|
||||
{
|
||||
if (wl_ioctl(dev,WLC_GET_RTS,&(wrqu->rts.value),sizeof(int)) < 0)
|
||||
if (wl_iovar_get(dev, "rtsthresh", &(wrqu->rts.value), sizeof(int)) < 0)
|
||||
return -EINVAL;
|
||||
break;
|
||||
}
|
||||
case SIOCSIWRTS:
|
||||
{
|
||||
if (wl_ioctl(dev,WLC_SET_RTS,&(wrqu->rts.value),sizeof(int)) < 0)
|
||||
if (wl_iovar_set(dev, "rtsthresh", &(wrqu->rts.value), sizeof(int)) < 0)
|
||||
return -EINVAL;
|
||||
break;
|
||||
}
|
||||
case SIOCGIWFRAG:
|
||||
{
|
||||
if (wl_ioctl(dev,WLC_GET_FRAG,&(wrqu->frag.value),sizeof(int)) < 0)
|
||||
if (wl_iovar_get(dev, "fragthresh", &(wrqu->frag.value), sizeof(int)) < 0)
|
||||
return -EINVAL;
|
||||
break;
|
||||
}
|
||||
case SIOCSIWFRAG:
|
||||
{
|
||||
if (wl_ioctl(dev,WLC_SET_FRAG,&(wrqu->frag.value),sizeof(int)) < 0)
|
||||
if (wl_iovar_set(dev, "fragthresh", &(wrqu->frag.value), sizeof(int)) < 0)
|
||||
return -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
@ -524,7 +666,7 @@ static int wlcompat_ioctl(struct net_device *dev,
|
|||
|
||||
wl_ioctl(dev, WLC_GET_RADIO, &radio, sizeof(int));
|
||||
|
||||
if (wl_get_val(dev, "qtxpower", &(wrqu->txpower.value), sizeof(int)) < 0)
|
||||
if (wl_iovar_get(dev, "qtxpower", &(wrqu->txpower.value), sizeof(int)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
override = (wrqu->txpower.value & WL_TXPWR_OVERRIDE) == WL_TXPWR_OVERRIDE;
|
||||
|
@ -548,7 +690,7 @@ static int wlcompat_ioctl(struct net_device *dev,
|
|||
if (!wrqu->txpower.disabled && (wrqu->txpower.value > 0)) {
|
||||
int value;
|
||||
|
||||
if (wl_get_val(dev, "qtxpower", &value, sizeof(int)) < 0)
|
||||
if (wl_iovar_get(dev, "qtxpower", &value, sizeof(int)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
value &= WL_TXPWR_OVERRIDE;
|
||||
|
@ -559,7 +701,7 @@ static int wlcompat_ioctl(struct net_device *dev,
|
|||
return -EINVAL;
|
||||
|
||||
if (wrqu->txpower.value > 0)
|
||||
if (wl_set_val(dev, "qtxpower", &(wrqu->txpower.value), sizeof(int)) < 0)
|
||||
if (wl_iovar_set(dev, "qtxpower", &(wrqu->txpower.value), sizeof(int)) < 0)
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
|
@ -609,34 +751,23 @@ static int wlcompat_ioctl(struct net_device *dev,
|
|||
case SIOCGIWENCODE:
|
||||
{
|
||||
int val;
|
||||
|
||||
if (wl_ioctl(dev, WLC_GET_WEP, &val, sizeof(val)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
|
||||
if (val > 0) {
|
||||
int key = get_primary_key(dev);
|
||||
|
||||
wrqu->data.flags = IW_ENCODE_ENABLED;
|
||||
if (key-- > 0) {
|
||||
int *info_addr;
|
||||
wkey *wep_key;
|
||||
|
||||
info_addr = (int *) dev->priv;
|
||||
wep_key = (wkey *) ((*info_addr) + 0x2752 + (key * 0x110));
|
||||
|
||||
wrqu->data.flags |= key + 1;
|
||||
wrqu->data.length = wep_key->len;
|
||||
|
||||
memset(extra, 0, 16);
|
||||
memcpy(extra, wep_key->data, 16);
|
||||
} else {
|
||||
wrqu->data.flags |= IW_ENCODE_NOKEY;
|
||||
}
|
||||
} else {
|
||||
if (wl_ioctl(dev, WLC_GET_WSEC, &val, sizeof(val)) < 0)
|
||||
return -EINVAL;
|
||||
if (!(val & WEP_ENABLED)) {
|
||||
wrqu->data.flags = IW_ENCODE_DISABLED;
|
||||
break;
|
||||
}
|
||||
|
||||
key = get_primary_key(dev);
|
||||
wrqu->data.flags = IW_ENCODE_ENABLED;
|
||||
|
||||
/* the driver apparently doesn't allow us to read the wep key */
|
||||
wrqu->data.flags |= IW_ENCODE_NOKEY;
|
||||
|
||||
break;
|
||||
}
|
||||
case SIOCGIWRANGE:
|
||||
|
@ -716,12 +847,8 @@ static int wlcompat_ioctl(struct net_device *dev,
|
|||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
if (info->cmd >= SIOCIWFIRSTPRIV)
|
||||
return wlcompat_private_ioctl(dev, info, wrqu, extra);
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -775,183 +902,10 @@ static const iw_handler wlcompat_handler[] = {
|
|||
};
|
||||
|
||||
|
||||
#define WLCOMPAT_SET_MONITOR SIOCIWFIRSTPRIV + 0
|
||||
#define WLCOMPAT_GET_MONITOR SIOCIWFIRSTPRIV + 1
|
||||
#define WLCOMPAT_SET_TXPWR_LIMIT SIOCIWFIRSTPRIV + 2
|
||||
#define WLCOMPAT_GET_TXPWR_LIMIT SIOCIWFIRSTPRIV + 3
|
||||
#define WLCOMPAT_SET_ANTDIV SIOCIWFIRSTPRIV + 4
|
||||
#define WLCOMPAT_GET_ANTDIV SIOCIWFIRSTPRIV + 5
|
||||
#define WLCOMPAT_SET_TXANT SIOCIWFIRSTPRIV + 6
|
||||
#define WLCOMPAT_GET_TXANT SIOCIWFIRSTPRIV + 7
|
||||
#define WLCOMPAT_SET_BSS_FORCE SIOCIWFIRSTPRIV + 8
|
||||
#define WLCOMPAT_GET_BSS_FORCE SIOCIWFIRSTPRIV + 9
|
||||
|
||||
|
||||
static int wlcompat_private_ioctl(struct net_device *dev,
|
||||
struct iw_request_info *info,
|
||||
union iwreq_data *wrqu,
|
||||
char *extra)
|
||||
{
|
||||
int *value = (int *) wrqu->name;
|
||||
|
||||
switch (info->cmd) {
|
||||
case WLCOMPAT_SET_MONITOR:
|
||||
{
|
||||
if (wl_ioctl(dev, WLC_SET_MONITOR, value, sizeof(int)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
break;
|
||||
}
|
||||
case WLCOMPAT_GET_MONITOR:
|
||||
{
|
||||
if (wl_ioctl(dev, WLC_GET_MONITOR, extra, sizeof(int)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
break;
|
||||
}
|
||||
case WLCOMPAT_SET_TXPWR_LIMIT:
|
||||
{
|
||||
int val;
|
||||
|
||||
|
||||
if (wl_get_val(dev, "qtxpower", &val, sizeof(int)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
if (*extra > 0)
|
||||
val |= WL_TXPWR_OVERRIDE;
|
||||
else
|
||||
val &= ~WL_TXPWR_OVERRIDE;
|
||||
|
||||
if (wl_set_val(dev, "qtxpower", &val, sizeof(int)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
break;
|
||||
}
|
||||
case WLCOMPAT_GET_TXPWR_LIMIT:
|
||||
{
|
||||
if (wl_get_val(dev, "qtxpower", value, sizeof(int)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
*value = ((*value & WL_TXPWR_OVERRIDE) == WL_TXPWR_OVERRIDE ? 1 : 0);
|
||||
|
||||
break;
|
||||
}
|
||||
case WLCOMPAT_SET_ANTDIV:
|
||||
{
|
||||
if (wl_ioctl(dev, WLC_SET_ANTDIV, value, sizeof(int)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
break;
|
||||
}
|
||||
case WLCOMPAT_GET_ANTDIV:
|
||||
{
|
||||
if (wl_ioctl(dev, WLC_GET_ANTDIV, extra, sizeof(int)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
break;
|
||||
}
|
||||
case WLCOMPAT_SET_TXANT:
|
||||
{
|
||||
if (wl_ioctl(dev, WLC_SET_TXANT, value, sizeof(int)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
break;
|
||||
}
|
||||
case WLCOMPAT_GET_TXANT:
|
||||
{
|
||||
if (wl_ioctl(dev, WLC_GET_TXANT, extra, sizeof(int)) < 0)
|
||||
return -EINVAL;
|
||||
|
||||
break;
|
||||
}
|
||||
case WLCOMPAT_SET_BSS_FORCE:
|
||||
{
|
||||
bss_force = (unsigned short) *value;
|
||||
break;
|
||||
}
|
||||
case WLCOMPAT_GET_BSS_FORCE:
|
||||
{
|
||||
*extra = (int) bss_force;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct iw_priv_args wlcompat_private_args[] =
|
||||
{
|
||||
{ WLCOMPAT_SET_MONITOR,
|
||||
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
|
||||
0,
|
||||
"set_monitor"
|
||||
},
|
||||
{ WLCOMPAT_GET_MONITOR,
|
||||
0,
|
||||
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
|
||||
"get_monitor"
|
||||
},
|
||||
{ WLCOMPAT_SET_TXPWR_LIMIT,
|
||||
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
|
||||
0,
|
||||
"set_txpwr_force"
|
||||
},
|
||||
{ WLCOMPAT_GET_TXPWR_LIMIT,
|
||||
0,
|
||||
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
|
||||
"get_txpwr_force"
|
||||
},
|
||||
{ WLCOMPAT_SET_ANTDIV,
|
||||
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
|
||||
0,
|
||||
"set_antdiv"
|
||||
},
|
||||
{ WLCOMPAT_GET_ANTDIV,
|
||||
0,
|
||||
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
|
||||
"get_antdiv"
|
||||
},
|
||||
{ WLCOMPAT_SET_TXANT,
|
||||
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
|
||||
0,
|
||||
"set_txant"
|
||||
},
|
||||
{ WLCOMPAT_GET_TXANT,
|
||||
0,
|
||||
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
|
||||
"get_txant"
|
||||
},
|
||||
{ WLCOMPAT_SET_BSS_FORCE,
|
||||
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
|
||||
0,
|
||||
"set_bss_force"
|
||||
},
|
||||
{ WLCOMPAT_GET_BSS_FORCE,
|
||||
0,
|
||||
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
|
||||
"get_bss_force"
|
||||
},
|
||||
};
|
||||
|
||||
static const iw_handler wlcompat_private[] =
|
||||
{
|
||||
wlcompat_private_ioctl,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
static const struct iw_handler_def wlcompat_handler_def =
|
||||
{
|
||||
.standard = (iw_handler *) wlcompat_handler,
|
||||
.num_standard = sizeof(wlcompat_handler)/sizeof(iw_handler),
|
||||
.private = wlcompat_private,
|
||||
.num_private = 1,
|
||||
.private_args = wlcompat_private_args,
|
||||
.num_private_args = sizeof(wlcompat_private_args) / sizeof(wlcompat_private_args[0])
|
||||
};
|
||||
|
||||
|
||||
|
@ -979,14 +933,7 @@ static int new_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) {
|
|||
|
||||
#ifdef DEBUG
|
||||
printk("dev: %s ioctl: 0x%04x\n",dev->name,cmd);
|
||||
#endif
|
||||
|
||||
if (cmd >= SIOCIWFIRSTPRIV) {
|
||||
info.cmd = cmd;
|
||||
info.flags = 0;
|
||||
ret = wlcompat_private_ioctl(dev, &info, &(iwr->u), (char *) &(iwr->u));
|
||||
#ifdef DEBUG
|
||||
} else if (cmd==SIOCDEVPRIVATE) {
|
||||
if (cmd==SIOCDEVPRIVATE) {
|
||||
wl_ioctl_t *ioc = (wl_ioctl_t *)ifr->ifr_data;
|
||||
unsigned char *buf = ioc->buf;
|
||||
printk(" cmd: %d buf: 0x%08x len: %d\n",ioc->cmd,&(ioc->buf),ioc->len);
|
||||
|
@ -996,8 +943,9 @@ static int new_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) {
|
|||
printk(" recv: ->");
|
||||
print_buffer(ioc->len, buf);
|
||||
printk(" ret: %d\n", ret);
|
||||
} else
|
||||
#endif
|
||||
} else {
|
||||
{
|
||||
ret = old_ioctl(dev,ifr,cmd);
|
||||
}
|
||||
return ret;
|
||||
|
@ -1005,17 +953,22 @@ static int new_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) {
|
|||
|
||||
#ifndef DEBUG
|
||||
static struct timer_list rng_timer;
|
||||
static spinlock_t rng_lock = SPIN_LOCK_UNLOCKED;
|
||||
|
||||
static void rng_timer_tick(unsigned long n)
|
||||
{
|
||||
struct net_device *dev = (struct net_device *) n;
|
||||
unsigned long flags;
|
||||
u16 data[4];
|
||||
int i, ret;
|
||||
|
||||
ret = 0;
|
||||
spin_lock_irqsave(&rng_lock, flags);
|
||||
for (i = 0; i < 3; i++) {
|
||||
ret |= wl_get_val(dev, "rand", &data[i], sizeof(u16));
|
||||
ret |= wl_iovar_get(dev, "rand", &data[i], sizeof(u16));
|
||||
}
|
||||
spin_unlock_irqrestore(&rng_lock, flags);
|
||||
|
||||
if (!ret)
|
||||
batch_entropy_store(*((u32 *) &data[0]), *((u32 *) &data[2]), (jiffies % 255));
|
||||
|
||||
|
@ -1027,7 +980,6 @@ static int __init wlcompat_init()
|
|||
{
|
||||
int found = 0, i;
|
||||
char devname[4] = "wl0";
|
||||
bss_force = 0;
|
||||
|
||||
while (!found && (dev = dev_get_by_name(devname))) {
|
||||
if ((dev->wireless_handlers == NULL) && ((wl_ioctl(dev, WLC_GET_MAGIC, &i, sizeof(i)) == 0) && i == WLC_IOCTL_MAGIC))
|
||||
|
|
Loading…
Reference in a new issue