![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
网络
刘星燎
弱小和无知不是生产的障碍,傲慢才是
展开
-
通过socket获取网卡状态
#include <stdio.h>#include <string.h>#include <errno.h>#include <fcntl.h>#include <getopt.h>#include <sys/socket.h>#include <sys/ioctl.h>#include &转载 2018-10-10 17:20:50 · 1968 阅读 · 0 评论 -
获取mac地址
#include <sys/ioctl.h>#include <net/if.h>#include <unistd.h>#include <netinet/in.h>#include <string.h>#include <stdio.h> int main(int argc,char *argv[]) { ...转载 2018-10-10 17:22:02 · 325 阅读 · 1 评论 -
获取ip地址
#include <stdio.h>#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>#include <arpa/inet.h>#include <sys/ioctl.h>#include <stdlib.h>#i转载 2018-10-10 17:22:23 · 196 阅读 · 0 评论 -
SIOCGMIIPHY,SIOCSMIIREG,SIOCGMIIPHY,SIOCETHTOOL
内核中定义在头文件 include/linux/sockios.h,定义如下:#define SIOCETHTOOL 0x8946 /* Ethtool interface */ ethtool 接口#define SIOCGMIIPHY 0x8947 /* Get address of MII PHY in use. */ ...转载 2018-10-10 17:23:02 · 1825 阅读 · 0 评论 -
ioctl在设置或获取套接字属性时的一些标识
所在文件sockios.h/* * INET An implementation of the TCP/IP protocol suite for the LINUX * operating system. INET is implemented using the BSD Socket * interface as the means of communication w...原创 2018-10-10 17:23:35 · 1769 阅读 · 0 评论 -
ifreq和ifconf
一、文件/usr/include/net/if.h二、作用ifreq用来配置ip地址,激活接口,配置MTU等接口信息的。其中包含了一个接口的名 字和具体内容(是个共用体,有可能是IP地址,广播地址,子网掩码,MAC号,MTU或其他内容)。ifreq包含在ifconf结构中。而 ifconf结构通常是用来保存所有接口的信息的。/* * Interface request stru...转载 2018-10-10 17:24:02 · 1039 阅读 · 0 评论