Ethereal-dev: [ethereal-dev] signed integer support

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

From: Phil Techau <phil_t@xxxxxxxxxxxxx>
Date: Fri, 08 Oct 1999 15:42:39 -0400
Gentlemen,

I needed signed integer support for a proprietary protocol, so I've
added it with the attached mods: this time as a "cvs diff".  I guess at
some point I'd like to get the capability to put my own mods in the cvs
respository.

For now when using hex notation, you have to sign extend the value
you're looking for if you look for negative values in a signed field.
As an example, if you have an FT_INT8 field, you can search for a value
of -128, but searching for 0x80 won't work ( 0xFFFFFF80 will, at least
on a 32 bit int machine).  This could be somewhat exasperating for an
end user, so I'll probably work on cleaning that up some later.

I've got some other things I need to work on next week, but the next
item I'll probably work on for ethereal will probably be filtering
support for strings (c-style null-terminated) unless somebody beats me
to it.

Thanks,

Phil Techau
Index: dfilter-grammar.y
===================================================================
RCS file: /cvsroot/ethereal/dfilter-grammar.y,v
retrieving revision 1.20
diff -r1.20 dfilter-grammar.y
138a139,141
> %token <variable>	T_FT_INT8
> %token <variable>	T_FT_INT16
> %token <variable>	T_FT_INT32
280a284,286
> 	|		T_FT_INT8	{ $$ = dfilter_mknode_numeric_variable($1.id); }
> 	|		T_FT_INT16	{ $$ = dfilter_mknode_numeric_variable($1.id); }
> 	|		T_FT_INT32	{ $$ = dfilter_mknode_numeric_variable($1.id); }
317a324,326
> 	|		T_FT_INT8 { $$ = $1; }
> 	|		T_FT_INT16 { $$ = $1; }
> 	|		T_FT_INT32 { $$ = $1; }
Index: dfilter-scanner.l
===================================================================
RCS file: /cvsroot/ethereal/dfilter-scanner.l,v
retrieving revision 1.15
diff -r1.15 dfilter-scanner.l
90a91
> minus		[-]
204a206,214
> 		case FT_INT8:
> 			retval = T_FT_INT8;
> 			break;
> 		case FT_INT16:
> 			retval = T_FT_INT16;
> 			break;
> 		case FT_INT32:
> 			retval = T_FT_INT32;
> 			break;
214c224
< [0-9]+ {				/* decimal or octal values */
---
> {minus}*[0-9]+ {				/* decimal or octal values */
Index: proto.c
===================================================================
RCS file: /cvsroot/ethereal/proto.c,v
retrieving revision 1.31
diff -r1.31 proto.c
432a433,438
> 		case FT_INT8:
> 		case FT_INT16:
> 		case FT_INT32:
> 			fi->value.numeric = va_arg(ap, int);
> 			break;
> 
541c547,548
< 		hfinfo->type == FT_VALS_UINT24 || hfinfo->type == FT_VALS_UINT32));
---
> 		hfinfo->type == FT_VALS_UINT24 || hfinfo->type == FT_VALS_UINT32 ||
> 		hfinfo->type == FT_INT8 || hfinfo->type == FT_INT16 || hfinfo->type == FT_INT32));
581a589,596
> 		case FT_INT8:
> 		case FT_INT16:
> 		case FT_INT32:
> 			snprintf(label_str, ITEM_LABEL_LENGTH,
> 				"%s: %d", fi->hfinfo->name,
> 				fi->value.numeric);
> 			break;
> 
859a875,883
> 				break;
> 			case FT_INT8:
> 				enum_name = "FT_INT8";
> 				break;
> 			case FT_INT16:
> 				enum_name = "FT_INT16";
> 				break;
> 			case FT_INT32:
> 				enum_name = "FT_INT32";
Index: proto.h
===================================================================
RCS file: /cvsroot/ethereal/proto.h,v
retrieving revision 1.13
diff -r1.13 proto.h
58a59,61
> 	FT_INT8,
> 	FT_INT16,
> 	FT_INT32,