diff options
author | glebius <glebius@FreeBSD.org> | 2012-10-23 10:29:31 +0000 |
---|---|---|
committer | glebius <glebius@FreeBSD.org> | 2012-10-23 10:29:31 +0000 |
commit | e4588fbb85bd0666ca8a968aaa2ec629cec2991f (patch) | |
tree | 7e4d610c873d26f59c77183cdd9bfb3b95d9993a /sys/netinet/ip_options.c | |
parent | fea857f2a843cb039f3757ef79ba28b083d7a0c3 (diff) | |
download | FreeBSD-src-e4588fbb85bd0666ca8a968aaa2ec629cec2991f.zip FreeBSD-src-e4588fbb85bd0666ca8a968aaa2ec629cec2991f.tar.gz |
Simplify ip_stripoptions() reducing number of intermediate
variables.
Diffstat (limited to 'sys/netinet/ip_options.c')
-rw-r--r-- | sys/netinet/ip_options.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/sys/netinet/ip_options.c b/sys/netinet/ip_options.c index 5083f6f..df32027 100644 --- a/sys/netinet/ip_options.c +++ b/sys/netinet/ip_options.c @@ -458,20 +458,18 @@ ip_srcroute(struct mbuf *m0) void ip_stripoptions(struct mbuf *m) { - int i; struct ip *ip = mtod(m, struct ip *); - caddr_t opts; int olen; - olen = (ip->ip_hl << 2) - sizeof (struct ip); - opts = (caddr_t)(ip + 1); - i = m->m_len - (sizeof (struct ip) + olen); - bcopy(opts + olen, opts, (unsigned)i); + olen = (ip->ip_hl << 2) - sizeof(struct ip); m->m_len -= olen; if (m->m_flags & M_PKTHDR) m->m_pkthdr.len -= olen; ip->ip_len = htons(ntohs(ip->ip_len) - olen); ip->ip_hl = sizeof(struct ip) >> 2; + + bcopy((char *)ip + sizeof(struct ip) + olen, (ip + 1), + (size_t )(m->m_len - sizeof(struct ip))); } /* |