[Top] [All Lists]

Re: How to determine source ip address

To: Julian Anastasov <ja@xxxxxx>
Subject: Re: How to determine source ip address
From: Padraig Brady <padraig@xxxxxxxxxxxxx>
Date: Wed, 12 Sep 2001 12:06:12 +0100
Cc: Christopher Friesen <cfriesen@xxxxxxxxxxxxxxxxxx>, netdev@xxxxxxxxxxx
References: <Pine.LNX.4.33.0109112221030.17728-100000@u.domain.uli>
Sender: owner-netdev@xxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.3) Gecko/20010808
Julian Anastasov wrote:


On Tue, 11 Sep 2001, Padraig Brady wrote:

Chris, I'm only filling in the TCP header, and I realise the IP header
will be
filled appropriately when sent. However I need to calculate the checksum for
the TCP header which is actually calculated for the pseudo header:

The checksum is calculated for you in raw_getrawfrag()

For IP not *TCP*. I must do this myself I think, but it's fine, I can do this easily.

So I need to determine the source address before sending...

getsockname() gives it to you after connect() to the DGRAM socket.

I don't have to worry about source routing, but thanks for the info. I
don't think
I have to call connect() so, do I?

You have to, if you need the source address

Great I don't have to do it so.

I'm still unsure how to get a source port that will never clash with
existing connections, but that's not a major problem.

Hm, then you have to create a normal TCP socket and to receive port with bind(). I don't know your goals, so you have to take into account everything you know.

Basically I'm building a TCP header and need to use a local port number that
wont clash with anything. I'll just use rand() for the moment, if there is nothing


<Prev in Thread] Current Thread [Next in Thread>