netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH series][6LoWPAN]
@ 2011-11-02 16:25 Alexander Smirnov
  2011-11-02 16:32 ` [PATCH 1/6] [6LoWPAN] add fragmentation support Alexander Smirnov
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Alexander Smirnov @ 2011-11-02 16:25 UTC (permalink / raw)
  To: davem, dbaryshkov
  Cc: linux-zigbee-devel, alex.bluesman.smirnov, netdev, jonsmirl

Hello all,

The following patch series adds both major feature and minor fixes.
Please find detailed description in each of the patches.

Just to summarize current development status:
By using MAC and PHY layers support from
    "http://sourceforge.net/projects/linux-zigbee"
project now it's possible to run generic network applications (ssh, iperf) over
ieee802.15.4 network.

iperf shows about ~40Kbits/sec for TCP :-)

With best regards,
Alexander

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 1/6] [6LoWPAN] add fragmentation support
  2011-11-02 16:25 [PATCH series][6LoWPAN] Alexander Smirnov
@ 2011-11-02 16:32 ` Alexander Smirnov
  2011-11-02 16:34 ` [PATCH 3/6] [6LoWPAN] set proper netdev flags Alexander Smirnov
       [not found] ` <20111102162520.GA2669-AUGNqIMGY+bGcXpsla5Oef8+0UxHXcjY@public.gmane.org>
  2 siblings, 0 replies; 17+ messages in thread
From: Alexander Smirnov @ 2011-11-02 16:32 UTC (permalink / raw)
  To: davem; +Cc: dbaryshkov, linux-zigbee-devel, netdev, Alexander Smirnov

This patch adds support for frame fragmentation.

Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
---
 include/net/ieee802154.h |    6 +
 net/ieee802154/6lowpan.c |  254 +++++++++++++++++++++++++++++++++++++++++++++-
 net/ieee802154/6lowpan.h |   18 ++++
 3 files changed, 274 insertions(+), 4 deletions(-)

diff --git a/include/net/ieee802154.h b/include/net/ieee802154.h
index d52685d..ee59f8b 100644
--- a/include/net/ieee802154.h
+++ b/include/net/ieee802154.h
@@ -21,11 +21,14 @@
  * Maxim Gorbachyov <maxim.gorbachev@siemens.com>
  * Maxim Osipov <maxim.osipov@siemens.com>
  * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
+ * Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
  */
 
 #ifndef NET_IEEE802154_H
 #define NET_IEEE802154_H
 
+#define IEEE802154_MTU			127
+
 #define IEEE802154_FC_TYPE_BEACON	0x0	/* Frame is beacon */
 #define	IEEE802154_FC_TYPE_DATA		0x1	/* Frame is data */
 #define IEEE802154_FC_TYPE_ACK		0x2	/* Frame is acknowledgment */
@@ -56,6 +59,9 @@
 	(((x) & IEEE802154_FC_DAMODE_MASK) >> IEEE802154_FC_DAMODE_SHIFT)
 
 
+/* MAC footer size */
+#define IEEE802154_MFR_SIZE	2 /* 2 octets */
+
 /* MAC's Command Frames Identifiers */
 #define IEEE802154_CMD_ASSOCIATION_REQ		0x01
 #define IEEE802154_CMD_ASSOCIATION_RESP		0x02
diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index 19d6aef..890ecef 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -113,6 +113,20 @@ struct lowpan_dev_record {
 	struct list_head list;
 };
 
+struct lowpan_fragment {
+	struct sk_buff		*skb;		/* skb to be assembled */
+	spinlock_t		lock;		/* concurency lock */
+	u16			length;		/* length to be assemled */
+	u32			bytes_rcv;	/* bytes received */
+	u16			tag;		/* current fragment tag */
+	struct timer_list	timer;		/* assembling timer */
+	struct list_head	list;		/* fragments list */
+};
+
+static unsigned short fragment_tag;
+static LIST_HEAD(lowpan_fragments);
+spinlock_t flist_lock;
+
 static inline struct
 lowpan_dev_info *lowpan_dev_info(const struct net_device *dev)
 {
@@ -244,6 +258,17 @@ static u8 lowpan_fetch_skb_u8(struct sk_buff *skb)
 	return ret;
 }
 
+static u16 lowpan_fetch_skb_u16(struct sk_buff *skb)
+{
+	u16 ret;
+
+	BUG_ON(!pskb_may_pull(skb, 2));
+
+	ret = skb->data[0] | (skb->data[1] << 8);
+	skb_pull(skb, 2);
+	return ret;
+}
+
 static int lowpan_header_create(struct sk_buff *skb,
 			   struct net_device *dev,
 			   unsigned short type, const void *_daddr,
@@ -467,6 +492,7 @@ static int lowpan_header_create(struct sk_buff *skb,
 		memcpy(&(sa.hwaddr), saddr, 8);
 
 		mac_cb(skb)->flags = IEEE802154_FC_TYPE_DATA;
+
 		return dev_hard_header(skb, lowpan_dev_info(dev)->real_dev,
 				type, (void *)&da, (void *)&sa, skb->len);
 	}
@@ -511,6 +537,21 @@ static int lowpan_skb_deliver(struct sk_buff *skb, struct ipv6hdr *hdr)
 	return stat;
 }
 
+static void lowpan_fragment_timer_expired(unsigned long entry_addr)
+{
+	struct lowpan_fragment *entry = (struct lowpan_fragment *)entry_addr;
+
+	pr_debug("%s: timer expired for frame with tag %d\n", __func__,
+								entry->tag);
+
+	spin_lock(&flist_lock);
+	list_del(&entry->list);
+	spin_unlock(&flist_lock);
+
+	dev_kfree_skb(entry->skb);
+	kfree(entry);
+}
+
 static int
 lowpan_process_data(struct sk_buff *skb)
 {
@@ -525,6 +566,104 @@ lowpan_process_data(struct sk_buff *skb)
 	if (skb->len < 2)
 		goto drop;
 	iphc0 = lowpan_fetch_skb_u8(skb);
+
+	/* fragments assembling */
+	switch (iphc0 & LOWPAN_DISPATCH_MASK) {
+	case LOWPAN_DISPATCH_FRAG1:
+	case LOWPAN_DISPATCH_FRAGN:
+	{
+		struct lowpan_fragment *frame;
+		u8 len, offset;
+		u16 tag;
+
+		len = lowpan_fetch_skb_u8(skb); /* frame length */
+		tag = lowpan_fetch_skb_u16(skb);
+
+		/*
+		 * check if frame assembling with the same tag is
+		 * already in progress
+		 */
+		spin_lock(&flist_lock);
+
+		list_for_each_entry(frame, &lowpan_fragments, list)
+			if (frame->tag == tag)
+				break;
+
+		/* alloc new frame structure */
+		if (frame->tag != tag) {
+			frame = kzalloc(sizeof(struct lowpan_fragment),
+								GFP_ATOMIC);
+			if (!frame)
+				goto drop;
+
+			INIT_LIST_HEAD(&frame->list);
+
+			frame->length = (iphc0 & 7) | (len << 3);
+			frame->tag = tag;
+
+			/* allocate buffer for frame assembling */
+			frame->skb = alloc_skb(frame->length +
+					sizeof(struct ipv6hdr), GFP_ATOMIC);
+
+			frame->skb->priority = skb->priority;
+			frame->skb->dev = skb->dev;
+
+			if (!frame->skb) {
+				kfree(frame);
+				goto drop;
+			}
+
+			/* reserve headroom for uncompressed ipv6 header */
+			skb_reserve(frame->skb, sizeof(struct ipv6hdr));
+			skb_put(frame->skb, frame->length);
+
+			init_timer(&frame->timer);
+			/* time out is the same as for ipv6 - 60 sec */
+			frame->timer.expires = jiffies + LOWPAN_FRAG_TIMEOUT;
+			frame->timer.data = (unsigned long)frame;
+			frame->timer.function = lowpan_fragment_timer_expired;
+
+			add_timer(&frame->timer);
+
+			list_add_tail(&frame->list, &lowpan_fragments);
+		}
+
+		if ((iphc0 & LOWPAN_DISPATCH_MASK) == LOWPAN_DISPATCH_FRAG1)
+			goto drop;
+
+		offset = lowpan_fetch_skb_u8(skb); /* fetch offset */
+
+		/* if payload fits buffer, copy it */
+		if (likely((offset * 8 + skb->len) <= frame->length))
+			skb_copy_to_linear_data_offset(frame->skb, offset * 8,
+							skb->data, skb->len);
+		else
+			goto drop;
+
+		frame->bytes_rcv += skb->len;
+
+		/* frame assembling complete */
+		if ((frame->bytes_rcv == frame->length) &&
+		     frame->timer.expires > jiffies) {
+			/* if timer haven't expired - first of all delete it */
+			del_timer(&frame->timer);
+			list_del(&frame->list);
+			spin_unlock(&flist_lock);
+
+			dev_kfree_skb(skb);
+			skb = frame->skb;
+			kfree(frame);
+			iphc0 = lowpan_fetch_skb_u8(skb);
+			break;
+		}
+		spin_unlock(&flist_lock);
+
+		return kfree_skb(skb), 0;
+	}
+	default:
+		break;
+	}
+
 	iphc1 = lowpan_fetch_skb_u8(skb);
 
 	_saddr = mac_cb(skb)->sa.hwaddr;
@@ -692,18 +831,118 @@ static int lowpan_set_address(struct net_device *dev, void *p)
 	return 0;
 }
 
+static int lowpan_get_mac_header_length(struct sk_buff *skb)
+{
+	/*
+	 * Currently long addressing mode is supported only, so the overall
+	 * header size is 21:
+	 * FC SeqNum DPAN DA  SA  Sec
+	 * 2  +  1  +  2 + 8 + 8 + 0  = 21
+	 */
+	return 21;
+}
+
+static int
+lowpan_fragment_xmit(struct sk_buff *skb, u8 *head,
+			int mlen, int plen, int offset)
+{
+	struct sk_buff *frag;
+	int hlen, ret;
+
+	/* if payload length is zero, therefore it's a first fragment */
+	hlen = (plen == 0 ? LOWPAN_FRAG1_HEAD_SIZE :  LOWPAN_FRAGN_HEAD_SIZE);
+
+	lowpan_raw_dump_inline(__func__, "6lowpan fragment header", head, hlen);
+
+	frag = dev_alloc_skb(hlen + mlen + plen + IEEE802154_MFR_SIZE);
+	if (!frag)
+		return -ENOMEM;
+
+	frag->priority = skb->priority;
+	frag->dev = skb->dev;
+
+	/* copy header, MFR and payload */
+	memcpy(skb_put(frag, mlen), skb->data, mlen);
+	memcpy(skb_put(frag, hlen), head, hlen);
+
+	if (plen)
+		skb_copy_from_linear_data_offset(skb, offset + mlen,
+					skb_put(frag, plen), plen);
+
+	lowpan_raw_dump_table(__func__, " raw fragment dump", frag->data,
+								frag->len);
+
+	ret = dev_queue_xmit(frag);
+
+	if (ret < 0)
+		dev_kfree_skb(frag);
+
+	return ret;
+}
+
+static int
+lowpan_skb_fragmentation(struct sk_buff *skb)
+{
+	int  err, header_length, payload_length, tag, offset = 0;
+	u8 head[5];
+
+	header_length = lowpan_get_mac_header_length(skb);
+	payload_length = skb->len - header_length;
+	tag = fragment_tag++;
+
+	/* first fragment header */
+	head[0] = LOWPAN_DISPATCH_FRAG1 | (payload_length & 0x7);
+	head[1] = (payload_length >> 3) & 0xff;
+	head[2] = tag & 0xff;
+	head[3] = tag >> 8;
+
+	err = lowpan_fragment_xmit(skb, head, header_length, 0, 0);
+
+	/* next fragment header */
+	head[0] &= ~LOWPAN_DISPATCH_FRAG1;
+	head[0] |= LOWPAN_DISPATCH_FRAGN;
+
+	while ((payload_length - offset > 0) && (err >= 0)) {
+		int len = LOWPAN_FRAG_SIZE;
+
+		head[4] = offset / 8;
+
+		if (payload_length - offset < len)
+			len = payload_length - offset;
+
+		err = lowpan_fragment_xmit(skb, head, header_length,
+							len, offset);
+		offset += len;
+	}
+
+	return err;
+}
+
 static netdev_tx_t lowpan_xmit(struct sk_buff *skb, struct net_device *dev)
 {
-	int err = 0;
+	int err = -1;
 
 	pr_debug("(%s): package xmit\n", __func__);
 
 	skb->dev = lowpan_dev_info(dev)->real_dev;
 	if (skb->dev == NULL) {
 		pr_debug("(%s) ERROR: no real wpan device found\n", __func__);
-		dev_kfree_skb(skb);
-	} else
+		goto error;
+	}
+
+	if (skb->len <= IEEE802154_MTU) {
 		err = dev_queue_xmit(skb);
+		goto out;
+	}
+
+	pr_debug("(%s): frame is too big, fragmentation is needed\n",
+								__func__);
+	err = lowpan_skb_fragmentation(skb);
+error:
+	dev_kfree_skb(skb);
+out:
+	if (err < 0)
+		pr_debug("(%s): ERROR: xmit failed\n", __func__);
 
 	return (err < 0 ? NETDEV_TX_BUSY : NETDEV_TX_OK);
 }
@@ -765,8 +1004,15 @@ static int lowpan_rcv(struct sk_buff *skb, struct net_device *dev,
 		goto drop;
 
 	/* check that it's our buffer */
-	if ((skb->data[0] & 0xe0) == 0x60)
+	switch (skb->data[0] & 0xe0) {
+	case LOWPAN_DISPATCH_IPHC:	/* ipv6 datagram */
+	case LOWPAN_DISPATCH_FRAG1:	/* first fragment header */
+	case LOWPAN_DISPATCH_FRAGN:	/* next fragments headers */
 		lowpan_process_data(skb);
+		break;
+	default:
+		break;
+	}
 
 	return NET_RX_SUCCESS;
 
diff --git a/net/ieee802154/6lowpan.h b/net/ieee802154/6lowpan.h
index 5d8cf80..5d2e5a0 100644
--- a/net/ieee802154/6lowpan.h
+++ b/net/ieee802154/6lowpan.h
@@ -159,6 +159,24 @@
 #define LOWPAN_DISPATCH_FRAG1	0xc0 /* 11000xxx */
 #define LOWPAN_DISPATCH_FRAGN	0xe0 /* 11100xxx */
 
+#define LOWPAN_DISPATCH_MASK	0xf8 /* 11111000 */
+
+#define LOWPAN_FRAG_TIMEOUT	(HZ * 60)	/* time-out 60 sec */
+
+#define LOWPAN_FRAG1_HEAD_SIZE	0x4
+#define LOWPAN_FRAGN_HEAD_SIZE	0x5
+
+/*
+ * According IEEE802.15.4 standard:
+ *   - MTU is 127 octets
+ *   - maximum MHR size is 37 octets
+ *   - MFR size is 2 octets
+ *
+ * so minimal payload size that we may guarantee is:
+ *   MTU - MHR - MFR = 88 octets
+ */
+#define LOWPAN_FRAG_SIZE	88
+
 /*
  * Values of fields within the IPHC encoding first byte
  * (C stands for compressed and I for inline)
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 2/6] [6LoWPAN] disable debugging by default
       [not found] ` <20111102162520.GA2669-AUGNqIMGY+bGcXpsla5Oef8+0UxHXcjY@public.gmane.org>
@ 2011-11-02 16:34   ` Alexander Smirnov
  2011-11-08 14:43     ` Dmitry Eremin-Solenikov
  2011-11-02 16:35   ` [PATCH 4/6] [6LoWPAN] UDP header compression Alexander Smirnov
                     ` (3 subsequent siblings)
  4 siblings, 1 reply; 17+ messages in thread
From: Alexander Smirnov @ 2011-11-02 16:34 UTC (permalink / raw)
  To: davem-fT/PcQaiUtIeIZ0/mPfg9Q
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

This patch disables debug output enabled by default.

Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 net/ieee802154/6lowpan.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index 890ecef..e5709fa 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -50,8 +50,6 @@
  * SUCH DAMAGE.
  */
 
-#define DEBUG
-
 #include <linux/bitops.h>
 #include <linux/if_arp.h>
 #include <linux/module.h>
-- 
1.7.2.5


------------------------------------------------------------------------------
RSA&#174; Conference 2012
Save $700 by Nov 18
Register now&#33;
http://p.sf.net/sfu/rsa-sfdev2dev1

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 3/6] [6LoWPAN] set proper netdev flags
  2011-11-02 16:25 [PATCH series][6LoWPAN] Alexander Smirnov
  2011-11-02 16:32 ` [PATCH 1/6] [6LoWPAN] add fragmentation support Alexander Smirnov
@ 2011-11-02 16:34 ` Alexander Smirnov
  2011-11-08 14:42   ` Dmitry Eremin-Solenikov
       [not found] ` <20111102162520.GA2669-AUGNqIMGY+bGcXpsla5Oef8+0UxHXcjY@public.gmane.org>
  2 siblings, 1 reply; 17+ messages in thread
From: Alexander Smirnov @ 2011-11-02 16:34 UTC (permalink / raw)
  To: davem; +Cc: dbaryshkov, linux-zigbee-devel, netdev, Alexander Smirnov

This patch fixes settings for device initialization which makes possible to
use NDISC and TCP.

Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
---
 net/ieee802154/6lowpan.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index e5709fa..c4aae4e 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -967,13 +967,12 @@ static void lowpan_setup(struct net_device *dev)
 	dev->addr_len		= IEEE802154_ADDR_LEN;
 	memset(dev->broadcast, 0xff, IEEE802154_ADDR_LEN);
 	dev->type		= ARPHRD_IEEE802154;
-	dev->features		= NETIF_F_NO_CSUM;
 	/* Frame Control + Sequence Number + Address fields + Security Header */
 	dev->hard_header_len	= 2 + 1 + 20 + 14;
 	dev->needed_tailroom	= 2; /* FCS */
 	dev->mtu		= 1281;
 	dev->tx_queue_len	= 0;
-	dev->flags		= IFF_NOARP | IFF_BROADCAST;
+	dev->flags		= IFF_BROADCAST | IFF_MULTICAST;
 	dev->watchdog_timeo	= 0;
 
 	dev->netdev_ops		= &lowpan_netdev_ops;
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 4/6] [6LoWPAN] UDP header compression
       [not found] ` <20111102162520.GA2669-AUGNqIMGY+bGcXpsla5Oef8+0UxHXcjY@public.gmane.org>
  2011-11-02 16:34   ` [PATCH 2/6] [6LoWPAN] disable debugging by default Alexander Smirnov
@ 2011-11-02 16:35   ` Alexander Smirnov
       [not found]     ` <1320251711-2897-1-git-send-email-alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2011-11-02 16:35   ` [PATCH 5/6] [6LoWPAN] UDP header decompression Alexander Smirnov
                     ` (2 subsequent siblings)
  4 siblings, 1 reply; 17+ messages in thread
From: Alexander Smirnov @ 2011-11-02 16:35 UTC (permalink / raw)
  To: davem-fT/PcQaiUtIeIZ0/mPfg9Q
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

This patch adds support for UDP header compression.
Derived from Contiki OS.

Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 net/ieee802154/6lowpan.c |   51 ++++++++++++++++++++++++++++++++++++++++++---
 net/ieee802154/6lowpan.h |    5 ++++
 2 files changed, 52 insertions(+), 4 deletions(-)

diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index c4aae4e..6da3357 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -365,8 +365,6 @@ static int lowpan_header_create(struct sk_buff *skb,
 	if (hdr->nexthdr == UIP_PROTO_UDP)
 		iphc0 |= LOWPAN_IPHC_NH_C;
 
-/* TODO: next header compression */
-
 	if ((iphc0 & LOWPAN_IPHC_NH_C) == 0) {
 		*hc06_ptr = hdr->nexthdr;
 		hc06_ptr += 1;
@@ -454,8 +452,53 @@ static int lowpan_header_create(struct sk_buff *skb,
 		}
 	}
 
-	/* TODO: UDP header compression */
-	/* TODO: Next Header compression */
+	/* UDP header compression */
+	if (hdr->nexthdr == UIP_PROTO_UDP) {
+		struct udphdr *uh = udp_hdr(skb);
+
+		pr_debug("(%s): UDP header compression\n", __func__);
+
+		if (((uh->source & LOWPAN_NHC_UDP_4BIT_MASK) ==
+					LOWPAN_NHC_UDP_4BIT_PORT) &&
+		    ((uh->dest & LOWPAN_NHC_UDP_4BIT_MASK) ==
+					LOWPAN_NHC_UDP_4BIT_PORT)) {
+			pr_debug("(%s): both ports compression to 4 bits\n",
+								__func__);
+			*hc06_ptr = LOWPAN_NHC_UDP_CS_P_11;
+			*(hc06_ptr + 1) = /* subtraction is faster */
+			   (u8)((uh->dest - LOWPAN_NHC_UDP_4BIT_PORT) +
+			       ((uh->source & LOWPAN_NHC_UDP_4BIT_PORT) << 4));
+			hc06_ptr += 2;
+		} else if ((uh->dest & LOWPAN_NHC_UDP_8BIT_MASK) ==
+				LOWPAN_NHC_UDP_8BIT_PORT) {
+			pr_debug("(%s): remove 8 bits of dest\n", __func__);
+			*hc06_ptr = LOWPAN_NHC_UDP_CS_P_01;
+			memcpy(hc06_ptr + 1, &uh->source, 2);
+			*(hc06_ptr + 3) =
+				(u8)(uh->dest - LOWPAN_NHC_UDP_8BIT_PORT);
+			hc06_ptr += 4;
+		} else if ((uh->source & LOWPAN_NHC_UDP_8BIT_MASK) ==
+				LOWPAN_NHC_UDP_8BIT_PORT) {
+			pr_debug("(%s): remove 8 bits of source\n", __func__);
+			*hc06_ptr = LOWPAN_NHC_UDP_CS_P_10;
+			memcpy(hc06_ptr + 1, &uh->dest, 2);
+			*(hc06_ptr + 3) =
+				(u8)(uh->source - LOWPAN_NHC_UDP_8BIT_PORT);
+			hc06_ptr += 4;
+		} else {
+			pr_debug("(%s): can't compress header\n", __func__);
+			*hc06_ptr = LOWPAN_NHC_UDP_CS_P_00;
+			memcpy(hc06_ptr + 1, &uh->source, 2);
+			memcpy(hc06_ptr + 3, &uh->dest, 2);
+			hc06_ptr += 5;
+		}
+
+		/* checksum is always inline */
+		memcpy(hc06_ptr, &uh->check, 2);
+		hc06_ptr += 2;
+	}
+
+	/* TODO: other NH types support? */
 
 	head[0] = iphc0;
 	head[1] = iphc1;
diff --git a/net/ieee802154/6lowpan.h b/net/ieee802154/6lowpan.h
index 5d2e5a0..aeff3f3 100644
--- a/net/ieee802154/6lowpan.h
+++ b/net/ieee802154/6lowpan.h
@@ -219,6 +219,11 @@
 #define LOWPAN_NHC_UDP_CHECKSUMC	0x04
 #define LOWPAN_NHC_UDP_CHECKSUMI	0x00
 
+#define LOWPAN_NHC_UDP_4BIT_PORT	0xF0B0
+#define LOWPAN_NHC_UDP_4BIT_MASK	0xFFF0
+#define LOWPAN_NHC_UDP_8BIT_PORT	0xF000
+#define LOWPAN_NHC_UDP_8BIT_MASK	0xFF00
+
 /* values for port compression, _with checksum_ ie bit 5 set to 0 */
 #define LOWPAN_NHC_UDP_CS_P_00	0xF0 /* all inline */
 #define LOWPAN_NHC_UDP_CS_P_01	0xF1 /* source 16bit inline,
-- 
1.7.2.5


------------------------------------------------------------------------------
RSA&#174; Conference 2012
Save $700 by Nov 18
Register now&#33;
http://p.sf.net/sfu/rsa-sfdev2dev1

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 5/6] [6LoWPAN] UDP header decompression
       [not found] ` <20111102162520.GA2669-AUGNqIMGY+bGcXpsla5Oef8+0UxHXcjY@public.gmane.org>
  2011-11-02 16:34   ` [PATCH 2/6] [6LoWPAN] disable debugging by default Alexander Smirnov
  2011-11-02 16:35   ` [PATCH 4/6] [6LoWPAN] UDP header compression Alexander Smirnov
@ 2011-11-02 16:35   ` Alexander Smirnov
  2011-11-08 14:40     ` Dmitry Eremin-Solenikov
  2011-11-02 16:35   ` [PATCH 6/6] [6LoWPAN] update documentation Alexander Smirnov
  2011-11-02 19:57   ` [PATCH series][6LoWPAN] David Miller
  4 siblings, 1 reply; 17+ messages in thread
From: Alexander Smirnov @ 2011-11-02 16:35 UTC (permalink / raw)
  To: davem-fT/PcQaiUtIeIZ0/mPfg9Q
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

This patch provides possibility to decompress UDP headers.
Derived from Contiki OS.

Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 net/ieee802154/6lowpan.c |   50 +++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 49 insertions(+), 1 deletions(-)

diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
index 6da3357..49f42a8 100644
--- a/net/ieee802154/6lowpan.c
+++ b/net/ieee802154/6lowpan.c
@@ -839,7 +839,55 @@ lowpan_process_data(struct sk_buff *skb)
 			goto drop;
 	}
 
-	/* TODO: UDP header parse */
+	/* UDP data uncompression */
+	if (iphc0 & LOWPAN_IPHC_NH_C) {
+		tmp = lowpan_fetch_skb_u8(skb);
+
+		if ((tmp & LOWPAN_NHC_UDP_MASK) == LOWPAN_NHC_UDP_ID) {
+			struct udphdr *uh = udp_hdr(skb);
+
+			pr_debug("(%s): UDP header uncompression\n", __func__);
+			switch (tmp & LOWPAN_NHC_UDP_CS_P_11) {
+			case LOWPAN_NHC_UDP_CS_P_00:
+				memcpy(&uh->source, &skb->data[0], 2);
+				memcpy(&uh->dest, &skb->data[2], 2);
+				skb_pull(skb, 4);
+				break;
+			case LOWPAN_NHC_UDP_CS_P_01:
+				memcpy(&uh->source, &skb->data[0], 2);
+				uh->dest =
+				   skb->data[2] + LOWPAN_NHC_UDP_8BIT_PORT;
+				skb_pull(skb, 3);
+				break;
+			case LOWPAN_NHC_UDP_CS_P_10:
+				uh->source = skb->data[0] + LOWPAN_NHC_UDP_8BIT_PORT;
+				memcpy(&uh->dest, &skb->data[1], 2);
+				skb_pull(skb, 3);
+				break;
+			case LOWPAN_NHC_UDP_CS_P_11:
+				uh->source =
+				   LOWPAN_NHC_UDP_4BIT_PORT + (skb->data[0] >> 4);
+				uh->dest =
+				   LOWPAN_NHC_UDP_4BIT_PORT + (skb->data[0] & 0x0f);
+				skb_pull(skb, 1);
+				break;
+			default:
+				pr_debug("(%s) ERROR: unknown UDP format\n", __func__);
+				goto drop;
+			}
+
+			pr_debug("(%s): uncompressed UDP ports: src = %d, dst = %d\n",
+					__func__, uh->source, uh->dest);
+
+			/* copy checksum */
+			memcpy(&uh->check, &skb->data[0], 2);
+			skb_pull(skb, 2);
+		} else {
+			pr_debug("(%s): ERROR: unsupported NH format\n",
+								__func__);
+			goto drop;
+		}
+	}
 
 	/* Not fragmented package */
 	hdr.payload_len = htons(skb->len);
-- 
1.7.2.5


------------------------------------------------------------------------------
RSA&#174; Conference 2012
Save $700 by Nov 18
Register now&#33;
http://p.sf.net/sfu/rsa-sfdev2dev1

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 6/6] [6LoWPAN] update documentation
       [not found] ` <20111102162520.GA2669-AUGNqIMGY+bGcXpsla5Oef8+0UxHXcjY@public.gmane.org>
                     ` (2 preceding siblings ...)
  2011-11-02 16:35   ` [PATCH 5/6] [6LoWPAN] UDP header decompression Alexander Smirnov
@ 2011-11-02 16:35   ` Alexander Smirnov
  2011-11-08 14:32     ` Dmitry Eremin-Solenikov
  2011-11-02 19:57   ` [PATCH series][6LoWPAN] David Miller
  4 siblings, 1 reply; 17+ messages in thread
From: Alexander Smirnov @ 2011-11-02 16:35 UTC (permalink / raw)
  To: davem-fT/PcQaiUtIeIZ0/mPfg9Q
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

This patch adds chapter to documentation which describes how to use
6lowpan technology.

Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 Documentation/networking/ieee802154.txt |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/Documentation/networking/ieee802154.txt b/Documentation/networking/ieee802154.txt
index 23c995e..7d50b26 100644
--- a/Documentation/networking/ieee802154.txt
+++ b/Documentation/networking/ieee802154.txt
@@ -78,3 +78,29 @@ in software. This is currently WIP.
 
 See header include/net/mac802154.h and several drivers in drivers/ieee802154/.
 
+6LoWPAN Linux implementation
+============================
+
+The IEEE 802.15.4 standard specifies an MTU of 128 bytes, yielding about 80
+octets of actual MAC payload once security is turned on, on a wireless link
+with a link throughput of 250 kbps or less.  The 6LoWPAN adaptation format
+[RFC4944] was specified to carry IPv6 datagrams over such constrained links,
+taking into account limited bandwidth, memory, or energy resources that are
+expected in applications such as wireless Sensor Networks.  [RFC4944] defines
+a Mesh Addressing header to support sub-IP forwarding, a Fragmentation header
+to support the IPv6 minimum MTU requirement [RFC2460], and stateless header
+compression for IPv6 datagrams (LOWPAN_HC1 and LOWPAN_HC2) to reduce the
+relatively large IPv6 and UDP headers down to (in the best case) several bytes.
+
+All the code related to 6lowpan you may find in files: net/ieee802154/6lowpan.*
+
+To setup 6lowpan interface you need:
+1. Add IEEE802.15.4 interface and initialize PANid;
+2. Add 6lowpan interface by command like:
+   # ip link add link wpan0 name lowpan0 type lowpan
+3. Set MAC (if needs):
+   # ip link set lowpan0 address de:ad:be:ef:ca:fe:ba:be
+4. Bring up 'lowpan0' interface
+
+
+
-- 
1.7.2.5


------------------------------------------------------------------------------
RSA&#174; Conference 2012
Save $700 by Nov 18
Register now&#33;
http://p.sf.net/sfu/rsa-sfdev2dev1

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH series][6LoWPAN]
       [not found] ` <20111102162520.GA2669-AUGNqIMGY+bGcXpsla5Oef8+0UxHXcjY@public.gmane.org>
                     ` (3 preceding siblings ...)
  2011-11-02 16:35   ` [PATCH 6/6] [6LoWPAN] update documentation Alexander Smirnov
@ 2011-11-02 19:57   ` David Miller
  2011-11-04 19:19     ` Alexander Smirnov
  4 siblings, 1 reply; 17+ messages in thread
From: David Miller @ 2011-11-02 19:57 UTC (permalink / raw)
  To: alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

From: Alexander Smirnov <alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Date: Wed, 2 Nov 2011 19:25:20 +0300

> The following patch series adds both major feature and minor fixes.
> Please find detailed description in each of the patches.

Right in the middle of the merge window is not the time to be
submitting new features.

You'll need to repost these when the net-next tree opens back
up.

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH series][6LoWPAN]
  2011-11-02 19:57   ` [PATCH series][6LoWPAN] David Miller
@ 2011-11-04 19:19     ` Alexander Smirnov
  2011-11-08 13:34       ` Benjamin Poirier
  0 siblings, 1 reply; 17+ messages in thread
From: Alexander Smirnov @ 2011-11-04 19:19 UTC (permalink / raw)
  To: netdev

Hello everybody,

2011/11/2, David Miller <davem@davemloft.net>:
> From: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
> Date: Wed, 2 Nov 2011 19:25:20 +0300
>
>> The following patch series adds both major feature and minor fixes.
>> Please find detailed description in each of the patches.
>
> Right in the middle of the merge window is not the time to be
> submitting new features.
>
> You'll need to repost these when the net-next tree opens back
> up.
>

sorry if my question looks too silly, but I'm not so long here and
don't know all the patch-submitting-process details. :-(

Could anyone please describe me (or link to some wiki) the merge
process, how the new merge window is announced, what the proper time
to send bug fixes/new features and so on..

Thank you for your time!

With best regards,
Alexander

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH series][6LoWPAN]
  2011-11-04 19:19     ` Alexander Smirnov
@ 2011-11-08 13:34       ` Benjamin Poirier
  0 siblings, 0 replies; 17+ messages in thread
From: Benjamin Poirier @ 2011-11-08 13:34 UTC (permalink / raw)
  To: Alexander Smirnov; +Cc: netdev

On 11/11/04 22:19, Alexander Smirnov wrote:
> Hello everybody,
> 
> 2011/11/2, David Miller <davem@davemloft.net>:
> > From: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
> > Date: Wed, 2 Nov 2011 19:25:20 +0300
> >
> >> The following patch series adds both major feature and minor fixes.
> >> Please find detailed description in each of the patches.
> >
> > Right in the middle of the merge window is not the time to be
> > submitting new features.
> >
> > You'll need to repost these when the net-next tree opens back
> > up.
> >
> 
> sorry if my question looks too silly, but I'm not so long here and
> don't know all the patch-submitting-process details. :-(
> 
> Could anyone please describe me (or link to some wiki) the merge
> process, how the new merge window is announced, what the proper time
> to send bug fixes/new features and so on..
> 
> Thank you for your time!

You may find answers in Documentation/development-process/ (in the
kernel source tree).

-Ben

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 6/6] [6LoWPAN] update documentation
  2011-11-02 16:35   ` [PATCH 6/6] [6LoWPAN] update documentation Alexander Smirnov
@ 2011-11-08 14:32     ` Dmitry Eremin-Solenikov
       [not found]       ` <CALT56yOb5oZLEuHcM8dM8_gpT7mzV+9_YbsxWL3nU2N3ypCg3w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 17+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-11-08 14:32 UTC (permalink / raw)
  To: Alexander Smirnov; +Cc: davem, linux-zigbee-devel, netdev

On 11/2/11, Alexander Smirnov <alex.bluesman.smirnov@gmail.com> wrote:
> This patch adds chapter to documentation which describes how to use
> 6lowpan technology.
>
> Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
> ---
>  Documentation/networking/ieee802154.txt |   26 ++++++++++++++++++++++++++
>  1 files changed, 26 insertions(+), 0 deletions(-)
>
> diff --git a/Documentation/networking/ieee802154.txt
> b/Documentation/networking/ieee802154.txt
> index 23c995e..7d50b26 100644
> --- a/Documentation/networking/ieee802154.txt
> +++ b/Documentation/networking/ieee802154.txt
> @@ -78,3 +78,29 @@ in software. This is currently WIP.
>
>  See header include/net/mac802154.h and several drivers in
> drivers/ieee802154/.
>
> +6LoWPAN Linux implementation
> +============================
> +
> +The IEEE 802.15.4 standard specifies an MTU of 128 bytes, yielding about 80
> +octets of actual MAC payload once security is turned on, on a wireless link
> +with a link throughput of 250 kbps or less.  The 6LoWPAN adaptation format
> +[RFC4944] was specified to carry IPv6 datagrams over such constrained
> links,
> +taking into account limited bandwidth, memory, or energy resources that are
> +expected in applications such as wireless Sensor Networks.  [RFC4944]
> defines
> +a Mesh Addressing header to support sub-IP forwarding, a Fragmentation
> header
> +to support the IPv6 minimum MTU requirement [RFC2460], and stateless header
> +compression for IPv6 datagrams (LOWPAN_HC1 and LOWPAN_HC2) to reduce the
> +relatively large IPv6 and UDP headers down to (in the best case) several
> bytes.

It might be a good idea to mention fresh RFC 6282, to note that it
updates RFC 4944,
deprecating old compression schemes and adding a new one. Then you can
add a note
that following RFC 6282 6lowpan code doesn't implement compression via
HC1 and HC2
schemes (it doesn't, am I right?).

> +
> +All the code related to 6lowpan you may find in files:
> net/ieee802154/6lowpan.*
> +
> +To setup 6lowpan interface you need:
> +1. Add IEEE802.15.4 interface and initialize PANid;
> +2. Add 6lowpan interface by command like:
> +   # ip link add link wpan0 name lowpan0 type lowpan

Does this work with busybox ip or only with iproute2?

> +3. Set MAC (if needs):
> +   # ip link set lowpan0 address de:ad:be:ef:ca:fe:ba:be

IIRC address can be also specified at the step 2.

> +4. Bring up 'lowpan0' interface

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 5/6] [6LoWPAN] UDP header decompression
  2011-11-02 16:35   ` [PATCH 5/6] [6LoWPAN] UDP header decompression Alexander Smirnov
@ 2011-11-08 14:40     ` Dmitry Eremin-Solenikov
  0 siblings, 0 replies; 17+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-11-08 14:40 UTC (permalink / raw)
  To: Alexander Smirnov; +Cc: davem, linux-zigbee-devel, netdev

On 11/2/11, Alexander Smirnov <alex.bluesman.smirnov@gmail.com> wrote:
> This patch provides possibility to decompress UDP headers.
> Derived from Contiki OS.

This asks to go to a separate function.

>
> Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
> ---
>  net/ieee802154/6lowpan.c |   50
> +++++++++++++++++++++++++++++++++++++++++++++-
>  1 files changed, 49 insertions(+), 1 deletions(-)
>
> diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
> index 6da3357..49f42a8 100644
> --- a/net/ieee802154/6lowpan.c
> +++ b/net/ieee802154/6lowpan.c
> @@ -839,7 +839,55 @@ lowpan_process_data(struct sk_buff *skb)
>  			goto drop;
>  	}
>
> -	/* TODO: UDP header parse */
> +	/* UDP data uncompression */
> +	if (iphc0 & LOWPAN_IPHC_NH_C) {
> +		tmp = lowpan_fetch_skb_u8(skb);
> +
> +		if ((tmp & LOWPAN_NHC_UDP_MASK) == LOWPAN_NHC_UDP_ID) {
> +			struct udphdr *uh = udp_hdr(skb);
> +
> +			pr_debug("(%s): UDP header uncompression\n", __func__);
> +			switch (tmp & LOWPAN_NHC_UDP_CS_P_11) {
> +			case LOWPAN_NHC_UDP_CS_P_00:
> +				memcpy(&uh->source, &skb->data[0], 2);
> +				memcpy(&uh->dest, &skb->data[2], 2);
> +				skb_pull(skb, 4);
> +				break;
> +			case LOWPAN_NHC_UDP_CS_P_01:
> +				memcpy(&uh->source, &skb->data[0], 2);
> +				uh->dest =
> +				   skb->data[2] + LOWPAN_NHC_UDP_8BIT_PORT;
> +				skb_pull(skb, 3);
> +				break;
> +			case LOWPAN_NHC_UDP_CS_P_10:
> +				uh->source = skb->data[0] + LOWPAN_NHC_UDP_8BIT_PORT;
> +				memcpy(&uh->dest, &skb->data[1], 2);
> +				skb_pull(skb, 3);
> +				break;
> +			case LOWPAN_NHC_UDP_CS_P_11:
> +				uh->source =
> +				   LOWPAN_NHC_UDP_4BIT_PORT + (skb->data[0] >> 4);
> +				uh->dest =
> +				   LOWPAN_NHC_UDP_4BIT_PORT + (skb->data[0] & 0x0f);
> +				skb_pull(skb, 1);
> +				break;
> +			default:
> +				pr_debug("(%s) ERROR: unknown UDP format\n", __func__);
> +				goto drop;
> +			}
> +
> +			pr_debug("(%s): uncompressed UDP ports: src = %d, dst = %d\n",
> +					__func__, uh->source, uh->dest);
> +
> +			/* copy checksum */
> +			memcpy(&uh->check, &skb->data[0], 2);
> +			skb_pull(skb, 2);
> +		} else {
> +			pr_debug("(%s): ERROR: unsupported NH format\n",
> +								__func__);
> +			goto drop;
> +		}
> +	}
>
>  	/* Not fragmented package */
>  	hdr.payload_len = htons(skb->len);
> --
> 1.7.2.5
>
>


-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/6] [6LoWPAN] UDP header compression
       [not found]     ` <1320251711-2897-1-git-send-email-alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2011-11-08 14:42       ` Dmitry Eremin-Solenikov
  0 siblings, 0 replies; 17+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-11-08 14:42 UTC (permalink / raw)
  To: Alexander Smirnov
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, davem-fT/PcQaiUtIeIZ0/mPfg9Q,
	linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

On 11/2/11, Alexander Smirnov <alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> This patch adds support for UDP header compression.
> Derived from Contiki OS.

>From my point of view, this code would also benefit from being refactored
to a separate function.

>
> Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  net/ieee802154/6lowpan.c |   51
> ++++++++++++++++++++++++++++++++++++++++++---
>  net/ieee802154/6lowpan.h |    5 ++++
>  2 files changed, 52 insertions(+), 4 deletions(-)
>
> diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
> index c4aae4e..6da3357 100644
> --- a/net/ieee802154/6lowpan.c
> +++ b/net/ieee802154/6lowpan.c
> @@ -365,8 +365,6 @@ static int lowpan_header_create(struct sk_buff *skb,
>  	if (hdr->nexthdr == UIP_PROTO_UDP)
>  		iphc0 |= LOWPAN_IPHC_NH_C;
>
> -/* TODO: next header compression */
> -
>  	if ((iphc0 & LOWPAN_IPHC_NH_C) == 0) {
>  		*hc06_ptr = hdr->nexthdr;
>  		hc06_ptr += 1;
> @@ -454,8 +452,53 @@ static int lowpan_header_create(struct sk_buff *skb,
>  		}
>  	}
>
> -	/* TODO: UDP header compression */
> -	/* TODO: Next Header compression */
> +	/* UDP header compression */
> +	if (hdr->nexthdr == UIP_PROTO_UDP) {
> +		struct udphdr *uh = udp_hdr(skb);
> +
> +		pr_debug("(%s): UDP header compression\n", __func__);
> +
> +		if (((uh->source & LOWPAN_NHC_UDP_4BIT_MASK) ==
> +					LOWPAN_NHC_UDP_4BIT_PORT) &&
> +		    ((uh->dest & LOWPAN_NHC_UDP_4BIT_MASK) ==
> +					LOWPAN_NHC_UDP_4BIT_PORT)) {
> +			pr_debug("(%s): both ports compression to 4 bits\n",
> +								__func__);
> +			*hc06_ptr = LOWPAN_NHC_UDP_CS_P_11;
> +			*(hc06_ptr + 1) = /* subtraction is faster */
> +			   (u8)((uh->dest - LOWPAN_NHC_UDP_4BIT_PORT) +
> +			       ((uh->source & LOWPAN_NHC_UDP_4BIT_PORT) << 4));
> +			hc06_ptr += 2;
> +		} else if ((uh->dest & LOWPAN_NHC_UDP_8BIT_MASK) ==
> +				LOWPAN_NHC_UDP_8BIT_PORT) {
> +			pr_debug("(%s): remove 8 bits of dest\n", __func__);
> +			*hc06_ptr = LOWPAN_NHC_UDP_CS_P_01;
> +			memcpy(hc06_ptr + 1, &uh->source, 2);
> +			*(hc06_ptr + 3) =
> +				(u8)(uh->dest - LOWPAN_NHC_UDP_8BIT_PORT);
> +			hc06_ptr += 4;
> +		} else if ((uh->source & LOWPAN_NHC_UDP_8BIT_MASK) ==
> +				LOWPAN_NHC_UDP_8BIT_PORT) {
> +			pr_debug("(%s): remove 8 bits of source\n", __func__);
> +			*hc06_ptr = LOWPAN_NHC_UDP_CS_P_10;
> +			memcpy(hc06_ptr + 1, &uh->dest, 2);
> +			*(hc06_ptr + 3) =
> +				(u8)(uh->source - LOWPAN_NHC_UDP_8BIT_PORT);
> +			hc06_ptr += 4;
> +		} else {
> +			pr_debug("(%s): can't compress header\n", __func__);
> +			*hc06_ptr = LOWPAN_NHC_UDP_CS_P_00;
> +			memcpy(hc06_ptr + 1, &uh->source, 2);
> +			memcpy(hc06_ptr + 3, &uh->dest, 2);
> +			hc06_ptr += 5;
> +		}
> +
> +		/* checksum is always inline */
> +		memcpy(hc06_ptr, &uh->check, 2);
> +		hc06_ptr += 2;
> +	}
> +
> +	/* TODO: other NH types support? */
>
>  	head[0] = iphc0;
>  	head[1] = iphc1;
> diff --git a/net/ieee802154/6lowpan.h b/net/ieee802154/6lowpan.h
> index 5d2e5a0..aeff3f3 100644
> --- a/net/ieee802154/6lowpan.h
> +++ b/net/ieee802154/6lowpan.h
> @@ -219,6 +219,11 @@
>  #define LOWPAN_NHC_UDP_CHECKSUMC	0x04
>  #define LOWPAN_NHC_UDP_CHECKSUMI	0x00
>
> +#define LOWPAN_NHC_UDP_4BIT_PORT	0xF0B0
> +#define LOWPAN_NHC_UDP_4BIT_MASK	0xFFF0
> +#define LOWPAN_NHC_UDP_8BIT_PORT	0xF000
> +#define LOWPAN_NHC_UDP_8BIT_MASK	0xFF00
> +
>  /* values for port compression, _with checksum_ ie bit 5 set to 0 */
>  #define LOWPAN_NHC_UDP_CS_P_00	0xF0 /* all inline */
>  #define LOWPAN_NHC_UDP_CS_P_01	0xF1 /* source 16bit inline,
> --
> 1.7.2.5
>
>


-- 
With best wishes
Dmitry

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 6/6] [6LoWPAN] update documentation
       [not found]       ` <CALT56yOb5oZLEuHcM8dM8_gpT7mzV+9_YbsxWL3nU2N3ypCg3w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2011-11-08 14:42         ` Christophe Aeschlimann
  0 siblings, 0 replies; 17+ messages in thread
From: Christophe Aeschlimann @ 2011-11-08 14:42 UTC (permalink / raw)
  To: Dmitry Eremin-Solenikov
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, davem-fT/PcQaiUtIeIZ0/mPfg9Q,
	linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

On 08.11.2011 15:32, Dmitry Eremin-Solenikov wrote:

>> +To setup 6lowpan interface you need:
>> > +1. Add IEEE802.15.4 interface and initialize PANid;
>> > +2. Add 6lowpan interface by command like:
>> > +   # ip link add link wpan0 name lowpan0 type lowpan
> Does this work with busybox ip or only with iproute2?
> 


It requires that commit :

http://git.busybox.net/busybox/commit/?id=6faebfa663fd008fa28f0d69d0663fe80675ebec

Which means a busybox release > 1.17.0

Kind Regards,

-- 
Christophe Aeschlimann

Embedded Software Engineer & IT Manager
ACN Advanced Communications Networks S.A.
2000 - Neuchâtel, Switzerland
Tel. +41 32 724 74 31

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 3/6] [6LoWPAN] set proper netdev flags
  2011-11-02 16:34 ` [PATCH 3/6] [6LoWPAN] set proper netdev flags Alexander Smirnov
@ 2011-11-08 14:42   ` Dmitry Eremin-Solenikov
  0 siblings, 0 replies; 17+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-11-08 14:42 UTC (permalink / raw)
  To: Alexander Smirnov; +Cc: davem, linux-zigbee-devel, netdev

On 11/2/11, Alexander Smirnov <alex.bluesman.smirnov@gmail.com> wrote:
> This patch fixes settings for device initialization which makes possible to
> use NDISC and TCP.
>
> Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>

Acked-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 2/6] [6LoWPAN] disable debugging by default
  2011-11-02 16:34   ` [PATCH 2/6] [6LoWPAN] disable debugging by default Alexander Smirnov
@ 2011-11-08 14:43     ` Dmitry Eremin-Solenikov
  0 siblings, 0 replies; 17+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-11-08 14:43 UTC (permalink / raw)
  To: Alexander Smirnov; +Cc: davem, linux-zigbee-devel, netdev

On 11/2/11, Alexander Smirnov <alex.bluesman.smirnov@gmail.com> wrote:
> This patch disables debug output enabled by default.
>
> Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>

Acked-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 6/6] [6LoWPAN] update documentation
  2011-11-10 17:32 [PATCH series][6LoWPAN][net-next] Alexander Smirnov
@ 2011-11-10 17:41 ` Alexander Smirnov
  0 siblings, 0 replies; 17+ messages in thread
From: Alexander Smirnov @ 2011-11-10 17:41 UTC (permalink / raw)
  To: davem; +Cc: dbaryshkov, linux-zigbee-devel, netdev, Alexander Smirnov

This patch adds chapter to documentation which describes how to use
6lowpan technology.

Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
---
 Documentation/networking/ieee802154.txt |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/Documentation/networking/ieee802154.txt b/Documentation/networking/ieee802154.txt
index 23c995e..83cbee4 100644
--- a/Documentation/networking/ieee802154.txt
+++ b/Documentation/networking/ieee802154.txt
@@ -78,3 +78,30 @@ in software. This is currently WIP.
 
 See header include/net/mac802154.h and several drivers in drivers/ieee802154/.
 
+6LoWPAN Linux implementation
+============================
+
+The IEEE 802.15.4 standard specifies an MTU of 128 bytes, yielding about 80
+octets of actual MAC payload once security is turned on, on a wireless link
+with a link throughput of 250 kbps or less.  The 6LoWPAN adaptation format
+[RFC4944] was specified to carry IPv6 datagrams over such constrained links,
+taking into account limited bandwidth, memory, or energy resources that are
+expected in applications such as wireless Sensor Networks.  [RFC4944] defines
+a Mesh Addressing header to support sub-IP forwarding, a Fragmentation header
+to support the IPv6 minimum MTU requirement [RFC2460], and stateless header
+compression for IPv6 datagrams (LOWPAN_HC1 and LOWPAN_HC2) to reduce the
+relatively large IPv6 and UDP headers down to (in the best case) several bytes.
+
+In Semptember 2011 the standard update was published - [RFC6282].
+It deprecates HC1 and HC2 compression and defines IPHC encoding format which is
+used in this Linux implementation.
+
+All the code related to 6lowpan you may find in files: net/ieee802154/6lowpan.*
+
+To setup 6lowpan interface you need (busybox release > 1.17.0):
+1. Add IEEE802.15.4 interface and initialize PANid;
+2. Add 6lowpan interface by command like:
+   # ip link add link wpan0 name lowpan0 type lowpan
+3. Set MAC (if needs):
+   # ip link set lowpan0 address de:ad:be:ef:ca:fe:ba:be
+4. Bring up 'lowpan0' interface
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2011-11-10 17:39 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-02 16:25 [PATCH series][6LoWPAN] Alexander Smirnov
2011-11-02 16:32 ` [PATCH 1/6] [6LoWPAN] add fragmentation support Alexander Smirnov
2011-11-02 16:34 ` [PATCH 3/6] [6LoWPAN] set proper netdev flags Alexander Smirnov
2011-11-08 14:42   ` Dmitry Eremin-Solenikov
     [not found] ` <20111102162520.GA2669-AUGNqIMGY+bGcXpsla5Oef8+0UxHXcjY@public.gmane.org>
2011-11-02 16:34   ` [PATCH 2/6] [6LoWPAN] disable debugging by default Alexander Smirnov
2011-11-08 14:43     ` Dmitry Eremin-Solenikov
2011-11-02 16:35   ` [PATCH 4/6] [6LoWPAN] UDP header compression Alexander Smirnov
     [not found]     ` <1320251711-2897-1-git-send-email-alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-11-08 14:42       ` Dmitry Eremin-Solenikov
2011-11-02 16:35   ` [PATCH 5/6] [6LoWPAN] UDP header decompression Alexander Smirnov
2011-11-08 14:40     ` Dmitry Eremin-Solenikov
2011-11-02 16:35   ` [PATCH 6/6] [6LoWPAN] update documentation Alexander Smirnov
2011-11-08 14:32     ` Dmitry Eremin-Solenikov
     [not found]       ` <CALT56yOb5oZLEuHcM8dM8_gpT7mzV+9_YbsxWL3nU2N3ypCg3w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-11-08 14:42         ` Christophe Aeschlimann
2011-11-02 19:57   ` [PATCH series][6LoWPAN] David Miller
2011-11-04 19:19     ` Alexander Smirnov
2011-11-08 13:34       ` Benjamin Poirier
2011-11-10 17:32 [PATCH series][6LoWPAN][net-next] Alexander Smirnov
2011-11-10 17:41 ` [PATCH 6/6] [6LoWPAN] update documentation Alexander Smirnov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).