I'm relatively new to kernel hacking and am working on a netfilter module. I'm trying to look at the contents of skb->data and am using this logging statement:
printk(KERN_INFO "==> before copy bits data %x\n\n", skb->data);
but I'm only getting what looks like the memory address, i.e. c672f5a0. How can I print this in ASCII?
Unprintable ASCII
What do u mean - 0xc6 is not a printable character, and so is 0xf5, and 0xa0.
printk and skb->data
Hi,
Have you tried to change %x to %p ?
Regards,
Douglas Landgraf
pointers
you really don't know how to dereference a pointer?
you may want to read the manual page of printf(). %x of course prints the value passed as argument (like %d or %c) and does not dereference it (like %s). how would printk() know the length of the data array anyway? you may want to preformat the data into a temporary string and print that with %s.
printing skb->data
why not just follow the way it is done in some parts of the linux kernel source code, eg,
in the drivers/net/macb.c:
For the pointer value:
printk("%x", skb->data);
For the data itself:
for(i=0;i<16;i++) printk("%02x", skb->data[i]);