网络安全编程——网络接口信息获取(1)

一、网络接口信息获取

1.1 获取网络接口信息

本代码来源于《网络安全开发包详解》部分地方做了修改。

编译方式:(懒人编译法)

gcc  1_1.c -lpcap 生成a.out可执行文件使用命令:./a.out执行。

与书上不同的地方:

1)用inet_ntoa()函数需要使用头文件<arpa/int.h>。如果不加入该头文件,编译过程中会发现该函数未定义的警告。

2.)使用man可能无法查找到inet_ntoa()函数。使用:apt-get install manpages-posix-dev 命令安装相关包可以解决这个问题。通过man可以看出使用相关函数时需要 #include <sys/socket.h>、#include <netinet/in.h>、#include <arpa/inet.h>三个头文件。而本程序中只需要<arpa/inet.h>就可以了。

3)在#include <arpa/inet.h>中已经包含了struct in_addr所以不需要重新定义。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
#ifndef __REQUIRED_RPCNDR_H_VERSION__ #define __REQUIRED_RPCNDR_H_VERSION__ 440 #endif #include "rpc.h" #include "rpcndr.h" #ifndef __RPCNDR_H_VERSION__ #error this stub requires an updated version of #endif // __RPCNDR_H_VERSION__ #ifndef COM_NO_WINDOWS_H #include "windows.h" #include "ole2.h" #endif /*COM_NO_WINDOWS_H*/ #ifndef __netcon_h__ #define __netcon_h__ /* Forward Declarations */ #ifndef __IEnumNetConnection_FWD_DEFINED__ #define __IEnumNetConnection_FWD_DEFINED__ typedef interface IEnumNetConnection IEnumNetConnection; #endif /* __IEnumNetConnection_FWD_DEFINED__ */ #ifndef __INetConnection_FWD_DEFINED__ #define __INetConnection_FWD_DEFINED__ typedef interface INetConnection INetConnection; #endif /* __INetConnection_FWD_DEFINED__ */ #ifndef __INetConnectionManager_FWD_DEFINED__ #define __INetConnectionManager_FWD_DEFINED__ typedef interface INetConnectionManager INetConnectionManager; #endif /* __INetConnectionManager_FWD_DEFINED__ */ #ifndef __INetConnectionConnectUi_FWD_DEFINED__ #define __INetConnectionConnectUi_FWD_DEFINED__ typedef interface INetConnectionConnectUi INetConnectionConnectUi; #endif /* __INetConnectionConnectUi_FWD_DEFINED__ */ #ifndef __INetConnectionPropertyUi_FWD_DEFINED__ #define __INetConnectionPropertyUi_FWD_DEFINED__ typedef interface INetConnectionPropertyUi INetConnectionPropertyUi; #endif /* __INetConnectionPropertyUi_FWD_DEFINED__ */ #ifndef __INetConnectionCommonUi_FWD_DEFINED__ #define __INetConnectionCommonUi_FWD_DEFINED__ typedef interface INetConnectionCommonUi INetConnectionCommonUi;

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值