1

I am writing a module that extracts the MAC address of the Ethernet Mac header of wireless 802.11 packet. I extract the ethernetmac header as

ieee = (struct ieee80211_hdr *)skb_mac_header(sock_buff);
ieee->addr1[ETH_ALEN];
ieee->addr2[ETH_ALEN];
ieee->addr3[ETH_ALEN];

I want to print these addresses to see the values it contains. How do I do that using printk and KERN_INFO

Currently i am using this statement but it causes kernel in panic mode

printk(KERN_INFO "The address is %x:%x:%x:%x:%x:%x", ieee->addr1[0],ieee->addr1[1],ieee->addr1[2],ieee->addr1[3],ieee->addr1[4],ieee->addr1[5]);
Areebah
  • 43
  • 8

1 Answers1

0

Hm, according to this, addr1 is u8 addr1[ETH_LEN], so:

printk("MAC %pM: \n", ieee->addr1);
Oleksandr Kravchuk
  • 5,963
  • 1
  • 20
  • 31
  • Noops, kernel again went under panic mode – Areebah Apr 06 '14 at 10:59
  • are you completely sure it panics on printk() call? check if it's not NULL. – Oleksandr Kravchuk Apr 06 '14 at 11:14
  • Yes, if I comment it out the kernel does not panic,but if I do write a statement that prints a variable value like this address the kernel panics. Also it does not panic if i use printk only to print some statement. I checked it this address is null, and its not null. What can be the problem? – Areebah Apr 06 '14 at 11:44
  • And also i just initialized an int i =9; and printed it, and it worked fine without panic and gave correct value of i variable – Areebah Apr 06 '14 at 11:47