Thursday, March 27, 2008

iptables compile

1. check out a iptables from SVN
svn co https://svn.netfilter.org/netfilter/trunk/iptables
2. cd iptables
3. run autogen.sh, here is the content of autogen.sh
#!/bin/bash
autoreconf -fi;
rm -Rf autom4te*.cache;
--------------------------------------
This will generate configure

4. run ./configure with following option, or run_configure with content as below

./configure CC=powerpc-405-linux-gnu-gcc --build=powerpc-405-linux-gnu --target=powerpc-amcc-linux --host=powerpc-amcc-linux --with-kernel=/localhome/wli/linux-2.6.24 --with-ksource=/localhome/wli/linux-2.6.24 --with-gnu-ld

5. run ./made with content as below
#!/bin/bash
if [ -n "$1" ]; then
linux_path=$1
else
linux_path="/localhome/wli/linux-2.6.24"
fi
mv $linux_path/include/linux/errno.h $linux_path/include/linux/errno_org.h
ln -s $linux_path/include/asm-generic/errno.h $linux_path/include/linux/errno.h
make CC=powerpc-405-linux-gnu-gcc KERNEL_DIR=$linux_path KBUILD_OUTPUT=""
mv $linux_path/include/linux/errno_org.h $linux_path/include/linux/errno.h


Tuesday, March 18, 2008

how to compile dnrd package

1. untar dnrd package
tar xvfz dnrd-2.20.3.tar.gz
2. cd dnrd-2.20.3
./configure CC=powerpc-405-linux-gnu-gcc --host=powerpc-amcc-linux --build=powerpc-405-linux-gnu --target=powerpc-amcc-linux
3. run make

How to build AR680 image

1. Untar ar680w package
tar xvfz ar680w_v1.00_gpl.070802.tgz
2. cd ar680
Run ./build_tool_chain
3. Edit setupenv
change arm crosstool path to /localhome/wli/ar680/crosstol/....
4. make
5. make
6. After build sucessfully, here is the message..
WRG-N15 make F/W image (release image)!
boundary: 0x10000 (64K)
output: raw.img
input(0): kernel.img
input(1): rootfs.img
Opening file (0): kernel.img ...
Input File ------ size : 0x000c2084 (794756)
Add IN File ----- size : 0x000c2084 (794756)
Opening file (1): rootfs.img ...
Input File ------ size : 0x001af000 (1765376)
Output File ----- size : 0x000c2084 (794756)
Output Pack To -- size : 0x000d0000 (851968)
Tags Added ------ size : 0x000d0028 (852008)
Add IN File ----- size : 0x0027f028 (2617384)
packimgs exit with code 0.
Create a new image file web.img
image header ----------------------------------------
signature : [wrgn15_airlink_ar680w]
magic : 0x20040220
-----------------------------------------------------
input image file ------------------------------------
file length : 2617384 (0x27f028)
file peek : 5d00008000508a210000000000000062
digest : 8359a62ad10c0c8930c360fa8283f3a9
-----------------------------------------------------
v2 image block header -------------------------------
Little endian image !
magic : 0x20040220
size : 2617384 (0x27f028)
offset : 0 (0x0)
devname : /dev/mtdblock/1
digest : 8359a62ad10c0c8930c360fa8283f3a9
-----------------------------------------------------
-----------------------------------------------------
Image file : ar680w_v1.00_83id.bin
Signature : wrgn15_airlink_ar680w
Build number : 83id
-----------------------------------------------------
-rw-rw-r-- 1 wli wli 2617496 Mar 18 13:44 images/ar680w_v1.00_83id.bin

Friday, March 14, 2008

How to set timezone in busybox

busybox time display utility date, by default use UTC zone. To change time zone to PST.
set TZ=PST8PDT, where PST is a acrynom for Pacific standard time, 8=PST is 8 hours ealier than UTC, PDT=pacific daylight saving time.

To change to mountain time, which is GMT-6. set TZ=MST6MDT.

Another example.
TZ=NST3:30NDT1:30
This means that Newfoundland Standard Time (NST) is 3.5 hours
earlier than Coordinated Universal Time (UTC). Both standard
time and daylight saving time apply to this locale. Newfoundland
Daylight Time is 1.5 hours earlier than Coordinated Universal
Time (UTC).


Wednesday, March 12, 2008

how to setup httpd, CGI script on busybox

1. httpd setup--Hyper Text Transfer Protocol Daemon

Two ways of launching httpd daemon-- with inetd and standalone. To launch httpd in inetd, add a line to the /etc/inetd.conf
http stream tcp nowait root /usr/sbin/httpd httpd -i -h /www

Note: -i switch indicates httpd to be launched by inetd super daemon and -h indicates the http home directory is /www. All the webpages should be under /www. To make http service more secure, we probably should not use root user. Instead we should change root user to apach(or whatever user account). Create the user account apach, here is the line in /etc/passwd
apach:x:48:48:webaccess:/www:/bin/false
and the line in /etc/group
apach:x:48:
and the line in /etc/shadow
apach:x:48:
Change the ownership of /www and /etc/httpd.conf to apach
chown apach:apach /etc/httpd.conf
chown -R apach:apach /www


By default, it will look for /etc/httpd.conf for
setup information Here is a sample httpd.conf

#httpd.conf
A:127.0.0.1
A:172.30. #Allow address from 172.30.0.0/16

D:* # Deny from any other IP connec
tions
/cgi-bin:wli:123456 #require user wli, password on url starting with /cgi-bin

This configuration only allow local host and machines 172.30/16 subnet to have http access. For any script in cgi-bin directory, it requires username wli and password 123456. Password can be encrypted with MD5 hash.

In addition, make sure http is in the /etc/service. It should look like
http 80/tcp # WorldWideWeb H
TTP
http 80/udp # WorldWideWeb HTTP


The above lines open up port 80 for http traffic. That's the default port for http access. We can change toe other port as well if needed.

Create a html test page called index.html and put it in directory /www

When you open up the page(http://172.30.80.24/index.html or simply http://172.30.80.24) f rom any 172.30 subnet machine, it will look like the following

Hello, this is a test page.


2. CGI script setup

CGI script is an executable program. It can be written in any language supported by the server machine. All CGI script will be placed in /www/cgi-bin directory. As configured in httpd.conf. The username and password are required to run the CGI script.

The following is a sample CGI script. Make sure the script has executable permission.

This sample script is a shell script. It will execute env command on server machine and send the result back in html format. Here is the output(http://172.30.80.24/cgi-bin/test).

GATEWAY_INTERFACE=CGI/1.1
REMOTE_USER=wli
USER=root
REMOTE_ADDR=172.30.80.21
QUERY_STRING=
HOME=/
AUTH_TYPE=Basic
HTTP_USER_AGENT=Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12
SCRIPT_FILENAME=/www/cgi-bin/test.cgi
REQUEST_URI=/cgi-bin/test.cgi
inetd_dummy=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
SERVER_SOFTWARE=busybox httpd/1.9.1
TERM=vt102
PATH=/sbin:/usr/sbin:/bin:/usr/bin
SERVER_PROTOCOL=HTTP/1.0
PATH_INFO=
SHELL=/bin/sh
REQUEST_METHOD=GET
PWD=/www/cgi-bin
SCRIPT_NAME=/cgi-bin/test.cgi