All pastes #148772 Raw Edit

Something

public c v1 · immutable
#148772 ·published 2006-08-25 10:50 UTC
rendered paste body
#include <stdio.h>#include <pcap.h>#include <sys/types.h>#include <net/bpf.h>#include <netgraph.h>#include <netgraph/ng_bpf.h>int main (){        const int  SNAP_LEN = 1518;        pcap_t *handle;        struct bpf_program fp;        char filter_exp[] = "port 25";        struct ng_bpf_hookprog bpf_hookprog;        handle = pcap_open_dead(DLT_EN10MB, SNAP_LEN);        if (handle == NULL){                fprintf (stderr, "Could not open device");                return (2);        }        if (pcap_compile (handle, &fp, filter_exp, 0, 0) < 0){                                fprintf (stderr, "Could not compile filter");                return (2);        }        bpf_hookprog.bpf_prog_len = fp.bf_len;        bpf_hookprog.bpf_prog = fp.bf_insns;        pcap_close (handle);        pcap_freecode (&fp);        return (0);}