This area is my sharing area. Include some technical/believing/life experiences. Hope you can enjoy with me. God bless you. :)
2008年12月24日 星期三
2008年12月9日 星期二
2008年12月8日 星期一
The difference between AF_XXX and PF_XXX
Sometimes we are confused in using the AF_XXX and PF_XXX, like AF_INET vs PF_INET, AF_NETLINK vs PF_NETLINK. From the viewpoint of source, both them are identical.
Refer to the include/linux/socket.h. You can observe that the PF_XXX (protocol family) is defined the same as AF_XXX (address family)
/* Protocol families, same as address families. */
#define PF_UNSPEC AF_UNSPEC
#define PF_UNIX AF_UNIX
#define PF_LOCAL AF_LOCAL
#define PF_INET AF_INET
#define PF_AX25 AF_AX25
#define PF_IPX AF_IPX
#define PF_APPLETALK AF_APPLETALK
#define PF_NETROM AF_NETROM
#define PF_BRIDGE AF_BRIDGE
#define PF_ATMPVC AF_ATMPVC
#define PF_X25 AF_X25
#define PF_INET6 AF_INET6
#define PF_ROSE AF_ROSE
#define PF_DECnet AF_DECnet
#define PF_NETBEUI AF_NETBEUI
#define PF_SECURITY AF_SECURITY
#define PF_KEY AF_KEY
#define PF_NETLINK AF_NETLINK
#define PF_ROUTE AF_ROUTE
#define PF_PACKET AF_PACKET
#define PF_ASH AF_ASH
The following is the definition of the constant of each address family variable
/* Supported address families. */
#define AF_UNSPEC 0
#define AF_UNIX 1 /* Unix domain sockets */
#define AF_LOCAL 1 /* POSIX name for AF_UNIX */
#define AF_INET 2 /* Internet IP Protocol */
#define AF_AX25 3 /* Amateur Radio AX.25 */
#define AF_IPX 4 /* Novell IPX */
#define AF_APPLETALK 5 /* AppleTalk DDP */
#define AF_NETROM 6 /* Amateur Radio NET/ROM */
#define AF_BRIDGE 7 /* Multiprotocol bridge */
#define AF_ATMPVC 8 /* ATM PVCs */
#define AF_X25 9 /* Reserved for X.25 project */
#define AF_INET6 10 /* IP version 6 */
#define AF_ROSE 11 /* Amateur Radio X.25 PLP */
#define AF_DECnet 12 /* Reserved for DECnet project */
#define AF_NETBEUI 13 /* Reserved for 802.2LLC project*/
#define AF_SECURITY 14 /* Security callback pseudo AF */
#define AF_KEY 15 /* PF_KEY key management API */
#define AF_NETLINK 16
#define AF_ROUTE AF_NETLINK /* Alias to emulate 4.4BSD */
#define AF_PACKET 17 /* Packet family */
#define AF_ASH 18 /* Ash */
#define AF_ECONET 19 /* Acorn Econet */
#define AF_ATMSVC 20 /* ATM SVCs */
Refer to the include/linux/socket.h. You can observe that the PF_XXX (protocol family) is defined the same as AF_XXX (address family)
/* Protocol families, same as address families. */
#define PF_UNSPEC AF_UNSPEC
#define PF_UNIX AF_UNIX
#define PF_LOCAL AF_LOCAL
#define PF_INET AF_INET
#define PF_AX25 AF_AX25
#define PF_IPX AF_IPX
#define PF_APPLETALK AF_APPLETALK
#define PF_NETROM AF_NETROM
#define PF_BRIDGE AF_BRIDGE
#define PF_ATMPVC AF_ATMPVC
#define PF_X25 AF_X25
#define PF_INET6 AF_INET6
#define PF_ROSE AF_ROSE
#define PF_DECnet AF_DECnet
#define PF_NETBEUI AF_NETBEUI
#define PF_SECURITY AF_SECURITY
#define PF_KEY AF_KEY
#define PF_NETLINK AF_NETLINK
#define PF_ROUTE AF_ROUTE
#define PF_PACKET AF_PACKET
#define PF_ASH AF_ASH
The following is the definition of the constant of each address family variable
/* Supported address families. */
#define AF_UNSPEC 0
#define AF_UNIX 1 /* Unix domain sockets */
#define AF_LOCAL 1 /* POSIX name for AF_UNIX */
#define AF_INET 2 /* Internet IP Protocol */
#define AF_AX25 3 /* Amateur Radio AX.25 */
#define AF_IPX 4 /* Novell IPX */
#define AF_APPLETALK 5 /* AppleTalk DDP */
#define AF_NETROM 6 /* Amateur Radio NET/ROM */
#define AF_BRIDGE 7 /* Multiprotocol bridge */
#define AF_ATMPVC 8 /* ATM PVCs */
#define AF_X25 9 /* Reserved for X.25 project */
#define AF_INET6 10 /* IP version 6 */
#define AF_ROSE 11 /* Amateur Radio X.25 PLP */
#define AF_DECnet 12 /* Reserved for DECnet project */
#define AF_NETBEUI 13 /* Reserved for 802.2LLC project*/
#define AF_SECURITY 14 /* Security callback pseudo AF */
#define AF_KEY 15 /* PF_KEY key management API */
#define AF_NETLINK 16
#define AF_ROUTE AF_NETLINK /* Alias to emulate 4.4BSD */
#define AF_PACKET 17 /* Packet family */
#define AF_ASH 18 /* Ash */
#define AF_ECONET 19 /* Acorn Econet */
#define AF_ATMSVC 20 /* ATM SVCs */
Some stuff that have used netlink to pass data to kernel
Some stuff that have used netlink to pass data to kernel
* ulogd
http://www.netfilter.org/projects/ulogd/index.html
* libipq
http://www.cs.princeton.edu/~nakao/libipq.htm
* ulogd
http://www.netfilter.org/projects/ulogd/index.html
* libipq
http://www.cs.princeton.edu/~nakao/libipq.htm
2008年12月7日 星期日
Some Makefile tips and questions
$(SHARED_LIBS:%.so=%.d): %.d: %.c
@-$(CC) -M -MG $(CFLAGS) $< | \
sed -e 's@^.*\.o:@$*.d $*_sh.o:@' > $@
Q. What doest this mean? $(SHARED_LIBS:%.so=%.d)
Q. What does here two colon mean?
-------------------------------------------------------
Makefile Rule Format:
In general, a rule looks like this:
targets : prerequisites
command
...
or like this:
targets : prerequisites ; command
command
-------------------------------------------------------
Another similar parts.
$(SHARED_LIBS): %.so : %_sh.o
$(CC) -shared $(EXT_LDFLAGS) -o $@ $<
$(SHARED_SE_LIBS:%.so=%.d): %.d: %.c
@-$(CC) -M -MG $(CFLAGS) $< | \
sed -e 's@^.*\.o:@$*.d $*_sh.o:@' > $@
$(SHARED_SE_LIBS): %.so : %_sh.o
$(LD) -shared $(EXT_LDFLAGS) -o $@ $< $(LDLIBS)
@-$(CC) -M -MG $(CFLAGS) $< | \
sed -e 's@^.*\.o:@$*.d $*_sh.o:@' > $@
Q. What doest this mean? $(SHARED_LIBS:%.so=%.d)
Q. What does here two colon mean?
-------------------------------------------------------
Makefile Rule Format:
In general, a rule looks like this:
targets : prerequisites
command
...
or like this:
targets : prerequisites ; command
command
-------------------------------------------------------
Another similar parts.
$(SHARED_LIBS): %.so : %_sh.o
$(CC) -shared $(EXT_LDFLAGS) -o $@ $<
$(SHARED_SE_LIBS:%.so=%.d): %.d: %.c
@-$(CC) -M -MG $(CFLAGS) $< | \
sed -e 's@^.*\.o:@$*.d $*_sh.o:@' > $@
$(SHARED_SE_LIBS): %.so : %_sh.o
$(LD) -shared $(EXT_LDFLAGS) -o $@ $< $(LDLIBS)
2008年12月3日 星期三
vmware config process
Run /usr/bin/vmware-config.pl to config the vMware interface settings
Would you like to skip networking setup and keep your old settings as they are?
(yes/no) [yes] no
Do you want networking for your virtual machines? (yes/no/help) [yes]
Would you prefer to modify your existing networking configuration using the
wizard or the editor? (wizard/editor/help) [wizard] editor ==> use editor to add the vmware vmnet <==> physical interface mapping
The following virtual networks have been defined:
. vmnet0 is bridged to eth0
. vmnet1 is a host-only network on private subnet 172.16.198.0.
. vmnet2 is bridged to eth1
. vmnet3 is bridged to eth2
. vmnet8 is a NAT network on private subnet 172.16.126.0.
Do you wish to make any changes to the current virtual networks settings?
(yes/no) [no] yes
Which virtual network do you wish to configure? (0-99) 4
What type of virtual network do you wish to set vmnet4?
(bridged,hostonly,nat,none) [none] bridged
Configuring a bridged network for vmnet4.
Your computer has multiple ethernet network interfaces available: eth3, eth4,
eth5, eth6, eth7, eth8. Which one do you want to bridge to vmnet4? [eth0] eth3
The following virtual networks have been defined:
. vmnet0 is bridged to eth0
. vmnet1 is a host-only network on private subnet 172.16.198.0.
. vmnet2 is bridged to eth1
. vmnet3 is bridged to eth2
. vmnet4 is bridged to eth3 ==> The new added one interface
. vmnet8 is a NAT network on private subnet 172.16.126.0.
Would you like to skip networking setup and keep your old settings as they are?
(yes/no) [yes] no
Do you want networking for your virtual machines? (yes/no/help) [yes]
Would you prefer to modify your existing networking configuration using the
wizard or the editor? (wizard/editor/help) [wizard] editor ==> use editor to add the vmware vmnet <==> physical interface mapping
The following virtual networks have been defined:
. vmnet0 is bridged to eth0
. vmnet1 is a host-only network on private subnet 172.16.198.0.
. vmnet2 is bridged to eth1
. vmnet3 is bridged to eth2
. vmnet8 is a NAT network on private subnet 172.16.126.0.
Do you wish to make any changes to the current virtual networks settings?
(yes/no) [no] yes
Which virtual network do you wish to configure? (0-99) 4
What type of virtual network do you wish to set vmnet4?
(bridged,hostonly,nat,none) [none] bridged
Configuring a bridged network for vmnet4.
Your computer has multiple ethernet network interfaces available: eth3, eth4,
eth5, eth6, eth7, eth8. Which one do you want to bridge to vmnet4? [eth0] eth3
The following virtual networks have been defined:
. vmnet0 is bridged to eth0
. vmnet1 is a host-only network on private subnet 172.16.198.0.
. vmnet2 is bridged to eth1
. vmnet3 is bridged to eth2
. vmnet4 is bridged to eth3 ==> The new added one interface
. vmnet8 is a NAT network on private subnet 172.16.126.0.
vmware daemon
>> If we show the vmware process, we can know there are some vmware daemons provide the services
- vmnet-natd
always exist, even no vmware client images
- vmware-serverd
always exist, even no vmware client images
- vmnet-dhcpd
provide the dhcp service, only service in the vmnet1 (Host-only) and vmnet8 (NAT)
- vmware-vmx
For each vmware client image, the vmware will fork a vmware-vmx to provide the service
# ps auxwww | grep vmware
root 3101 0.0 0.0 1756 356 ? Ss Nov07 0:00 /usr/bin/vmnet-natd -d /var/run/vmnet-natd-8.pid -m /var/run/vmnet-natd-8.mac -c /etc/vmware/vmnet8/nat/nat.conf
root 3107 0.0 0.3 17336 14800 ? Ss Nov07 2:45 /usr/sbin/vmware-serverd -s -d
root 3629 0.0 0.0 1756 232 ? Ss Nov07 0:00 /usr/bin/vmnet-dhcpd -cf /etc/vmware/vmnet1/dhcpd/dhcpd.conf -lf /etc/vmware/vmnet1/dhcpd/dhcpd.leases -pf /var/run/vmnet-dhcpd-vmnet1.pid vmnet1
root 3630 0.0 0.0 1756 232 ? Ss Nov07 0:00 /usr/bin/vmnet-dhcpd -cf /etc/vmware/vmnet8/dhcpd/dhcpd.conf -lf /etc/vmware/vmnet8/dhcpd/dhcpd.leases -pf /var/run/vmnet-dhcpd-vmnet8.pid vmnet8
root 3710 10.6 7.2 404380 292520 ? S
- vmnet-natd
always exist, even no vmware client images
- vmware-serverd
always exist, even no vmware client images
- vmnet-dhcpd
provide the dhcp service, only service in the vmnet1 (Host-only) and vmnet8 (NAT)
- vmware-vmx
For each vmware client image, the vmware will fork a vmware-vmx to provide the service
# ps auxwww | grep vmware
root 3101 0.0 0.0 1756 356 ? Ss Nov07 0:00 /usr/bin/vmnet-natd -d /var/run/vmnet-natd-8.pid -m /var/run/vmnet-natd-8.mac -c /etc/vmware/vmnet8/nat/nat.conf
root 3107 0.0 0.3 17336 14800 ? Ss Nov07 2:45 /usr/sbin/vmware-serverd -s -d
root 3629 0.0 0.0 1756 232 ? Ss Nov07 0:00 /usr/bin/vmnet-dhcpd -cf /etc/vmware/vmnet1/dhcpd/dhcpd.conf -lf /etc/vmware/vmnet1/dhcpd/dhcpd.leases -pf /var/run/vmnet-dhcpd-vmnet1.pid vmnet1
root 3630 0.0 0.0 1756 232 ? Ss Nov07 0:00 /usr/bin/vmnet-dhcpd -cf /etc/vmware/vmnet8/dhcpd/dhcpd.conf -lf /etc/vmware/vmnet8/dhcpd/dhcpd.leases -pf /var/run/vmnet-dhcpd-vmnet8.pid vmnet8
root 3710 10.6 7.2 404380 292520 ? S
2008年12月1日 星期一
hexdump experience
>> Show the hex and ascill data of a specified file
# hexdump -C fingerprint.dat
00000000 0a 00 00 00 49 2c e7 24 61 6c 65 78 31 30 30 00 |....I,.$alex100.|
00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000020 00 00 00 00 00 00 00 00 01 00 00 00 8c 71 66 aa |.............qf.|
00000030 00 00 00 00 01 00 00 00 |........|
00000038
# hexdump -C fingerprint.dat
00000000 0a 00 00 00 49 2c e7 24 61 6c 65 78 31 30 30 00 |....I,.$alex100.|
00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000020 00 00 00 00 00 00 00 00 01 00 00 00 8c 71 66 aa |.............qf.|
00000030 00 00 00 00 01 00 00 00 |........|
00000038
訂閱:
文章 (Atom)