version 1.149.2.1, 2015/01/23 09:27:15 |
version 1.149.2.1.2.2, 2018/02/25 23:17:22 |
Line 249 ip6_input(struct mbuf *m) |
|
Line 249 ip6_input(struct mbuf *m) |
|
int hit, off = sizeof(struct ip6_hdr), nest; |
int hit, off = sizeof(struct ip6_hdr), nest; |
u_int32_t plen; |
u_int32_t plen; |
u_int32_t rtalert = ~0; |
u_int32_t rtalert = ~0; |
int nxt, ours = 0, rh_present = 0; |
int nxt, ours = 0, rh_present = 0, frg_present; |
struct ifnet *deliverifp = NULL; |
struct ifnet *deliverifp = NULL; |
int srcrt = 0; |
int srcrt = 0; |
const struct rtentry *rt; |
const struct rtentry *rt; |
Line 720 ip6_input(struct mbuf *m) |
|
Line 720 ip6_input(struct mbuf *m) |
|
nest = 0; |
nest = 0; |
|
|
rh_present = 0; |
rh_present = 0; |
|
frg_present = 0; |
while (nxt != IPPROTO_DONE) { |
while (nxt != IPPROTO_DONE) { |
if (ip6_hdrnestlimit && (++nest > ip6_hdrnestlimit)) { |
if (ip6_hdrnestlimit && (++nest > ip6_hdrnestlimit)) { |
IP6_STATINC(IP6_STAT_TOOMANYHDR); |
IP6_STATINC(IP6_STAT_TOOMANYHDR); |
Line 744 ip6_input(struct mbuf *m) |
|
Line 745 ip6_input(struct mbuf *m) |
|
IP6_STATINC(IP6_STAT_BADOPTIONS); |
IP6_STATINC(IP6_STAT_BADOPTIONS); |
goto bad; |
goto bad; |
} |
} |
|
} else if (nxt == IPPROTO_FRAGMENT) { |
|
if (frg_present++) { |
|
in6_ifstat_inc(m->m_pkthdr.rcvif, |
|
ifs6_in_hdrerr); |
|
IP6_STATINC(IP6_STAT_BADOPTIONS); |
|
goto bad; |
|
} |
} |
} |
|
|
#ifdef IPSEC |
#ifdef IPSEC |
Line 1384 ip6_pullexthdr(struct mbuf *m, size_t of |
|
Line 1392 ip6_pullexthdr(struct mbuf *m, size_t of |
|
} |
} |
|
|
/* |
/* |
* Get pointer to the previous header followed by the header |
* Get offset to the previous header followed by the header |
* currently processed. |
* currently processed. |
* XXX: This function supposes that |
|
* M includes all headers, |
|
* the next header field and the header length field of each header |
|
* are valid, and |
|
* the sum of each header length equals to OFF. |
|
* Because of these assumptions, this function must be called very |
|
* carefully. Moreover, it will not be used in the near future when |
|
* we develop `neater' mechanism to process extension headers. |
|
*/ |
*/ |
u_int8_t * |
int |
ip6_get_prevhdr(struct mbuf *m, int off) |
ip6_get_prevhdr(struct mbuf *m, int off) |
{ |
{ |
struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *); |
struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *); |
|
|
if (off == sizeof(struct ip6_hdr)) |
if (off == sizeof(struct ip6_hdr)) { |
return (&ip6->ip6_nxt); |
return offsetof(struct ip6_hdr, ip6_nxt); |
else { |
} else if (off < sizeof(struct ip6_hdr)) { |
int len, nxt; |
panic("%s: off < sizeof(struct ip6_hdr)", __func__); |
struct ip6_ext *ip6e = NULL; |
} else { |
|
int len, nlen, nxt; |
|
struct ip6_ext ip6e; |
|
|
nxt = ip6->ip6_nxt; |
nxt = ip6->ip6_nxt; |
len = sizeof(struct ip6_hdr); |
len = sizeof(struct ip6_hdr); |
|
nlen = 0; |
while (len < off) { |
while (len < off) { |
ip6e = (struct ip6_ext *)(mtod(m, char *) + len); |
m_copydata(m, len, sizeof(ip6e), &ip6e); |
|
|
switch (nxt) { |
switch (nxt) { |
case IPPROTO_FRAGMENT: |
case IPPROTO_FRAGMENT: |
len += sizeof(struct ip6_frag); |
nlen = sizeof(struct ip6_frag); |
break; |
break; |
case IPPROTO_AH: |
case IPPROTO_AH: |
len += (ip6e->ip6e_len + 2) << 2; |
nlen = (ip6e.ip6e_len + 2) << 2; |
break; |
break; |
default: |
default: |
len += (ip6e->ip6e_len + 1) << 3; |
nlen = (ip6e.ip6e_len + 1) << 3; |
break; |
break; |
} |
} |
nxt = ip6e->ip6e_nxt; |
len += nlen; |
|
nxt = ip6e.ip6e_nxt; |
} |
} |
if (ip6e) |
|
return (&ip6e->ip6e_nxt); |
return (len - nlen); |
else |
|
return NULL; |
|
} |
} |
} |
} |
|
|