1/* 2 * Shell-like utility functions 3 * 4 * Copyright (C) 2012, Broadcom Corporation. All Rights Reserved. 5 * 6 * Permission to use, copy, modify, and/or distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 13 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 15 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 16 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 * 18 * $Id: wlif_utils.h 415105 2013-07-28 03:40:28Z $ 19 */ 20 21#ifndef _wlif_utils_h_ 22#define _wlif_utils_h_ 23 24#ifndef IFNAMSIZ 25#define IFNAMSIZ 16 26#endif 27 28#ifndef ETHER_ADDR_LEN 29#define ETHER_ADDR_LEN 6 30#endif 31 32#define WLIFU_MAX_NO_BRIDGE 2 33#define WLIFU_MAX_NO_WAN 2 34 35#define MAX_USER_KEY_LEN 80 /* same as NAS_WKSP_MAX_USER_KEY_LEN */ 36#define MAX_SSID_LEN 32 /* same as DOT11_MAX_SSID_LEN */ 37 38typedef struct wsec_info_s { 39 int unit; /* interface unit */ 40 int ibss; /* IBSS vs. Infrastructure mode */ 41 int gtk_rekey_secs; /* group key rekey interval */ 42 int wep_index; /* wep key index */ 43 int ssn_to; /* ssn timeout value */ 44 int debug; /* verbose - 0:no | others:yes */ 45 int preauth; /* preauth */ 46 int auth_blockout_time; /* update auth blockout retry interval */ 47 unsigned int auth; /* shared key authentication optional (0) or required (1) */ 48 unsigned int akm; /* authentication mode */ 49 unsigned int wsec; /* encryption */ 50 unsigned int mfp; /* mfp */ 51 unsigned int flags; /* flags */ 52 char osifname[IFNAMSIZ]; /* interface name */ 53 unsigned char ea[ETHER_ADDR_LEN]; /* interface hw address */ 54 unsigned char remote[ETHER_ADDR_LEN]; /* wds remote address */ 55 unsigned short radius_port; /* radius server port number */ 56 char ssid[MAX_SSID_LEN + 1]; /* ssid info */ 57 char psk[MAX_USER_KEY_LEN + 1]; /* user-supplied psk passphrase */ 58 char *secret; /* user-supplied radius secret */ 59 char *wep_key; /* user-supplied wep key */ 60 char *radius_addr; /* radius server address */ 61 char *nas_id; /* nas mac address */ 62} wsec_info_t; 63 64#define WLIFU_WSEC_SUPPL 0x00000001 /* role is supplicant */ 65#define WLIFU_WSEC_AUTH 0x00000002 /* role is authenticator */ 66#define WLIFU_WSEC_WDS 0x00000004 /* WDS mode */ 67 68#define WLIFU_AUTH_RADIUS 0x20 /* same as nas_mode_t RADIUS in nas.h */ 69 70/* get wsec return code */ 71#define WLIFU_WSEC_SUCCESS 0 72#define WLIFU_ERR_INVALID_PARAMETER 1 73#define WLIFU_ERR_NOT_WL_INTERFACE 2 74#define WLIFU_ERR_NOT_SUPPORT_MODE 4 75#define WLIFU_ERR_WL_REMOTE_HWADDR 3 76#define WLIFU_ERR_WL_WPA_ROLE 5 77 78extern int get_spoof_mac(const char *osifname, char *mac, int maclen); 79extern int get_spoof_ifname(char *mac, char *osifname, int osifnamelen); 80extern int get_real_mac(char *mac, int maclen); 81extern int get_lan_mac(unsigned char *mac); 82extern unsigned char *get_wlmacstr_by_unit(char *unit); 83extern int get_wlname_by_mac(unsigned char *mac, char *wlname); 84extern char *get_ifname_by_wlmac(unsigned char *mac, char *name); 85extern int get_wsec(wsec_info_t *info, unsigned char *mac, char *osifname); 86extern bool wl_wlif_is_psta(char *ifname); 87extern bool wl_wlif_is_dwds(char *ifname); 88 89#endif /* _wlif_utils_h_ */ 90