rtpsniff icon indicating copy to clipboard operation
rtpsniff copied to clipboard

anysniff: Combine #1 and #2 and allow multiple modules to be run.

Open wdoekes opened this issue 10 years ago • 0 comments

If we have implemented #1 and #2, we can have anysniff initialize the modules as needed and call them all from a loop:

sniff_loop() will be implemented once, and will call incoming_packet on all sniff-modules.

static void sniff_got_packet(u_char *args, const struct pcap_pkthdr *header,
                        const u_char *packet) {
...
    for (i = 0; i < MAX_MODULES && sniff_modules[i]; ++i) {
          /* fixme: fetch his_storage */
          sniff_modules[i]->incoming_packet(his_storage, args, header, packet);
    }

out_write() will be implemented once (called from the timer module) and will call print_summary() on all enabled sniff-modules:

void write_summary() { /* out_write */
...
    FILE **fps[MAX_MODULES+1] = {0,};
    int i, j;
    for (i = 0; i < MAX_MODULES && output_modules[i]; ++i)
          fps[i] = output_modules[i]->begin_summary();
    for (i = 0; i < MAX_MODULES && sniff_modules[i]; ++i) {
          /* fixme: fetch his_storage */
          for (j = 0; fps[j]; ++j)
                sniff_modules[i]->print_summary(fps[j], his_storage);
    }

wdoekes avatar Oct 07 '15 07:10 wdoekes