From 9fa0fd268273d90e765d9ebfe0be87ea4d64e138 Mon Sep 17 00:00:00 2001 From: Dag-Erling Smørgrav Date: Tue, 6 Jul 2004 12:13:28 +0000 Subject: Introduce inline {ip,udp,tcp}_next() functions which take a pointer to an {ip,udp,tcp} header and return a void * pointing to the payload (i.e. the first byte past the end of the header and any required padding). Use them consistently throughout libalias to a) reduce code duplication, b) improve code legibility, c) get rid of a bunch of alignment warnings. --- sys/netinet/libalias/alias_nbt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sys/netinet/libalias/alias_nbt.c') diff --git a/sys/netinet/libalias/alias_nbt.c b/sys/netinet/libalias/alias_nbt.c index 151bc9d934d1..b51abd1c5da5 100644 --- a/sys/netinet/libalias/alias_nbt.c +++ b/sys/netinet/libalias/alias_nbt.c @@ -218,10 +218,10 @@ AliasHandleUdpNbt( (void)lnk; /* Calculate data length of UDP packet */ - uh = (struct udphdr *)((char *)pip + (pip->ip_hl << 2)); + uh = (struct udphdr *)ip_next(pip); pmax = (char *)uh + ntohs(uh->uh_ulen); - ndh = (NbtDataHeader *) ((char *)uh + (sizeof(struct udphdr))); + ndh = (NbtDataHeader *)udp_next(uh); if ((char *)(ndh + 1) > pmax) return (-1); #ifdef DEBUG @@ -654,9 +654,9 @@ AliasHandleUdpNbtNS( nbtarg.newport = *original_port; /* Calculate data length of UDP packet */ - uh = (struct udphdr *)((char *)pip + (pip->ip_hl << 2)); + uh = (struct udphdr *)ip_next(pip); nbtarg.uh_sum = &(uh->uh_sum); - nsh = (NbtNSHeader *) ((char *)uh + (sizeof(struct udphdr))); + nsh = (NbtNSHeader *)udp_next(uh); p = (u_char *) (nsh + 1); pmax = (char *)uh + ntohs(uh->uh_ulen); -- cgit v1.3