Search code examples
network-programmingkernelnetwork-interfacenetfilter

Get network interface IPv4 address in a netfilter hook


To my understanding the

const struct net_device *in

hook parameter describes the network interface that the packet came in through.

Is there any possible way to get the IPv4 address of the interface from that struct?

kernel version 3.2.0

thanks


Solution

  • I found the code I needed here. My adapters only have one IPv4 address so I managed getting it with:

    ((in->ip_ptr)->ifa_list)->ifa_address;