Ethereal-dev: Re: [Ethereal-dev] Which characters can i compare using ' tvb_get_guint8'

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

From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Thu, 31 Jul 2003 11:23:13 -0700

On Thursday, July 31, 2003, at 7:18 AM, Anders Broman (TN/EAB) wrote:

Shold'nt the following coding work?

Yes.


	guint8		tempchar;

	tempchar = tvb_get_guint8(tvb, tvb_previous_offset );
	
	switch ( tempchar ){
		/* domainAddress */
		case '[':
tvb_current_offset = tvb_find_guint8(tvb, tvb_previous_offset, tvb_len, ']');

I don't get a match eventhoug I'm prety certain that tempchar holds '['

By "I don't get a match" do you mean that the "switch" statement doesn't go to the '[' case, or do you mean that "tvb_find_guint8()" doesn't find a ']'?

If the former, then either

1) "tempchar" doesn't, in fact, contain a '[' ('[' doesn't have the 8th bit set in ASCII, so "guint8" vs. "char" won't matter)

or

	2) you have a buggy C compiler.

If the latter, then the existence of a '[' at "tvb_previous_offset" doesn't necessarily imply the existence of a ']' later in the packet (e.g., the snapshot length might have been short enough to cut the packet off, or the packet might be malformed).