diff options
author | des <des@FreeBSD.org> | 2004-07-06 12:13:28 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2004-07-06 12:13:28 +0000 |
commit | 93180ebf2d291b1bba586c96cddb79d028f53e29 (patch) | |
tree | 26f30e4465d6cc4e19885a8912879ee00b6630f9 /lib/libalias/alias_local.h | |
parent | 858232d10a73b399e1b8a7eedd3dc58a225442a6 (diff) | |
download | FreeBSD-src-93180ebf2d291b1bba586c96cddb79d028f53e29.zip FreeBSD-src-93180ebf2d291b1bba586c96cddb79d028f53e29.tar.gz |
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.
Diffstat (limited to 'lib/libalias/alias_local.h')
-rw-r--r-- | lib/libalias/alias_local.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/libalias/alias_local.h b/lib/libalias/alias_local.h index bf923a2..67947da 100644 --- a/lib/libalias/alias_local.h +++ b/lib/libalias/alias_local.h @@ -324,6 +324,32 @@ enum alias_tcp_state { ALIAS_TCP_STATE_DISCONNECTED }; +#if defined(_NETINET_IP_H_) +static __inline void * +ip_next(struct ip *iphdr) +{ + char *p = (char *)iphdr; + return (&p[iphdr->ip_hl * 4]); +} +#endif + +#if defined(_NETINET_TCP_H_) +static __inline void * +tcp_next(struct tcphdr *tcphdr) +{ + char *p = (char *)tcphdr; + return (&p[tcphdr->th_off * 4]); +} +#endif + +#if defined(_NETINET_UDP_H_) +static __inline void * +udp_next(struct udphdr *udphdr) +{ + return ((void *)(udphdr + 1)); +} +#endif + /*lint -restore */ #endif /* !_ALIAS_LOCAL_H_ */ |