Skip to contentSkip to conversation

About conversion between iphdr->saddr and String-format IP Address

DISCUSSION Kunsheng Chen 2 participants 2 messages Mar 23, 2009 netfilter

lore
Share & tools
lore
#0 lore raw

Hello everyone,

I am looking for some functions to convert ip address in string format into=
unsigned int and versa vice.

Does it have some function like 'inet_addr' inside kernel for that?=A0 Basi= cally what I want to do is conver iphdr->s_addr into a String type, which w= ould give me a readable ip address for debugging.

Any idea is well appreciated,

Thanks,

+Kunsheng

#1 lore raw
Quoted 9 lines · Kunsheng Chen

Hello everyone,

I am looking for some functions to convert ip address in string format into= unsigned int and versa vice.

Does it have some function like 'inet_addr' inside kernel for that?=A0 Basi= cally what I want to do is conver iphdr->s_addr into a String type, which w= ould give me a readable ip address for debugging.

printk(KERN_DEBUG "%pI6", &ih->saddr); /* 2.6.29+ */ printk(KERN_DEBUG NIP6_FMT, NIP6(ih->saddr)); /* older */