Exemplo n.º 1
0
void
xmpp_failure(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, xmpp_element_t *packet)
{
    proto_item *fail_item;
    proto_tree *fail_tree;

    xmpp_attr_info attrs_info[] = {
        {"xmlns", &hf_xmpp_xmlns, TRUE, TRUE, NULL, NULL},
        {"condition", NULL, FALSE, TRUE, NULL, NULL}
    };

    static const gchar *fail_names[] = {"aborted","account-disabled", "credentials-expired",
        "encryption-required", "incorrect-encoding", "invalid-authzid", "invalid-mechanism",
        "malformed-request", "mechanism-too-weak", "not-authorized", "temporary-auth-failure",
        "transition-needed"
    };

    xmpp_element_t *fail_condition, *text;

    col_add_fstr(pinfo->cinfo, COL_INFO, "FAILURE ");

    fail_item = proto_tree_add_item(tree, hf_xmpp_failure, tvb, packet->offset, packet->length, ENC_BIG_ENDIAN);
    fail_tree = proto_item_add_subtree(fail_item, ett_xmpp_failure);

    if((fail_condition = xmpp_steal_element_by_names(packet, fail_names, array_length(fail_names)))!=NULL)
    {
        xmpp_attr_t *fake_cond = xmpp_ep_init_attr_t(fail_condition->name, fail_condition->offset, fail_condition->length);
        g_hash_table_insert(packet->attrs, (gpointer)"condition", fake_cond);
    }

    if((text = xmpp_steal_element_by_name(packet, "text"))!=NULL)
    {
        xmpp_failure_text(fail_tree, tvb, text);
    }

    xmpp_display_attrs(fail_tree, packet, pinfo, tvb, attrs_info, array_length(attrs_info));

    xmpp_unknown(fail_tree, tvb, pinfo, packet);
}
Exemplo n.º 2
0
static void
xmpp_gtalk_session_reason(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element)
{
    proto_item *reason_item;
    proto_tree *reason_tree;

    xmpp_attr_info attrs_info[] = {
        {"condition", -1, TRUE, TRUE, NULL, NULL},
        {"text", -1, FALSE, FALSE, NULL, NULL}
   };

    xmpp_element_t *condition;
    xmpp_element_t *text;

    const gchar *reason_names[] = { "success", "busy", "cancel"};

    reason_item = proto_tree_add_text(tree, tvb, element->offset, element->length, "REASON");
    reason_tree = proto_item_add_subtree(reason_item, ett_xmpp_gtalk_session_reason);


    /*Looks for reason description.*/
    if((condition = xmpp_steal_element_by_names(element, reason_names, array_length(reason_names)))!=NULL)
    {
        xmpp_attr_t *fake_cond = xmpp_ep_init_attr_t(condition->name, condition->offset, condition->length);
        g_hash_table_insert(element->attrs, (gpointer)"condition", fake_cond);

    }

    if((text = xmpp_steal_element_by_name(element, "text"))!=NULL)
    {
        xmpp_attr_t *fake_text = xmpp_ep_init_attr_t(text->data?text->data->value:"", text->offset, text->length);
        g_hash_table_insert(element->attrs, (gpointer)"text", fake_text);
    }

    xmpp_display_attrs(reason_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info));

    xmpp_unknown(reason_tree, tvb, pinfo, element);
}
Exemplo n.º 3
0
static void
xmpp_jingle_reason(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element)
{
    proto_item *reason_item;
    proto_tree *reason_tree;

    xmpp_attr_info attrs_info[] = {
        {"condition", hf_xmpp_jingle_reason_condition, TRUE, TRUE, NULL, NULL},
        {"sid", -1, FALSE, TRUE, NULL, NULL},
        {"rtp-error", -1, FALSE, TRUE, NULL, NULL},
        {"text", hf_xmpp_jingle_reason_text, FALSE, FALSE, NULL, NULL}
   };

    xmpp_element_t *condition; /*1?*/
    xmpp_element_t *text; /*0-1*/
    xmpp_element_t *rtp_error;

    const gchar *reason_names[] = { "success", "busy", "failed-application", "cancel", "connectivity-error",
        "decline", "expired", "failed-transport", "general-error", "gone", "incompatible-parameters",
        "media-error", "security-error", "timeout", "unsupported-applications", "unsupported-transports"};

    const gchar *rtp_error_names[] = {"crypto-required", "invalid-crypto"};

    reason_item = proto_tree_add_item(tree, hf_xmpp_jingle_reason, tvb, element->offset, element->length, ENC_BIG_ENDIAN);
    reason_tree = proto_item_add_subtree(reason_item, ett_xmpp_jingle_reason);


    /*Looks for reason description. "alternative-session" may contain "sid" element
     Elements are changed into attribute*/
    if((condition = xmpp_steal_element_by_names(element, reason_names, array_length(reason_names)))!=NULL)
    {
        xmpp_attr_t *fake_cond = xmpp_ep_init_attr_t(condition->name, condition->offset, condition->length);
        g_hash_table_insert(element->attrs, "condition", fake_cond);

    } else if((condition = xmpp_steal_element_by_name(element, "alternative-session"))!=NULL)
    {
        xmpp_attr_t *fake_cond,*fake_alter_sid;
        xmpp_element_t *sid;

        fake_cond = xmpp_ep_init_attr_t(condition->name, condition->offset, condition->length);
        g_hash_table_insert(element->attrs, "condition", fake_cond);


        if((sid = xmpp_steal_element_by_name(condition, "sid"))!=NULL)
        {
            fake_alter_sid = xmpp_ep_init_attr_t(sid->name, sid->offset, sid->length);
            g_hash_table_insert(element->attrs, "sid", fake_alter_sid);
        }
    }

    if((rtp_error = xmpp_steal_element_by_names(element, rtp_error_names, array_length(rtp_error_names)))!=NULL)
    {
        xmpp_attr_t *fake_rtp_error = xmpp_ep_init_attr_t(rtp_error->name, rtp_error->offset, rtp_error->length);
        g_hash_table_insert(element->attrs, "rtp-error", fake_rtp_error);
    }

    if((text = xmpp_steal_element_by_name(element, "text"))!=NULL)
    {
        xmpp_attr_t *fake_text = xmpp_ep_init_attr_t(text->data?text->data->value:"", text->offset, text->length);
        g_hash_table_insert(element->attrs, "text", fake_text);
    }

    xmpp_display_attrs(reason_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info));

    xmpp_unknown(reason_tree, tvb, pinfo, element);
}