Ethereal-dev: Re: [Ethereal-dev] Ethereal plugin versioning question

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

From: Guy Harris <gharris@xxxxxxxxx>
Date: Mon, 25 Oct 2004 11:05:15 -0700
Jaap Keuter wrote:

Which would be nice if you have a unified source.... But than it would be
riddled with version selection logic, making it _very_ difficult to
maintain.

...only if the protocol itself is riddled with places where the protocols differ.

If that's really the case, you can just do:

	static void
	dissect_foo_v1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
	{
		...
	}

	static void
	dissect_foo_v2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
	{
		...
	}

	static void
	dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
	{
		switch (protocol_version) {

		case VERSION_1:
			dissect_foo_v1(tvb, pinfo, tree);
			break;

		case VERSION_2:
			dissect_foo_v1(tvb, pinfo, tree);
			break;
		}
	}