linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: drscholl <drscholl@users.sourceforge.net>
To: Iain Sandoe <iain@sandoe.co.uk>
Cc: "Clayton,Keith - Programmer" <Clayton@ltcc.cc.ca.us>,
	"'alex@cosmo.allay.net'" <alex@cosmo.allay.net>,
	linuxppc-dev@lists.linuxppc.org, drscholl@users.sourceforge.net
Subject: Re: Endianness and comparing IP's
Date: Sat, 6 Jan 2001 17:14:07 -0500	[thread overview]
Message-ID: <20010106171407.A68753@frostedflakes.neglected.net> (raw)
In-Reply-To: <20010106012137.8A8651BFBA@atlas.valhalla.net>; from iain@sandoe.co.uk on Sat, Jan 06, 2001 at 12:22:33AM +0000


On Sat, Jan 06, 2001 at 12:22:33AM +0000, Iain Sandoe wrote:
> more to the point is that there are a set of macros/functions designed for
> this purpose (try man htons)... which avoids thinking to hard about
> transferring between endian-ness of machines.
>
> I'm not sure why the BSWAP32 is being used instead of one of the network
> macros... maybe a red-herring but...

Unfortunately Napster, Inc. chose to use little-endian format IP addresses
in the protocol, so the traditional htonl() macros aren't useful in
this case.  What gets stored in the context for the connection is the
little-endian version so that each time the ip address is sent as part
of the protocol, there is no need for bit manipulation.  The particular check
that Alex set has the IP address in network byte order (from the
gethostbyname() call), so its *required* that the bits be swapped to check
against what is stored in the context.

All of the ints in question are unsigned, so there isn't an issue of
conversion (I beleive gcc -W -Wall -pedantic would have warned if you
tried to do a comparison of different types, anyway).

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

  reply	other threads:[~2001-01-06 22:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-01-06  0:22 Endianness and comparing IP's Iain Sandoe
2001-01-06 22:14 ` drscholl [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-01-06 23:37 Iain Sandoe
2001-01-07  2:54 ` Keith Clayton
2001-01-08  7:16 ` Geert Uytterhoeven
2001-01-08 13:20   ` alex avriette
2001-01-06 23:05 Iain Sandoe
2001-01-06 22:28 Iain Sandoe
2001-01-06 22:39 ` drscholl
2001-01-05 23:26 Iain Sandoe
2001-01-05 21:45 Clayton,Keith - Programmer
2001-01-05 21:07 Jerome L Quinn
2001-01-05 20:25 alex avriette

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010106171407.A68753@frostedflakes.neglected.net \
    --to=drscholl@users.sourceforge.net \
    --cc=Clayton@ltcc.cc.ca.us \
    --cc=alex@cosmo.allay.net \
    --cc=iain@sandoe.co.uk \
    --cc=linuxppc-dev@lists.linuxppc.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).