Re: determine outgoing interface (eth0,eth1) for a packet according to the dest IP

2006-04-30 Thread Herbert Xu
On Sun, Apr 30, 2006 at 11:17:11AM +0200, Lennert Buytenhek wrote: > > A fragile and ugly but easier/shorter way of getting the source address > (which I've used a couple of times in the past) is to open a SOCK_DGRAM > socket, connect() it to the intended destination, and then do > getsockname().

Re: determine outgoing interface (eth0,eth1) for a packet according to the dest IP

2006-04-30 Thread Lennert Buytenhek
On Wed, Apr 26, 2006 at 11:58:00PM +1000, Herbert Xu wrote: > > I had spent time trying to write something which > > uses RTA_SRC and RTA_DST and got some problems. > > (I probably made something stupid.) > > I googled for such examples and did not get much. > > I saw that the zebra project and ip

Re: determine outgoing interface (eth0,eth1) for a packet according to the dest IP

2006-04-26 Thread Herbert Xu
John Que <[EMAIL PROTECTED]> wrote: > > I had spent time trying to write something which > uses RTA_SRC and RTA_DST and got some problems. > (I probably made something stupid.) > I googled for such examples and did not get much. > I saw that the zebra project and iproute uses > netlinks but it is

Re: determine outgoing interface (eth0,eth1) for a packet according to the dest IP

2006-04-26 Thread John Que
Hello, Does anybody knows where suh a code example which gets routing info according to the destination IP using GETROUTE netlink sockets can be found ? I had spent time trying to write something which uses RTA_SRC and RTA_DST and got some problems. (I probably made something stupid.) I googled f

Re: determine outgoing interface (eth0,eth1) for a packet according to the dest IP

2006-04-25 Thread Andi Kleen
On Tuesday 25 April 2006 16:44, John Que wrote: > Thanks a lot ! > > I had tried the sending RTM_GETROUTE message using a NETLINK_ROUTE > socket in a User Space program and it went OK. > > It gaves correct routing struct which I could parse. > In fact it gave the rotuing

Re: determine outgoing interface (eth0,eth1) for a packet according to the dest IP

2006-04-25 Thread John Que
Thanks a lot ! I had tried the sending RTM_GETROUTE message using a NETLINK_ROUTE socket in a User Space program and it went OK. It gaves correct routing struct which I could parse. In fact it gave the rotuing table. But in sending that message I did not

Re: determine outgoing interface (eth0,eth1) for a packet according to the dest IP

2006-04-25 Thread David S. Miller
From: Andi Kleen <[EMAIL PROTECTED]> Date: Tue, 25 Apr 2006 09:43:49 +0200 > On Tuesday 25 April 2006 09:31, John Que wrote: > > Hello, > > What is the right way to determine on which interface card > > (eth0 or eth1) will a packet be sent (according to the dest IP)? > > You can send a rtnetlink

Re: determine outgoing interface (eth0,eth1) for a packet according to the dest IP

2006-04-25 Thread Andi Kleen
On Tuesday 25 April 2006 09:31, John Que wrote: > Hello, > What is the right way to determine on which interface card > (eth0 or eth1) will a packet be sent (according to the dest IP)? You can send a rtnetlink RTM_GETROUTE message to ask the kernel. Result is the interface index in RTA_OIF, which

determine outgoing interface (eth0,eth1) for a packet according to the dest IP

2006-04-25 Thread John Que
Hello, What is the right way to determine on which interface card (eth0 or eth1) will a packet be sent (according to the dest IP)? I have a machine with two NICS (eth0 and eth1). I have 2 different gateways. I need to know on which interface (eth0 or eth1) will the packet be send according to the