#include stdio.h> #include stdlib.h> #include string.h> #include errno.h> #include unistd.h> #include sys/socket.h> #include sys/ioctl.h> #include net/if.h> #include net/if_arp.h> #include arpa/inet.h> #define inaddrr( x ) ( *( struct in_addr * )&ifr->x[ sizeof( sa.sin_port ) ] ) #define IFRSIZE ( ( int )( size * sizeof( struct ifreq ) ) ) int main ( void ) { unsigned char * u; int sockfd...
一个示例脚本: import os import re def Getmac(): if os.name == 'nt': try: ret = '' CmdLine = 'ipconfig /all' r = os.popen(CmdLine).read() if r: L = re.findall('Physical Address.*?([0-9,A-F]{2}-[0-9,A-F]{2}-[0-9,A-F]{2}-[0-9,A-F]{2}-[0-9,A-F]{2}-[0-9,A-F]{2})', r) if len(L) > 0: ret =...
/** * 获取网卡mac地址 */ public static String getmacOnWindow() { try { String mac = null; Process process = Runtime.getRuntime().exec("ipconfig /all"); BufferedReader buffer = new BufferedReader(new InputStreamReader(process.getInputStream())); for (String line = buffer.readLine(); line != null; line = buf...
获取主机mac地址的代码: #include #include #include #include #include #include #include int main() { struct ifreq ifr; int sock; unsigned char *ptr; int status; strcpy (ifr.ifr_name , "eth0"); sock = socket (PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); if (sock == -1) { perror ("socket error "); return -1; } status = ioctl (sock, SIOCGIFHWA...
获取mac: # fping -g 192.168.0.1 192.168.0.255 # 指定一个地址范围 # arp -na # ip跟mac 就是这么简单. :m01:
请问,如何在程序当中获取局域网里机器的所有ip地址与其对应的mac地址. OS : RedHat Linux9.0 我下载了一些本论坛的代码, 没有一个可以编译过去的, 提示都是些宏找不到, 我就搜索/usr/include/下的所有文件,唉,好难找啊. 有些头文件都找不到. 郁闷 啊, 那位有写好的代码给share一下咯. 小弟感谢了. 谢谢!