摘要: 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 阅读(1821) 评论(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 阅读(712) 评论(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 阅读(329) 评论(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) 编辑