Ethereal-dev: [Ethereal-dev] Support for MLD v2 report message

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: David Fort <david.fort@xxxxxxxx>
Date: Fri, 19 Dec 2003 18:56:01 +0100
This attached patch adds support for MLD v2 report messages decoding.
That kind of message are send when you add an ipv6 address on a multicast
enabled linux box(at least that's how i found that they weren't decoded).

This patch is based on MLD v2 for ipv6 draft: draft-vida-mld-v2-03.txt

--
Projet IDsA
IRISA-INRIA, Campus de Beaulieu, 35042 Rennes cedex, France
Tél: +33 (0) 2 99 84 71 00, Fax: +33 (0) 2 99 84 71 71


Index: packet-icmpv6.c
===================================================================
RCS file: /cvsroot/ethereal/packet-icmpv6.c,v
retrieving revision 1.73
diff -r1.73 packet-icmpv6.c
88a89
> static gint ett_multicastRR = -1;
935a937,996
> static const value_string mldrv2ModesNames[] = {
>   { 1, "Include" },
>   { 2, "Exclude" },
>   { 3, "Changed to include" },
>   { 4, "Changed to exclude" },
>   { 5, "Allow new sources" },
>   { 6, "Block old sources" },
>   { 0, NULL }
> };
> 
> static void
> dissect_mldrv2( tvbuff_t *tvb, guint32 offset, guint16 count, proto_tree *tree )
> {
>   proto_tree *sub_tree;
>   proto_item *tf;
> 
>   guint8 recordType, auxDataLen;
>   guint32 sourceNb, recordSize, localOffset;
>   struct e_in6_addr addr;
> 
>   for( ; count; count--, offset += recordSize ) {
>     localOffset = offset;
>     recordType = tvb_get_guint8( tvb, localOffset );
>     localOffset += 1;
>     auxDataLen = tvb_get_guint8( tvb, localOffset );
>     localOffset += 1;
>     sourceNb = tvb_get_ntohs( tvb, localOffset );
>     localOffset += 2;
>     recordSize = 4 + 16 + (16 * sourceNb) + (auxDataLen * 4);
> 
>     tvb_memcpy(tvb, (guint8 *)&addr, localOffset, sizeof(addr) );
>     tf = proto_tree_add_text( tree, tvb, offset, recordSize, 
> #ifdef INET6
> 			      "%s: %s (%s)", val_to_str(recordType, mldrv2ModesNames,"Unknown mode"),
> 			      get_hostname6(&addr), ip6_to_str(&addr) 
> #else
> 			      "%s: %s", val_to_str(recordType, mldrv2ModesNames,"Unknown mode"),
> 			      ip6_to_str(&addr) 
> #endif
> 			      );
>     sub_tree = proto_item_add_subtree(tf, ett_multicastRR);
> 
>     proto_tree_add_text( sub_tree, tvb, offset,   1, "Mode: %s", 
> 			 val_to_str(recordType, mldrv2ModesNames,"Unknown mode") );
>     proto_tree_add_text( sub_tree, tvb, offset+1, 1, "Aux data len: %u", auxDataLen * 4);
>     proto_tree_add_text( sub_tree, tvb, localOffset, 16, "Multicast Address: %s", ip6_to_str(&addr) );
>     localOffset += 16;
> 
>     for( ; sourceNb; sourceNb--, localOffset += 16 ) {
>       tvb_memcpy(tvb, (guint8 *)&addr, localOffset, sizeof(addr) );
>       proto_tree_add_text( sub_tree, tvb, localOffset, 16, 
> #ifdef INET6
> 			   "Source Address: %s (%s)", get_hostname6(&addr), ip6_to_str(&addr) );
> #else
> 			   "Source Address: %s", ip6_to_str(&addr) );
> #endif
>     }
>   }
> }
> 
1129a1191,1195
>     case ICMP6_MLDV2_REPORT:
> 	typename = coltypename = "Multicast Listener Report Message v2";
> 	codename = "Should always be zero";
> 	colcodename = NULL;
> 	break;
1260a1327,1333
> 	case ICMP6_MLDV2_REPORT: {
> 	  guint16 nbRecords;
> 	  
> 	  nbRecords = tvb_get_ntohs( tvb, offset+4+2 );
> 	  dissect_mldrv2( tvb, offset+4+2+2, nbRecords, icmp6_tree );
> 	  break;
> 	}
1482a1556
>     &ett_multicastRR,
Index: packet-ipv6.h
===================================================================
RCS file: /cvsroot/ethereal/packet-ipv6.h,v
retrieving revision 1.31
diff -r1.31 packet-ipv6.h
220a221
> #define ICMP6_MLDV2_REPORT              206     /* MLD v2 report message : draft-vida-mld-v2-03.txt */