Lars Dörner wrote:
I guess my problem is a simple one but I got no idea how do solve it.
I’m writing on a dissector for an internal protocol.
The Problem is the PDU’s have the same type number for server -> client
as for client -> server.
I know Ethereal realizes the directions but how can I get hand on it?
What protocol does your protocol run on top of?
If it's an IP-based protocol, the best way would probably be to look at
pinfo->src and pinfo->dst; they're the source and destination addresses
of the packet. (They'll even work for many non-IP-based protocols, such
as Novell IPX-based protocols.) You could, for example, just compare
them with the CMP_ADDRESS() macro in epan/address.h - it returns 0 if
they're equal, -1 if the first is "less than" the second, and 1 if the
first is "greater than" the second (where "less than" and "greater than"
are not to be treated as doing anything other than imposing a total
order on address values; it has no deeper significance).
If it runs atop an Internet transport protocol such as TCP or UDP, you
can, if CMP_ADDRESS() returns 0, compare pinfo->srcport and
pinfo->destport, to compare the port numbers.
If it doesn't matter which machine is considered the client and which is
considered the server, it would be sufficient to call the "lower"
address or address/port pair the client and the other the server (or
call the lower one the server and the other the client).
If there's some way of determining *which* of them is the client and
server, and it's important to know that, you'd have to attach to the
conversation an indication of which address or address/port pair
corresponds to the client.