#include
typedef u_int32_t in_addr_t;
struct in_addr
{
in_addr_t s_addr;
};
void main()
{
char error_content[PCAP_ERRBUF_SIZE];
struct in_addr net_ip_address;
struct in_addr net_mask_address;
char *net_interface;
char *net_ip_string;
char *net_mask_string;
u_int32_t net_ip;
u_int32_t net_mask;
net_interface = pcap_lookupdev(error_content);
pcap_lookupnet(net_interface,&net_ip,&net_mask,error_content);
printf("Network Interface is : %s\n",net_interface);
net_ip_address.s_addr = net_ip;
net_ip_string = inet_ntoa(net_ip_address);
printf("Network IP Address is :%s\n",net_ip_string);
net_mask_address.s_addr = net_mask;
net_mask_string = inet_ntoa(net_mask_address);
printf("Network Mask Address is :%s\n",net_mask_string);
}
利用libpcap 编程获取网络接口信息的时候 无法 获得 IP地址和子网掩码,只能打印端口名,编译时报错 inet_ntoa()函数返回赋值时类型不匹配,运行程序时段错误 请教各位大神哪里出错
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。