摘要: 在tun_dev.c中定义: int tun_write(int fd, char *buf, int len){ return write(fd, buf, len);} int tun_read(int fd, char *buf, int len){ return read(fd, buf, len);} 阅读全文
posted @ 2012-09-21 10:04 helloweworld 阅读(572) 评论(0) 推荐(0) 编辑
摘要: vtun如何解析启动客户端或服务器的命令行参数?Usage: Server: vtund <-s> [-f file] [-P port] [-L local address] Client: vtund [-f file] [-p] [-m] [-t timeout] <host profile> <server address>预备知识:-s –f –P 等称为选项;file port称为选项对应的参数;host file server address ——暂且称它们为非选项字符串吧。解析代码在main.c中。在vtun源码中是这样实现的:1234567 阅读全文
posted @ 2012-09-20 20:07 helloweworld 阅读(1819) 评论(0) 推荐(0) 编辑
摘要: 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162/*原型:int getopt(int argc, char * const argv[], const char *optstring);四个全局变量:extern char *optarg; //指向选项的参数的指针。extern int optind, //存储位置,下一次调用getopt的时,从optind存储的位置处重新开始检查选项。extern int o 阅读全文
posted @ 2012-09-20 19:04 helloweworld 阅读(702) 评论(0) 推荐(0) 编辑
摘要: 1234567891011121314151617181920212223/**********************Name:a.outAuthor:不学则死Date:2012/9/20CopyRight:转载注明出处***********************//*argc是整个命令行参数的个数;argv[0] 指向程序运行的全路径名;argv[1] 指向执行程序名后的第一个字符串;argv[2] 指向执行程序名后的第二个字符串;...argv[argc]为NULL。*/#include<stdio.h>intmain(int argc, char** argv) { in 阅读全文
posted @ 2012-09-20 15:27 helloweworld 阅读(328) 评论(0) 推荐(1) 编辑
摘要: 一般步骤: #gcc –g test.c #l #break <行号> #r #n 要用gdb调试,在编译时要加-g选项。 如: #gcc –g test.c #gdb a.out 运行时要加入参数: 进入gdb后输入(gdb)run 参数1 参数2 ….即可 对应vtun即 #gdb vtund (gdb)r server [vtun服务器地址] 阅读全文
posted @ 2012-09-20 10:16 helloweworld 阅读(502) 评论(0) 推荐(0) 编辑
摘要: #gdb vtund (gdb)break 57 (gdb)r (gdb)n … vtund[4904]: Unknown option 'pass' line 12vtund[4904]: No hosts defined 原因:默认读/usr/local/etc/vtund.conf,此文件中的12行pass应该为passwd, 解决:将配置成功的的文件替换默认读的文件 阅读全文
posted @ 2012-09-20 10:11 helloweworld 阅读(318) 评论(0) 推荐(0) 编辑
摘要: 3.0.3 双系统 #./configure –-disable-lzo #make install vm安装提示找不到strip 解决方法:cp /usr/bin/strip /usr/local/bin vm安装3.0.1同上 阅读全文
posted @ 2012-09-19 22:46 helloweworld 阅读(349) 评论(0) 推荐(0) 编辑
摘要: http://wiki.ubuntu.org.cn/index.php?title=%E8%B7%9F%E6%88%91%E4%B8%80%E8%B5%B7%E5%86%99Makefile:MakeFile%E4%BB%8B%E7%BB%8D&variant=zh-cn 阅读全文
posted @ 2012-09-19 15:02 helloweworld 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 四个阶段:预编译、编译、汇编和链接。阶段输入输出工具示例预编译*.c*.i预处理器cppgcc –E test.c –o test.i编译*.i*.s 汇编代码编译器egcsgcc –S test.i –o test.s汇编*.s*.o 目标代码汇编器asgcc –c test.s –o test.o链接*.o可执行文件连接器ldgcc test.o –o test简单理解:预编译:替换宏定义的变量和include包含以及进行条件编译;即如#define PI 3.1415,则将文件中的PI用3.1415替换,include文件包含和条件编译同理。编译:生成汇编语言。汇编:生成机器语言。链接: 阅读全文
posted @ 2012-09-19 14:13 helloweworld 阅读(241) 评论(0) 推荐(0) 编辑
摘要: 一、客户端 options{port5000;#Listenonthisport.ppp/usr/sbin/pppd;ifconfig/sbin/ifconfig;route/sbin/route;firewall/sbin/iptables;}server{passwdMa&^TU;#Passwordkeepaliveyes;#Keepconnectionalivetypetun;protoud... 阅读全文
posted @ 2012-09-18 22:30 helloweworld 阅读(885) 评论(0) 推荐(0) 编辑