Welcome to the Linux Foundation Forum!

Fetch IP address of interface(port) in Kernel

Options

Hi guys, ( I am author/founder TrafficSqueezer - Linux kernel wan opt.solution).

I want a quick portion of code to get IP address of interface, (preferrably also IPv6) for a given interface/port name in a API.

for example I need whihin kernel context (its a part of TrafficSqueezer kernel source):

int ts_get_port_ip_addr(char *port_name, char *ip_addr, char *ipv6_addr)

{

....

}

So that i can call this:

ts_get_port_ip_addr("eth0", ip_addr, ipv6_addr) --> something like that.

Can someone come up with a direct suggestion or some api for it ? Which I can call in that above my API wrapper i.e: ts_get_port_ip_addr().

Currently I have this blank dummy api, so I push actually from user-space to kernel space, the extracted IPaddr directly. But I want to happen implicit within kernel. I search for APis in kernel, still didnt figured out exact API or call sequence, and I need a tip/suggestions from someone who knows it already.

Thank you in advance.

Categories

Upcoming Training