mirror of
https://github.com/DrHo1y/orangepi-build.git
synced 2026-03-27 19:16:43 +07:00
Add wl source code
This commit is contained in:
17
external/cache/sources/wl/shared/Android.mk
vendored
Normal file
17
external/cache/sources/wl/shared/Android.mk
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
|
||||
OBJS_c := bcmutils.c bcmwifi_channels.c bcm_app_utils.c miniopt.c wlu_client_shared.c wlu_common.c wlu_pipe.c wlu_pipe_linux.c
|
||||
INCLUDES := $(LOCAL_PATH)/../include $(LOCAL_PATH)/../wl
|
||||
L_CFLAGS := -DBCMWPA2 -DWLCNT -DWLBTAMP -Wextra -DWLPFN -DWLPFN_AUTO_CONNECT -DLINUX -DRWLASD -DRWL_SOCKET -DRWL_DONGLE -DRWL_WIFI
|
||||
L_CFLAGS += -DSDTEST -DTARGETENV_android -Dlinux -DLINUX -DD11AC_IOTYPES
|
||||
#IFLAGS += -DIL_BIGENDIAN
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := libshared
|
||||
LOCAL_MODULE_TAGS := debug tests
|
||||
LOCAL_SHARED_LIBRARIES := libcutils
|
||||
LOCAL_CFLAGS = $(L_CFLAGS)
|
||||
LOCAL_SRC_FILES := $(OBJS_c)
|
||||
LOCAL_C_INCLUDES := $(INCLUDES)
|
||||
#LOCAL_INCLUDES = $(LOCAL_PATH)
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
27
external/cache/sources/wl/shared/Makefile
vendored
Normal file
27
external/cache/sources/wl/shared/Makefile
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
CC = $(CROSS_COMPILE)gcc
|
||||
|
||||
#IFLAGS := -I../include -I../wl -I../shared -g -Wall -static
|
||||
IFLAGS := -I../include -I../wl -I../shared -g -Wall
|
||||
DFLAGS := -DBCMWPA2 -DWLCNT -DWLBTAMP -Wextra -DWLPFN -DWLPFN_AUTO_CONNECT -DLINUX -DRWLASD -DRWL_SOCKET -DRWL_DONGLE -DRWL_WIFI -DD11AC_IOTYPES
|
||||
#IFLAGS += -DIL_BIGENDIAN
|
||||
|
||||
obj-shared = \
|
||||
bcmutils.o \
|
||||
bcmwifi_channels.o \
|
||||
bcm_app_utils.o \
|
||||
miniopt.o \
|
||||
wlu_client_shared.o \
|
||||
wlu_common.o \
|
||||
wlu_pipe.o \
|
||||
wlu_pipe_linux.o \
|
||||
|
||||
CFLAGS := $(IFLAGS) $(DFLAGS)
|
||||
|
||||
LIBSHARED = libshared.a
|
||||
|
||||
$(LIBSHARED): $(obj-shared)
|
||||
ar rscv $(LIBSHARED) $(obj-shared)
|
||||
# $(CC) $(obj-shared) -shared -o $(LIBSHARED)
|
||||
|
||||
clean:
|
||||
-rm -f *.o *.a *.so
|
||||
236
external/cache/sources/wl/shared/bcm_app_utils.c
vendored
Normal file
236
external/cache/sources/wl/shared/bcm_app_utils.c
vendored
Normal file
@@ -0,0 +1,236 @@
|
||||
/*
|
||||
* Misc utility routines used by kernel or app-level.
|
||||
* Contents are wifi-specific, used by any kernel or app-level
|
||||
* software that might want wifi things as it grows.
|
||||
*
|
||||
* $Copyright Open Broadcom Corporation$
|
||||
* $Id: bcm_app_utils.c 401759 2013-05-13 16:08:08Z sudhirbs $
|
||||
*/
|
||||
|
||||
#include <typedefs.h>
|
||||
|
||||
#ifdef BCMDRIVER
|
||||
#include <osl.h>
|
||||
#include <bcmutils.h>
|
||||
#define strtoul(nptr, endptr, base) bcm_strtoul((nptr), (endptr), (base))
|
||||
#define tolower(c) (bcm_isupper((c)) ? ((c) + 'a' - 'A') : (c))
|
||||
#elif defined(__IOPOS__)
|
||||
#include <bcmutils.h>
|
||||
#define strtoul(nptr, endptr, base) bcm_strtoul((nptr), (endptr), (base))
|
||||
#define tolower(c) (bcm_tolower((c)))
|
||||
#ifndef ASSERT
|
||||
#define ASSERT(exp)
|
||||
#endif
|
||||
#else /* BCMDRIVER */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#ifndef ASSERT
|
||||
#define ASSERT(exp)
|
||||
#endif
|
||||
#endif /* BCMDRIVER */
|
||||
#include <bcmwifi_channels.h>
|
||||
|
||||
#if defined(WIN32) && (defined(BCMDLL) || defined(WLMDLL))
|
||||
#include <bcmstdlib.h> /* For wl/exe/GNUmakefile.brcm_wlu and GNUmakefile.wlm_dll */
|
||||
#endif
|
||||
|
||||
#include <bcmutils.h>
|
||||
#include <wlioctl.h>
|
||||
|
||||
cca_congest_channel_req_t *
|
||||
cca_per_chan_summary(cca_congest_channel_req_t *input, cca_congest_channel_req_t *avg,
|
||||
bool percent);
|
||||
|
||||
int
|
||||
cca_analyze(cca_congest_channel_req_t *input[], int num_chans, uint flags, chanspec_t *answer);
|
||||
|
||||
/* Take an array of measurments representing a single channel over time and return
|
||||
a summary. Currently implemented as a simple average but could easily evolve
|
||||
into more cpomplex alogrithms.
|
||||
*/
|
||||
cca_congest_channel_req_t *
|
||||
cca_per_chan_summary(cca_congest_channel_req_t *input, cca_congest_channel_req_t *avg, bool percent)
|
||||
{
|
||||
int sec;
|
||||
cca_congest_t totals;
|
||||
|
||||
totals.duration = 0;
|
||||
totals.congest_ibss = 0;
|
||||
totals.congest_obss = 0;
|
||||
totals.interference = 0;
|
||||
avg->num_secs = 0;
|
||||
|
||||
for (sec = 0; sec < input->num_secs; sec++) {
|
||||
if (input->secs[sec].duration) {
|
||||
totals.duration += input->secs[sec].duration;
|
||||
totals.congest_ibss += input->secs[sec].congest_ibss;
|
||||
totals.congest_obss += input->secs[sec].congest_obss;
|
||||
totals.interference += input->secs[sec].interference;
|
||||
avg->num_secs++;
|
||||
}
|
||||
}
|
||||
avg->chanspec = input->chanspec;
|
||||
|
||||
if (!avg->num_secs || !totals.duration)
|
||||
return (avg);
|
||||
|
||||
if (percent) {
|
||||
avg->secs[0].duration = totals.duration / avg->num_secs;
|
||||
avg->secs[0].congest_ibss = totals.congest_ibss * 100/totals.duration;
|
||||
avg->secs[0].congest_obss = totals.congest_obss * 100/totals.duration;
|
||||
avg->secs[0].interference = totals.interference * 100/totals.duration;
|
||||
} else {
|
||||
avg->secs[0].duration = totals.duration / avg->num_secs;
|
||||
avg->secs[0].congest_ibss = totals.congest_ibss / avg->num_secs;
|
||||
avg->secs[0].congest_obss = totals.congest_obss / avg->num_secs;
|
||||
avg->secs[0].interference = totals.interference / avg->num_secs;
|
||||
}
|
||||
|
||||
return (avg);
|
||||
}
|
||||
|
||||
static void
|
||||
cca_info(uint8 *bitmap, int num_bits, int *left, int *bit_pos)
|
||||
{
|
||||
int i;
|
||||
for (*left = 0, i = 0; i < num_bits; i++) {
|
||||
if (isset(bitmap, i)) {
|
||||
(*left)++;
|
||||
*bit_pos = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static uint8
|
||||
spec_to_chan(chanspec_t chspec)
|
||||
{
|
||||
uint8 center_ch, edge, primary, sb;
|
||||
|
||||
center_ch = CHSPEC_CHANNEL(chspec);
|
||||
|
||||
if (CHSPEC_IS20(chspec)) {
|
||||
return center_ch;
|
||||
} else {
|
||||
/* the lower edge of the wide channel is half the bw from
|
||||
* the center channel.
|
||||
*/
|
||||
if (CHSPEC_IS40(chspec)) {
|
||||
edge = center_ch - CH_20MHZ_APART;
|
||||
} else {
|
||||
/* must be 80MHz (until we support more) */
|
||||
ASSERT(CHSPEC_IS80(chspec));
|
||||
edge = center_ch - CH_40MHZ_APART;
|
||||
}
|
||||
|
||||
/* find the channel number of the lowest 20MHz primary channel */
|
||||
primary = edge + CH_10MHZ_APART;
|
||||
|
||||
/* select the actual subband */
|
||||
sb = (chspec & WL_CHANSPEC_CTL_SB_MASK) >> WL_CHANSPEC_CTL_SB_SHIFT;
|
||||
primary = primary + sb * CH_20MHZ_APART;
|
||||
|
||||
return primary;
|
||||
}
|
||||
}
|
||||
|
||||
#define CCA_THRESH_MILLI 14
|
||||
#define CCA_THRESH_INTERFERE 6
|
||||
|
||||
/*
|
||||
Take an array of measumrements representing summaries of different channels.
|
||||
Return a recomended channel.
|
||||
Interference is evil, get rid of that first.
|
||||
Then hunt for lowest Other bss traffic.
|
||||
Don't forget that channels with low duration times may not have accurate readings.
|
||||
For the moment, do not overwrite input array.
|
||||
*/
|
||||
int
|
||||
cca_analyze(cca_congest_channel_req_t *input[], int num_chans, uint flags, chanspec_t *answer)
|
||||
{
|
||||
uint8 bitmap[CEIL(MAX_CCA_CHANNELS, NBBY)]; /* 38 Max channels needs 5 bytes = 40 */
|
||||
int i, left, winner;
|
||||
uint32 min_obss = 1 << 30;
|
||||
|
||||
ASSERT(num_chans < MAX_CCA_CHANNELS);
|
||||
for (i = 0; i < (int)sizeof(bitmap); i++)
|
||||
bitmap[i] = 0;
|
||||
|
||||
/* Initially, all channels are up for consideration */
|
||||
for (i = 0; i < num_chans; i++) {
|
||||
if (input[i]->chanspec)
|
||||
setbit(bitmap, i);
|
||||
}
|
||||
cca_info(bitmap, num_chans, &left, &i);
|
||||
if (!left)
|
||||
return CCA_ERRNO_TOO_FEW;
|
||||
|
||||
/* Filter for 2.4 GHz Band */
|
||||
if (flags & CCA_FLAG_2G_ONLY) {
|
||||
for (i = 0; i < num_chans; i++) {
|
||||
if (!CHSPEC_IS2G(input[i]->chanspec))
|
||||
clrbit(bitmap, i);
|
||||
}
|
||||
}
|
||||
cca_info(bitmap, num_chans, &left, &i);
|
||||
if (!left)
|
||||
return CCA_ERRNO_BAND;
|
||||
|
||||
/* Filter for 5 GHz Band */
|
||||
if (flags & CCA_FLAG_5G_ONLY) {
|
||||
for (i = 0; i < num_chans; i++) {
|
||||
if (!CHSPEC_IS5G(input[i]->chanspec))
|
||||
clrbit(bitmap, i);
|
||||
}
|
||||
}
|
||||
cca_info(bitmap, num_chans, &left, &i);
|
||||
if (!left)
|
||||
return CCA_ERRNO_BAND;
|
||||
|
||||
/* Filter for Duration */
|
||||
if (!(flags & CCA_FLAG_IGNORE_DURATION)) {
|
||||
for (i = 0; i < num_chans; i++) {
|
||||
if (input[i]->secs[0].duration < CCA_THRESH_MILLI)
|
||||
clrbit(bitmap, i);
|
||||
}
|
||||
}
|
||||
cca_info(bitmap, num_chans, &left, &i);
|
||||
if (!left)
|
||||
return CCA_ERRNO_DURATION;
|
||||
|
||||
/* Filter for 1 6 11 on 2.4 Band */
|
||||
if (flags & CCA_FLAGS_PREFER_1_6_11) {
|
||||
int tmp_channel = spec_to_chan(input[i]->chanspec);
|
||||
int is2g = CHSPEC_IS2G(input[i]->chanspec);
|
||||
for (i = 0; i < num_chans; i++) {
|
||||
if (is2g && tmp_channel != 1 && tmp_channel != 6 && tmp_channel != 11)
|
||||
clrbit(bitmap, i);
|
||||
}
|
||||
}
|
||||
cca_info(bitmap, num_chans, &left, &i);
|
||||
if (!left)
|
||||
return CCA_ERRNO_PREF_CHAN;
|
||||
|
||||
/* Toss high interference interference */
|
||||
if (!(flags & CCA_FLAG_IGNORE_INTERFER)) {
|
||||
for (i = 0; i < num_chans; i++) {
|
||||
if (input[i]->secs[0].interference > CCA_THRESH_INTERFERE)
|
||||
clrbit(bitmap, i);
|
||||
}
|
||||
cca_info(bitmap, num_chans, &left, &i);
|
||||
if (!left)
|
||||
return CCA_ERRNO_INTERFER;
|
||||
}
|
||||
|
||||
/* Now find lowest obss */
|
||||
winner = 0;
|
||||
for (i = 0; i < num_chans; i++) {
|
||||
if (isset(bitmap, i) && input[i]->secs[0].congest_obss < min_obss) {
|
||||
winner = i;
|
||||
min_obss = input[i]->secs[0].congest_obss;
|
||||
}
|
||||
}
|
||||
*answer = input[winner]->chanspec;
|
||||
|
||||
return 0;
|
||||
}
|
||||
3597
external/cache/sources/wl/shared/bcmutils.c
vendored
Normal file
3597
external/cache/sources/wl/shared/bcmutils.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
255
external/cache/sources/wl/shared/bcmwifi.c
vendored
Normal file
255
external/cache/sources/wl/shared/bcmwifi.c
vendored
Normal file
@@ -0,0 +1,255 @@
|
||||
/*
|
||||
* Misc utility routines used by kernel or app-level.
|
||||
* Contents are wifi-specific, used by any kernel or app-level
|
||||
* software that might want wifi things as it grows.
|
||||
*
|
||||
* $Copyright Open Broadcom Corporation$
|
||||
* $Id: bcmwifi.c 241182 2011-02-17 21:50:03Z gmo $
|
||||
*/
|
||||
|
||||
#include <typedefs.h>
|
||||
|
||||
#ifdef BCMDRIVER
|
||||
#include <osl.h>
|
||||
#include <bcmutils.h>
|
||||
#define strtoul(nptr, endptr, base) bcm_strtoul((nptr), (endptr), (base))
|
||||
#define tolower(c) (bcm_isupper((c)) ? ((c) + 'a' - 'A') : (c))
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#ifndef ASSERT
|
||||
#define ASSERT(exp)
|
||||
#endif
|
||||
#endif
|
||||
#include <bcmwifi.h>
|
||||
|
||||
#if defined(WIN32) && (defined(BCMDLL) || defined(WLMDLL))
|
||||
#include <bcmstdlib.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
char *
|
||||
wf_chspec_ntoa(chanspec_t chspec, char *buf)
|
||||
{
|
||||
const char *band, *bw, *sb;
|
||||
uint channel;
|
||||
|
||||
band = "";
|
||||
bw = "";
|
||||
sb = "";
|
||||
channel = CHSPEC_CHANNEL(chspec);
|
||||
|
||||
if ((CHSPEC_IS2G(chspec) && channel > CH_MAX_2G_CHANNEL) ||
|
||||
(CHSPEC_IS5G(chspec) && channel <= CH_MAX_2G_CHANNEL))
|
||||
band = (CHSPEC_IS2G(chspec)) ? "b" : "a";
|
||||
if (CHSPEC_IS40(chspec)) {
|
||||
if (CHSPEC_SB_UPPER(chspec)) {
|
||||
sb = "u";
|
||||
channel += CH_10MHZ_APART;
|
||||
} else {
|
||||
sb = "l";
|
||||
channel -= CH_10MHZ_APART;
|
||||
}
|
||||
} else if (CHSPEC_IS10(chspec)) {
|
||||
bw = "n";
|
||||
}
|
||||
|
||||
|
||||
snprintf(buf, 6, "%d%s%s%s", channel, band, bw, sb);
|
||||
return (buf);
|
||||
}
|
||||
|
||||
|
||||
chanspec_t
|
||||
wf_chspec_aton(char *a)
|
||||
{
|
||||
char *endp = NULL;
|
||||
uint channel, band, bw, ctl_sb;
|
||||
char c;
|
||||
|
||||
channel = strtoul(a, &endp, 10);
|
||||
|
||||
|
||||
if (endp == a)
|
||||
return 0;
|
||||
|
||||
if (channel > MAXCHANNEL)
|
||||
return 0;
|
||||
|
||||
band = ((channel <= CH_MAX_2G_CHANNEL) ? WL_CHANSPEC_BAND_2G : WL_CHANSPEC_BAND_5G);
|
||||
bw = WL_CHANSPEC_BW_20;
|
||||
ctl_sb = WL_CHANSPEC_CTL_SB_NONE;
|
||||
|
||||
a = endp;
|
||||
|
||||
c = tolower(a[0]);
|
||||
if (c == '\0')
|
||||
goto done;
|
||||
|
||||
|
||||
if (c == 'a' || c == 'b') {
|
||||
band = (c == 'a') ? WL_CHANSPEC_BAND_5G : WL_CHANSPEC_BAND_2G;
|
||||
a++;
|
||||
c = tolower(a[0]);
|
||||
if (c == '\0')
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
||||
if (c == 'n') {
|
||||
bw = WL_CHANSPEC_BW_10;
|
||||
} else if (c == 'l') {
|
||||
bw = WL_CHANSPEC_BW_40;
|
||||
ctl_sb = WL_CHANSPEC_CTL_SB_LOWER;
|
||||
|
||||
if (channel <= (MAXCHANNEL - CH_20MHZ_APART))
|
||||
channel += CH_10MHZ_APART;
|
||||
else
|
||||
return 0;
|
||||
} else if (c == 'u') {
|
||||
bw = WL_CHANSPEC_BW_40;
|
||||
ctl_sb = WL_CHANSPEC_CTL_SB_UPPER;
|
||||
|
||||
if (channel > CH_20MHZ_APART)
|
||||
channel -= CH_10MHZ_APART;
|
||||
else
|
||||
return 0;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
done:
|
||||
return (channel | band | bw | ctl_sb);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
wf_chspec_malformed(chanspec_t chanspec)
|
||||
{
|
||||
|
||||
if (!CHSPEC_IS5G(chanspec) && !CHSPEC_IS2G(chanspec))
|
||||
return TRUE;
|
||||
|
||||
if (!CHSPEC_IS40(chanspec) && !CHSPEC_IS20(chanspec))
|
||||
return TRUE;
|
||||
|
||||
|
||||
if (CHSPEC_IS20(chanspec)) {
|
||||
if (!CHSPEC_SB_NONE(chanspec))
|
||||
return TRUE;
|
||||
} else {
|
||||
if (!CHSPEC_SB_UPPER(chanspec) && !CHSPEC_SB_LOWER(chanspec))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
uint8
|
||||
wf_chspec_ctlchan(chanspec_t chspec)
|
||||
{
|
||||
uint8 ctl_chan;
|
||||
|
||||
|
||||
if (CHSPEC_CTL_SB(chspec) == WL_CHANSPEC_CTL_SB_NONE) {
|
||||
return CHSPEC_CHANNEL(chspec);
|
||||
} else {
|
||||
|
||||
ASSERT(CHSPEC_BW(chspec) == WL_CHANSPEC_BW_40);
|
||||
|
||||
if (CHSPEC_CTL_SB(chspec) == WL_CHANSPEC_CTL_SB_UPPER) {
|
||||
|
||||
ctl_chan = UPPER_20_SB(CHSPEC_CHANNEL(chspec));
|
||||
} else {
|
||||
ASSERT(CHSPEC_CTL_SB(chspec) == WL_CHANSPEC_CTL_SB_LOWER);
|
||||
|
||||
ctl_chan = LOWER_20_SB(CHSPEC_CHANNEL(chspec));
|
||||
}
|
||||
}
|
||||
|
||||
return ctl_chan;
|
||||
}
|
||||
|
||||
chanspec_t
|
||||
wf_chspec_ctlchspec(chanspec_t chspec)
|
||||
{
|
||||
chanspec_t ctl_chspec = 0;
|
||||
uint8 channel;
|
||||
|
||||
ASSERT(!wf_chspec_malformed(chspec));
|
||||
|
||||
|
||||
if (CHSPEC_CTL_SB(chspec) == WL_CHANSPEC_CTL_SB_NONE) {
|
||||
return chspec;
|
||||
} else {
|
||||
if (CHSPEC_CTL_SB(chspec) == WL_CHANSPEC_CTL_SB_UPPER) {
|
||||
channel = UPPER_20_SB(CHSPEC_CHANNEL(chspec));
|
||||
} else {
|
||||
channel = LOWER_20_SB(CHSPEC_CHANNEL(chspec));
|
||||
}
|
||||
ctl_chspec = channel | WL_CHANSPEC_BW_20 | WL_CHANSPEC_CTL_SB_NONE;
|
||||
ctl_chspec |= CHSPEC_BAND(chspec);
|
||||
}
|
||||
return ctl_chspec;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
wf_mhz2channel(uint freq, uint start_factor)
|
||||
{
|
||||
int ch = -1;
|
||||
uint base;
|
||||
int offset;
|
||||
|
||||
|
||||
if (start_factor == 0) {
|
||||
if (freq >= 2400 && freq <= 2500)
|
||||
start_factor = WF_CHAN_FACTOR_2_4_G;
|
||||
else if (freq >= 5000 && freq <= 6000)
|
||||
start_factor = WF_CHAN_FACTOR_5_G;
|
||||
}
|
||||
|
||||
if (freq == 2484 && start_factor == WF_CHAN_FACTOR_2_4_G)
|
||||
return 14;
|
||||
|
||||
base = start_factor / 2;
|
||||
|
||||
|
||||
if ((freq < base) || (freq > base + 1000))
|
||||
return -1;
|
||||
|
||||
offset = freq - base;
|
||||
ch = offset / 5;
|
||||
|
||||
|
||||
if (offset != (ch * 5))
|
||||
return -1;
|
||||
|
||||
|
||||
if (start_factor == WF_CHAN_FACTOR_2_4_G && (ch < 1 || ch > 13))
|
||||
return -1;
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
wf_channel2mhz(uint ch, uint start_factor)
|
||||
{
|
||||
int freq;
|
||||
|
||||
if ((start_factor == WF_CHAN_FACTOR_2_4_G && (ch < 1 || ch > 14)) ||
|
||||
(ch > 200))
|
||||
freq = -1;
|
||||
else if ((start_factor == WF_CHAN_FACTOR_2_4_G) && (ch == 14))
|
||||
freq = 2484;
|
||||
else
|
||||
freq = ch * 5 + start_factor / 2;
|
||||
|
||||
return freq;
|
||||
}
|
||||
1175
external/cache/sources/wl/shared/bcmwifi_channels.c
vendored
Normal file
1175
external/cache/sources/wl/shared/bcmwifi_channels.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
external/cache/sources/wl/shared/build_kingston.sh
vendored
Normal file
1
external/cache/sources/wl/shared/build_kingston.sh
vendored
Normal file
@@ -0,0 +1 @@
|
||||
make -j2 CROSS_COMPILE=/home/terence/project/ampak/kingston/source/ti-sdk-am180x-evm/linux-devkit/bin/arm-arago-linux-gnueabi-
|
||||
151
external/cache/sources/wl/shared/miniopt.c
vendored
Normal file
151
external/cache/sources/wl/shared/miniopt.c
vendored
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Description.
|
||||
*
|
||||
* $Copyright Open Broadcom Corporation$
|
||||
* $Id: miniopt.c 401759 2013-05-13 16:08:08Z sudhirbs $
|
||||
*/
|
||||
|
||||
/* ---- Include Files ---------------------------------------------------- */
|
||||
|
||||
#include <typedefs.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <miniopt.h>
|
||||
|
||||
|
||||
/* ---- Public Variables ------------------------------------------------- */
|
||||
/* ---- Private Constants and Types -------------------------------------- */
|
||||
|
||||
/* XXX FIXME: this should be moved to a common header file. */
|
||||
#if defined(_CFE_)
|
||||
#define fprintf(stream, fmt, args...) xprintf(fmt , ## args)
|
||||
#elif defined(__IOPOS__)
|
||||
#define fprintf(file, fmt, arg...) jtag_printf(fmt , ## arg)
|
||||
#endif
|
||||
|
||||
|
||||
/* ---- Private Variables ------------------------------------------------ */
|
||||
/* ---- Private Function Prototypes -------------------------------------- */
|
||||
/* ---- Functions -------------------------------------------------------- */
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
void
|
||||
miniopt_init(miniopt_t *t, const char* name, const char* flags, bool longflags)
|
||||
{
|
||||
static const char *null_flags = "";
|
||||
|
||||
memset(t, 0, sizeof(miniopt_t));
|
||||
t->name = name;
|
||||
if (flags == NULL)
|
||||
t->flags = null_flags;
|
||||
else
|
||||
t->flags = flags;
|
||||
t->longflags = longflags;
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
int
|
||||
miniopt(miniopt_t *t, char **argv)
|
||||
{
|
||||
int keylen;
|
||||
char *p, *eq, *valstr, *endptr = NULL;
|
||||
int err = 0;
|
||||
|
||||
t->consumed = 0;
|
||||
t->positional = FALSE;
|
||||
memset(t->key, 0, MINIOPT_MAXKEY);
|
||||
t->opt = '\0';
|
||||
t->valstr = NULL;
|
||||
t->good_int = FALSE;
|
||||
valstr = NULL;
|
||||
|
||||
if (*argv == NULL) {
|
||||
err = -1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
p = *argv++;
|
||||
t->consumed++;
|
||||
|
||||
if (!t->opt_end && !strcmp(p, "--")) {
|
||||
t->opt_end = TRUE;
|
||||
if (*argv == NULL) {
|
||||
err = -1;
|
||||
goto exit;
|
||||
}
|
||||
p = *argv++;
|
||||
t->consumed++;
|
||||
}
|
||||
|
||||
if (t->opt_end) {
|
||||
t->positional = TRUE;
|
||||
valstr = p;
|
||||
}
|
||||
else if (!strncmp(p, "--", 2)) {
|
||||
eq = strchr(p, '=');
|
||||
if (eq == NULL && !t->longflags) {
|
||||
fprintf(stderr,
|
||||
"%s: missing \" = \" in long param \"%s\"\n", t->name, p);
|
||||
err = 1;
|
||||
goto exit;
|
||||
}
|
||||
keylen = eq ? (eq - (p + 2)) : (int)strlen(p) - 2;
|
||||
if (keylen > 63) keylen = 63;
|
||||
memcpy(t->key, p + 2, keylen);
|
||||
|
||||
if (eq) {
|
||||
valstr = eq + 1;
|
||||
if (*valstr == '\0') {
|
||||
fprintf(stderr,
|
||||
"%s: missing value after \" = \" in long param \"%s\"\n",
|
||||
t->name, p);
|
||||
err = 1;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!strncmp(p, "-", 1)) {
|
||||
t->opt = p[1];
|
||||
if (strlen(p) > 2) {
|
||||
fprintf(stderr,
|
||||
"%s: only single char options, error on param \"%s\"\n",
|
||||
t->name, p);
|
||||
err = 1;
|
||||
goto exit;
|
||||
}
|
||||
if (strchr(t->flags, t->opt)) {
|
||||
/* this is a flag option, no value expected */
|
||||
valstr = NULL;
|
||||
} else {
|
||||
if (*argv == NULL) {
|
||||
fprintf(stderr,
|
||||
"%s: missing value parameter after \"%s\"\n", t->name, p);
|
||||
err = 1;
|
||||
goto exit;
|
||||
}
|
||||
valstr = *argv;
|
||||
argv++;
|
||||
t->consumed++;
|
||||
}
|
||||
} else {
|
||||
t->positional = TRUE;
|
||||
valstr = p;
|
||||
}
|
||||
|
||||
/* parse valstr as int just in case */
|
||||
if (valstr) {
|
||||
t->uval = (uint)strtoul(valstr, &endptr, 0);
|
||||
t->val = (int)t->uval;
|
||||
t->good_int = (*endptr == '\0');
|
||||
}
|
||||
|
||||
t->valstr = valstr;
|
||||
|
||||
exit:
|
||||
if (err == 1)
|
||||
t->opt = '?';
|
||||
|
||||
return err;
|
||||
}
|
||||
1228
external/cache/sources/wl/shared/wlu_client_shared.c
vendored
Normal file
1228
external/cache/sources/wl/shared/wlu_client_shared.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
33
external/cache/sources/wl/shared/wlu_client_shared.h
vendored
Normal file
33
external/cache/sources/wl/shared/wlu_client_shared.h
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* OS independent client specific declarations
|
||||
*
|
||||
* $Copyright (C) 2008 Broadcom Corporation$
|
||||
*
|
||||
* $Id: wlu_client_shared.h 295438 2011-11-10 14:27:25Z alwin $
|
||||
*/
|
||||
#ifndef _wlu_client_shared_h
|
||||
#define _wlu_client_shared_h
|
||||
|
||||
/* Newly added wrappers from wlu_client_shared.c */
|
||||
extern int
|
||||
rwl_shell_cmd_proc(void *wl, char **argv, int cmd);
|
||||
extern int
|
||||
rwl_queryinformation_fe(void *wl, int cmd, void* input_buf, unsigned long *input_len,
|
||||
int debug, int rem_ioctl_select);
|
||||
extern int
|
||||
rwl_setinformation_fe(void *wl, int cmd, void* buf, unsigned long *len, int debug,
|
||||
int rem_ioctl_select);
|
||||
extern void
|
||||
rwl_usage(int remote_type);
|
||||
extern int
|
||||
rwl_detect(void *wl, bool debug, int* os_type_ptr);
|
||||
|
||||
extern int rwl_shell_createproc(void *wl);
|
||||
extern void rwl_shell_killproc(int pid);
|
||||
#ifndef UNDER_CE
|
||||
/* declaring these as extern to be used in wlu_ndis.c and wlu_linux.c */
|
||||
extern volatile sig_atomic_t g_sig_ctrlc;
|
||||
extern void ctrlc_handler(int num);
|
||||
#endif /* Not UNDER_CE */
|
||||
|
||||
#endif /* _wlu_client_share_h */
|
||||
307
external/cache/sources/wl/shared/wlu_common.c
vendored
Normal file
307
external/cache/sources/wl/shared/wlu_common.c
vendored
Normal file
@@ -0,0 +1,307 @@
|
||||
/*
|
||||
* Common code for wl routines
|
||||
*
|
||||
* $Copyright (C) 2002-2005 Broadcom Corporation$
|
||||
*
|
||||
* $Id: wlu_common.c 288685 2011-10-08 00:50:34Z pgarg $
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "wlu_common.h"
|
||||
#include "wlu.h"
|
||||
#include <bcmendian.h>
|
||||
|
||||
extern int wl_get(void *wl, int cmd, void *buf, int len);
|
||||
extern int wl_set(void *wl, int cmd, void *buf, int len);
|
||||
|
||||
wl_cmd_list_t cmd_list;
|
||||
int cmd_pkt_list_num;
|
||||
bool cmd_batching_mode;
|
||||
|
||||
const char *wlu_av0;
|
||||
|
||||
#ifdef SERDOWNLOAD
|
||||
extern int debug;
|
||||
#endif
|
||||
|
||||
#ifdef ATE_BUILD
|
||||
int wlu_iovar_get(void *wl, const char *iovar, void *outbuf, int len);
|
||||
int wlu_get(void *wl, int cmd, void *cmdbuf, int len);
|
||||
int wlu_set(void *wl, int cmd, void *cmdbuf, int len);
|
||||
int add_one_batched_cmd(int cmd, void *cmdbuf, int len);
|
||||
int wlu_iovar_setint(void *wl, const char *iovar, int val);
|
||||
int wlu_iovar_set(void *wl, const char *iovar, void *param, int paramlen);
|
||||
#endif /* ATE_BUILD */
|
||||
|
||||
/*
|
||||
* format an iovar buffer
|
||||
* iovar name is converted to lower case
|
||||
*/
|
||||
static uint
|
||||
wl_iovar_mkbuf(const char *name, char *data, uint datalen, char *iovar_buf, uint buflen, int *perr)
|
||||
{
|
||||
uint iovar_len;
|
||||
char *p;
|
||||
|
||||
iovar_len = strlen(name) + 1;
|
||||
|
||||
/* check for overflow */
|
||||
if ((iovar_len + datalen) > buflen) {
|
||||
*perr = BCME_BUFTOOSHORT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* copy data to the buffer past the end of the iovar name string */
|
||||
if (datalen > 0)
|
||||
memmove(&iovar_buf[iovar_len], data, datalen);
|
||||
|
||||
/* copy the name to the beginning of the buffer */
|
||||
strcpy(iovar_buf, name);
|
||||
|
||||
/* wl command line automatically converts iovar names to lower case for
|
||||
* ease of use
|
||||
*/
|
||||
p = iovar_buf;
|
||||
while (*p != '\0') {
|
||||
*p = tolower((int)*p);
|
||||
p++;
|
||||
}
|
||||
|
||||
*perr = 0;
|
||||
return (iovar_len + datalen);
|
||||
}
|
||||
|
||||
void
|
||||
init_cmd_batchingmode(void)
|
||||
{
|
||||
cmd_pkt_list_num = 0;
|
||||
cmd_batching_mode = FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
clean_up_cmd_list(void)
|
||||
{
|
||||
wl_seq_cmd_pkt_t *this_cmd, *next_cmd;
|
||||
|
||||
this_cmd = cmd_list.head;
|
||||
while (this_cmd != NULL) {
|
||||
next_cmd = this_cmd->next;
|
||||
if (this_cmd->data != NULL) {
|
||||
free(this_cmd->data);
|
||||
}
|
||||
free(this_cmd);
|
||||
this_cmd = next_cmd;
|
||||
}
|
||||
cmd_list.head = NULL;
|
||||
cmd_list.tail = NULL;
|
||||
cmd_pkt_list_num = 0;
|
||||
}
|
||||
|
||||
int
|
||||
add_one_batched_cmd(int cmd, void *cmdbuf, int len)
|
||||
{
|
||||
wl_seq_cmd_pkt_t *new_cmd;
|
||||
|
||||
new_cmd = malloc(sizeof(wl_seq_cmd_pkt_t));
|
||||
|
||||
if (new_cmd == NULL) {
|
||||
printf("malloc(%d) failed, free %d batched commands and exit batching mode\n",
|
||||
(int)sizeof(wl_seq_cmd_pkt_t), cmd_pkt_list_num);
|
||||
goto free_and_exit;
|
||||
} else {
|
||||
#ifdef SERDOWNLOAD
|
||||
if (debug)
|
||||
#endif /* SERDOWNLOAD */
|
||||
printf("batching %dth command %d\n", cmd_pkt_list_num+1, cmd);
|
||||
|
||||
}
|
||||
|
||||
new_cmd->cmd_header.cmd = cmd;
|
||||
new_cmd->cmd_header.len = len;
|
||||
new_cmd->next = NULL;
|
||||
|
||||
new_cmd->data = malloc(len);
|
||||
|
||||
if (new_cmd->data == NULL) {
|
||||
printf("malloc(%d) failed, free %d batched commands and exit batching mode\n",
|
||||
len, cmd_pkt_list_num);
|
||||
free(new_cmd);
|
||||
goto free_and_exit;
|
||||
}
|
||||
|
||||
memcpy(new_cmd->data, cmdbuf, len);
|
||||
|
||||
if (cmd_list.tail != NULL)
|
||||
cmd_list.tail->next = new_cmd;
|
||||
else
|
||||
cmd_list.head = new_cmd;
|
||||
|
||||
cmd_list.tail = new_cmd;
|
||||
|
||||
cmd_pkt_list_num ++;
|
||||
return 0;
|
||||
|
||||
free_and_exit:
|
||||
|
||||
clean_up_cmd_list();
|
||||
|
||||
if (cmd_batching_mode) {
|
||||
cmd_batching_mode = FALSE;
|
||||
}
|
||||
else {
|
||||
printf("calling add_one_batched_cmd() at non-command-batching mode, weird\n");
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifndef ATE_BUILD
|
||||
int
|
||||
wlu_get_req_buflen(int cmd, void *cmdbuf, int len)
|
||||
{
|
||||
int modified_len = len;
|
||||
char *cmdstr = (char *)cmdbuf;
|
||||
|
||||
if (len == WLC_IOCTL_MAXLEN) {
|
||||
if ((strcmp(cmdstr, "dump") == 0) ||
|
||||
(cmd == WLC_SCAN_RESULTS))
|
||||
modified_len = WLC_IOCTL_MAXLEN;
|
||||
else
|
||||
modified_len = WLC_IOCTL_MEDLEN;
|
||||
}
|
||||
return modified_len;
|
||||
}
|
||||
#endif /* !ATE_BUILD */
|
||||
|
||||
/* now IOCTL GET commands shall call wlu_get() instead of wl_get() so that the commands
|
||||
* can be batched when needed
|
||||
*/
|
||||
int
|
||||
wlu_get(void *wl, int cmd, void *cmdbuf, int len)
|
||||
{
|
||||
if (cmd_batching_mode) {
|
||||
if (!WL_SEQ_CMDS_GET_IOCTL_FILTER(cmd)) {
|
||||
printf("IOCTL GET command %d is not supported in batching mode\n", cmd);
|
||||
return IOCTL_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return wl_get(wl, cmd, cmdbuf, len);
|
||||
}
|
||||
|
||||
/* now IOCTL SET commands shall call wlu_set() instead of wl_set() so that the commands
|
||||
* can be batched when needed
|
||||
*/
|
||||
int
|
||||
wlu_set(void *wl, int cmd, void *cmdbuf, int len)
|
||||
{
|
||||
if (cmd_batching_mode) {
|
||||
return add_one_batched_cmd(cmd, cmdbuf, len);
|
||||
}
|
||||
else {
|
||||
return wl_set(wl, cmd, cmdbuf, len);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* get named iovar providing both parameter and i/o buffers
|
||||
* iovar name is converted to lower case
|
||||
*/
|
||||
int
|
||||
wlu_iovar_getbuf(void* wl, const char *iovar,
|
||||
void *param, int paramlen, void *bufptr, int buflen)
|
||||
{
|
||||
int err;
|
||||
|
||||
wl_iovar_mkbuf(iovar, param, paramlen, bufptr, buflen, &err);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
return wlu_get(wl, WLC_GET_VAR, bufptr, buflen);
|
||||
}
|
||||
|
||||
/*
|
||||
* set named iovar providing both parameter and i/o buffers
|
||||
* iovar name is converted to lower case
|
||||
*/
|
||||
int
|
||||
wlu_iovar_setbuf(void* wl, const char *iovar,
|
||||
void *param, int paramlen, void *bufptr, int buflen)
|
||||
{
|
||||
int err;
|
||||
int iolen;
|
||||
|
||||
iolen = wl_iovar_mkbuf(iovar, param, paramlen, bufptr, buflen, &err);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
return wlu_set(wl, WLC_SET_VAR, bufptr, iolen);
|
||||
}
|
||||
|
||||
/*
|
||||
* get named iovar without parameters into a given buffer
|
||||
* iovar name is converted to lower case
|
||||
*/
|
||||
int
|
||||
wlu_iovar_get(void *wl, const char *iovar, 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 = wlu_iovar_getbuf(wl, iovar, NULL, 0, outbuf, len);
|
||||
} else {
|
||||
memset(smbuf, 0, sizeof(smbuf));
|
||||
err = wlu_iovar_getbuf(wl, iovar, NULL, 0, smbuf, sizeof(smbuf));
|
||||
if (err == 0)
|
||||
memcpy(outbuf, smbuf, len);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
* set named iovar given the parameter buffer
|
||||
* iovar name is converted to lower case
|
||||
*/
|
||||
int
|
||||
wlu_iovar_set(void *wl, const char *iovar, void *param, int paramlen)
|
||||
{
|
||||
char smbuf[WLC_IOCTL_SMLEN*2];
|
||||
|
||||
memset(smbuf, 0, sizeof(smbuf));
|
||||
|
||||
return wlu_iovar_setbuf(wl, iovar, param, paramlen, smbuf, sizeof(smbuf));
|
||||
}
|
||||
|
||||
/*
|
||||
* get named iovar as an integer value
|
||||
* iovar name is converted to lower case
|
||||
*/
|
||||
int
|
||||
wlu_iovar_getint(void *wl, const char *iovar, int *pval)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = wlu_iovar_get(wl, iovar, pval, sizeof(int));
|
||||
if (ret >= 0)
|
||||
{
|
||||
*pval = dtoh32(*pval);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* set named iovar given an integer parameter
|
||||
* iovar name is converted to lower case
|
||||
*/
|
||||
int
|
||||
wlu_iovar_setint(void *wl, const char *iovar, int val)
|
||||
{
|
||||
val = htod32(val);
|
||||
return wlu_iovar_set(wl, iovar, &val, sizeof(int));
|
||||
}
|
||||
132
external/cache/sources/wl/shared/wlu_common.h
vendored
Normal file
132
external/cache/sources/wl/shared/wlu_common.h
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Common code for wl routines
|
||||
*
|
||||
* $Copyright (C) 2002-2005 Broadcom Corporation$
|
||||
*
|
||||
* $Id: wlu_common.h 370210 2012-11-21 05:35:27Z nisar $
|
||||
*/
|
||||
#include <wlioctl.h>
|
||||
#include <bcmutils.h>
|
||||
#if defined(_CFE_)
|
||||
#include <lib_types.h>
|
||||
#include <lib_string.h>
|
||||
#include <lib_printf.h>
|
||||
#include <lib_malloc.h>
|
||||
#include <cfe_error.h>
|
||||
#elif defined(__IOPOS__)
|
||||
#include <typedefs.h>
|
||||
#include <bcmstdlib.h>
|
||||
#include <bcmutils.h>
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
#endif /* defined(_CFE_) */
|
||||
#if defined (__NetBSD__) || defined(linux) || defined(MACOSX) || defined(EFI)
|
||||
#define stricmp strcasecmp
|
||||
#define strnicmp strncasecmp
|
||||
#elif defined(vxworks) || defined(__ECOS)
|
||||
extern int stricmp(const char *s1, const char *s2);
|
||||
extern int strnicmp(const char *s1, const char *s2, size_t len);
|
||||
#elif defined(UNDER_CE) || defined(_CRT_SECURE_NO_DEPRECATE)
|
||||
#define stricmp _stricmp
|
||||
#define strnicmp _strnicmp
|
||||
#elif defined(_HNDRTE_)
|
||||
#define stricmp strcmp
|
||||
#define strnicmp strncmp
|
||||
#elif defined(_CFE_)
|
||||
#include <bcmutils.h>
|
||||
#include <osl.h>
|
||||
#define isalnum(c) bcm_isalnum(c)
|
||||
#define isalpha(c) bcm_isalpha(c)
|
||||
#define iscntrl(c) bcm_iscntrl(c)
|
||||
#define isdigit(c) bcm_isdigit(c)
|
||||
#define isgraph(c) bcm_isgraph(c)
|
||||
#define islower(c) bcm_islower(c)
|
||||
#define isprint(c) bcm_isprint(c)
|
||||
#define ispunct(c) bcm_ispunct(c)
|
||||
#define isspace(c) bcm_isspace(c)
|
||||
#define isupper(c) bcm_isupper(c)
|
||||
#define isxdigit(c) bcm_isxdigit(c)
|
||||
#define stricmp(s1, s2) lib_strcmpi((s1), (s2))
|
||||
#define strtoul(nptr, endptr, base) bcm_strtoul((nptr), (endptr), (base))
|
||||
#define tolower(c) (bcm_isupper((c)) ? ((c) + 'a' - 'A') : (c))
|
||||
#define fprintf(stream, fmt, args...) xprintf(fmt, ##args)
|
||||
#define fputs(s, stream) puts(s)
|
||||
#define malloc(size) KMALLOC((size), 0)
|
||||
#define free(ptr) KFREE(ptr)
|
||||
/* XXX Buggy implementations */
|
||||
#define strnicmp(s1, s2, len) strncmp((s1), (s2), (len))
|
||||
#define strspn(s, accept) (0)
|
||||
#define strtol(nptr, endptr, base) bcm_strtoul((nptr), (endptr), (base))
|
||||
#elif defined(__IOPOS__)
|
||||
#define fprintf(file, fmt, arg...) jtag_printf(fmt, ##arg)
|
||||
#define fputs(s, stream) jtag_puts(s)
|
||||
#define printf jtag_printf
|
||||
#define stricmp strcmp
|
||||
#define strnicmp strncmp
|
||||
#define strtol(nptr, endptr, base) ((long)strtoul((nptr), (endptr), (base)))
|
||||
#define tolower(c) bcm_tolower(c)
|
||||
#define toupper(c) bcm_toupper(c)
|
||||
#define islower(c) bcm_islower(c)
|
||||
#define isprint(c) bcm_isprint(c)
|
||||
#define isspace(c) bcm_isspace(c)
|
||||
#define isupper(c) bcm_isupper(c)
|
||||
#define isxdigit(c) bcm_isxdigit(c)
|
||||
#define isdigit(c) bcm_isdigit(c)
|
||||
#elif defined(BWL_STRICMP)
|
||||
#define stricmp bcmstricmp
|
||||
#define strnicmp bcmstrnicmp
|
||||
#endif /* __NetBSD__ */
|
||||
|
||||
|
||||
/* 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. */
|
||||
static bool g_swap = FALSE;
|
||||
#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;
|
||||
|
||||
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);
|
||||
1104
external/cache/sources/wl/shared/wlu_pipe.c
vendored
Normal file
1104
external/cache/sources/wl/shared/wlu_pipe.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
42
external/cache/sources/wl/shared/wlu_pipe.h
vendored
Normal file
42
external/cache/sources/wl/shared/wlu_pipe.h
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* OS independent declarations
|
||||
*
|
||||
* $Copyright (C) 2008 Broadcom Corporation$
|
||||
*
|
||||
* $Id: wlu_pipe.h 287128 2011-09-30 04:27:53Z estucki $
|
||||
*/
|
||||
#ifndef _wlu_pipe_h
|
||||
#define _wlu_pipe_h
|
||||
|
||||
/* Function prototypes defined in wlu_pipe.c */
|
||||
|
||||
/* Macros to access globals */
|
||||
extern char *g_rwl_device_name_serial;
|
||||
#define rwl_get_serial_port_name() (g_rwl_device_name_serial)
|
||||
#define rwl_set_serial_port_name(name) (g_rwl_device_name_serial = name)
|
||||
extern char *g_rwl_buf_mac;
|
||||
#define rwl_get_wifi_mac() (g_rwl_buf_mac)
|
||||
|
||||
extern int remote_CDC_tx(void *wl, uint cmd, uchar *buf, uint buf_len,
|
||||
uint data_len, uint flags, int debug);
|
||||
extern rem_ioctl_t *remote_CDC_rx_hdr(void *remote, int debug);
|
||||
extern int remote_CDC_rx(void *wl, rem_ioctl_t *rem_ptr, uchar *readbuf, uint buflen, int debug);
|
||||
|
||||
extern void* rwl_open_pipe(int remote_type, char *port, int ReadTotalTimeout, int debug);
|
||||
extern int rwl_close_pipe(int remote_type, void* hndle);
|
||||
|
||||
#ifdef RWL_SOCKET
|
||||
extern int rwl_sockconnect(int SockDes, struct sockaddr *servAddr, int size);
|
||||
#endif /* RWL_SOCKET */
|
||||
|
||||
extern int remote_CDC_DATA_wifi_rx_frag(void *wl, rem_ioctl_t *rem_ptr, uint input_len,
|
||||
void *input, bool shell);
|
||||
extern int remote_CDC_DATA_wifi_rx(void *wl, struct dot11_action_wifi_vendor_specific *rec_frame);
|
||||
extern int
|
||||
remote_CDC_wifi_tx(void *wl, uint cmd, uchar *buf, uint buf_len, uint data_len, uint flags);
|
||||
extern void rwl_wifi_server_response(void *wl, struct dot11_action_wifi_vendor_specific *rec_frame);
|
||||
extern int rwl_find_remote_wifi_server(void *wl, char *id);
|
||||
extern void rwl_wifi_purge_actionframes(void *wl);
|
||||
extern void rwl_wifi_swap_remote_type(int flag);
|
||||
extern void remote_wifi_ser_init_cmds(void *wl);
|
||||
#endif /* _wlu_pipe_h */
|
||||
572
external/cache/sources/wl/shared/wlu_pipe_linux.c
vendored
Normal file
572
external/cache/sources/wl/shared/wlu_pipe_linux.c
vendored
Normal file
@@ -0,0 +1,572 @@
|
||||
/*
|
||||
* linux version of remote Wl transport mechanisms (pipes).
|
||||
*
|
||||
* $Copyright (C) 2008 Broadcom Corporation$
|
||||
*
|
||||
* $Id: wlu_pipe_linux.c 281542 2011-09-02 17:31:19Z hharte $
|
||||
*/
|
||||
|
||||
/* Revision History: Linux version of remote Wl transport mechanisms (pipes).
|
||||
*
|
||||
* Date Author Description
|
||||
*
|
||||
* 27-Dec-2007 Suganthi Version 0.0
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
#include <netdb.h>
|
||||
#include <signal.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <net/if.h>
|
||||
#include <termios.h>
|
||||
#include <fcntl.h>
|
||||
#include <proto/802.11.h>
|
||||
#include <bcmendian.h>
|
||||
#include <bcmcdc.h>
|
||||
#include <proto/802.11.h>
|
||||
#include <wlioctl.h>
|
||||
#if defined(MACOSX)
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#include <typedefs.h>
|
||||
#include "wlu_remote.h"
|
||||
#include <miniopt.h>
|
||||
#if defined(RWL_DONGLE) || defined(RWL_SERIAL)
|
||||
#define READ_DELAY 500000
|
||||
#define BAUD_RATE_115200 115200
|
||||
#define VMIN_VAL 16
|
||||
#define VTIME_VAL 50
|
||||
#define LINUX_SYNC_DELAY 200
|
||||
extern char *g_rwl_device_name_serial;
|
||||
#endif
|
||||
|
||||
#define MICRO_SEC_CONVERTER_VAL 1000
|
||||
int g_irh;
|
||||
int g_shellsync_pid;
|
||||
|
||||
#ifdef RWL_SOCKET
|
||||
#define MAX_INTERFACE_NAME 32
|
||||
|
||||
static int
|
||||
rwl_opensocket(int AddrFamily, int Type, int Protocol)
|
||||
{
|
||||
int SockDes;
|
||||
|
||||
if ((SockDes = socket(AddrFamily, Type, Protocol)) == -1) {
|
||||
perror("rwl_opensocket Fails:");
|
||||
DPRINT_ERR(ERR, "\nerrno:%d\n", errno);
|
||||
return FAIL;
|
||||
}
|
||||
return SockDes;
|
||||
}
|
||||
|
||||
static int
|
||||
rwl_set_socket_option(int SocketDes, int Level, int OptName, int Val)
|
||||
{
|
||||
if (setsockopt(SocketDes, Level, OptName, &Val, sizeof(int)) == -1) {
|
||||
perror("Error at SetTCPSocketOpt()");
|
||||
DPRINT_ERR(ERR, "\n errno:%d\n", errno);
|
||||
return FAIL;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/* Function to connect with the server waiting in the same port */
|
||||
int
|
||||
rwl_connectsocket(int SocketDes, struct sockaddr* SerAddr, int SizeOfAddr)
|
||||
{
|
||||
if (connect(SocketDes, SerAddr, SizeOfAddr) == -1) {
|
||||
perror("Failed to connect() to server");
|
||||
DPRINT_ERR(ERR, "\n errno:%d\n", errno);
|
||||
return FAIL;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function for associating a local address with a socket.
|
||||
*/
|
||||
int
|
||||
rwl_bindsocket(int SocketDes, struct sockaddr * MyAddr, int SizeOfAddr)
|
||||
{
|
||||
if (bind(SocketDes, MyAddr, SizeOfAddr) == -1) {
|
||||
perror("Error at rwl_bindSocket()");
|
||||
DPRINT_ERR(ERR, "\n errno:%d\n", errno);
|
||||
return FAIL;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function for making the socket to listen for incoming connection.
|
||||
*/
|
||||
int
|
||||
rwl_listensocket(int SocketDes, int BackLog)
|
||||
{
|
||||
if (listen(SocketDes, BackLog) == -1) {
|
||||
perror("Error at rwl_listensocket()");
|
||||
DPRINT_ERR(ERR, "\n errno:%d\n", errno);
|
||||
return FAIL;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function for permitting an incoming connection attempt on a socket
|
||||
* Function called by server
|
||||
*/
|
||||
int
|
||||
rwl_acceptconnection(int SocketDes, struct sockaddr* ClientAddr, int *SizeOfAddr)
|
||||
{
|
||||
int NewSockDes;
|
||||
|
||||
if ((NewSockDes = accept(SocketDes, ClientAddr, (socklen_t*)SizeOfAddr)) == -1) {
|
||||
perror("Error at rwl_acceptConnection()");
|
||||
DPRINT_ERR(ERR, "\n errno:%d\n", errno);
|
||||
return FAIL;
|
||||
}
|
||||
return NewSockDes;
|
||||
}
|
||||
|
||||
static int
|
||||
rwl_closesocket(int SocketDes)
|
||||
{
|
||||
if (close(SocketDes) == -1) {
|
||||
perror("Error at rwl_closeSocket()");
|
||||
DPRINT_ERR(ERR, "\n errno:%d\n", errno);
|
||||
return FAIL;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/* Transmit the response in the opened TCP stream socket */
|
||||
int
|
||||
rwl_send_to_streamsocket(int SocketDes, const char* SendBuff, int data_size, int Flag)
|
||||
{
|
||||
int total_numwritten = 0, numwritten = 0;
|
||||
while (total_numwritten < data_size) {
|
||||
if ((numwritten = send(SocketDes, SendBuff,
|
||||
data_size - total_numwritten, Flag)) == -1) {
|
||||
perror("Failed to send()");
|
||||
DPRINT_ERR(ERR, "\n errno:%d\n", errno);
|
||||
return (FAIL);
|
||||
}
|
||||
|
||||
/* Sent successfully at first attempt no more retries */
|
||||
if (numwritten == data_size) {
|
||||
total_numwritten = numwritten;
|
||||
break;
|
||||
}
|
||||
|
||||
/* If socket is busy we may hit this condition */
|
||||
if (numwritten != data_size - total_numwritten) {
|
||||
DPRINT_DBG(OUTPUT, "wanted to send %d bytes sent only %d bytes\n",
|
||||
data_size - total_numwritten, numwritten);
|
||||
}
|
||||
|
||||
/* Now send the remaining buffer */
|
||||
total_numwritten += numwritten;
|
||||
SendBuff += numwritten;
|
||||
}
|
||||
|
||||
return total_numwritten;
|
||||
}
|
||||
|
||||
/* Receive the response from the opened TCP stream socket */
|
||||
int
|
||||
rwl_receive_from_streamsocket(int SocketDes, char* RecvBuff, int data_size, int Flag)
|
||||
{
|
||||
int numread;
|
||||
int total_numread = 0;
|
||||
|
||||
while (total_numread < data_size) {
|
||||
if ((numread = recv(SocketDes, RecvBuff, data_size - total_numread, Flag)) == -1) {
|
||||
perror("Failed to Receive()");
|
||||
DPRINT_ERR(ERR, "\n errno:%d\n", errno);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (numread != data_size - total_numread) {
|
||||
DPRINT_DBG(OUTPUT, "asked %d bytes got %d bytes\n",
|
||||
data_size - total_numread, numread);
|
||||
}
|
||||
|
||||
if (numread == 0)
|
||||
break;
|
||||
|
||||
total_numread += numread;
|
||||
RecvBuff += numread;
|
||||
}
|
||||
|
||||
return numread;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
rwl_init_server_socket_setup(int argc, char** argv, uint remote_type)
|
||||
{
|
||||
char netif[MAX_INTERFACE_NAME];
|
||||
unsigned short servPort;
|
||||
struct sockaddr_in ServerAddress;
|
||||
int err, SockDes, val;
|
||||
|
||||
/* Default option */
|
||||
servPort = DEFAULT_SERVER_PORT;
|
||||
|
||||
#ifdef MACOSX
|
||||
strcpy(netif, "en0");
|
||||
#else
|
||||
strcpy(netif, "eth0");
|
||||
#endif
|
||||
|
||||
/* User option can override default arguments */
|
||||
if (argc == 3) {
|
||||
argv++;
|
||||
|
||||
if (isalpha(**argv) == FALSE) {
|
||||
DPRINT_ERR(ERR, "USAGE ERROR:Incorrect network interface\n");
|
||||
return FAIL;
|
||||
}
|
||||
strcpy(netif, *argv);
|
||||
argv++;
|
||||
|
||||
if (isdigit(**argv) == FALSE) {
|
||||
DPRINT_ERR(ERR, "USAGE ERROR:Incorrect port\n");
|
||||
return FAIL;
|
||||
}
|
||||
servPort = atoi(*argv);
|
||||
}
|
||||
|
||||
if (argc == 2) {
|
||||
argv++;
|
||||
|
||||
if (isalpha(**argv) == FALSE) {
|
||||
if (isdigit(**argv) == FALSE) {
|
||||
DPRINT_ERR(ERR, "USAGE ERROR\n");
|
||||
return FAIL;
|
||||
}
|
||||
else
|
||||
servPort = atoi(*argv);
|
||||
}
|
||||
else
|
||||
strcpy(netif, *argv);
|
||||
}
|
||||
|
||||
DPRINT_INFO(OUTPUT, "INFO: Network Interface:%s, Port:%d\n",
|
||||
netif, servPort);
|
||||
|
||||
if ((SockDes = (*(int *)rwl_open_transport(remote_type, NULL, 0, 0))) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
val = 1;
|
||||
if ((rwl_set_socket_option(SockDes, SOL_SOCKET, SO_REUSEADDR, val)) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
memset(&ServerAddress, 0, sizeof(ServerAddress));
|
||||
|
||||
rwl_GetifAddr(netif, &ServerAddress);
|
||||
ServerAddress.sin_family = AF_INET; /* host byte order */
|
||||
ServerAddress.sin_port = hton16(servPort); /* short, network byte order */
|
||||
|
||||
if (((err = rwl_bindsocket(SockDes, (struct sockaddr *)&ServerAddress,
|
||||
sizeof(ServerAddress))) == FAIL))
|
||||
return err;
|
||||
if ((err = rwl_listensocket(SockDes, BACKLOG)) == FAIL)
|
||||
return err;
|
||||
|
||||
DPRINT_DBG(OUTPUT, "Waiting for client to connect...\n");
|
||||
|
||||
return SockDes;
|
||||
}
|
||||
|
||||
int rwl_GetifAddr(char *ifname, struct sockaddr_in *sa)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
int fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
|
||||
|
||||
if (fd < 0)
|
||||
{
|
||||
DPRINT_ERR(ERR, "socket open error\n");
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
strcpy(ifr.ifr_name, ifname);
|
||||
ifr.ifr_addr.sa_family = AF_INET;
|
||||
if (ioctl(fd, SIOCGIFADDR, &ifr) == 0)
|
||||
{
|
||||
memcpy(sa, (struct sockaddr_in *)&ifr.ifr_addr, sizeof(struct sockaddr_in));
|
||||
}
|
||||
else
|
||||
{
|
||||
return FAIL;
|
||||
}
|
||||
close(fd);
|
||||
return FAIL;
|
||||
}
|
||||
#endif /* RWL_SOCKET */
|
||||
|
||||
#if defined (RWL_SERIAL) || defined (RWL_DONGLE)
|
||||
static int
|
||||
rwl_open_serial(int remote_type, char *port)
|
||||
{
|
||||
struct termios tio;
|
||||
int fCom;
|
||||
int speed;
|
||||
long BAUD, DATABITS, STOPBITS, PARITYON;
|
||||
speed_t baud_rate;
|
||||
|
||||
DPRINT_DBG(OUTPUT, "\n rwl_open_serial:%s\n", port);
|
||||
if (remote_type == REMOTE_DONGLE)
|
||||
fCom = open(port, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
else
|
||||
fCom = open(port, O_RDWR | O_NOCTTY | O_NDELAY | O_SYNC);
|
||||
if (fCom < 0) {
|
||||
DPRINT_ERR(ERR, "open COM failed with error %d.\n", errno);
|
||||
return fCom;
|
||||
} else {
|
||||
/* To make the read as a blocking operation */
|
||||
fcntl(fCom, F_SETFL, 0);
|
||||
}
|
||||
|
||||
bzero(&tio, sizeof(tio));
|
||||
/* Get the current option for the port... */
|
||||
tcgetattr(fCom, &tio);
|
||||
/* Set the baud rate */
|
||||
cfsetispeed(&tio, B115200);
|
||||
cfsetospeed(&tio, B115200);
|
||||
if (remote_type == REMOTE_DONGLE) {
|
||||
if (tcsetattr(fCom, TCSANOW, &tio) < 0) {
|
||||
perror("tcsetattr:setspeed");
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
baud_rate = cfgetospeed(&tio);
|
||||
if (baud_rate == B115200)
|
||||
speed = BAUD_RATE_115200;
|
||||
DPRINT_DBG(OUTPUT, "Baud_rate set is:%d\n", speed);
|
||||
|
||||
BAUD = B115200;
|
||||
DATABITS = CS8;
|
||||
STOPBITS = 1;
|
||||
PARITYON = 0;
|
||||
|
||||
tio.c_cflag = BAUD | DATABITS | STOPBITS | PARITYON | CLOCAL | CREAD;
|
||||
tio.c_iflag = IGNPAR;
|
||||
tio.c_oflag = 0;
|
||||
tio.c_lflag = 0;
|
||||
tio.c_cc[VMIN] = VMIN_VAL;
|
||||
tio.c_cc[VTIME] = VTIME_VAL;
|
||||
|
||||
tcflush(fCom, TCIOFLUSH);
|
||||
if (tcsetattr(fCom, TCSANOW, &tio) < 0) {
|
||||
perror("tcsetattr:");
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (tcgetattr(fCom, &tio) < 0) {
|
||||
perror("tcgetattr:");
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
DPRINT_DBG(OUTPUT, "tcgetattr:VMIN is:%d\n", tio.c_cc[VMIN]);
|
||||
DPRINT_DBG(OUTPUT, "tcgetattr:VTIME is:%d\n", tio.c_cc[VTIME]);
|
||||
tcflush(fCom, TCIOFLUSH);
|
||||
}
|
||||
else {
|
||||
UNUSED_PARAMETER(PARITYON);
|
||||
UNUSED_PARAMETER(STOPBITS);
|
||||
UNUSED_PARAMETER(DATABITS);
|
||||
UNUSED_PARAMETER(BAUD);
|
||||
UNUSED_PARAMETER(baud_rate);
|
||||
UNUSED_PARAMETER(speed);
|
||||
|
||||
/* Enable the receiver and set local mode */
|
||||
tio.c_cflag |= (CLOCAL | CREAD);
|
||||
|
||||
tio.c_cflag &= ~PARENB;
|
||||
tio.c_cflag &= ~CSTOPB;
|
||||
tio.c_cflag &= ~CSIZE;
|
||||
tio.c_cflag |= CS8;
|
||||
tio.c_cc[VTIME] = 255;
|
||||
tio.c_cc[VMIN] = 1;
|
||||
|
||||
tio.c_iflag = 0;
|
||||
tio.c_iflag |= IGNBRK;
|
||||
|
||||
tio.c_oflag &= ~OPOST;
|
||||
tio.c_oflag &= ~OLCUC;
|
||||
tio.c_oflag &= ~ONLCR;
|
||||
tio.c_oflag &= ~OCRNL;
|
||||
tio.c_oflag &= ~ONOCR;
|
||||
tio.c_oflag &= ~ONLRET;
|
||||
tio.c_oflag &= ~OFILL;
|
||||
|
||||
tio.c_lflag &= ~ICANON;
|
||||
tio.c_lflag &= ~ISIG;
|
||||
tio.c_lflag &= ~XCASE;
|
||||
tio.c_lflag &= ~ECHO;
|
||||
tio.c_lflag &= ~FLUSHO;
|
||||
tio.c_lflag &= ~IEXTEN;
|
||||
tio.c_lflag |= NOFLSH;
|
||||
/* Set the new tio for the port... */
|
||||
tcsetattr(fCom, TCSANOW, &tio);
|
||||
tcflush(fCom, TCIOFLUSH);
|
||||
}
|
||||
return (fCom);
|
||||
}
|
||||
int
|
||||
rwl_write_serial_port(void* hndle, char* write_buf, unsigned long size, unsigned long *numwritten)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = write((*(int *)hndle), (const void*)write_buf, size);
|
||||
*numwritten = ret;
|
||||
if (ret == -1) {
|
||||
perror("WriteToPort Failed");
|
||||
DPRINT_ERR(ERR, "Errno:%d\n", errno);
|
||||
return FAIL;
|
||||
}
|
||||
if (*numwritten != size) {
|
||||
DPRINT_ERR(ERR, "rwl_write_serial_port failed numwritten %ld != len %ld\n",
|
||||
*numwritten, size);
|
||||
return FAIL;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
rwl_read_serial_port(void* hndle, char* read_buf, uint data_size, uint *numread)
|
||||
{
|
||||
int ret;
|
||||
uint total_numread = 0;
|
||||
while (total_numread < data_size) {
|
||||
ret = read(*(int *)hndle, read_buf, data_size - total_numread);
|
||||
*numread = ret;
|
||||
if (ret == -1) {
|
||||
|
||||
perror("ReadFromPort Failed");
|
||||
DPRINT_ERR(ERR, "Errno:%d\n", errno);
|
||||
return FAIL;
|
||||
}
|
||||
if (*numread != data_size - total_numread) {
|
||||
DPRINT_DBG(OUTPUT, "asked for %d bytes got %d bytes\n",
|
||||
data_size - total_numread, *numread);
|
||||
}
|
||||
if (*numread == 0)
|
||||
break;
|
||||
|
||||
total_numread += *numread;
|
||||
read_buf += *numread;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
rwl_sync_delay(uint noframes)
|
||||
{
|
||||
if (noframes > 1) {
|
||||
rwl_sleep(LINUX_SYNC_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* RWL_DONGLE ||RWL_SERIAL */
|
||||
|
||||
#if defined (RWL_DONGLE) || defined (RWL_SOCKET) || defined(RWL_SERIAL)
|
||||
void*
|
||||
rwl_open_transport(int remote_type, char *port, int ReadTotalTimeout, int debug)
|
||||
{
|
||||
void* hndle;
|
||||
|
||||
UNUSED_PARAMETER(port);
|
||||
UNUSED_PARAMETER(ReadTotalTimeout);
|
||||
UNUSED_PARAMETER(debug);
|
||||
|
||||
switch (remote_type) {
|
||||
#if defined(RWL_DONGLE) || defined(RWL_SERIAL)
|
||||
case REMOTE_SERIAL:
|
||||
#ifdef RWL_SERIAL
|
||||
g_rwl_device_name_serial = port;
|
||||
#endif
|
||||
case REMOTE_DONGLE:
|
||||
if ((g_irh = rwl_open_serial(remote_type, g_rwl_device_name_serial))
|
||||
== FAIL) {
|
||||
/* Initial port opening settings failed in reboot.
|
||||
* So retry opening the serial port
|
||||
*/
|
||||
if ((g_irh = rwl_open_serial(remote_type, g_rwl_device_name_serial))
|
||||
== FAIL) {
|
||||
DPRINT_ERR(ERR, "Can't open serial port\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif /* RWL_DONGLE || RWL_SERIAL */
|
||||
|
||||
#ifdef RWL_SOCKET
|
||||
case REMOTE_SOCKET:
|
||||
if ((g_irh = rwl_opensocket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == FAIL) {
|
||||
DPRINT_ERR(ERR, "\nCan't open socket \n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
break;
|
||||
#endif /* RWL_SOCKET */
|
||||
|
||||
default:
|
||||
DPRINT_ERR(ERR, "rwl_open_transport: Unknown remote_type %d\n", remote_type);
|
||||
return NULL;
|
||||
break;
|
||||
} /* end - switch case */
|
||||
|
||||
hndle = (void*) &g_irh;
|
||||
return hndle;
|
||||
}
|
||||
|
||||
int
|
||||
rwl_close_transport(int remote_type, void* Des)
|
||||
{
|
||||
switch (remote_type) {
|
||||
#ifdef RWL_SOCKET
|
||||
case REMOTE_SOCKET:
|
||||
if (rwl_closesocket(*(int *)Des) == FAIL)
|
||||
return FAIL;
|
||||
break;
|
||||
#endif /* RWL_SOCKET */
|
||||
|
||||
#if defined(RWL_DONGLE) || defined(RWL_SERIAL)
|
||||
case REMOTE_DONGLE:
|
||||
case REMOTE_SERIAL:
|
||||
if (close(*(int *)Des) == -1)
|
||||
return FAIL;
|
||||
break;
|
||||
#endif /* RWL_DONGLE || RWL_SERIAL */
|
||||
|
||||
default:
|
||||
DPRINT_ERR(ERR, "close_pipe: Unknown remote_type %d\n", remote_type);
|
||||
break;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
#endif /* #if defined (RWL_DONGLE) || defined (RWL_SOCKET) */
|
||||
|
||||
void
|
||||
rwl_sleep(int delay)
|
||||
{
|
||||
usleep(delay * MICRO_SEC_CONVERTER_VAL);
|
||||
}
|
||||
|
||||
#if defined(WLMSO)
|
||||
int
|
||||
rwl_init_socket(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
255
external/cache/sources/wl/shared/wlu_remote.h
vendored
Normal file
255
external/cache/sources/wl/shared/wlu_remote.h
vendored
Normal file
@@ -0,0 +1,255 @@
|
||||
/*
|
||||
* OS independent remote wl declarations
|
||||
*
|
||||
* $Copyright (C) 2008 Broadcom Corporation$
|
||||
*
|
||||
* $Id: wlu_remote.h 401759 2013-05-13 16:08:08Z sudhirbs $
|
||||
*/
|
||||
#ifndef _wlu_remote_h
|
||||
#define _wlu_remote_h
|
||||
#include <wlioctl.h>
|
||||
/* Remote wl declararions */
|
||||
#define NO_REMOTE 0
|
||||
#define REMOTE_SERIAL 1
|
||||
#define REMOTE_SOCKET 2
|
||||
#define REMOTE_WIFI 3
|
||||
#define REMOTE_DONGLE 4
|
||||
#define SHELL_CMD -1 /* Invalid cmd id for shell */
|
||||
#define ASD_CMD -2 /* Cmd id for ASD command */
|
||||
#define SERVER_RESPONSE_MAX_BUF_LEN 8192
|
||||
#define SHELL_RESP_SIZE 1024
|
||||
#define CTRLC_PACKET 0xDEADBEAF
|
||||
#define CTRLC_FLAG -4
|
||||
#define VISTA_CMD -3 /* cmd id for remote vista */
|
||||
|
||||
/* For cross OS support */
|
||||
/* For autonegotiation to work, these defines should be
|
||||
* the same for client and server.
|
||||
*/
|
||||
#define UNKNOWN_OS 0
|
||||
#define LINUX_OS 1
|
||||
#define WIN32_OS 2
|
||||
#define MAC_OSX 3
|
||||
#define BACKLOG 4
|
||||
#define WINVISTA_OS 5
|
||||
#define INDONGLE 6
|
||||
#define INVALID_OS 7 /* Should be last */
|
||||
|
||||
/* Used in cdc_ioctl_t.flags field */
|
||||
#define REMOTE_SET_IOCTL 1
|
||||
#define REMOTE_GET_IOCTL 2
|
||||
#define REMOTE_REPLY 4
|
||||
#define REMOTE_SHELL_CMD 8
|
||||
#define REMOTE_FINDSERVER_IOCTL 16 /* Find remote server */
|
||||
#define REMOTE_ASD_CMD 32 /* ASD integration */
|
||||
#define RDHD_SET_IOCTL 64
|
||||
#define RDHD_GET_IOCTL 128
|
||||
#define REMOTE_VISTA_CMD 256 /* for remote vista specific commands */
|
||||
#define REMOTE_NEGOTIATE_CMD 512 /* for RWL negotiation */
|
||||
#define NEGOTIATE_GET_OS 0 /* detect remote OS */
|
||||
#define RWL_WIFI_DEFAULT_TYPE 0x00
|
||||
#define RWL_WIFI_DEFAULT_SUBTYPE 0x00
|
||||
#define RWL_ACTION_FRAME_DATA_SIZE 1024 /* fixed size for the wifi frame data */
|
||||
#define RWL_WIFI_CDC_HEADER_OFFSET 0
|
||||
#define RWL_WIFI_FRAG_DATA_SIZE 960 /* max size of the frag data */
|
||||
#define RWL_DEFAULT_WIFI_FRAG_COUNT 127 /* maximum fragment count */
|
||||
#define RWL_WIFI_RETRY 5 /* CMD retry count for wifi */
|
||||
#define RWL_WIFI_RX_RETRY 20 /* WIFI response rerty count */
|
||||
#define RWL_WIFI_SEND 5 /* WIFI frame sent count */
|
||||
#define RWL_WIFI_RETRY_DELAY 1000 /* wifi specific retry delay */
|
||||
#define RWL_WIFI_SEND_DELAY 100 /* delay between two frames */
|
||||
#define RWL_WIFI_RX_DELAY 250 /* wait between send and receive */
|
||||
#define RWL_WIFI_RX_SHELL_DELAY 1000 /* delay added for shell cmd response read */
|
||||
#define RWL_CHANNEL_RX_SCAN_DELAY 10 /* Delay between findserver rx calls */
|
||||
#define RWL_CHANNEL_SCAN_WAIT 250 /* Sleep time in between the channel scans */
|
||||
#define RWL_WIFI_BUF_LEN 64
|
||||
#define RWL_WIFI_SHELL_CMD 1
|
||||
#define RWL_WIFI_WL_CMD 0
|
||||
#define RWL_WIFI_FIND_SER_CMD "findserver"
|
||||
#define RWL_WIFI_ACTION_CMD "wifiaction"
|
||||
#define RWL_WIFI_GET_ACTION_CMD "rwlwifivsaction"
|
||||
#define RWL_DONGLE_SET_CMD "dongleset"
|
||||
#define DATA_FRAME_LEN 960
|
||||
/* wl & shell cmd work fine for 960 (512+256+128+64) */
|
||||
|
||||
|
||||
/*
|
||||
* Information about the action frame data fields in the
|
||||
* dot11_action_wifi_vendor_specific
|
||||
* cdc struct (1 to 16. This does not include status flag. Since this
|
||||
* is not directly visible to the driver code we cant use sizeof struct
|
||||
* cdc_ioctl_t. Hence Ref MAC address offset starts from byte 17.
|
||||
* REF MAC ADDR (6 bytes (MAC Address len) from byte 17 to 22)
|
||||
* DUT MAC ADDR (6 bytes after the REF MAC Address byte 23 to 28)
|
||||
* unused (byte 29 to 49)
|
||||
* REF/Client Channel offset (50)
|
||||
* DUT/Server channel offset (51)
|
||||
* ---------------------------------------------------------------------------------------
|
||||
* cdc struct|REF MAC ADDR|DUT_MAC_ADDR|un used|REF Channel|DUT channel|Action frame Data|
|
||||
* 1---------17-----------23-------------------50----------51----------52----------------1040
|
||||
* REF MAC addr after CDC struct without status flag (status flag not used by wifi)
|
||||
*/
|
||||
#define RWL_ACTION_WIFI_CATEGORY 127 /* Vendor Specific category value for wifi */
|
||||
#define RWL_REF_MAC_ADDRESS_OFFSET 17
|
||||
#define RWL_DUT_MAC_ADDRESS_OFFSET 23
|
||||
#define RWL_WIFI_CLIENT_CHANNEL_OFFSET 50
|
||||
#define RWL_WIFI_SERVER_CHANNEL_OFFSET 51
|
||||
|
||||
#define SUCCESS 1
|
||||
#define FAIL -1
|
||||
#define NO_PACKET -2
|
||||
#define SERIAL_PORT_ERR -3
|
||||
|
||||
#define DEFAULT_SERVER_PORT 8000
|
||||
|
||||
#define WL_MAX_BUF_LEN (127 * 1024)
|
||||
#define MAX_VISTA_ARGC 10
|
||||
#define HOST_TO_NETWORK TRUE
|
||||
#define NETWORK_TO_HOST FALSE
|
||||
|
||||
#ifndef IFNAMSIZ
|
||||
#define IFNAMSIZ 16
|
||||
#endif
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
/* We don't want the server to allocate bigger buffers for some of the commands
|
||||
* like scanresults. Server can still allocate 8K memory and send the response
|
||||
* in fragments. This is used in case of Get commands only.
|
||||
*/
|
||||
#define SERVER_RESPONSE_MAX_BUF_LEN 8192
|
||||
#endif
|
||||
/* Used to set the cmds for wifi specific init */
|
||||
typedef struct remote_wifi_cmds {
|
||||
uint32 cmd; /* common ioctl definition */
|
||||
char *data; /* max size of the data length */
|
||||
int value;
|
||||
} remote_wifi_cmds_t;
|
||||
|
||||
/* Added for debug utility support */
|
||||
#define ERR stderr
|
||||
#define OUTPUT stdout
|
||||
|
||||
#define DEBUG_DEFAULT 0x0001
|
||||
#define DEBUG_ERR 0x0001
|
||||
#define DEBUG_INFO 0x0002
|
||||
#define DEBUG_DBG 0x0004
|
||||
|
||||
/* #ifdef TARGETOS_symbian */
|
||||
#if 0
|
||||
/* There is some side-defect when SymbianPrintf is used
|
||||
* Error in Com Port Recv
|
||||
*/
|
||||
extern void SymbianPrintf(void *fd, char *format, ...);
|
||||
#define DPRINT_ERR if (defined_debug & DEBUG_ERR) \
|
||||
SymbianPrintf
|
||||
#define DPRINT_INFO if (defined_debug & DEBUG_INFO) \
|
||||
SymbianPrintf
|
||||
#define DPRINT_DBG if (defined_debug & DEBUG_DBG) \
|
||||
SymbianPrintf
|
||||
#else
|
||||
#define DPRINT_ERR if (defined_debug & DEBUG_ERR) \
|
||||
fprintf
|
||||
#define DPRINT_INFO if (defined_debug & DEBUG_INFO) \
|
||||
fprintf
|
||||
#define DPRINT_DBG if (defined_debug & DEBUG_DBG) \
|
||||
fprintf
|
||||
#endif /* TARGETOS_symbian */
|
||||
extern unsigned short defined_debug;
|
||||
#ifdef WIN32
|
||||
#if 0
|
||||
#define IPV4_ADDR_LEN 4
|
||||
/* IPV4 packet formats */
|
||||
struct ipv4_addr {
|
||||
uint8 addr[IPV4_ADDR_LEN];
|
||||
} PACKED;
|
||||
#endif
|
||||
/* Function defined in wlu.c for client and wlu_server_ce.c for server */
|
||||
extern int wl_atoip(const char *a, struct ipv4_addr *n);
|
||||
#endif /* WIN32 */
|
||||
/* Function defined to do host to network and network to host conversions */
|
||||
void rwl_swap_header(rem_ioctl_t *rem_ptr, bool host_to_network);
|
||||
|
||||
/* Macros to access remote type */
|
||||
extern int remote_type;
|
||||
#define rwl_get_remote_type() (remote_type)
|
||||
#define rwl_set_remote_type(type) (remote_type = type)
|
||||
|
||||
/* Macros to access server IP and port globals */
|
||||
extern char *g_rwl_servIP;
|
||||
#define rwl_get_server_ip() (g_rwl_servIP)
|
||||
#define rwl_set_server_ip(ip) (g_rwl_servIP = ip)
|
||||
extern unsigned short g_rwl_servport;
|
||||
#define rwl_get_server_port() (g_rwl_servport)
|
||||
#define rwl_set_server_port(port) (g_rwl_servport = port)
|
||||
|
||||
/* Wrapper functions defined in wlu_pipe_xxx.c where xxx is OS specific */
|
||||
extern int rwl_read_serial_port(void* hndle, char* read_buf, uint data_size, uint *numread);
|
||||
extern int rwl_write_serial_port(void* hndle, char* write_buf, unsigned long size,
|
||||
unsigned long *numwritten);
|
||||
extern void rwl_sleep(int delay);
|
||||
extern void* rwl_open_transport(int remote_type, char *port, int ReadTotalTimeout, int debug);
|
||||
extern int rwl_close_transport(int remote_type, void * handle);
|
||||
extern int rwl_poll_serial_buffer(void *hndle);
|
||||
extern int rwl_serial_handle_timeout(void);
|
||||
extern void rwl_sync_delay(uint noframes);
|
||||
|
||||
#ifdef RWL_SOCKET
|
||||
extern int rwl_connectsocket(int SocketDes, struct sockaddr* SerAddr, int SizeOfAddr);
|
||||
extern int rwl_acceptconnection(int SocketDes, struct sockaddr *ClientAddr, int *SizeOfAddr);
|
||||
extern int rwl_send_to_streamsocket(int SocketDes, const char* SendBuff, int data_size, int Flag);
|
||||
extern int rwl_receive_from_streamsocket(int SocketDes, char* RecvBuff, int data_size, int Flag);
|
||||
extern int rwl_init_server_socket_setup(int argc, char** argv, uint remote_type);
|
||||
#ifdef vxworks
|
||||
extern int rwl_GetifAddr(char *ifname, char *ifaddr);
|
||||
#else
|
||||
extern int rwl_GetifAddr(char *ifname, struct sockaddr_in* sa);
|
||||
#endif /* vxworks */
|
||||
#endif /* RWL_SOCKET */
|
||||
|
||||
#if defined(vxworks) || defined(LINUX)
|
||||
extern int set_interface(void *wl, char *intf_name);
|
||||
#endif /* defined(vxworks) || defined(LINUX) */
|
||||
|
||||
/* Win32 specific function wlu_pipe_win32.c */
|
||||
extern int rwl_init_ws2_32dll(void);
|
||||
extern int rwl_terminate_ws2_32dll(void);
|
||||
|
||||
/* Function definitions for wlu_client_shared.c and wlu_server_shared.c */
|
||||
extern int rwl_var_getbuf(void *wl, const char *iovar, void *param, int param_len, void **bufptr);
|
||||
extern int rwl_var_setbuf(void *wl, const char *iovar, void *param, int param_len);
|
||||
extern int rwl_var_send_vs_actionframe(void* wl, const char* iovar, void* param, int param_len);
|
||||
|
||||
/* Function definitions for wlu_ndis.c/wlu_linux.c and wlu_server_ce.c/wlu_server_linux.c */
|
||||
extern int wl_get(void *wl, int cmd, void *buf, int len);
|
||||
extern int wl_set(void *wl, int cmd, void *buf, int len);
|
||||
#ifdef RWLASD
|
||||
typedef unsigned char BYTE;
|
||||
extern void wfa_dut_init(BYTE **tBuf, BYTE **rBuf, BYTE **paBuf, BYTE **cBuf, struct timeval **);
|
||||
extern int remote_asd_exec(unsigned char* command, int* cmd_len);
|
||||
void wfa_dut_deinit(void);
|
||||
#endif
|
||||
extern int get_ctrlc_header(void *wl);
|
||||
extern int remote_tx_response(void *wl, void *buf_ptr, int cmd);
|
||||
extern rem_ioctl_t *g_rem_ptr;
|
||||
extern int g_rwl_hndle;
|
||||
#if defined (LINUX) || defined (MACOSX)
|
||||
/* Variable to indiate if the server child has completed execution */
|
||||
extern volatile sig_atomic_t g_sig_chld;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Separate paths are defined for android and linux machines
|
||||
* / filesystem on android is read only memory
|
||||
*/
|
||||
#ifndef WIN32
|
||||
#ifdef TARGETENV_android
|
||||
#define SH_PATH "/data/busybox/sh"
|
||||
#define SHELL_RESP_PATH "/data/local/RWL/" /* Default path for storing files for shell response */
|
||||
#define TEMPLATE "/data/local/RWL/SyncXXXXXX"
|
||||
#else
|
||||
#define SHELL_RESP_PATH "/tmp/RWL/" /* Default path for storing files for shell response */
|
||||
#define TEMPLATE "/tmp/RWL/SyncXXXXXX"
|
||||
#define SH_PATH "/bin/sh"
|
||||
#endif
|
||||
#endif /* !WIN32 */
|
||||
#endif /* _wlu_remote_h */
|
||||
Reference in New Issue
Block a user