Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Can you determine direction programmatically?

One way of doing that is comparing the source and destination port numbers.
Search code for string port >.

epan/dissectors/packet-udp.c:

    /* check direction and get ua lists */
    direction = cmp_address(&pinfo->src, &pinfo->dst);
    /* if the addresses are equal, match the ports instead */
    if (direction == 0) {
        direction = (pinfo->srcport > pinfo->destport) ? 1 : -1;
    }


epan/dissectors/packet-tpm20.c:

    if (pinfo->srcport > pinfo->destport) {
        col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, " [TPM Request]");
        if (length >= TPM_COMMAND_HEADER_LEN)
            dissect_tpm20_tpm_command(tvb, pinfo, tpm_tree);
        else
            dissect_tpm20_platform_command(tvb, pinfo, tpm_tree);

    } else {
        col_append_sep_str(pinfo->cinfo, COL_INFO, NULL, " [TPM Response]");
        if (length >= TPM_COMMAND_HEADER_LEN)
            dissect_tpm20_tpm_response(tvb, pinfo, tpm_tree);
        else
            dissect_tpm20_platform_response(tvb, pinfo, tpm_tree);
    }