[mc1322x] [PATCH 3/4] pass data up to ipv6
Mariano Alvira
mar at devl.org
Mon Mar 29 19:52:29 EDT 2010
---
net/mac802154/dev.c | 45 +++++++++++++++++++++++++++++++++------------
1 files changed, 33 insertions(+), 12 deletions(-)
diff --git a/net/mac802154/dev.c b/net/mac802154/dev.c
index 6f8bd90..0d997f3 100644
--- a/net/mac802154/dev.c
+++ b/net/mac802154/dev.c
@@ -274,18 +274,26 @@ static int ieee802154_header_create(struct sk_buff *skb,
saddr = &dev_addr;
}
- if (daddr->addr_type != IEEE802154_ADDR_NONE) {
- fc |= (IEEE802154_ADDR_SHORT << IEEE802154_FC_DAMODE_SHIFT);
-
- /* set in contiki */
- head[pos++] = 0xcd;
- head[pos++] = 0xab;
-
- /* FIXME: broadcasts are always short */
-
- head[pos++] = daddr->short_addr & 0xff;
+ if (daddr->addr_type != IEEE802154_ADDR_NONE) {
+ /* panid*/
+ head[pos++] = daddr->short_addr & 0xff;
head[pos++] = daddr->short_addr >> 8;
+ /* check if this should be a broadcast packet */
+ /* e.g ff02:: link-local multicast */
+ pr_debug("to %x%x::\n",skb->data[24],skb->data[25]);
+ if(((skb->data[24] == 0xff) && (skb->data[25] == 0x02))) {
+ fc |= (IEEE802154_ADDR_SHORT << IEEE802154_FC_DAMODE_SHIFT);
+ head[pos++] = 0xff;
+ head[pos++] = 0xff;
+ } else {
+ /* force long for contiki */
+ fc |= (IEEE802154_ADDR_LONG << IEEE802154_FC_DAMODE_SHIFT);
+ ieee802154_haddr_copy_swap(head + pos, (u8 *)(&skb->data[0x20]));
+ head[pos+7] ^= 0x02;
+ pos += IEEE802154_ADDR_LEN;
+ }
+
}
if (saddr->addr_type != IEEE802154_ADDR_NONE) {
@@ -625,6 +633,15 @@ static int ieee802154_process_ack(struct net_device *dev, struct sk_buff *skb)
static int ieee802154_process_data(struct net_device *dev, struct sk_buff *skb)
{
+ /* strip 6lowpan byte */
+ skb->data++; skb->len--;
+
+ dev->stats.rx_packets++;
+ dev->stats.rx_bytes += skb->len;
+
+ skb->protocol = htons(ETH_P_IPV6);
+ skb->pkt_type = PACKET_HOST;
+
if (in_interrupt())
return netif_rx(skb);
else
@@ -662,11 +679,15 @@ static int ieee802154_subif_frame(struct ieee802154_sub_if_data *sdata,
if (mac_cb(skb)->da.pan_id != sdata->pan_id &&
mac_cb(skb)->da.pan_id != IEEE802154_PANID_BROADCAST)
skb->pkt_type = PACKET_OTHERHOST;
- else if (mac_cb(skb)->da.short_addr == sdata->short_addr)
- skb->pkt_type = PACKET_HOST;
+ /* check if it's broadcast before host */
+ /* otherwise if we've set our address to 0xffff we */
+ /* incorrectly id broadcasts as host */
+ /* should probably get pushed up stream */
else if (mac_cb(skb)->da.short_addr ==
IEEE802154_ADDR_BROADCAST)
skb->pkt_type = PACKET_BROADCAST;
+ else if (mac_cb(skb)->da.short_addr == sdata->short_addr)
+ skb->pkt_type = PACKET_HOST;
else
skb->pkt_type = PACKET_OTHERHOST;
break;
--
1.7.0.3
More information about the mc1322x
mailing list