Skip to content

anysniff: Expose sniff_rtp/sniff_loss functions through a module-struct #1

@wdoekes

Description

@wdoekes

Current situation

Sniffing module implements all of these:

void sniff_help(); /* show info */
int sniff_snaplen();
void sniff_loop(pcap_t *handle, struct memory_t *memory);
void sniff_release_data(void **data);

Wanted situation

Sniffing module initializes/exposes a struct like this:

struct sniff_module {
    int (*get_snaplen)();
    void (*print_help)(FILE *fp);
    void (*print_summary)(FILE *fp, void **my_storage);
    void (*incoming_packet)(
        void **my_storage,
        u_char *args, const struct pcap_pkthdr *header,
        const u_char *packet);
    void (*free_storage)(void **data);
};

If we delegate the memory switching to the caller of the functions. Alternately we could have the module implement memory switching itself, but that feels like code duplication.

In that case we wouldn't pass void *my_storage, but would require an init() function and a switch_memory(). Seems worse.

Now, what do we do with the print_output? For stat file logging and log file logging, that's okay. And for syslog we could even wrap the syslog call into a FILE object (using fmemopen or fopencookie).

For the loggers, we won't need any configuration, afaict, so we can do without an init function (assuming we'll init the mem from the incoming_packet call, as needed).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions