I haven't tested these patches but they look OK to me, based on my experience with similar code for a different stack.
- Ralph On Jul 14, 2013, at 7:29 PM 7/14/13, Alexander Aring <alex.ar...@gmail.com> wrote: > Add function to uncompress multicast address. > This function split the uncompress function for a multicast address > in a seperate function. > > To uncompress a multicast address is different than a other > non-multicasts addresses according to rfc6292. > > Signed-off-by: Alexander Aring <alex.ar...@gmail.com> > --- > net/ieee802154/6lowpan.c | 82 +++++++++++++++++++++++++++++++++++++----------- > 1 file changed, 63 insertions(+), 19 deletions(-) > > diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c > index 569d541..14e29d8 100644 > --- a/net/ieee802154/6lowpan.c > +++ b/net/ieee802154/6lowpan.c > @@ -88,15 +88,6 @@ static const u8 lowpan_unc_llconf[] = {0x0f, 0x28, 0x22, > 0x20}; > */ > static const u8 lowpan_unc_ctxconf[] = {0x00, 0x88, 0x82, 0x80}; > > -/* > - * Uncompression of ctx-base > - * 0 -> 0 bits from packet > - * 1 -> 2 bytes from prefix - bunch of zeroes 5 from packet > - * 2 -> 2 bytes from prefix - zeroes + 3 from packet > - * 3 -> 2 bytes from prefix - infer 1 bytes from lladdr > - */ > -static const u8 lowpan_unc_mxconf[] = {0x0f, 0x25, 0x23, 0x21}; > - > /* Link local prefix */ > static const u8 lowpan_llprefix[] = {0xfe, 0x80}; > > @@ -240,6 +231,67 @@ lowpan_uncompress_addr(struct sk_buff *skb, struct > in6_addr *ipaddr, > return 0; > } > > +/* > + * Uncompress function for multicast destination address, > + * when M bit is set. > + */ > +static int > +lowpan_uncompress_multicast_daddr(struct sk_buff *skb, > + struct in6_addr *ipaddr, > + const u8 dam) > +{ > + switch (dam) { > + case LOWPAN_IPHC_DAM_00: > + /* > + * 00: 128 bits. The full address > + * is carried in-line. > + */ > + memcpy(ipaddr->s6_addr, skb->data, 16); > + skb_pull(skb, 16); > + break; > + case LOWPAN_IPHC_DAM_01: > + /* > + * 01: 48 bits. The address takes > + * the form ffXX::00XX:XXXX:XXXX. > + */ > + memset(&ipaddr->s6_addr[0], 0xFF, 1); > + memcpy(&ipaddr->s6_addr[1], skb->data, 1); > + skb_pull(skb, 1); > + memcpy(&ipaddr->s6_addr[11], skb->data, 5); > + skb_pull(skb, 5); > + break; > + case LOWPAN_IPHC_DAM_10: > + /* > + * 10: 32 bits. The address takes > + * the form ffXX::00XX:XXXX. > + */ > + memset(&ipaddr->s6_addr[0], 0xFF, 1); > + memcpy(&ipaddr->s6_addr[1], skb->data, 1); > + skb_pull(skb, 1); > + memcpy(&ipaddr->s6_addr[13], skb->data, 3); > + skb_pull(skb, 3); > + break; > + case LOWPAN_IPHC_DAM_11: > + /* > + * 11: 8 bits. The address takes > + * the form ff02::00XX. > + */ > + memset(&ipaddr->s6_addr[0], 0xFF, 1); > + memset(&ipaddr->s6_addr[1], 0x02, 1); > + memcpy(&ipaddr->s6_addr[15], skb->data, 1); > + skb_pull(skb, 1); > + break; > + default: > + pr_debug("DAM value has a wrong value: 0x%x\n", dam); > + return -EINVAL; > + } > + > + pr_debug("Reconstructed ipv6 multicast addr is:\n"); > + lowpan_raw_dump_inline(NULL, NULL, ipaddr->s6_addr, 16); > + > + return 0; > +} > + > static void > lowpan_compress_udp_header(u8 **hc06_ptr, struct sk_buff *skb) > { > @@ -922,16 +974,8 @@ lowpan_process_data(struct sk_buff *skb) > pr_debug("dest: context-based mcast compression\n"); > /* TODO: implement this */ > } else { > - u8 prefix[] = {0xff, 0x02}; > - > - pr_debug("dest: non context-based mcast compression\n"); > - if (0 < tmp && tmp < 3) { > - if (lowpan_fetch_skb_u8(skb, &prefix[1])) > - goto drop; > - } > - > - err = lowpan_uncompress_addr(skb, &hdr.daddr, prefix, > - lowpan_unc_mxconf[tmp], NULL); > + err = lowpan_uncompress_multicast_daddr( > + skb, &hdr.daddr, tmp); > if (err) > goto drop; > } > -- > 1.8.3.2 > > > ------------------------------------------------------------------------------ > See everything from the browser to the database with AppDynamics > Get end-to-end visibility with application monitoring from AppDynamics > Isolate bottlenecks and diagnose root cause in seconds. > Start your free trial of AppDynamics Pro today! > http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk > _______________________________________________ > Linux-zigbee-devel mailing list > Linux-zigbee-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel ------------------------------------------------------------------------------ See everything from the browser to the database with AppDynamics Get end-to-end visibility with application monitoring from AppDynamics Isolate bottlenecks and diagnose root cause in seconds. Start your free trial of AppDynamics Pro today! http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk _______________________________________________ Linux-zigbee-devel mailing list Linux-zigbee-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel