Showing posts with label Wi-Fi. Show all posts
Showing posts with label Wi-Fi. Show all posts

Friday, July 13, 2012

Android wireless-tools


1. Download wireless_tools.30.pre9.tar.gz from 
www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html 
This version supports non-ASCII char in ESSID.

2. Unpack it into mydroid/external/wireless-tools directory.

3. Create Android.mk file with the following content:

LOCAL_PATH:= $(call my-dir)
################## build iwlib ###################
include $(CLEAR_VARS)
LOCAL_SRC_FILES := iwlib.c
LOCAL_CFLAGS += -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wpointer-arith -Wcast-qual -Winline -MMD -fPIC
LOCAL_MODULE:= libiw
LOCAL_STATIC_LIBRARIES := libcutils libc libm
include $(BUILD_STATIC_LIBRARY)
################## build iwconfig ###################
include $(CLEAR_VARS)
LOCAL_SRC_FILES := iwconfig.c
LOCAL_CFLAGS += -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wpointer-arith -Wcast-qual -Winline -MMD -fPIC
LOCAL_MODULE:= iwconfig
LOCAL_STATIC_LIBRARIES := libcutils libc libm libiw
#LOCAL_FORCE_STATIC_EXECUTABLE := true
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) # install to system/xbin
#LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED)
#LOCAL_MODULE_TAGS := eng user
include $(BUILD_EXECUTABLE)
################## build iwlist ###################
include $(CLEAR_VARS)
LOCAL_SRC_FILES := iwlist.c iwlib.h
LOCAL_CFLAGS += -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wpointer-arith -Wcast-qual -Winline -MMD -fPIC
LOCAL_MODULE:= iwlist
LOCAL_STATIC_LIBRARIES := libcutils libc libm libiw
#LOCAL_FORCE_STATIC_EXECUTABLE := true
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) # install to system/xbin
#LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED)
#LOCAL_MODULE_TAGS := eng user
include $(BUILD_EXECUTABLE)

4. Modify it as follows:
4.1 Change  wireless.22.h to be wireless.h ;
4.2 Modify ifrename.c, add a getline() function. You can get the code from external/genext2fs/genext2fs.c ;
Notice that this file uses macro to pass another function to getline() .
4.3 Modify iwlib.h ,  change #include to be #include .
[I don't know what it means. -- spica]

5. Compile

qiu@qiubutu:~/eclair-21/external/wireless-tools$ . ../../build/envsetup.sh
qiu@qiubutu:~/eclair-21/external/wireless-tools$ mm
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.1-update1
TARGET_PRODUCT=generic
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=ECLAIR
============================================
make: Entering '/home/qiu/eclair-21'
target thumb C: iwconfig <= external/wireless-tools/iwconfig.c
In file included from external/wireless-tools/iwlib.h:25,
                 from external/wireless-tools/iwlib-private.h:19,
                 from external/wireless-tools/iwconfig.c:14:
bionic/libc/include/stdlib.h:84: warning: declaration of 'abs' shadows a built-in function
bionic/libc/include/stdlib.h:88: warning: declaration of 'labs' shadows a built-in function
bionic/libc/include/stdlib.h:92: warning: declaration of 'llabs' shadows a built-in function
target thumb C: libiw <= external/wireless-tools/iwlib.c
In file included from external/wireless-tools/iwlib.h:25,
                 from external/wireless-tools/iwlib-private.h:19,
                 from external/wireless-tools/iwlib.c:14:
bionic/libc/include/stdlib.h:84: warning: declaration of 'abs' shadows a built-in function
bionic/libc/include/stdlib.h:88: warning: declaration of 'labs' shadows a built-in function
bionic/libc/include/stdlib.h:92: warning: declaration of 'llabs' shadows a built-in function
target StaticLib: libiw (out/target/product/generic/obj/STATIC_LIBRARIES/libiw_intermediates/libiw.a)
target Executable: iwconfig (out/target/product/generic/obj/EXECUTABLES/iwconfig_intermediates/LINKED/iwconfig)
target Non-prelinked: iwconfig (out/target/product/generic/symbols/system/bin/iwconfig)
target Strip: iwconfig (out/target/product/generic/obj/EXECUTABLES/iwconfig_intermediates/iwconfig)
Install: out/target/product/generic/system/xbin/iwconfig
target thumb C: iwlist <= external/wireless-tools/iwlist.c
In file included from external/wireless-tools/iwlib.h:25,
                 from external/wireless-tools/iwlib-private.h:19,
                 from external/wireless-tools/iwlist.c:14:
bionic/libc/include/stdlib.h:84: warning: declaration of 'abs' shadows a built-in function
bionic/libc/include/stdlib.h:88: warning: declaration of 'labs' shadows a built-in function
bionic/libc/include/stdlib.h:92: warning: declaration of 'llabs' shadows a built-in function
target Executable: iwlist (out/target/product/generic/obj/EXECUTABLES/iwlist_intermediates/LINKED/iwlist)
target Non-prelinked: iwlist (out/target/product/generic/symbols/system/bin/iwlist)
target Strip: iwlist (out/target/product/generic/obj/EXECUTABLES/iwlist_intermediates/iwlist)
Install: out/target/product/generic/system/xbin/iwlist
make: Leaving “/home/qiu/eclair-21”

6. Copy files to the system
qiu@qiubutu:~/eclair-21/external/wireless-tools$ croot
qiu@qiubutu:~/eclair-21$ cp out/target/product/generic/system/xbin/iwconfig /nfs/rootfs/system/xbin/iwconfig
qiu@qiubutu:~/eclair-21$ cp out/target/product/generic/system/xbin/iwlist /nfs/rootfs/system/xbin/

7.Test
After starting Android:

# modprobe libertas
# modprobe libertas_sdio
libertas_sdio: Libertas SDIO driver
libertas_sdio: Copyright Pierre Ossman
model=0xb
sd8686_helper.bin sd8686.bin
init: untracked pid 853 exited
init: untracked pid 856 exited
libertas: eth1: Marvell WLAN 802.11 adapter
# iwconfig eth1                
eth1      IEEE 802.11b/g  ESSID:"Antrose-11g"
          Mode:Managed  Frequency:2.437 GHz  Access Point: 00:15:E9:0C:87:7C
          Bit Rate:1 Mb/s   Tx-Power=13 dBm
          Retry limit:8   RTS thr=2347 B   Fragment thr=2346 B
          Encryption key:off
          Power Management:off
          Link Quality=83/100  Signal level=-60 dBm  Noise level=-93 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:1441
          Tx excessive retries:44  Invalid misc:11220   Missed beacon:0
# iwlist scan
eth1      Scan completed :
          Cell 01 - Address: 00:22:6B:8C:5D:3A
                    ESSID:"Antrose-11g"
                    Mode:Managed
                    Frequency:2.412 GHz (Channel 1)
                    Quality=65/100  Signal level=-78 dBm  Noise level=-96 dBm
                    Encryption key:off
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s
                              24 Mb/s; 36 Mb/s; 54 Mb/s; 6 Mb/s; 9 Mb/s
                              12 Mb/s; 48 Mb/s
# iwconfig eth1 essid Antrose-11g
# iwconfig eth1                
eth1      IEEE 802.11b/g  ESSID:"Antrose-11g"
          Mode:Managed  Frequency:2.437 GHz  Access Point: 00:15:E9:0C:87:7C
          Bit Rate:1 Mb/s   Tx-Power=13 dBm
          Retry limit:8   RTS thr=2347 B   Fragment thr=2346 B
          Encryption key:off
          Power Management:off
          Link Quality=83/100  Signal level=-60 dBm  Noise level=-93 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:1441
          Tx excessive retries:44  Invalid misc:11220   Missed beacon:0

Done.

Monday, April 9, 2012

HowTo - Building Android kernel modules (bcm4329.ko)


This document tells us how to build individual modules instead of compiling the whole kernel. 

bcm4329.ko is the wireless driver module for Google Nexus One. It is located in the kernel files. 

Under kernel directory:

1. Include the arm-eabi- tool directory into the path.

$ export PATH=$PATH:~/android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/

2. Generate the configuration file.

2.1 Use herring_defconfig as the default configuration file.

$ make ARCH=arm herring_defconfig

2.2 Modify the configuration file.

vi .config

Make changes as follows:

CONFIG_CROSS_COMPILE = "arm-eabi-"
CONFIG_LOCAL_VERSION = "-cyanogenmod"
#CONFIG_LOCALVERSION_AUTO
set all CONFIG_BCM* to m

3. Change another file (and I don't know why)

$ vi scripts/setlocalversion
Locate the following line

if $short; then
echo "+"

and change echo "+" to echo ""

5. Set building architecture to be arm.

$ export ARCH=arm

6. Make.

$ make modules

7. Push the new module into the phone.

7.1 Remount to be writable.
  
$ adb remount

7.2 Push.

adb push drivers/net/wireless/bcm4329/bcm4320.ko /system/modules



Ref: http://stevechui.blogspot.com/2011/10/compiling-kernel-modules-tunko-for.html

Wednesday, November 16, 2011

HowTo - TCPDump


Installation[1]




# git clone git://bpf.tcpdump.org/tcpdump                                                                         

Configurations [3]


Change into monitor mode [4]

First
wlanconfig ath0 destroy
And then to create an interface (called ath0) in monitor mode, issue the command:
wlanconfig ath0 create wlandev wifi0 wlanmode monitor
To finish bring the interface up
ifconfig ath0 up

By default, monitor mode receives packets with prism2 headers prepended on them. To change this, you must run one of the following:
  • Only 802.11 headers: echo '801' > /proc/sys/net/ath0/dev_type
  • Prism2 headers: echo '802' > /proc/sys/net/ath0/dev_type
  • Radiotap headers: echo '803' > /proc/sys/net/ath0/dev_type
  • Atheros Descriptors: echo '804' > /proc/sys/net/ath0/dev_type

Command



Capture packets from a particular ethernet interface 


# tcpdump -i ath0 -w file -y IEEE802_11_RADIO
                                                                                       

-i: interface
-y: radiotap header
-w: write into files


Whole package viewing[5]



# tcpdump -nnvvXSs 1514

// the final "s" increases the snaplength, grabbing the whole packet

References


[1] http://www.tcpdump.org/#source
[3] http://www.thegeekstuff.com/2010/08/tcpdump-command-examples/
[4] http://madwifi-project.org/wiki/UserDocs/MonitorModeInterface