That might also convince the compiler that it can "helpfully" optimize
the copy into something that assumes 4-byte alignment, which we don't
want it to do on platforms where the optimized code will trap if the IP
header *isn't* aligned on a 4-byte boundary, given that there's no
guarantee that it *is* aligned on a 4-byte boundary.
void
ipN_print(register const u_char *bp, register u_int length)
{
- struct ip *ip, hdr;
+ struct ip hdr;
- ip = (struct ip *)bp;
if (length < 4) {
(void)printf("truncated-ip %d", length);
return;
}
- memcpy (&hdr, (char *)ip, 4);
+ memcpy (&hdr, bp, 4);
switch (IP_V(&hdr)) {
case 4:
ip_print (gndo, bp, length);