Ethereal-dev: [Ethereal-dev] Fix decoding of DNS NSEC packets

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, 23 Jan 2004 11:33:57 +0100
The format has changed a little in between NXT and new NSEC packets, this patch fixes things.

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


Index: packet-dns.c
===================================================================
RCS file: /cvsroot/ethereal/packet-dns.c,v
retrieving revision 1.119
diff -r1.119 packet-dns.c
1559a1560,1606
>     {
>       int rr_len = data_len;
>       char next_domain_name[MAXDNAME];
>       int next_domain_name_len;
>       int rr_type;
>       guint8 bits;
>       int mask, blockbase, blocksize;
>       int i;
> 
>       next_domain_name_len = get_dns_name(tvb, cur_offset, dns_data_offset,
> 			next_domain_name, sizeof(next_domain_name));
>       if (cinfo != NULL)
> 	col_append_fstr(cinfo, COL_INFO, " %s", next_domain_name);
>       if (dns_tree != NULL) {
> 	proto_item_append_text(trr, ", next domain name %s",
> 		     next_domain_name);
> 	proto_tree_add_text(rr_tree, tvb, cur_offset, next_domain_name_len,
> 			"Next domain name: %s", next_domain_name);
> 	cur_offset += next_domain_name_len;
> 	rr_len -= next_domain_name_len;
> 	rr_type = 0;
> 	while (rr_len != 0) {
> 	  blockbase = tvb_get_guint8(tvb, cur_offset);
> 	  blocksize = tvb_get_guint8(tvb, cur_offset + 1);
> 	  cur_offset += 2;
> 	  rr_len -= 2;
> 	  rr_type = blockbase * 256;
> 	  for( ; blocksize; blocksize-- ) {	    
>   	       bits = tvb_get_guint8(tvb, cur_offset);
> 	       mask = 1<<7;
> 	       for (i = 0; i < 8; i++) {
> 		 if (bits & mask) {
> 		   proto_tree_add_text(rr_tree, tvb, cur_offset, 1,
> 			"RR type in bit map: %s (%s)",
> 			dns_type_name(rr_type),
> 			dns_long_type_name(rr_type));
> 		 }
> 		 mask >>= 1;
> 		 rr_type++;
> 	       }
> 	       cur_offset += 1;
> 	       rr_len -= 1;
> 	}
>       }
>     }
>     break;
>   }