Linux下获取MAC地址
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <netinet/if_ether.h>
#include <string.h>
#include <netinet/ether.h>
#include<unistd.h>
int main(int argc, char **argv)
{
printf("helloworld\n");
int nSocket;
struct ifreq struReq;
nSocket = socket(PF_INET,SOCK_STREAM,0);
memset(&struReq,0,sizeof(struReq));
if(argc < 2)
strncpy(struReq.ifr_name, "eth0", sizeof(struReq.ifr_name));
else
strncpy(struReq.ifr_name, argv[1], sizeof(struReq.ifr_name));
ioctl(nSocket,SIOCGIFHWADDR,&struReq);
fprintf(stderr, "%d-%s\n", __LINE__, strerror(errno));
printf("%s \n", ether_ntoa( (const ether_addr*)(struReq.ifr_ifru.ifru_hwaddr.sa_data)));
close(nSocket);
}
man reference
http://linux.die.net/man/7/netdevice
相关文档:
PCI是外围设备互连(Peripheral Component Interconnect)的简称,作为一种通用的总线接口标准,它在目前的计算机系统中得到了非常广泛的应用。PCI提供了一组完整的总线接口规范,其目的是描述如何将计算机系统中的外围设备以一种结构化和可控化的方式连接在一起。
&nbs ......
Qt 以其开源,免费,完全面向对象(很容易扩展),允许真正的组件编程以及可移植跨平台等诸多优势得到越来越多的开发人员的青睐。Qt
Creator 是 Nokia 官方推出的专门针对 Qt 开发的 IDE。本文详细介绍了 Linux 下 Qt Creator 的安装,并针对
Qt Creator 的使用举了一个 Hello World 级别的例子,希望对第一次接触 Qt Cre ......
linux的free命令中,cached和buffers的区别
Free
free 命令相对于top 提供了更简洁的查看系统内存使用情况:
$ free
total used free shared buffers cachedMem: 255268 238332 16936 0 85540 126384-/+ buffers/cache: 26408 228860Swap: 265000 0 265000
Mem:表示物理内存统计
-/+ buffers/ca ......
Linux, named after the inventor, Linus Torvalds, is a so different OS for everyone against Windows. To everyone who used to use Windows, Linux need us to do more for everything which we usually do by computer, such as playing a video.
Someone says, Linux is for the ones who are good at the computer ......
一、Qt3/Embedded的输入设备的驱动接口实现原理分析
1、Qt3/Embedded把与底层硬件相关的源文件统一放在src/embedded目录下,所以我们最好也把自己的设备驱动接口文件放到此目录。
2、Qt/Embedded中的输入设备分为鼠标类与键盘类。在3.x版本系列中,鼠标设备的抽象基类为QWSMouseHandler,在sr ......