2006年12月27日 星期三

chillispot installion

為了Support FON今天試著把chillispot裝到ECS040的平台上,記錄一下裝的過程.

1.Download fonear.tar.gz
2.解開並patch
3.修改configure:20961

else
if test "$cross_compiling" = yes; then
ac_cv_func_malloc_0_nonnull=yes <---------------------------------原來是no改成yes
else

4.CFLAGS="-O2 -G 0 -mips32" LDFLAGS="-lcrypt" ./configure --host=mipsel-linux --target=mipsel-linux --cache-file=/dev/null
5.make
6.在來就將src/chilli擺到target上跑跑看.對了,還需要對應FON hotspot的config file
##############################################################################
#
# Fon ChilliSpot configuration file
# Powered by FON (www.fon.com)
#
##############################################################################
radiusserver1 radius01.fon.com
radiusserver2 radius02.fon.com
radiussecret garrafon
uamserver https://login.fon.com/cp/index.php
uamsecret garrafon
uamallowed www.fon.com,www.paypal.com,www.paypalobjects.com,www.skype.com
uamanydns

7.執行囉.注意要停止原本ath0上的dhcp server
./chilli -c ./chilli.conf --dns1=168.95.1.1 --dhcpif=ath0

8.有個地方有bug.在wireless client連線上由dhcp取得IP後送出的封包會轉送到eth0,這會造成skb_buf的錯誤,然後就panic

/fsdata # skput:under: 8010d2e0:54 put:14 dev:eth0Break instruction in kernel code in traps.c::do_bp, line 689:
$0 : 00000000 10008400 00000028 00000000 801bf900 00000001 00000001 00000001
$8 : 00000001 ffffd95e 0000195e 00000000 fffffffa ffffffff 0000000a 00000001
$16: 811b51a0 82c0f920 803aa0a2 810e6e24 00019923 801b3aa8 801b3a80 82a4de60
$24: 82a4dc89 803b4967 82a4c000 82a4dd70 00000005 800df800
Hi : 00000188
Lo : 002b0cdd
epc : 800df800 Tainted: P
Status: 10008403
Cause : 10800024
PrId : 0001800b
Process chilli (pid: 740, stackpage=82a4c000)
Stack: 00019923 8010d2e0 00000036 0000000e 801cb784 82a4dd90 8010d2f0
80000000 803d7780 82a4ddb8 811b51a0 811b51a0 00000008 810e6e24 801cb784
811b51a0 80107a94 80107d28 80154e54 80154fa4 00000036 801c0cb4 00000000
80107fa0 80000000 82a4de00 82a4de68 00000000 00000000 811b51a0 00000008
00000040 800e5558 800dfe18 811b51a0 8368c2e0 00000000 00000000 810e6e24
00000000 ...
Call Trace: [<8010d2e0>] [<8010d2f0>] [<80107a94>] [<80107d28>] [<80154e54>]
[<80154fa4>] [<80107fa0>] [<800e5558>] [<800dfe18>] [<800e5778>] [<800e593c>]
[<8001b20c>] [<800df938>] [<800e5174>] [<800516c0>] [<800c9190>] [<800c9158>]
[<800c921c>] [<8003ddf4>] [<800dd198>] [<8000ba60>]

Code: 248446c8 0c0057bc afa30010 <0000800d> 8fbf0018 03e00008 27bd0020 3c02803c 8c4289e4
Kernel panic: Aiee, killing interrupt handler!
In interrupt handler - not syncing


Trace一下吧

net/core/skbuff.c

void skb_under_panic(struct sk_buff *skb, int sz, void *here)
{
printk("skput:under: %p:%d put:%d dev:%s",
here, skb->len, sz, skb->dev ? skb->dev->name : " ");
BUG(); <-------------------------------------------就在這裡死啦
}

include/linux/skbuff.h

/**
* skb_push - add data to the start of a buffer
* @skb: buffer to use
* @len: amount of data to add
*
* This function extends the used data area of the buffer at the buffer
* start. If this would exceed the total buffer headroom the kernel will
* panic. A pointer to the first byte of the extra data is returned.
*/

static inline unsigned char *skb_push(struct sk_buff *skb, unsigned int len)
{
skb->data-=len;
skb->len+=len;
if(skb->data head) {
skb_under_panic(skb, len, current_text_addr());
}
return skb->data;
}

馬的,找到真正的原因了,Inferone提供的kernel裡有個Netfilter->Turbo NAT.拿掉就好了







2006年12月21日 星期四

Wireless Destribute System (WDS)



http://www.homeoffice.idv.tw/archives/000689.html

http://en.wikipedia.org/wiki/Wireless_Distribution_System


WDS can be used to provide two modes of wireless AP-to-AP connectivity:


  • Wireless Bridging in which WDS APs communicate only with each other and don't allow wireless clients or Stations (STA) to access them
  • Wireless Repeating in which APs communicate with each other and with wireless STAs

http://www.geocities.com/backgndtest/wlan_tut.html


http://www.meshnode.org/wiki/index.php/Madwifi-WDS-Bridge


WDS is used between Access Points to allow transparent bridging of two ethernets over a wireless link.


Linux wireless WDS


Model




<1.1>.P-to-P WDS support
/*Create WDS device*/
wlanconfig wds0 create wlandev wifi0 wlanmode wds
/*Add WDS peer MAC address*/


iwpriv wds0 wds_add XX:XX:XX:XX:XX:XX
/*Enable WDS*/
iwpriv wds0 wds 1


/*Set ip address*/


/*Attention !!! Both WDS peer must at the same network*/
ifconfig wds0 172.16.100.1


/*Destroy it*/
wlanconfig wds0 destroy




<2.1>.Access Point with WDS support (Multi Bridge)
wlanconfig wds0 create wlandev wifi0 wlanmode ap


iwconfig wds0 essid "WDS_AP"


< Modify Mac filter >


/*Enable WDS support*/
iwpriv wds0 wds 1
iwconfig wds0 key s:xxxxx <------可支援WEP


iwpriv wds0 maccmd X


iwpriv wds0 addmac XX:XX:XX:XX:XX:XX <------可支援Mac filter

brctl addif br0 wds0 <------加入DHCP server服務範圍


ifconfig wds0 up


/*Destroy it*/
brctl delif br0 wds0
wlanconfig wds0 destroy


<2.2>.Access Point + WDS Station (Repeater)
/*Create WDS station*/
wlanconfig wds0 create wlandev wifi0 wlanmode sta nosbeacon
iwconfig wds0 essid "WDS_AP"
iwpriv wds0 wds 1


iwconfig wds0 key s:xxxxx <------可支援WEP


ifconfig wds0 up


brctl addbr br1


brctl addif br1 ath0
brctl addif br1 wds0 <------透過WDS通道使用DHCP服務


/*Destroy it*/
brctl delif br0 wds0
wlanconfig wds0 destroy


2006年12月11日 星期一

802.11技術規格筆記

1.規格簡述


802.11a : Freq 5 GHz, Max speed 54 Mbps, PHY OFDM(Orthogonal frequency division multiplexing)


802.11b : Freq 2.4 GHz, Max speed 11 Mbps, PHY HR/DSSS(High Rate/Direct Sequence Spread Spectrum)


802.11g : Freq 2.4 GHz, Max speed 54 Mbps, PHY OFDM


 


2.IEEE 802.11 specification


Including 3 layer : LLC (Logical Link Control), MAC(Media Access Control), PHY(Phyical layer)


There are one MAC and two PHY layer in 802.11


Component : Station, Access point, Wireless media (RF), Distribution system (Bridge)


Network type (Basic Service Set) : 


  -> Independent BSS (ad hoc bss) : Peer to peer network


  -> Infrastructure BSS : Station type network


  -> ESS (Extended Service Set) : 以骨幹網路將BSS串聯在一起提供服務,並擁有相同的SSID (Service Set Identifier)


 


Wi-Fi Multimedia (WMM) and WMM Power Save modes. WMM adds Quality of Service (QoS) capabilities to Wi-Fi networks. WMM Power Save is an improvement to the 802.11e amendment adding advanced power management functionality to WMM. WMM Power Save is based on Unscheduled Automatic Power Save Delivery (U-APSD), which, like WMM, is based on Enhanced Distributed Channel Access (EDCA). U-APSD is a solution well suited for dynamic environments where Wi-Fi is generally deployed and allows clients supporting U-APSD to download all or some of the frames buffered by the access point during unscheduled service periods.


關於WME


考慮到基於時間的數據傳輸的QoS重要性,在IEEE正式批准802.11e標準(預計在2005年上半年)之前,已經有一些無線設備製造商開始在實施能基本滿足近期需要的QoS機制,這些大都是基於EDCF的,最有代表性的就是由Wi-Fi聯盟開發的WME(Wireless Mutimedia Enhancements)技術。WME技術並不是除802.11e標準之外的又一個標準,它實際上只是部份地使用了EDCF的標準,所以WME技術是802.11e的一個子集,或者說是在802.11e正式批准之前的過渡標準。一旦802.11e被批准,採用WME技術的設備都可以升級到802.11e標準。


另外,Wi-Fi聯盟還提出了無線計畫媒體(WSM,Wireless Scheduled Multimedia)技術,這是基於HCF機制的增強QoS的技術。Wi-Fi聯盟將初步使用WME,當802.11e標準最終批准之後才有可能採用WSM。


2006年11月6日 星期一

後龍站積分賽

影片

Hostapd configuration

./hostapd /etc/hostapd.conf

With debug message
./hostapd -dd /etc/hostapd.conf

/etc/hostapd.conf的範例如下

interface=ath0
bridge=br0
driver=madwifi
logger_syslog=-1
logger_syslog_level=0
logger_stdout=-1
logger_stdout_level=0
debug=0
ssid=imhotep
macaddr_acl=0
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0
wpa=1
#wpa_psk_file=/etc/hostapd.wpa_psk
wpa_passphrase=abcdefgh
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
wpa_group_rekey=600
wpa_gmk_rekey=86400

1.WPA
# This field is a bit field that can be used to enable WPA (IEEE 802.11i/D3.0)
# and/or WPA2 (full IEEE 802.11i/RSN):
# bit0 = WPA
# bit1 = IEEE 802.11i/RSN (WPA2) (dot11RSNAEnabled)

wpa = 1 /*WPA*/
wpa = 2 /*WPA2*/
wpa = 3 /*WPA, WPA2*/

2.Key management
# Set of accepted key management algorithms (WPA-PSK, WPA-EAP, or both).

wpa_key_mgmt=WPA-PSK
wpa_key_mgmt=WPA-EAP
wpa_key_mgmt=WPA-PSK WPA-EAP

3.Encryption algorithms
# Set of accepted cipher suites (encryption algorithms) for pairwise keys
# (unicast packets). This is a space separated list of algorithms:
# CCMP = AES in Counter mode with CBC-MAC [RFC 3610, IEEE 802.11i/D7.0]
# TKIP = Temporal Key Integrity Protocol [IEEE 802.11i/D7.0]

wpa_pairwise=TKIP
wpa_pairwise=CCMP
wpa_pairwise=TKIP CCMP

Attention !!!
Remember to insmod wlan_ccmp driver while using CCMP

4.WPA Key
# WPA pre-shared keys for WPA-PSK. This can be either entered as a 256-bit
# secret in hex format (64 hex digits), wpa_psk, or as an ASCII passphrase
# (8..63 characters) that will be converted to PSK. This conversion uses SSID
# so the PSK changes when ASCII passphrase is used and the SSID is changed.
# wpa_psk (dot11RSNAConfigPSKValue)
# wpa_passphrase (dot11RSNAConfigPSKPassPhrase)

wpa_psk=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
wpa_passphrase=abcdefgh



2006年11月5日 星期日

Wirless tools by examples

1.列出可用的頻道及目前所使用的頻道


~ # iwlist ath0 channel
ath0 26 channels in total; available frequencies :
Channel 01 : 2.412 GHz
Channel 02 : 2.417 GHz
Channel 03 : 2.422 GHz
Channel 04 : 2.427 GHz
Channel 05 : 2.432 GHz
Channel 06 : 2.437 GHz
Channel 07 : 2.442 GHz
Channel 08 : 2.447 GHz
Channel 09 : 2.452 GHz
Channel 10 : 2.457 GHz
Channel 11 : 2.462 GHz
Channel 12 : 2.467 GHz
Channel 13 : 2.472 GHz
Current Frequency:2.422 GHz (Channel 3)


2.設定使用的第9頻道(2.452 GHz)
iwconfig ath0 channel 9


3.列出支援的傳輸速率
~ # iwlist ath0 rate
ath0 12 available bit-rates :
1 Mb/s
2 Mb/s
5.5 Mb/s
11 Mb/s
6 Mb/s
9 Mb/s
12 Mb/s
18 Mb/s
24 Mb/s
36 Mb/s
48 Mb/s
54 Mb/s
Current Bit Rate:0 kb/s


4.設定傳輸速率
~ # iwconfig ath0 rate 54M


5.載入wireless driver.啟動wireless interface並設定為access point
#載入driver且不create athX interface
modprobe ath_pci autocreate=none
#載入wep driver
insmod wlan_wep
wlanconfig ath0 destroy
#Create ath0 & wifi0 interface.設定為access point
wlanconfig ath0 create wlandev wifi0 wlanmode ap


6.設定ESSID
iwconfig ath0 essid myap


7.設定WEP encryption key


WEP encryption key 有64bits及128bits兩種.分別可以5及13個字元或10及26個十六進位數值.
同時可以有四把key可以使用.


~ # iwlist ath0 key
ath0 3 key sizes : 40, 104, 128bits
4 keys available :
[1]: 3132-3334-3637-1234-0000-1111-23 (104 bits)
[2]: off
[3]: off
[4]: off
Current Transmit Key: [1]
Security mode:restricted


#40-bit WEP (also known as 64-bit WEP with 40 secret bits)
#104-bit WEP (also known as 128-bit WEP with 104 secret bits)


#Set current key equal to string "abcde"
iwconfig ath0 key s:abcde
#Set key[1] equal to hex value 0123-4567-89
iwconfig ath0 key [1] 0123-4567-89
iwconfig ath0 key s:abcdefghijklm
iwconfig ath0 key 0123-4567-8901-2345-6789-0123-45


Security mode
有兩種模式open及restricted. 在open mode下不需要認證也會允許未加密的連線.在restricted mode下,加密認證是必要的.


#Set restricted mode, key[2] = abcde
iwconfig ath0 key restricted [2] s:abcde


關閉取消key
#Disable all key
iwconfig ath0 key off


設定使用的Key
#Set current key by key index 2
iwconfig ath0 key [2]


關閉AccessPoint
wlanconfig ath0 destroy


啟動AccessPoint
wlanconfig ath0 create wlandev wifi0 wlanmode ap


設定ESSID
iwconfig ath0 essid imhotep


加入Bridge control
brctl addif br0 ath0


設定physical layer
iwconfig ath0 channel 0
iwpriv ath0 mode 0 /*0 = auto, 1 = a, 2 = b, 3 = g*/


設定mac filter規則
iwpriv ath0 maccmd 0 /*No ACL checking is performed*/
iwpriv ath0 maccmd 1 /*Only allow ACLs in the ACL list*/
iwpriv ath0 maccmd 2 /*Only deny ACLs in the ACL list*/
iwpriv ath0 maccmd 3 /*Clear ACL list*/
iwpriv ath0 maccmd 4 /*Clear ACL list and no ACL checking is performed*/


加入mac address到ACL list
iwpriv ath0 addmac 00:11:22:33:44:55


刪除ACL list中的mac address
iwpriv ath0 delmac 00:11:22:33:44:55


進階設定
1.Beacon interval ( Default : 100, Milliseconds, Range : 1 - 65535)
iwpriv ath0 bintval 100


2.RTS/CTS Threshold ( Default : off, Range : 1 - 2346) , The smallest packet for which the node send RTS.
iwconfig ath0 rts 2346
iwconfig ath0 rts off /*Disable RTS*/


3.DTIM interval ( Default : 1, Range : 1 - 255)
iwpriv ath0 dtim_period 1


4.Atheros SuperA/G bursting mode (Default 1)
iwpriv ath0 burst 0 /* 1 Enable, 0 Disable */


2006年9月13日 星期三

PowerPC linux 2.4.19 to 2.6.18-rc4 porting

Processor : MPC8241
Platform : ECS320

Some important constant variable

/* Accroding Address Map B  */ 
#define ECS320_ISA_IO_BASE 0xFE000000

#define ECS320_ISA_MEM_BASE 0xFD000000

#define ECS320_PCI_MEM_BASE 0x80000000
#define ECS320_PCI_MEM_OFFSET 0x00000000

/* defined by ourself */
#define ECS320_EUMB_BASE 0xFDF00000
...
#define MPC82XX_CONFIG_ADDR_ADDR 0xFEC00000
#define MPC82XX_CONFIG_DATA_ADDR 0xFEE00000
#define MPC82XX_CONFIG_BASE 0x80000000




2006年8月24日 星期四

Linux wireless access point

基礎認識Wireless communication


Chipset : Atheros 5212


Platform : ADM-5120 mipsel linux-2.4.31


Driver : MadWifi version r1705
Mipsel 的設定檔在 hal/public/mips-le-elf.inc, 去掉COPTS中的-EL選項.
另一個需要修正的地方在 Makefile.inc, 去掉COPTS中Werror選項.這個東西會把Warning當做Error來處理,也就是中段編譯.
編 譯完成後會有ath_hal.o ath_pci.o ath_rate_sample.o wlan_acl.o wlan_ccmp.o wlan.o wlan_scan_ap.o wlan_scan_sta.o wlan_tkip.o wlan_wep.o wlan_xauth.o.這些都是kernel module. 另外還有一些工具會在tools/目錄中,其中很重要的是wlanconfig.
在busybox的環境中建立module dependence的方式如下.
./examples/depmod.pl --stdout -b ./ramdisk/lib/modules/2.4.31-ADM5120 -k ../linux_2_4_31/vmlinux -F ../linux_2_4_31/System.map


產生modules.dep


這時候會有錯誤 :
unresolved symbol crypto_alloc_tfm in file /lib/modules/2.4.31-ADM5120/net/wlan_ccmp.o
unresolved symbol crypto_cipher_encrypt in file /lib/modules/2.4.31-ADM5120/net/wlan_ccmp.o
unresolved symbol crypto_cipher_setkey in file /lib/modules/2.4.31-ADM5120/net/wlan_ccmp.o
unresolved symbol crypto_free_tfm in file /lib/modules/2.4.31-ADM5120/net/wlan_ccmp.o


經過檢查這幾個function在kerne source中的crypto/api.c,但是並沒有被編譯在kernel中.我嘗試強制將它加入crypto/Makefile並編譯,Error...Error..Error...
wlan_ccmp.o這個module主要是負責AES加解密,我暫時將它移除讓module dependence可以順利完成.
今天看了一下linux-2.4.33的source發現crypto的部份跟偶目前linux-2.4.31有很大的差異.直接copy過來 compile看看.crypto_alloc_tfm, crypto_cipher_encrypt, crypto_cipher_setkey, crypto_free_tfm這幾個symbol就都找到了.問題算是解決了.