2009年12月22日 星期二

httptunnel usage

Q. How to configure the httptunnel as a debug mode package
A.
# ./configure --enable-debug --prefix=/usr/local/httptunnel

Afterwards, you will find the DEBUG config turn on in the config.h
# cat config.h | grep DEBUG
#define DEBUG_MODE 1

// Then you can compile the httptunnel package as usual to produce a debug-version program
# make clean all


// Test Cases as following examples
// Non-Proxy example
// In server side, listen on port 80, telnetd (port 23) is the real service
# ./hts -F localhost:23 -D 4 80

// In client side, listen on the port 23 (for user fully transparency), redirect to the server port 80 using HTTP POST as the intermediate protocol
# ./htc -F 23 -D 4 Server-IP:80

2009年12月18日 星期五

Linux Command - hostname

// Do the hostname positive/negative resolution

// hostname will print the name of the system as returned by the gethostname(2) function.
# hostname

// "-a", Display the alias name of the host (if used).
# hostname -a
// "-f", Display the FQDN (Fully Qualified Domain Name). A FQDN consists of a short host name and the DNS domain name. Unless you are using bind or NIS for host lookups you can change the FQDN and the DNS domain name (which is part of the FQDN) in the /etc/hosts file.
# hostname -f

http://www.faqs.org/docs/securing/chap9sec95.html

example /etc/hosts file:
IPAddress Hostname Alias
127.0.0.1 localhost deep.openna.com
208.164.186.1 deep.openna.com deep
208.164.186.2 mail.openna.com mail
208.164.186.3 web.openna.com web

The leftmost column is the IP address to be resolved. The next column is that host's name. Any subsequent columns are alias for that host. In the second line, for example, the IP address 208.164.186.1 is for the host deep.openna.com. Another name for deep.openna.com is deep.

2009年12月16日 星期三

Linux Command - cvs tar/rtag/branch

// mark a new cvs tag "abc123"
# cvs tag abc123
T turn/lib/TurnClient.hxx ==> mark as "T" label
T turn/lib/TurnHmac.cxx
T turn/lib/TurnHmac.hxx
T turn/lib/TurnMsg.cxx
T turn/lib/TurnMsg.hxx
T turn/lib/log.cxx

// Mark a cvs tag "abc456" on a existing cvs branch
# cvs tag -r sipBranch abc456
# cvs st -v Makefile
userName@1.2.3.4's password:
===================================================================
File: Makefile Status: Up-to-date

Working revision: 1.38
Repository revision: 1.38 /home/cvs/XXX/Makefile,v
Sticky Tag: (none)
Sticky Date: (none)
Sticky Options: (none)

Existing Tags:
abc456 (revision: 1.32) ==> This is produced by cvs tag
abc123 (revision: 1.38) ==> This is produced by cvs tag
sipBranch (branch: 1.32.2) ==> This is produced by cvs rtag -b
main (revision: 1.1.1.1) ==> This is produced by cvs import
vendor (branch: 1.1.1) ==> This is produced by cvs import


# cvs rtag -r branchABC -b branchABC_123 myProjectName
userName@1.2.3.4's password:
cvs rtag: warning: cannot open /home/cvs/CVSROOT/val-tags read/write: Permission denied
cvs rtag: Tagging myProjectName
cvs rtag: Tagging myProjectName/AutoTestAgent
cvs rtag: Tagging myProjectName/AutoTestAgent/AutoTestAgent


// cvs revision/branch 版號的制定邏輯請見下面分析
// 查看目前local 端skype 檔案的目前狀態,目前client 端工作版本為1.3.2.1.2.1, CVS Server 端的版本為1.3.2.1.2.1 (一樣),
目前client 端的檔案是隸屬於ID_1_6 這個branch的分支

// 另外在下面有列出目前隸屬於skype 這個檔案所有的tag name, branch name, 由這邊可知,
目前共存在有3個branch

[root@nestlin-7 l7fw]# cvs st -v ./skype
userName@1.2.3.4's password:
===================================================================
File: skype Status: Up-to-date ==> client 與server 的檔案一致

Working revision: 1.3.2.1.2.1 ==> Client 端, Working Directory revision
Repository revision: 1.3.2.1.2.1 ==> Server 端, Repository Directory revision
Sticky Tag: ABC_123 (branch: 1.3.2.1.2) ==> 目前Working Directory 的branch/revision
Sticky Date: (none)
Sticky Options: (none)

Existing Tags:
PPP_1_6 (branch: 1.5.2)
ABC_123 (branch: 1.3.2.1.2)
III_123 (branch: 1.3.2)

# cvs log ./skype
userName@1.2.3.4's password:

RCS file: /home/cvsroot/X/Y/Z/skype,v
Working file: skype
head: 1.6
branch:
locks: strict
access list:
symbolic names:
PPP_1_6: 1.5.0.2
ABC_123: 1.3.2.1.0.2
III_123: 1.3.0.2

keyword substitution: kv
total revisions: 13; selected revisions: 13
[omit]
----------------------------
revision 1.3
date: 2005/03/04 09:59:51; author: userName; state: Exp; lines: +3 -3
branches: 1.3.2; ==> 從這邊可以知道有切一個branch 1.3.2, 參考上面cvs st -v 的指令可知道,其branch name 為III_123
User Commit Descriptions
----------------------------
[omit]
revision 1.3.2.1
date: 2005/03/09 09:06:03; author: userName; state: Exp; lines: +1 -0
branches: 1.3.2.1.2; ==> 從這邊可以知道有切一個branch 1.3.2.1.2, 參考上面cvs st -v 的指令可知道,其branch name 為ABC_123
User Commit Descriptions
----------------------------
[omit]

# cvs st -v Makefile
userName@1.2.3.4's password:
===================================================================
File: Makefile Status: Up-to-date

Working revision: 1.38
Repository revision: 1.38 /home/cvs/XXXXX/Makefile,v
Sticky Tag: (none)
Sticky Date: (none)
Sticky Options: (none)

Existing Tags:
branch_1_32_branch_20091216 (revision: 1.32)
tag456 (revision: 1.38)
branch_1_32 (branch: 1.32.2)
main (revision: 1.1.1.1)
vendor (branch: 1.1.1)

# cvs log Makefile | more
userName@1.2.3.4's password:

RCS file: /home/cvs/XXXXX/Makefile,v
Working file: Makefile
head: 1.38
branch:
locks: strict
access list:
symbolic names:
branch_1_32_branch_20091216: 1.32
tag456: 1.38
branch_1_32: 1.32.0.2
main: 1.1.1.1
vendor: 1.1.1
keyword substitution: kv


從上面的情況可知
原先在main trunk上面有切了一個branch III_123 (branch 1.3.2), 後來又在該branch (1.3.2) 上面又切了一個branch ABC_123(1.3.2.1.2), 這裡可以做出下面的結論
1. main trunk 的revision 是從1.1, 1.2, 1.3開始的
2. 如果從main trunk 切branch, 則branch 會變成1.X.Y (e.g. 如果從1.3切branch, 則新版號為1.3.2), 如果是從第一層branch 要切第二層branch, 則版號會是1.3.2.M.N (e.g. 譬如上面從III_123 branch 1.3.2 的子版本1.3.2.1 切出來, 版號會變成1.3.2.1.2
所以
main trunck 的revision main number 為1(1碼), main+sub revision number為1.M(2碼, 從1.1開始)
第一層branch 的revision main number 為1.M.2(3碼), main+sub revision number為1.M.2.N(4碼, 從1.M.2.1開始)
第二層branch 的revision main number 為1.M.2.N.2(5碼), main+sub revision number為1.M.2.N.2.O(6碼, 從1.M.2.N.2.1開始)
==> 結論cvs revision 奇數碼數為branch (如1.3.2), 偶數碼數為tag (如1.32), 只有偶數碼才是真正的revision number, 奇數碼只是main trunk/branch 的base而已
3. symbolic names 和 Existing Tags的關係如下
Existing Tags 表示該branch/tag是從哪一個原先的版號切出來的
Symbolic names 則是一個CVS 內部版號link mark(不確定是否正確), 碼數固定為偶數碼, 其規則如下
a. branch 將原先的Existing Tag 尾碼 .2 改成 .0.2, 例如上面branch branch_1_32 1.32.2, 其Symbolic name為1.32.0.2
b. revision 的Existing Tag 和 Symbolic 的revision完全相同
c. 上面a點所描述的情形中, 唯一會有例外的是vendor branch, 這是利用cvs import 所產生的imitial project(將既存的project import到cvs repository當中), 如下所示
cvs import -m "initial" project-name vendor main

會發現vendor 這個branch在 Existing TAG 和 Symbolic Name 上面的revision 完全相同, 而且這是一個branch, 可能這個vendor branch 對cvs而言有特別的意義?

2009年12月14日 星期一

Public STUN servers

Public STUN servers

* stun.ekiga.net (alias for stun01.sipphone.com)
* stun.fwdnet.net (no XOR_MAPPED_ADDRESS support)
* stun.ideasip.com (no XOR_MAPPED_ADDRESS support)
* stun01.sipphone.com
* stun.softjoys.com (no DNS SRV record) (no XOR_MAPPED_ADDRESS support)
* stun.voipbuster.com (no DNS SRV record) (no XOR_MAPPED_ADDRESS support)
* stun.voxgratia.org (no DNS SRV record) (no XOR_MAPPED_ADDRESS support)
* stun.xten.com
* stunserver.org see their usage policy
* stun.sipgate.net:10000
* numb.viagenie.ca (http://numb.viagenie.ca) (XOR_MAPPED_ADDRESS only with rfc3489bis magic number in transaction ID)
* stun.ipshka.com inside UA-IX zone russsian explanation at http://www.ipshka.com/main/help/hlp_stun.php

Linux Command - update password

# chage -l foo << list the password related information about the user "foo"
Last password change : Dec 14, 2009
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7

2009年12月10日 星期四

Linux Development - Makefile, gcc

Makefile tips

-include $(TARGET_HOME)/.config
-include $(TARGET_HOME)/release.mak
==> while we add the prefix sign "--" in front of include statement, it means that if the include file is not exist, this statement is still ok without any error



Sample Makefile:
all: testLibiptcless1

testLibiptcless1: testLibiptcless1.c
gcc -Wall -Wunused -DNETFILTER_VERSION=\"1.2.6\" -rdynamic -o $@ $< \
/usr/local/lib/iptables.o /usr/local/lib/libiptc.a -ldl ==> We can link the other object file directly in the gcc command, remember be aware put all the linked libraries after the source code/output executed files

Sometimes we need some parameters inside the function (maybe for further usage). But that parameter is currently not used. So we can declare the attribute after the unused parameter. The attribute is declared as following usage.

#if defined(__GNUC__)
# define dlna_unused __attribute__((unused)) ==> define the dlna_unused
#else
# define dlna_unused
#endif

void
soap_device_callback( IN http_parser_t * parser dlna_unused, // we tag the dlna_unused here to quiet the gcc produce the Warning messages
IN http_message_t * request,
INOUT SOCKINFO * info )



-Wunused causes gcc to complain about unused parameters. This is often a good thing, if it makes you check twice whether you mistyped a variable name or forgot to implement something. But sometimes you really need to have a parameter which is not used, perhaps because the function needs to match a particular prototype.

gcc has a __attribute__((unused)) thing you can apply to paramters to quieten the warning. This actually means possibly unused: if you do use the parameter, gcc doesn't complain. So with unused alone, you can make errors in the opposite direction.

Linux Development - ccache

Use the following method to show the gcc
# readlink -f $(which gcc)
/usr/bin/ccache

# which gcc
/usr/lib/ccache/gcc
# ls -la /usr/lib/ccache/gcc
lrwxrwxrwx 1 root root 16 2008-02-27 01:05 /usr/lib/ccache/gcc -> ../../bin/ccache ==> Actually the gcc was link as a ccache

ccache
ccache is a compiler cache. It acts as a caching pre-processor to C/C++ compilers, using the -E compiler switch and a hash to detect when a compilation can be satisfied from cache. This often results in a 5 to 10 times speedup in common compilations.

The idea came from Erik Thiele wrote the original compilercache program as a bourne shell script. ccache is a re-implementation of Erik's idea in C with more features and better performance.

2009年12月3日 星期四

Linux Development - Cross Compilation

Q. How to compile the libpcap in the linux x86 enviroment for the ARM target?

>> Before compile the package. We need to setup the related tools as the cross compiler toolchain tools as following.
# set | grep arm
AR=arm-linux-uclibc-ar
AS=arm-linux-uclibc-as
BUILD='-Os -mtune=arm9e -march=armv5te'
CC=arm-linux-uclibc-gcc
CROSS_TARGET=arm-linux-uclibc
CXX=arm-linux-uclibc-g++
LD=arm-linux-uclibc-ld
RANLIB=arm-linux-uclibc-ranlib
READELF=arm-linux-uclibc-readelf
STRIP=arm-linux-uclibc-strip


# ac_cv_linux_vers=2 ./configure --host=arm --build=arm-linux --prefix=/usr/local/libpcap

How to instruct the configure to build the crosscompile code version of iperf
For example of ARM device target
# ./configure --host="armeb-linux" --enable-debuginfo --prefix=/pat/prefix

Linux Service - Monitoring tools

Cacti
* http://www.cacti.net/
* written in PHP

MRTG
* http://oss.oetiker.ch/mrtg/
* written in Perl

Embedded Linux - scratchbox/MontaVista

http://www.scratchbox.org/

A brief summary of features:
* Scratchbox is used by Maemo development platform (Nokia 770). But it is not restricted to that use.
* Supports ARM and x86 targets (PowerPC, MIPS and CRIS targets are experimental)
* Especially Debian is supported, but Scratchbox has also been used to cross-compile eg. Slackware for ARM.
* Provides glibc and uClibc as C-library choices
* Uses either QEMU or a real target hardware to execute cross-compiled binaries (extremely useful when cross-compiling software which uses autoconf & co.)



MontaVista Linux
http://www.mvista.com/

2009年12月2日 星期三

Linux Command - source

read the linux bash scripts
# source script files
e.g.
# source $HOME/.bashrc
# source $HOME/.cshrc
# source crosstools-env.sh

Network Routing and IP info

Show myIP (NAT server reflexive IP address)

http://www.dheart.net/ip/

http://ipid.shat.net/

http://www.ip-adress.com/

Show the routing info in Taiwan (from TWNIC)
http://map.twnic.net.tw/bwimages/dirFDCy2009s1m1/pageDisplayConnect.htm

Show the ip geography and your ip info
http://dir.twseo.org/ip-check.php

Linux Command - man, less

man -S section command
e.g.
# man -S 1 ls

Show all man pages
# man -a netstat

specified the man page to display, less is the default PAGER/BROWSER of man
# /usr/bin/less -is pure-ftpd.8

man config file
/etc/man.config

2009年12月1日 星期二

Linux Command - rdesktop

A tool that can help you to connect to Windows Terminal from linux client
http://www.rdesktop.org/

>> install the remote desktop client
# yum install rdesktop.i386

>> connect to Windows Server
# /usr/bin/rdesktop IP:port
e.g. /usr/bin/rdesktop 1.2.3.4:5678

Linux Command - readlink

readlink - display value of a symbolic link

Just display the real program, not the soft link
# readlink -f $(which gcc)
/usr/bin/ccache

# readlink -f $(which tcpdump)
/usr/sbin/tcpdump