http://www.ubnt.com/nanostationloco
only $49
October 19, 2010
October 8, 2010
Difference between typedef and define in C
here are two differences between define and typedef.
Firstly, typedef obeys scoping rules just like variables, whereas define
stays valid until the end of the file (or until a matching undef).
Secondly, some things can be done with typedef that cannot be done with define.
Examples:
Source: http://www.go4expert.com/forums/showthread.php?t=13405
Firstly, typedef obeys scoping rules just like variables, whereas define
stays valid until the end of the file (or until a matching undef).
Secondly, some things can be done with typedef that cannot be done with define.
Examples:
Code:
typedef int* int_p1; int_p1 a, b, c; // a, b, and c are all int pointers. #define int_p2 int* int_p2 a, b, c; // only the first is a pointer!
Code:
typedef int a10[10]; a10 a, b, c; // create three 10-int arrays
Code:
typedef int (*func_p) (int);
func_p fp // func_p is a pointer to a function that
// takes an int and returns an intSource: http://www.go4expert.com/forums/showthread.php?t=13405
September 21, 2010
yahoo imap and STMP server, FREE to ALL
According to Wikipedia, Yahoo has free IMAP services.
"Free IMAP and SMTPs access
It is possible to get direct IMAP access without signing up for paid access nor using software like YPOPs! or FreePOPs. Yahoo operates IMAP servers (imap.mail.yahoo.com in particular), which are globally accessible. However they require a specific, but non-standard IMAP command to be sent before login is done. The command is: “ID ("GUID" "1")” and it is relatively easy to modify any email client to send it. In fact this is the method currently employed by YPOPSs! and FreePOPs. There are modified version of Mutt and Mozilla Thunderbird available that send this command.[23]
There is also an IMAPs server running at imap-ssl.mail.yahoo.com. It is using SSL on the standard port 993.
In addition it is also possible to send mail through mail clients as yahoo also operates an SMTP server (smtp.mail.yahoo.com). It is necessary to enable SSL through port 465. The username is the user's Yahoo mail address and the password is the same as for webmail access, this applies to both IMAP and SMTPs access.yahoo mail address and th e password is the same as for webmail access, the applies to both IMAP and amtps access."
"Free IMAP and SMTPs access
It is possible to get direct IMAP access without signing up for paid access nor using software like YPOPs! or FreePOPs. Yahoo operates IMAP servers (imap.mail.yahoo.com in particular), which are globally accessible. However they require a specific, but non-standard IMAP command to be sent before login is done. The command is: “ID ("GUID" "1")” and it is relatively easy to modify any email client to send it. In fact this is the method currently employed by YPOPSs! and FreePOPs. There are modified version of Mutt and Mozilla Thunderbird available that send this command.[23]
There is also an IMAPs server running at imap-ssl.mail.yahoo.com. It is using SSL on the standard port 993.
In addition it is also possible to send mail through mail clients as yahoo also operates an SMTP server (smtp.mail.yahoo.com). It is necessary to enable SSL through port 465. The username is the user's Yahoo mail address and the password is the same as for webmail access, this applies to both IMAP and SMTPs access.yahoo mail address and th e password is the same as for webmail access, the applies to both IMAP and amtps access."
Source(s):
September 17, 2010
Cross Compile cherokee 1.0.8 to ARM
ac_cv_func_malloc_0_nonnull=yes \
ac_cv_func_realloc_0_nonnull=yes \
./configure \
--host=arm-linux \
--disable-readdir_r \
--disable-tls \
--enable-static-module=all \
--enable-trace \
--enable-static \
--enable-shared=no \
--enable-beta \
--disable-ipv6 \
CC=arm-linux-gcc
make
you will get an errro about readdir_mutex.
go to file cherokee/util.c line 400, changed it to:
now you are good to go, just type make and the final files are in cherokee/{cherokee,cherokee-worker}
To run Cherokee on an embedded platform:
1. download cherokee-worker, cherokee
2. create a conf file with the following contents:
3. create a themes directory with the followings files:
4. run it "./cherokee -C cherokee.conf"
You can enable tracing to see the traces of cherokee.
ac_cv_func_realloc_0_nonnull=yes \
./configure \
--host=arm-linux \
--disable-readdir_r \
--disable-tls \
--enable-static-module=all \
--enable-trace \
--enable-static \
--enable-shared=no \
--enable-beta \
--disable-ipv6 \
CC=arm-linux-gcc
make
you will get an errro about readdir_mutex.
go to file cherokee/util.c line 400, changed it to:
#if defined(HAVE_PTHREAD)
now you are good to go, just type make and the final files are in cherokee/{cherokee,cherokee-worker}
To run Cherokee on an embedded platform:
1. download cherokee-worker, cherokee
2. create a conf file with the following contents:
server!bind!1!port = 80
server!timeout = 60
server!keepalive = 1
server!keepalive_max_requests = 500
server!server_tokens = full
#server!encoder!gzip!allow = html,html,txt,css,js
server!panic_action = /web/cherokee-panic
server!pid_file = /var/run/cherokee.pid
server!user = root
server!group = root
# Default virtual server
#
vserver!default!nick = default
vserver!default!document_root = /web
vserver!default!directory_index = index.php,index.html
vserver!default!logger = combined
vserver!default!logger!access!type = file
vserver!default!logger!access!filename = /var/log/cherokee.access
vserver!default!logger!access!buffsize = 16384
vserver!default!logger!error!type = file
vserver!default!logger!error!filename = /var/log/cherokee.error
vserver!default!rule!1!match = default
vserver!default!rule!1!handler = common
vserver!default!rule!1!handler!iocache = 0
vserver!default!rule!99999!match = extensions
vserver!default!rule!99999!match!extensions = php
vserver!default!rule!99999!handler = fcgi
vserver!default!rule!99999!handler!balancer = round_robin
vserver!default!rule!99999!handler!balancer!type = interpreter
vserver!default!rule!99999!handler!balancer!source!1 = 1
vserver!default!rule!99999!handler!balancer!local1!host = 127.0.0.1:1234
vserver!default!rule!99999!handler!balancer!local1!env!PHP_FCGI_CHILDREN = 5
vserver!default!rule!99999!handler!balancer!local1!interpreter = /web/php-cgi -b 1234
source!1!env!PHP_FCGI_CHILDREN = 5
source!1!host = 127.0.0.1:1234
source!1!interpreter = /web/php-cgi -b 1234
source!1!nick = php
#source!1!type = interpreter
source!1!type = host
3. create a themes directory with the followings files:
ls themes/default/
theme.css logo.png header.html footer.html entry.html
4. run it "./cherokee -C cherokee.conf"
You can enable tracing to see the traces of cherokee.
September 15, 2010
September 14, 2010
September 3, 2010
Determine your linux distribution version
Use 'uname -a' to get kernel info
Use 'cat /etc/redhat-release' to find out redhat/FC release info
Use 'cat cat /etc/debian_version' to find out debian release info
Ubuntu? Just use debian. :-)
Use 'cat /etc/redhat-release' to find out redhat/FC release info
Use 'cat cat /etc/debian_version' to find out debian release info
Ubuntu? Just use debian. :-)
List of VOIP phone and their codecs
This table is from http://www.ozvoip.com/voip-codecs/devices/
| Client | Supported Codecs |
|---|---|
| Billion BIPAC 7402VL | G.711, G.729 |
| Billion BIPAC-7100SV | G.711, G.729 |
| Billion BIPAC7402VGP | G.711, G.729 |
| Cisco 7960 | G.711, G.729 |
| Draytek Vigor 2100V(G) | G.711, G.723.1, G.726, G.729 |
| Draytek Vigor 2500V | G.711, G.729 |
| Draytek Vigor 2600V(G) | G.711, G.723.1, G.726, G.729 |
| Draytek Vigor 2900V(G) | G.711, G.723.1, G.726, G.729 |
| eyeBeam | GSM, iLBC, G.711, G.722, G.723.1, G.729, Speex |
| Grandstream BudgeTone 101 | iLBC, G.711, G.723.1, G.726, G.728, G.729 |
| Grandstream BudgeTone 102 | iLBC, G.711, G.723.1, G.726, G.728, G.729 |
| Grandstream GXP2000 | GSM, G.711, G.722, G.723.1, G.726, G.728, G.729 |
| Grandstream HandyTone 286 | iLBC, G.711, G.723.1, G.726, G.728, G.729 |
| Grandstream Handytone 486 | iLBC, G.711, G.723.1, G.726, G.728, G.729 |
| Leadtek 8051 | G.711, G.723.1, G.726, G.729 |
| Linksys PAP2 | G.711, G.723.1, G.726, G.729 |
| Linksys RT31P2 | G.711, G.723.1, G.726, G.729 |
| Linksys WRT54GP2 | G.711, G.729 |
| MS Office Communicator | GSM, G.711, G.722, G.723.1, DVI4, Siren |
| Octtel SPxxxx Series Gateways | G.711, G.729 |
| Polycom SoundPoint IP300 | G.711, G.729 |
| Polycom SoundPoint IP500 | G.711, G.729 |
| Polycom SoundPoint IP600 | G.711, G.729 |
| Siemens optiPoint 400 Family | G.723.1 |
| Siemens optiPoint 410 Family | G.711, G.723.1 |
| Siemens optiPoint 420 Family | G.711, G.722, G.723.1, G.729 |
| Sipura SPA-2000 | G.711, G.723.1, G.726, G.729 |
| Sipura SPA-2100 | G.711, G.723.1, G.726, G.729 |
| Sipura SPA-3000 | G.711, G.723.1, G.726, G.729 |
| Sipura SPA-841 | G.711, G.729 |
| sipXphone | G.711 |
| SJPhone (free version) | GSM, iLBC, G.711 |
| Snom 190 | GSM, G.711, G.722, G.723.1, G.726, G.729 |
| Snom 320 | GSM, G.711, G.722, G.723.1, G.726, G.729 |
| Snom 360 | GSM, G.711, G.722, G.723.1, G.726, G.729 |
| SwissVoice IP 10S | iLBC, G.729 |
| Uniden UIP-200 | G.711, G.729 |
| Windows Messenger | GSM, G.711, G.722, G.723.1, DVI4, Siren |
| X-lite | GSM, iLBC, G.711, Speex |
| X-Pro | GSM, iLBC, G.711, G.729, Speex |
| Zyxel Prestige 2000W | G.711, G.729 |
| Zyxel Prestige 2002 | G.711, G.729 |
| Zyxel Prestige 2602HW(-L) | G.711, G.729 |
September 2, 2010
Asterisk SIP PBX simple tutorial / quick start guide
Recently I start to investigate how to make asterisk to be an SIP BPX with small foot print, and I have a running SIP PBX now. Below are the notes on how I got it to run.
Platform: I am running asterisk in Colinux under Windows Vista. Debian 5 is running in Colinux.
Short summary:
version: asterisk 1.4 is stable and used widely. 1.6 is considered short-term support. Supposedly 1.8 is another stable version for long-term support. I use 1.4
source : the source tar gzip of asterisk is about 23MB. It uses the standard "./configure;make;make install" procedure to compile. See README in source tar ball.
structure: asterisk uses a lot of ".so" dynamic libraries, which are called modules and are loaded dynamically when program starts. Which one to load or not to load is controlled by the file "modules.conf". Many of the modules are essential to make asterisk useful, while others are optional for our purpose.
directories: configurations are under /etc/asterisk, modules (dynamic library files are under /usr/lib/asterisk/modules). Other directories are determined in compile-time and are listed in "asterisk.conf"
configurations: Unlike most unix programs, "asterisk.conf" is not what you change the most. In fact, you can probably leave it as is. The files we need to change the most for making a IP PBX are:
Platform: I am running asterisk in Colinux under Windows Vista. Debian 5 is running in Colinux.
Short summary:
version: asterisk 1.4 is stable and used widely. 1.6 is considered short-term support. Supposedly 1.8 is another stable version for long-term support. I use 1.4
source : the source tar gzip of asterisk is about 23MB. It uses the standard "./configure;make;make install" procedure to compile. See README in source tar ball.
structure: asterisk uses a lot of ".so" dynamic libraries, which are called modules and are loaded dynamically when program starts. Which one to load or not to load is controlled by the file "modules.conf". Many of the modules are essential to make asterisk useful, while others are optional for our purpose.
directories: configurations are under /etc/asterisk, modules (dynamic library files are under /usr/lib/asterisk/modules). Other directories are determined in compile-time and are listed in "asterisk.conf"
configurations: Unlike most unix programs, "asterisk.conf" is not what you change the most. In fact, you can probably leave it as is. The files we need to change the most for making a IP PBX are:
- modules.conf ; for configuring which modules to load or not load
- sip.conf ; for configuring all sip channels, both external and internal
- extensions.conf; the heart of the PBX, configures what key press/ what extension does what
- apt-get install asterisk
- /etc/init.d/asterisk stop. I like to use console for getting thing to run. so stop the daemon
- copy modules.conf below as your modules.conf
- copy sip.conf as your sip.conf. I use sipgate as my provider. ( I tested incoming call and outgoing call to toll-free numbers)
- copy extensions.conf to yours.
- start your asterisk in console mode (asterisk -cvvv)
- install x-lite software phone on your Windows and configure it as follows:
- now you can dial 123 to hear the playback voice from asterisk. go to asterisk CLI, and type "sip show peers" and you should see two peers, your sipgate and your x-lite phone.
- You can now make calls and receive calls.
- For further reading, I recommend the O'reilly book "Asterisk".
Free U.S.domestic phone number
You can get it from any of the following providers:
1. Google voice
2. SipGate
3. IPKall
4. IPComms (http://www.ipcomms.net/product-freedid.html)
I use Google voice and SipGate. Any one has used IPComms?
1. Google voice
2. SipGate
3. IPKall
4. IPComms (http://www.ipcomms.net/product-freedid.html)
I use Google voice and SipGate. Any one has used IPComms?
September 1, 2010
voip codecs and bps

- g.711 is raw data, highest quality, but requires highest bandwidth
- g.729a is the next best, very good quality, very low datarate, but it requires a $10 license per channel for asterisk. There is a free version for research and education use at http://asterisk.hosting.lv/
- iLBC may be the next best, it is free, good quality, and relatively low datarate. Go to this link to find out how to add iLBC back to Asterisk. Remember, you will need to copy the original Makefile in the ilbc folder to the new ilbc folder.
- GSM quality is acceptable, but not very good.
- G722 is wide band, hi-def stuff.
Real bps numbers:
- GSM: 30kbps
- g711: 80kbps
- iLBC: 30kbps
- g729: 30kbps (why it is this high? bps seen by bwm-ng)
* G.729 (NOT G.729a) has a MOS of 3.9-4.2 and uses 24 kbps @ 20 ms or 18.7 kbps @ 30 ms.
* G.729a has a MOS of 3.7-4.2 and uses 24 kbps @ 20 ms or 18.7 kbps @ 30 ms.
* G.723 has a MOS of 3.8-4.0 and uses 17.1 kbps @ 30 ms.
MOS is what nontechnical people think about each codec (5.0 is perfect). All of the above numbers are in EACH direction, so total bandwidth is double the above figures.
As you can see, there is very little quality or bandwidth difference betweeen G.729a and G.723. However, G.729a can send 50 packets/second, each packet containing 20 ms of voice payload. G.723's lowest setting is 30 ms. I think 20 ms sounds better than 30 ms because of smoothing (used to fill in for late packets). That's why I chose G.729a @ 20 ms over G.723 @ 30 ms for my Sipura adapter. (Sipura's default setting is 20 ms (that is, 'RTP Packet Size' = '0.020').)
It would be a very good idea to turn on silence suppression ('Silence Supp Enable' = 'yes'), because it will reduce your bandwidth usage by 65%. (Apparently each person in a two-person conversation only talks about 1/3 of the time.) With my Sipura 2100, I could not hear any difference between silence suppression being on or off.
G729 uses less compression (less latency problems) and has a higher level of voice quality BUT does use more bandwidth. I personally am not fond of g723.1 but usually find g729 to be OK. Some people despise both.
Packet8 started using g723.1 and later switched to g729 most likely due to customer complaints about the poor quality of g723.1 calls.
How to upgrade SPA942 IP Phone internal directory using wget
See the post here:
http://blog.grimsy.net/2007/02/23/spa942-personal-directory/
A Recap:
After trying a number of things, I upgraded to the latest firmware (5.1.5 at time of writing) and after some more stuffing around, I was finally able to get the following line to populate the Personal Directory:
A few things about the command.
Firstly, the command will enter in two contacts in the Directory. These will be under entry #5 (24686) and entry #2 (25390). A complete list of all the codes here can be seen in the source of the Personal Directory page in the phone’s web interface.
So taking the first of the two entries (24686), what we’re posting is:
n=Geoff; (we need to escape the ‘=’ signs so that wget will actually pass the info on correctly)
n is the Display Name that will appear in the Directory
p=6004;
p is the extension number (or phone number). My extension is 6004.
r=1
r is the ring to use. 0 is no sound, just flashing. Play around with the other numbers to find the ringtone you want to use.
To add more than one entry at a time, simply separate the strings with ‘&’.
http://blog.grimsy.net/2007/02/23/spa942-personal-directory/
A Recap:
After trying a number of things, I upgraded to the latest firmware (5.1.5 at time of writing) and after some more stuffing around, I was finally able to get the following line to populate the Personal Directory:
wget --post-data '24686=n%3DGeoff;p%3D6004;r%3D1&25390=n%3DMatt;p%3D6001;r%3D1' http://myphoneIP/pdir.spa
A few things about the command.
Firstly, the command will enter in two contacts in the Directory. These will be under entry #5 (24686) and entry #2 (25390). A complete list of all the codes here can be seen in the source of the Personal Directory page in the phone’s web interface.
So taking the first of the two entries (24686), what we’re posting is:
n%3DGeoff;
n is the Display Name that will appear in the Directory
p%3D6004;
p is the extension number (or phone number). My extension is 6004.
r%3D1
r is the ring to use. 0 is no sound, just flashing. Play around with the other numbers to find the ringtone you want to use.
To add more than one entry at a time, simply separate the strings with ‘&’.
August 31, 2010
mini2440 flash upgrade
How to upgrade mini2440/micro2440 kernel image after the systems boots to Linux:
killall processes
mount -o remount,ro /
cd /dev/shm
flash_erase /dev/mtd1 0 16
nandwrite -a -p /dev/mtd1 /zImage_new
Bootloader
There are two "official" bootloaders, supervivi-128M and viv. supervivi is a little bit less than 256K (0x40000), while vivi is only 3-4K. We have supervivi in NOR flash, and viv in NAND flash.
0x0,00000 - 0x0,40000 bootloader
0x0,48000 - 0x0,60000 bootloader parameters (linux_cmd_line starts at 0x48000 and ends with the first 0x0)
0x0,60000 - 0x2,60000 2M of kernel space
0x2,60000 - 0x80,00000 close to 126M application image
Tools to read/write/erase flash after system is booted (all in mtd-utils project):
- flash_erase
- nandwrite
- nanddump
- mtd_debug
echo -n -e "VIVICMDLnoinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0\0000" > /tmp/cmdline
/cmdc/flash_erase /dev/mtd0 0x40000 1
/cmdc/nandwrite -p /dev/mtd0 -s 0x48000 /tmp/cmdline
You can probably use the same nandwrite to update the bootloader itself. I haven't tried that yet.
killall processes
mount -o remount,ro /
cd /dev/shm
flash_erase /dev/mtd1 0 16
nandwrite -a -p /dev/mtd1 /zImage_new
Bootloader
There are two "official" bootloaders, supervivi-128M and viv. supervivi is a little bit less than 256K (0x40000), while vivi is only 3-4K. We have supervivi in NOR flash, and viv in NAND flash.
0x0,00000 - 0x0,40000 bootloader
0x0,48000 - 0x0,60000 bootloader parameters (linux_cmd_line starts at 0x48000 and ends with the first 0x0)
0x0,60000 - 0x2,60000 2M of kernel space
0x2,60000 - 0x80,00000 close to 126M application image
Tools to read/write/erase flash after system is booted (all in mtd-utils project):
- flash_erase
- nandwrite
- nanddump
- mtd_debug
echo -n -e "VIVICMDLnoinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0\0000" > /tmp/cmdline
/cmdc/flash_erase /dev/mtd0 0x40000 1
/cmdc/nandwrite -p /dev/mtd0 -s 0x48000 /tmp/cmdline
You can probably use the same nandwrite to update the bootloader itself. I haven't tried that yet.
Export MySQL database to CSV file
SELECT * INTO OUTFILE '/tmp/result.text'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM test_table;
And the results are sent to /tmp/result.text in CSV format.
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM test_table;
And the results are sent to /tmp/result.text in CSV format.
August 27, 2010
Thunderbird turn off signature in reply emails
August 23, 2010
defishing an image
Open source software: Hugin/Nona
http://www.pentaxforums.com/forums/pentax-slr-lens-discussion/33634-how-do-you-de-fish.html
http://wiki.panotools.org/Hugin
http://www.flickr.com/groups/67669253@N00/discuss/72157594344672391/
http://sourceforge.net/projects/hugin/files/hugin/
http://www.pbase.com/troyz/defishing_examples
http://www.pentaxforums.com/forums/pentax-slr-lens-discussion/33634-how-do-you-de-fish.html
http://wiki.panotools.org/Hugin
http://www.flickr.com/groups/67669253@N00/discuss/72157594344672391/
http://sourceforge.net/projects/hugin/files/hugin/
http://www.pbase.com/troyz/defishing_examples
August 17, 2010
Remove blank/empty lines from a file
There are many ways to do it:
- grep '.' file > newfile
- awk '/./' file > newfile
August 14, 2010
Vim embedded command in the file edited
This is called "modeline" in vim. you can file help on that.
http://vim.wikia.com/wiki/Modeline_magic
First, make sure modeline is enabled. Then
http://vim.wikia.com/wiki/Modeline_magic
First, make sure modeline is enabled. Then
The following examples show some alternatives that could be in a C file:
// vim: noai:ts=4:sw=4
-or-
/* vim: noai:ts=4:sw=4
*/
-or-
/* vim: set noai ts=4 sw=4: */
-or-
/* vim: set fdm=expr fde=getline(v\:lnum)=~'{'?'>1'\:'1': */
With "set", the modeline ends at the first colon not following a backslash. Without "set", no text can follow the options, so for example, the following is invalid:
Error E518: Unknown option: */
/* vim: noai:ts=4:sw=4 */
August 10, 2010
Disable ssh server reverse dns lookup
Add/Edit the following lines to your /etc/ssh/sshd_config and restart ssh service
UseDNS no
GSSAPIAuthentication no
GatewayPorts yes
UseDNS no
GSSAPIAuthentication no
To enable remote port forwarding for all the computers on your subnet, add this:
Subscribe to:
Posts (Atom)

