Ejemplo n.º 1
0
WSLUA_FUNCTION wslua_all_field_infos(lua_State* L) {
    /*
    Obtain all fields from the current tree.  Note this only gets whatever fields the underlying
    dissectors have filled in for this packet at this time - there may be fields applicable to
    the packet that simply aren't being filled in because at this time they're not needed for anything.
    This function only gets what the C-side code has currently populated, not the full list.
    */
    GPtrArray* found;
    int items_found = 0;
    guint i;

    if (! lua_tree || ! lua_tree->tree ) {
        WSLUA_ERROR(wslua_all_field_infos,"Cannot be called outside a listener or dissector");
        return 0;
    }

    found = proto_all_finfos(lua_tree->tree);

    if (found) {
        for (i=0; i<found->len; i++) {
            push_FieldInfo(L, (field_info *)g_ptr_array_index(found,i));
            items_found++;
        }

        g_ptr_array_free(found,TRUE);
    }

    return items_found;
}
Ejemplo n.º 2
0
void PacketList::contextMenuEvent(QContextMenuEvent *event)
{
    const char *module_name = NULL;
    if (cap_file_ && cap_file_->edt && cap_file_->edt->tree) {
        GPtrArray          *finfo_array = proto_all_finfos(cap_file_->edt->tree);

        for (guint i = finfo_array->len - 1; i > 0 ; i --) {
            field_info *fi = (field_info *)g_ptr_array_index (finfo_array, i);
            header_field_info *hfinfo =  fi->hfinfo;

            if (!g_str_has_prefix(hfinfo->abbrev, "text") &&
                    !g_str_has_prefix(hfinfo->abbrev, "_ws.expert") &&
                    !g_str_has_prefix(hfinfo->abbrev, "_ws.malformed")) {

                if (hfinfo->parent == -1) {
                    module_name = hfinfo->abbrev;
                } else {
                    module_name = proto_registrar_get_abbrev(hfinfo->parent);
                }
                break;
            }
        }
    }
    proto_prefs_menu_.setModule(module_name);

    foreach (QAction *action, copy_actions_) {
        action->setData(QVariant());
    }
Ejemplo n.º 3
0
WSLUA_FUNCTION wslua_all_field_infos(lua_State* L) {
	/* Obtain all fields from the current tree */
	GPtrArray* found;
	int items_found = 0;
	guint i;

	if (! lua_tree || ! lua_tree->tree ) {
		WSLUA_ERROR(wslua_all_field_infos,"Cannot be called outside a listener or dissector");
	}
	
	found = proto_all_finfos(lua_tree->tree);
	
	if (found) {
		for (i=0; i<found->len; i++) {
			pushFieldInfo(L,g_ptr_array_index(found,i));
			items_found++;
		}

		g_ptr_array_free(found,TRUE);
	}

	return items_found;
}