|
|
cranium.2003@xxxxxxxxx wrote:
> hello,
> I just want to know on which interface packet is routed and get that
> local ethernet IP address. Is that possible for me once routing
> decision takes place? I want to modify some code in kernel network
> stack.
Hi,
yes, it certainly is possible. But as I pointed out previously, there is no
need to do that. To make the TCP/IP stack do things, the Netfilter hooks
are the thing you are looking for. It is way easier, no need to recompile
the kernel and you can load/unload it any time. To log incoming interface
and IP, you will need hardly more than 4 or 5 lines of code. Try the
prerouting hook and call from there function ip_route_input(). The incoming
interface is sotred as a pointer to a net_device structure in the socket
buffer. The name is simply 'dev'. Lookup the interface BEFORE
ip_route_input(), because this function will change the pointer to the
outgoing device afterwards, or NULL if the packets destination is the local
host.
Alex
|
|