On Sep 22, 10:45 am, Nick Keighley <nick_keighley_ nos...@hotmail. com>
wrote:
Only problem is that then entire frame in memory might have strange
alignment.
Yup!
I'm writing a program at the moment which maps a network, telling you
all the hosts present, and also telling you which routers (if any)
lead to the internet. I test for an internet connection by sending DNS
request packets to the MAC address of each of the hosts and seeing if
I get a reply. I hand-craft these DNS requests by myself, sending them
to different MAC addresses.
I wonder if it'd be too "distancing " to do the following for now:
#define GET_S(p) (p[0] << 8 | p[1])
But of course then I've the issue of multiple evaluation of the macro
argument.
wrote:
TCP/IP (I'm including UDP in that) headers are arranged so
that on most sane architectures you don't have alignment issues.
that on most sane architectures you don't have alignment issues.
Only problem is that then entire frame in memory might have strange
alignment.
you *are* writing your own UDP stack?
Yup!
I have seen code blow up on this. A well written UDP implementation
should be ok with this. This is why I'm wondering if you are the
implementor.
should be ok with this. This is why I'm wondering if you are the
implementor.
I'm writing a program at the moment which maps a network, telling you
all the hosts present, and also telling you which routers (if any)
lead to the internet. I test for an internet connection by sending DNS
request packets to the MAC address of each of the hosts and seeing if
I get a reply. I hand-craft these DNS requests by myself, sending them
to different MAC addresses.
I go with shift and or. It isn't much more code!
>
After we had the alignment trap we put this code in
>
p[0] << 8 + p[1]
>
which was "interestin g"
>
After we had the alignment trap we put this code in
>
p[0] << 8 + p[1]
>
which was "interestin g"
I wonder if it'd be too "distancing " to do the following for now:
#define GET_S(p) (p[0] << 8 | p[1])
But of course then I've the issue of multiple evaluation of the macro
argument.
Comment