Access MAC address from sk_buff
来源:互联网 发布:iphone写作软件 编辑:程序博客网 时间:2024/05/01 20:42
http://stackoverflow.com/questions/10127806/access-mac-address-from-sk-buff
Access MAC address from sk_buff
unsigned char h_dest[ETH_ALEN]; /* destination eth addr*/
unsigned char h_source[ETH_ALEN]; /* source ether addr*/
unsigned shorth_proto;/* packet type ID field*/
};
I'm writing a kernel module to get the MAC address from a packet stored in sk_buff. I've used the following code to print the MAC address of source and destination:
struct ethhdr *mh = eth_hdr(skb); printk(KERN_EMERG "Source MAC=%x:%x:%x:%x:%x:%x\n",mh->h_source[0],mh->h_source[1],mh->h_source[2],mh->h_source[3],mh->h_source[4],mh->h_source[5]);
The destination address can be accessed using h_dest
inplace of h_source
.
My problem is that the source MAC address is always a8:c0:0:0:a8:c0
and the destination MAC address is always some junk value instead of my own MAC address.
Can anyone help me out on this? I want to get the correct MAC addresses.
2 Answers
Where exactly in the kernel are you doing this?
a8:c0 looks quite suspicious. It translates to 168.192 in decimal, which makes me suspect that you're in fact looking at the IPv4 header rather than the Ethernet header.
Using eth_hdr
only makes sense if the skb actually has a MAC header. If it does not, the skb's MAC header pointer will just point to other data in the packet.
- Access MAC address from sk_buff
- 摘要 from MAC address wiki
- charles提示Denying access from address not on ACL解决方法
- From mac to access Winxp by virtualbox
- MySQL: Extracting timstamp and MAC address from UUIDs
- mac-vlan mac-address
- get ip address & mac address
- Access the Address Book
- access violation at address
- sk_buff
- sk_buff
- sk_buff
- sk_buff
- sk_buff
- sk_buff
- sk_buff
- MAC Address && IP muticast->MAC address
- How to got the Mac address from …
- 旅游
- 面试100题:21.中兴面试题:求整数数列中和等于给定值的两个数
- 递归读取文件目录结构
- Bruno Buchberger: A life devoted to symbolic computation
- Oracle Data Guard支持跨平台列表
- Access MAC address from sk_buff
- 字母大小写转换经典程序
- 9个内置对象
- 远程调用的几种方式
- PHP抓取网站页面、CSS文件、图片
- liunx tar打包命令
- _MBCS
- Waiting for X server to begin accepting connections.
- php.exe 命令行