Ejemplo n.º 1
0
void tap_cleanup(void)
{
	volatile tap_listener_t *elem_lq;
	volatile tap_listener_t *head_lq = tap_listener_queue;
	tap_dissector_t *elem_dl;
	tap_dissector_t *head_dl = tap_dissector_list;

	while(head_lq){
		elem_lq = head_lq;
		head_lq = head_lq->next;
		free_tap_listener(elem_lq);
	}

	while(head_dl){
		elem_dl = head_dl;
		head_dl = head_dl->next;
		g_free((char*)elem_dl->name);
		g_free((gpointer)elem_dl);
	}

#ifdef HAVE_PLUGINS
	g_slist_free(tap_plugins);
	tap_plugins = NULL;
#endif /* HAVE_PLUGINS */
}
Ejemplo n.º 2
0
/* this function attaches the tap_listener to the named tap.
 * function returns :
 *     NULL: ok.
 * non-NULL: error, return value points to GString containing error
 *           message.
 */
GString *
register_tap_listener(const char *tapname, void *tapdata, const char *fstring,
		      guint flags, tap_reset_cb reset, tap_packet_cb packet, tap_draw_cb draw)
{
	volatile tap_listener_t *tl;
	int tap_id;
	dfilter_t *code=NULL;
	GString *error_string;
	gchar *err_msg;

	tap_id=find_tap_id(tapname);
	if(!tap_id){
		error_string = g_string_new("");
		g_string_printf(error_string, "Tap %s not found", tapname);
		return error_string;
	}

	tl=(volatile tap_listener_t *)g_malloc0(sizeof(tap_listener_t));
	tl->needs_redraw=TRUE;
	tl->flags=flags;
	if(fstring){
		if(!dfilter_compile(fstring, &code, &err_msg)){
			error_string = g_string_new("");
			g_string_printf(error_string,
			    "Filter \"%s\" is invalid - %s",
			    fstring, err_msg);
			g_free(err_msg);
			free_tap_listener(tl);
			return error_string;
		}
	}
	tl->fstring=g_strdup(fstring);
	tl->code=code;

	tl->tap_id=tap_id;
	tl->tapdata=tapdata;
	tl->reset=reset;
	tl->packet=packet;
	tl->draw=draw;
	tl->next=tap_listener_queue;

	tap_listener_queue=tl;

	return NULL;
}
Ejemplo n.º 3
0
/* this function removes a tap listener
 */
void
remove_tap_listener(void *tapdata)
{
	volatile tap_listener_t *tl=NULL,*tl2;

	if(!tap_listener_queue){
		return;
	}

	if(tap_listener_queue->tapdata==tapdata){
		tl=tap_listener_queue;
		tap_listener_queue=tap_listener_queue->next;
	} else {
		for(tl2=tap_listener_queue;tl2->next;tl2=tl2->next){
			if(tl2->next->tapdata==tapdata){
				tl=tl2->next;
				tl2->next=tl2->next->next;
				break;
			}

		}
	}
	free_tap_listener(tl);
}