| /* |
| * Common code for wl routines |
| * |
| * Broadcom Proprietary and Confidential. Copyright (C) 2017, |
| * All Rights Reserved. |
| * |
| * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Broadcom; |
| * the contents of this file may not be disclosed to third parties, copied |
| * or duplicated in any form, in whole or in part, without the prior |
| * written permission of Broadcom. |
| * |
| * |
| * <<Broadcom-WL-IPTag/Proprietary:>> |
| * |
| * $Id: wlu_common.h 649191 2016-07-15 06:30:56Z $ |
| */ |
| #include <wlioctl.h> |
| #include <bcmutils.h> |
| |
| #include <stdio.h> |
| #include <stdlib.h> |
| #include <string.h> |
| #include <ctype.h> |
| #include <assert.h> |
| |
| #if defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION >= 0x00020000) |
| #define strtoul(nptr, endptr, base) bcm_strtoul((nptr), (endptr), (base)) |
| #define strtol(nptr, endptr, base) (long)bcm_strtoul((nptr), (endptr), (base)) |
| #endif /* defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION >= 0x00020000) */ |
| |
| #if defined(linux) |
| |
| #define stricmp strcasecmp |
| #define strnicmp strncasecmp |
| |
| #elif defined(_CRT_SECURE_NO_DEPRECATE) /* MSVC common runtime */ |
| |
| #define stricmp _stricmp |
| #define strnicmp _strnicmp |
| |
| #elif defined(DONGLEBUILD) |
| |
| #define stricmp strcmp |
| #define strnicmp strncmp |
| |
| #elif defined(BWL_STRICMP) |
| |
| #define stricmp bcmstricmp |
| #define strnicmp bcmstrnicmp |
| |
| #endif /* BWL_STRICMP */ |
| |
| /* IOCTL swapping mode for Big Endian host with Little Endian dongle. Default to off */ |
| /* The below macros handle endian mis-matches between wl utility and wl driver. */ |
| extern bool g_swap; |
| #define htod64(i) (g_swap?bcmswap64(i):(uint64)(i)) |
| #define htod32(i) (g_swap?bcmswap32(i):(uint32)(i)) |
| #define htod16(i) (g_swap?bcmswap16(i):(uint16)(i)) |
| #define dtoh64(i) (g_swap?bcmswap64(i):(uint64)(i)) |
| #define dtoh32(i) (g_swap?bcmswap32(i):(uint32)(i)) |
| #define dtoh16(i) (g_swap?bcmswap16(i):(uint16)(i)) |
| #define htodchanspec(i) (g_swap?htod16(i):i) |
| #define dtohchanspec(i) (g_swap?dtoh16(i):i) |
| #define htodenum(i) (g_swap?((sizeof(i) == 4) ? htod32(i) : ((sizeof(i) == 2) ? htod16(i) : i)):i) |
| #define dtohenum(i) (g_swap?((sizeof(i) == 4) ? dtoh32(i) : ((sizeof(i) == 2) ? htod16(i) : i)):i) |
| |
| /* command batching data structure */ |
| typedef struct wl_seq_cmd_pkt { |
| struct wl_seq_cmd_pkt *next; |
| wl_seq_cmd_ioctl_t cmd_header; |
| char * data; /* user buffer */ |
| } wl_seq_cmd_pkt_t; |
| |
| typedef struct wl_cmd_list { |
| wl_seq_cmd_pkt_t *head; |
| wl_seq_cmd_pkt_t *tail; |
| } wl_cmd_list_t; |
| |
| /* |
| * Name table to associate strings with numeric IDs |
| */ |
| typedef struct wlu_name_entry { |
| uint id; |
| const char *name; |
| } wlu_name_entry_t; |
| |
| extern wl_cmd_list_t cmd_list; |
| extern int cmd_pkt_list_num; |
| extern bool cmd_batching_mode; |
| |
| extern int wlu_iovar_getbuf(void* wl, const char *iovar, |
| void *param, int paramlen, void *bufptr, int buflen); |
| extern int wlu_iovar_setbuf(void* wl, const char *iovar, |
| void *param, int paramlen, void *bufptr, int buflen); |
| extern int wlu_var_setbuf(void *wl, const char *iovar, void *param, int param_len); |
| extern int wlu_iovar_getint(void *wl, const char *iovar, int *pval); |
| extern void init_cmd_batchingmode(void); |
| extern void clean_up_cmd_list(void); |
| extern int wl_check(void *wl); |
| |
| extern int add_one_batched_cmd(int cmd, void *cmdbuf, int len); |
| extern int wlu_get_req_buflen(int cmd, void *cmdbuf, int len); |
| extern int wlu_get(void *wl, int cmd, void *cmdbuf, int len); |
| extern int wlu_set(void *wl, int cmd, void *cmdbuf, int len); |
| extern int wlu_iovar_get(void *wl, const char *iovar, void *outbuf, int len); |
| extern int wlu_iovar_set(void *wl, const char *iovar, void *param, int paramlen); |
| extern int wlu_iovar_getint(void *wl, const char *iovar, int *pval); |
| extern int wlu_iovar_setint(void *wl, const char *iovar, int val); |
| extern const char* wlu_lookup_name(const wlu_name_entry_t* tbl, uint id); |