2 #ifndef _TQ_NETWORK_H__ 3 #define _TQ_NETWORK_H__ 26 #include <arpa/inet.h> 27 #include <sys/ioctl.h> 28 #include <sys/types.h> 29 #include <sys/socket.h> 31 #include <netinet/in_systm.h> 32 #include <netinet/ip.h> 33 #include <netinet/ip_icmp.h> 44 #include <netinet/in.h> 46 #include <net/route.h> 47 #include <net/if_arp.h> 52 #define ETHER_ADDR_LEN 6 56 static char dns_file_path[] =
"/etc/resolv.conf\0";
86 int get_ip(
char *dev,
char *ip,
int size);
132 int get_mac(
char *dev,
char *mac,
int size);
144 int get_dns(
char *dns1,
int size1,
char *dns2,
int size2);
152 int check_ping(
const char *target,
unsigned int timeout_ms);
161 int check_ping2(
const char *iface,
const char *target,
unsigned int timeout_ms);
177 int SetIfAddr(
char *ifname,
char *Ipaddr,
char *mask);
203 int set_dns(
char *dns1,
char *dns2);
219 int ether_atoe(
const char *a,
unsigned char *e);
227 char *
ether_etoa(
const unsigned char *e,
char *a);
232 void udhcpc(
char *net_interface);
int get_dns(char *dns1, int size1, char *dns2, int size2)
获取本机指定的DNS服务器地址
int check_ping2(const char *iface, const char *target, unsigned int timeout_ms)
网络检测函数,类似于ping命令(指定端口)
int set_mac_addr(char *ifname, char *mac)
设置网卡MAC地址
int get_gateway(char *dev, char *gway, int size)
获取指定网卡设备的网关
int get_ip_by_domain(const char *trgtadd, char *ip, int size)
根据域名获取默认网卡设备的ip地址
int get_mac(char *dev, char *mac, int size)
获取指定网卡设备的mac地址
void udhcpc(char *net_interface)
用udhcpc获取ip地址
int detect_eth_cable(char *ifname)
网卡状态检测
int set_dns(char *dns1, char *dns2)
设置本机DNS服务器地址,DNS地址如114.114.114.114
int check_ping(const char *target, unsigned int timeout_ms)
网络检测函数,类似于ping命令
int get_ip(char *dev, char *ip, int size)
获取指定网卡设备的ip地址
int ether_atoe(const char *a, unsigned char *e)
将以太网地址串表示转换为二进制数据
int if_updown(char *ifname, int flag)
打开关闭网卡
int get_ip_info(char const *device, char *ip)
获取指定网卡设备的ip地址
int SetIfAddr(char *ifname, char *Ipaddr, char *mask)
设置网卡IP地址 子网掩码 网关等信息
int set_gateway(char *ifname, char *gateway)
设置网卡IP地址 子网掩码 网关等信息
int get_netmask(char *dev, char *mask, int size)
获取指定网卡设备的子网掩码
char * ether_etoa(const unsigned char *e, char *a)
将以太网地址二进制数据转换为字符串表示形式