Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wdoekes opened this issue Oct 7, 2015 · 0 comments
Open

Comments

@wdoekes
Copy link
Member

wdoekes commented Oct 7, 2015

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);
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant