ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-dev: [Wireshark-dev] adding tap listeners

From: Sach Kmat <sachkmat@xxxxxxxxx>
Date: Tue, 17 Nov 2009 17:51:37 -0800
Hi,

I have a couple of newbie question regarding taps.

1. I want to write a tap for tcp packets in a plugin that is already
dissecting some packets for me.
Can I register a tap listener (call register_tap_listener) in the
plugin_register function that I wrote for my dissector
or do I have to have a plugin_register_tap_listener exported from my
plugin and then call register_tap_listener in
plugin_register_tap_listener ?

2. I registered a tap listener for tcp (code snippet given below) and
all I did was to printf something to see that my tap listener is
getting called.
I see the printf message only once when the file is opened. Shouldn't
the tap listener be called after each tcp packet is dissected? My tap
doesn't do anything so far.
I just want to see it being called for every packet that is dissected.

Tap listener registration:
[code]
void plugin_register_tap_listener() {
    GString *error_string;
    error_string = register_tap_listener("tcp", NULL, NULL, 0, NULL,
foo_packet, NULL);
    if (!error_string) printf("tap registration failed\n");
}
[/code]

Tap listener:
[code]
gboolean
foo_packet(void *prs, packet_info *pinfo, epan_dissect_t *edt, const void *pri)
{
    printf("Tap called\n");
    return false;
}
[/code]


regards,
sk