Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 34577
b: refs/heads/master
c: c61a404
h: refs/heads/master
i:
  34575: 1f35f1b
v: v3
  • Loading branch information
Masahide NAKAMURA authored and David S. Miller committed Sep 22, 2006
1 parent 29e7e95 commit 5c7681e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 280a9d340057ce1b3cca63084df22f4ef5b35fba
refs/heads/master: c61a404325093250b676f40ad8f4dd00f3bcab5f
2 changes: 2 additions & 0 deletions trunk/include/net/ipv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,8 @@ extern int ipv6_skip_exthdr(const struct sk_buff *, int start,

extern int ipv6_ext_hdr(u8 nexthdr);

extern int ipv6_find_tlv(struct sk_buff *skb, int offset, int type);

extern struct ipv6_txoptions * ipv6_invert_rthdr(struct sock *sk,
struct ipv6_rt_hdr *hdr);

Expand Down
43 changes: 43 additions & 0 deletions trunk/net/ipv6/exthdrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,49 @@

#include <asm/uaccess.h>

int ipv6_find_tlv(struct sk_buff *skb, int offset, int type)
{
int packet_len = skb->tail - skb->nh.raw;
struct ipv6_opt_hdr *hdr;
int len;

if (offset + 2 > packet_len)
goto bad;
hdr = (struct ipv6_opt_hdr*)(skb->nh.raw + offset);
len = ((hdr->hdrlen + 1) << 3);

if (offset + len > packet_len)
goto bad;

offset += 2;
len -= 2;

while (len > 0) {
int opttype = skb->nh.raw[offset];
int optlen;

if (opttype == type)
return offset;

switch (opttype) {
case IPV6_TLV_PAD0:
optlen = 1;
break;
default:
optlen = skb->nh.raw[offset + 1] + 2;
if (optlen > len)
goto bad;
break;
}
offset += optlen;
len -= optlen;
}
/* not_found */
return -1;
bad:
return -1;
}

/*
* Parsing tlv encoded headers.
*
Expand Down

0 comments on commit 5c7681e

Please sign in to comment.