Ubuntu 9.04安装使用lipcap
2010-05-01 16:05
375 查看
一.安装 二.源程序 #include <stdio.h> #include <pcap.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> int main(void) { char *net_dev; char *ip_addr; char *net_mask; char errbuf[PCAP_ERRBUF_SIZE]; bpf_u_int32 netp; bpf_u_int32 maskp; struct in_addr addr; net_dev=pcap_lookupdev(errbuf); if(net_dev==NULL){ printf("cannot get the network device info: %s/n",errbuf); return 1; } printf("the network device is: %s/n",net_dev); if(pcap_lookupnet(net_dev,&netp,&maskp,errbuf)==-1){ printf("cannot get the network device ip info:%s/n",errbuf); return 1; } addr.s_addr=netp; ip_addr=inet_ntoa(addr); if(ip_addr==NULL){ printf("convert network address fail/n"); return 1; } printf("ip address is : %s/n",ip_addr); addr.s_addr=maskp; net_mask=inet_ntoa(addr); if(net_mask==NULL){ printf("convert network mask fail/n"); return 1; } printf("network mask is : %s/n",net_mask); return 0; } 三.编译运行
<html
xmlns="http://www.w3.org/1999/xhtml"><body
xmlns="http://www.w3.org/1999/xhtml"><div
xmlns="http://www.w3.org/1999/xhtml"><img width='77' height='5'
src='chrome://livemargins/skin/monitor-background-horizontal.png'
style='position: absolute;left:-77px;top:-5px'/> <img
src='chrome://livemargins/skin/monitor-background-vertical.png'
style='position: absolute;left:0;top:-5px;'/> <img
id='monitor-play-button'
src='chrome://livemargins/skin/monitor-play-button.png'
onmouseover='this.style.opacity=1' onmouseout='this.style.opacity=0.5'
style='position:
absolute;left:1px;top:0;opacity:0.5;cursor:pointer'/>
相关文章推荐
- Ubuntu9.04安装使用 用户名和密码 的squid代理服务器
- Windows 7下使用wubi安装Ubuntu9.04+新手常见问题
- ubuntu9.04安装和使用minicom串口通讯
- Mldonkey 在Ubuntu9.04的安装和使用
- Ubuntu 16.04 使用docker资料汇总与应用docker安装caffe并使用Classifier(ros kinetic+usb_cam+caffe)
- 支持在Ubuntu 8.10、Ubuntu 9.04系统上自动安装微软雅黑、monaco-linux、lu...
- Debian/Ubuntu下安装VirtualBox以及使用工行U盾
- Ubuntu Python2.7 django1.3 安装使用过程部分笔记
- 【转】VMware 6.5.2上安装Ubuntu9.04的问题探讨
- Ubuntu Docker安装及用户分组授权与Docker hub账号使用
- Ubuntu 9.04使用感受(升级到了10.04)
- Ubuntu 16.04下使用Wine安装文件比对工具Beyond Compare 4
- Win10下使用Hyper-V安装Ubuntu
- ubuntu14.04,必须会的技能-安装PPA源中的程序,更大范围使用deb格式安装文件!!
- Ubuntu下使用cmake的配置编译安装与卸载
- Ubuntu 14.04中安装Sublime Text 3并使用SublimeClang插件
- ubuntu安装rabbitmq和python的使用实现
- ubuntu git的安装配置使用
- UBuntu9.04安装NetBeans6.5.1中文乱码问题解决