GCC宣布对Google Go语言的支持
GCC项目组织宣布,
允许gccgo(Google 推出的新语言GO)增加到gcc的主分支,更详细的信息可能要在GCC4.5或之后的版本中体现。 也就是说在不远的将来GO语言将是Linux的标配。
GO语言: http://www.golang.org
GO中文资料参考: http://golang-china.org
GCC项目组织宣布,
允许gccgo(Google 推出的新语言GO)增加到gcc的主分支,更详细的信息可能要在GCC4.5或之后的版本中体现。 也就是说在不远的将来GO语言将是Linux的标配。
GO语言: http://www.golang.org
GO中文资料参考: http://golang-china.org
今天在wikipedia看IGMP的时候,无意中发现了XORP, 简单适用了一下非常好用,并且官方的资料真理的比较全,使用也比较方便,还提供了一个基本的shell xorpsh 来配置管理信息。刚好可以省去买支持IGMP的路由器,支持IGMP的路由器最少也要1.5W…
XORP, or Extensible Open Router Platform, is an open source routing software suite, aimed at being both stable and fully featured enough for production use and also extensible to support networking research.
Request:
OS: ubuntu 9.04 (Linux Kernel 2.6.28-11-generic) with GCC 4.3.3
SW: XORP (multicast routing daemon)
HW: PC with 2 or 3 ethernet card (default gw is itself) !
Step 1: Check Linux Kernel Functions!
CONFIG_IP_MULTICAST=y
CONFIG_IP_ADVANCED_ROUTER=y
CONFIG_IP_MROUTE=y
After this configurations, the linux kernel support IGMP, DVMRP and MOSPF. If want support PIM-SM , do below settings
CONFIG_IP_PIMSM_V2=y
PS: you can use vi view /boot/CONFIG-(kernel version) to confirm !
Step 2: edit /etc/sysctl.conf to enable ip_forward
net.ipv4.conf.default.forwarding=1
PS: reboot or use command “sysctl -p” to enable !
Step 3: Install XORP(To compile XORP requires nearly 1.4GB of free disk space)
Step 3.1: Download xorp-1.6.tar.gz
Step 3.2: untar the xorp-1.6.tar.gz
Step 3.3: ./configure
Step 3.4: make
Step 3.4-1: make check (just to check)(it is not necessary)
Step 4: run rtrmgr/xorp_rtrmgr rtrmgr/xorpsh (A sample xorp command shell)
Step 4.1: create user group named “xorp”
sudo addgroup xorp
Step 4.2: cp or edit config.boot in xorp-1.6/rtrmgr/config.boot
config.boot for our environment
protocols {
fib2mrib {
disable: false
}
igmp {
disable: false
interface eth0 {
vif eth0 {
disable: false
version: 3
enable-ip-router-alert-option-check: false
query-interval: 125
query-last-member-interval: 1
query-response-interval: 10
robust-count: 2
}
}
}
}
fea {
unicast-forwarding4 {
disable: false
}
}
interfaces {
restore-original-config-on-shutdown: false
interface eth0 {
disable: false
discard: false
description: “”
default-system-config {
}
}
}
Step 4.3: xorp-1.6/rtrmgr/xorp_rtrmgr -b xorp-1.6/rtrmgr/config.boot
Step 5: Check Mrouter work OK
Step 5.1: Connect eth0 to VLC Player server PC and connect eth1 to VLC Player client PC
Step 5.2: Use VLC Player server PC run multicast streaming
Step 5.3: Use VLC Player client PC to play multicast streaming by multicast URL
Step6: run rtrmgr/xorpsh (A sample xorp command shell)
xorp-1.6$ rtrmgr/xorpsh
Welcome to XORP on wifihackborder@wifihack> show igmp ?
Possible completions:
group Display information about IGMP group membership
interface Display information about IGMP interfacesborder@wifihack> show igmp group
Interface Group Source LastReported Timeout V State
eth0 224.0.0.2 0.0.0.0 192.168.1.134 240 3 E
eth0 224.0.0.22 0.0.0.0 192.168.1.134 240 3 E
eth0 224.0.0.251 0.0.0.0 192.168.1.134 232 3 E
eth0 224.0.0.252 0.0.0.0 192.168.1.30 232 3 E
eth0 239.255.255.250 0.0.0.0 192.168.1.104 240 3 E
参考:
1. http://www.linuxdiyf.com/bbs/redirect.php?fid=55&tid=69157&goto=nextnewset
2. http://www.xorp.org/getting_started.html
3. “User Manual” http://www.xorp.org/releases/current/docs/user_manual/user_manual.pdf
4. http://en.wikipedia.org/wiki/XORP
5. http://en.wikipedia.org/wiki/IGMP
今天在安装完xmpppy-0.5.0rc1 ,在运行的时候报md5和sha被hashlib替换,查了资料才发现,在Python2.6中使用md5, sha函数不推荐直接使用而是用hashlib替代。
md5
-import md5
-def HH(some): return md5.new(some)
+import hashlib
+def HH(some): return hashlib.md5(some)
sha
-import sha
-def HH(some): return sha.new(some)
+import hashlib
+def HH(some): return hashlib.sha1(some)
都包括 md5(), sha1(), sha224(), sha256(), sha384(), and sha512()
这里给出auth.py md5和sha的patch
diff –git a/xmpp/auth.py b/xmpp/auth.py
index 6e51d72..508718a 100755
— a/xmpp/auth.py
+++ b/xmpp/auth.py
@@ -21,11 +21,11 @@ Can be used both for client and transport authentication.from protocol import *
from client import PlugIn
-import sha,base64,random,dispatcher,re
+import base64,random,dispatcher,re-import md5
-def HH(some): return md5.new(some).hexdigest()
-def H(some): return md5.new(some).digest()
+import hashlib
+def HH(some): return hashlib.md5(some).hexdigest()
+def H(some): return hashlib.md5(some).digest()
def C(some): return ‘:’.join(some)class NonSASL(PlugIn):
@@ -54,15 +54,15 @@ class NonSASL(PlugIn):if query.getTag(’digest’):
self.DEBUG(”Performing digest authentication”,’ok’)
- query.setTagData(’digest’,sha.new(owner.Dispatcher.Stream._document_attrs['id']+self.password).hexdigest())
+ query.setTagData(’digest’,hashlib.sha1(owner.Dispatcher.Stream._document_attrs['id']+self.password).hexdigest())
if query.getTag(’password’): query.delChild(’password’)
method=’digest’
elif query.getTag(’token’):
token=query.getTagData(’token’)
seq=query.getTagData(’sequence’)
self.DEBUG(”Performing zero-k authentication”,’ok’)
- hash = sha.new(sha.new(self.password).hexdigest()+token).hexdigest()
- for foo in xrange(int(seq)): hash = sha.new(hash).hexdigest()
+ hash = hashlib.sha1(hashlib.sha1(self.password).hexdigest()+token).hexdigest()
+ for foo in xrange(int(seq)): hash = hashlib.sha1(hash).hexdigest()
query.setTagData(’hash’,hash)
method=’0k’
else:
@@ -81,7 +81,7 @@ class NonSASL(PlugIn):
def authComponent(self,owner):
“”" Authenticate component. Send handshake stanza and wait for result. Returns “ok” on success. “”"
self.handshake=0
- owner.send(Node(NS_COMPONENT_ACCEPT+’ handshake’,payload=[sha.new(owner.Dispatcher.Stream._document_attrs['id']+self.password).hexdigest()]))
+ owner.send(Node(NS_COMPONENT_ACCEPT+’ handshake’,payload=[hashlib.sha1(owner.Dispatcher.Stream._document_attrs['id']+self.password).hexdigest()]))
owner.RegisterHandler(’handshake’,self.handshakeHandler,xmlns=NS_COMPONENT_ACCEPT)
while not self.handshake:
self.DEBUG(”waiting on handshake”,’notify’)
参考:
1. hashlib http://docs.python.org/library/hashlib.html#module-hashlib
之前使用Graphviz生成了一张mongoose的函数调用图,这里将讲是怎么生成的。
通过Graphvis生成mongoose的函数调用关系
基本的理论可以参考这里(http://www.ibm.com/developerworks/cn/linux/l-graphvis/), 思路如下:
1. 通过GCC的 -finstrument-functions 和 -g 选项,获得函数调用关系的地址.
2. 使用 Addr2line 将函数地址解析为函数名.
3. 精简函数跟踪数据(可以参考pvtrace, http://download.boulder.ibm.com/ibmdl/pub/software/dw/library/l-graphvis/pvtrace.zip)
4. 使用Graphvis生成图片.
具体的步骤:
1. 在我们编译mongoose的时候,加上 instrument.c 文件。
instrument.c 文件的作用是在我们执行文件的时候,会自动记录函数入口和出口的函数地址,并保存在当前目录下面的trace.txt文件里面。 注意: 在用gcc编译的时候一定要加 -finstrument-functions 和 -g 参数。
在mongoose的Makefile文件中增加instrument.c文件。
原文:
$(CC) $(LINFLAGS) mongoose.c main.c -s -o $(PROG)
改为:
$(CC) $(LINFLAGS) instrument.c mongoose.c main.c -finstrument-functions -g -s -o $(PROG)
2. 编译mongoose.
make linux
3. 运行编译好的mongoose程序,并在当前目录生成一个trace.txt 文件。
3. 下载 pvtrace.zip 并编译。
回生成一个pvtrace程序,这个程序主要是从trace.txt和mongoose中提取函数地址对应的函数名,并生成graphivz的语法树。
4. 使用你编译好的文件pvtrace, 运行mongoose, 来获得graph.dot文件。
5. 使用Graph程序,生成图片, 前提是你必须安装graphivz
Debian/Ubuntu
sudo apt-get install graphviz.
安装完后运行:
dot -Tjpg graph.dot -o graph.jpg
6. Over.
效果图参考: http://wifihack.net/blog/2009/04/mongoose-start-function-call-use-graph/
instrument.c:
/********************************************************************
* File: instrument.c
*
* Instrumentation source — link this with your application, and
* then execute to build trace data file (trace.txt).
*
* Author: M. Tim Jones <mtj@mtjones.com>
*
*/#include <stdio.h>
#include <stdlib.h>/* Function prototypes with attributes */
void main_constructor( void )
__attribute__ ((no_instrument_function, constructor));void main_destructor( void )
__attribute__ ((no_instrument_function, destructor));void __cyg_profile_func_enter( void *, void * )
__attribute__ ((no_instrument_function));void __cyg_profile_func_exit( void *, void * )
__attribute__ ((no_instrument_function));static FILE *fp;
void main_constructor( void )
{
fp = fopen( “trace.txt”, “w” );
if (fp == NULL) exit(-1);
}void main_deconstructor( void )
{
fclose( fp );
}void __cyg_profile_func_enter( void *this, void *callsite )
{
fprintf(fp, “E%p\n”, (int *)this);
}void __cyg_profile_func_exit( void *this, void *callsite )
{
fprintf(fp, “X%p\n”, (int *)this);
}
Ref:
1. 用 Graphviz 可视化函数调用 http://www.ibm.com/developerworks/cn/linux/l-graphvis/
–EOF–
把系统升级到ubuntu 8.04 后分辨率变为800*600, Google找到开源的OpenChrome驱动支持P4M890, 就自己手动编译:
border@b0rder:~$ wget http://openchrome.org/releases/xf86-video-openchrome-0.2.902.tar.gz border@b0rder:~$ tar xvzf xf86-video-openchrome-0.2.902.tar.gz sudo apt-get build-dep xserver-xorg-driver-via 或者安装 sudo apt-get build-dep xserver-xorg-video-openchrome cd xf86-video-openchrome-0.2.902/ ./configure --prefix=/usr make sudo make install border@b0rder:~$ sudo displayconfig-gtk 通过displayconfig-gtk 选择openchrome驱动重新启动系统就可以
硬件信息:
border@b0rder:~/tools$ lspci 00:00.0 Host bridge: VIA Technologies, Inc. P4M890 Host Bridge 00:00.1 Host bridge: VIA Technologies, Inc. P4M890 Host Bridge 00:00.2 Host bridge: VIA Technologies, Inc. P4M890 Host Bridge 00:00.3 Host bridge: VIA Technologies, Inc. P4M890 Host Bridge 00:00.4 Host bridge: VIA Technologies, Inc. P4M890 Host Bridge 00:00.5 PIC: VIA Technologies, Inc. P4M890 I/O APIC Interrupt Controller 00:00.6 Host bridge: VIA Technologies, Inc. P4M890 Security Device 00:00.7 Host bridge: VIA Technologies, Inc. P4M890 Host Bridge 00:01.0 PCI bridge: VIA Technologies, Inc. VT8237 PCI Bridge 00:02.0 PCI bridge: VIA Technologies, Inc. P4M890 PCI to PCI Bridge Controller 00:03.0 PCI bridge: VIA Technologies, Inc. P4M890 PCI to PCI Bridge Controller 00:0f.0 IDE interface: VIA Technologies, Inc. VT8237A SATA 2-Port Controller (rev 80) 00:0f.1 IDE interface: VIA Technologies, Inc. VT82C586A/B/VT82C686/A/B/VT823x/A/C PIPC Bus Master IDE (rev 07) 00:10.0 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev a0) 00:10.1 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev a0) 00:10.2 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev a0) 00:10.3 USB Controller: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (rev a0) 00:10.4 USB Controller: VIA Technologies, Inc. USB 2.0 (rev 86) 00:11.0 ISA bridge: VIA Technologies, Inc. VT8237A PCI to ISA Bridge 00:11.7 Host bridge: VIA Technologies, Inc. VT8251 Ultra VLINK Controller 00:12.0 Ethernet controller: VIA Technologies, Inc. VT6102 [Rhine-II] (rev 7c) 00:13.0 PCI bridge: VIA Technologies, Inc. VT8237A Host Bridge 01:00.0 VGA compatible controller: VIA Technologies, Inc. UniChrome Pro IGP [VIA P4M890 Chipset] (rev 01) 04:01.0 Audio device: VIA Technologies, Inc. VIA High Definition Audio Controller (rev 10)
–EOF–
Recent Comments