Commit 607b0bd3 authored by Alexander Aring's avatar Alexander Aring Committed by Marcel Holtmann

6lowpan: nhc: move iphc manipulation out of nhc

This patch moves the iphc setting of next header commpression bit inside
iphc functionality. Setting of IPHC bits should be happen at iphc.c file
only.
Signed-off-by: default avatarAlexander Aring <alex.aring@gmail.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 478208e3
...@@ -532,9 +532,12 @@ int lowpan_header_compress(struct sk_buff *skb, const struct net_device *dev, ...@@ -532,9 +532,12 @@ int lowpan_header_compress(struct sk_buff *skb, const struct net_device *dev,
/* Check if we provide the nhc format for nexthdr and compression /* Check if we provide the nhc format for nexthdr and compression
* functionality. If not nexthdr is handled inline and not compressed. * functionality. If not nexthdr is handled inline and not compressed.
*/ */
ret = lowpan_nhc_check_compression(skb, hdr, &hc_ptr, &iphc0); ret = lowpan_nhc_check_compression(skb, hdr, &hc_ptr);
if (ret < 0) if (ret == -ENOENT)
return ret; lowpan_push_hc_data(&hc_ptr, &hdr->nexthdr,
sizeof(hdr->nexthdr));
else
iphc0 |= LOWPAN_IPHC_NH_C;
/* Hop limit /* Hop limit
* if 1: compress, encoding is 01 * if 1: compress, encoding is 01
......
...@@ -95,23 +95,20 @@ static struct lowpan_nhc *lowpan_nhc_by_nhcid(const struct sk_buff *skb) ...@@ -95,23 +95,20 @@ static struct lowpan_nhc *lowpan_nhc_by_nhcid(const struct sk_buff *skb)
} }
int lowpan_nhc_check_compression(struct sk_buff *skb, int lowpan_nhc_check_compression(struct sk_buff *skb,
const struct ipv6hdr *hdr, u8 **hc_ptr, const struct ipv6hdr *hdr, u8 **hc_ptr)
u8 *iphc0)
{ {
struct lowpan_nhc *nhc; struct lowpan_nhc *nhc;
int ret = 0;
spin_lock_bh(&lowpan_nhc_lock); spin_lock_bh(&lowpan_nhc_lock);
nhc = lowpan_nexthdr_nhcs[hdr->nexthdr]; nhc = lowpan_nexthdr_nhcs[hdr->nexthdr];
if (nhc && nhc->compress) if (!(nhc && nhc->compress))
*iphc0 |= LOWPAN_IPHC_NH_C; ret = -ENOENT;
else
lowpan_push_hc_data(hc_ptr, &hdr->nexthdr,
sizeof(hdr->nexthdr));
spin_unlock_bh(&lowpan_nhc_lock); spin_unlock_bh(&lowpan_nhc_lock);
return 0; return ret;
} }
int lowpan_nhc_do_compression(struct sk_buff *skb, const struct ipv6hdr *hdr, int lowpan_nhc_do_compression(struct sk_buff *skb, const struct ipv6hdr *hdr,
......
...@@ -86,19 +86,16 @@ struct lowpan_nhc *lowpan_nhc_by_nexthdr(u8 nexthdr); ...@@ -86,19 +86,16 @@ struct lowpan_nhc *lowpan_nhc_by_nexthdr(u8 nexthdr);
/** /**
* lowpan_nhc_check_compression - checks if we support compression format. If * lowpan_nhc_check_compression - checks if we support compression format. If
* we support the nhc by nexthdr field, the 6LoWPAN iphc NHC bit will be * we support the nhc by nexthdr field, the function will return 0. If we
* set. If we don't support nexthdr will be added as inline data to the * don't support the nhc by nexthdr this function will return -ENOENT.
* 6LoWPAN header.
* *
* @skb: skb of 6LoWPAN header to read nhc and replace header. * @skb: skb of 6LoWPAN header to read nhc and replace header.
* @hdr: ipv6hdr to check the nexthdr value * @hdr: ipv6hdr to check the nexthdr value
* @hc_ptr: pointer for 6LoWPAN header which should increment at the end of * @hc_ptr: pointer for 6LoWPAN header which should increment at the end of
* replaced header. * replaced header.
* @iphc0: iphc0 pointer to set the 6LoWPAN NHC bit
*/ */
int lowpan_nhc_check_compression(struct sk_buff *skb, int lowpan_nhc_check_compression(struct sk_buff *skb,
const struct ipv6hdr *hdr, u8 **hc_ptr, const struct ipv6hdr *hdr, u8 **hc_ptr);
u8 *iphc0);
/** /**
* lowpan_nhc_do_compression - calling compress callback for nhc * lowpan_nhc_do_compression - calling compress callback for nhc
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment