Ethereal-dev: Re: [Ethereal-dev] Can a dissector tell what protocol and port is using it?

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

From: Guy Harris <guy@xxxxxxxxxx>
Date: Thu, 12 Oct 2000 17:24:36 -0700 (PDT)
> It is easy/possible for the dissect_myprotocol function to tell if the
> packet came in via TCP or UDP, and/or tell which port it's on?

At least for TCP and UDP:

	if your dissector is an old-style dissector, "pi.ptype" will be
	PT_TCP or PT_UDP, depending on which protocol it was inside,
	and:

		"pi.srcport" will be the source port number of the
		packet;

		"pi.destport" will be the destination port number of the
		packet;

		"pi.match_port" will be the port number for the service
		(i.e., if the packet was sent *to* the port number you
		registered, it'll be equal to "pi.destport", and if it
		was sent *from* the port number you registered, it'll be
		equal to "pi.srcport");

	if your dissector is a new-style dissector, it will be passed as
	its second argument a "packet_info" structure, and the "ptype",
	"srcport", "destport", and "match_port" members of that
	structure will be as described above.