static void dump_receive(void *opaque, const uint8_t *buf, size_t size)

{

    DumpState *s = opaque;

    struct pcap_sf_pkthdr hdr;

    int64_t ts;

    int caplen;



    /* Early return in case of previous error. */

    if (s->fd < 0) {

        return;

    }



    ts = muldiv64(qemu_get_clock(vm_clock), 1000000, ticks_per_sec);

    caplen = size > s->pcap_caplen ? s->pcap_caplen : size;



    hdr.ts.tv_sec = ts / 1000000;

    hdr.ts.tv_usec = ts % 1000000;

    hdr.caplen = caplen;

    hdr.len = size;

    if (write(s->fd, &hdr, sizeof(hdr)) != sizeof(hdr) ||

        write(s->fd, buf, caplen) != caplen) {

        qemu_log("-net dump write error - stop dump\n");

        close(s->fd);

        s->fd = -1;

    }

}

static void dump_receive(void *opaque, const uint8_t *buf, size_t size)

{

    DumpState *s = opaque;

    struct pcap_sf_pkthdr hdr;

    int64_t ts;

    int caplen;



    

    if (s->fd < 0) {

        return;

    }



    ts = muldiv64(qemu_get_clock(vm_clock), 1000000, ticks_per_sec);

    caplen = size > s->pcap_caplen ? s->pcap_caplen : size;



    hdr.ts.tv_sec = ts / 1000000;

    hdr.ts.tv_usec = ts % 1000000;

    hdr.caplen = caplen;

    hdr.len = size;

    if (write(s->fd, &hdr, sizeof(hdr)) != sizeof(hdr) ||

        write(s->fd, buf, caplen) != caplen) {

        qemu_log("-net dump write error - stop dump\n");

        close(s->fd);

        s->fd = -1;

    }

}

static void FUNC_0(void *VAR_0, const uint8_t *VAR_1, size_t VAR_2)

{

    DumpState *s = VAR_0;

    struct pcap_sf_pkthdr VAR_3;

    int64_t ts;

    int VAR_4;



    

    if (s->fd < 0) {

        return;

    }



    ts = muldiv64(qemu_get_clock(vm_clock), 1000000, ticks_per_sec);

    VAR_4 = VAR_2 > s->pcap_caplen ? s->pcap_caplen : VAR_2;



    VAR_3.ts.tv_sec = ts / 1000000;

    VAR_3.ts.tv_usec = ts % 1000000;

    VAR_3.VAR_4 = VAR_4;

    VAR_3.len = VAR_2;

    if (write(s->fd, &VAR_3, sizeof(VAR_3)) != sizeof(VAR_3) ||

        write(s->fd, VAR_1, VAR_4) != VAR_4) {

        qemu_log("-net dump write error - stop dump\n");

        close(s->fd);

        s->fd = -1;

    }

}

static void FUNC_0(void *VAR_0, const uint8_t *VAR_1, size_t VAR_2)
{ DumpState *s = VAR_0; struct pcap_sf_pkthdr VAR_3; int64_t ts; int VAR_4; if (s->fd < 0) { return; } ts = muldiv64(qemu_get_clock(vm_clock), 1000000, ticks_per_sec); VAR_4 = VAR_2 > s->pcap_caplen ? s->pcap_caplen : VAR_2; VAR_3.ts.tv_sec = ts / 1000000; VAR_3.ts.tv_usec = ts % 1000000; VAR_3.VAR_4 = VAR_4; VAR_3.len = VAR_2; if (write(s->fd, &VAR_3, sizeof(VAR_3)) != sizeof(VAR_3) ||
write(s->fd, VAR_1, VAR_4) != VAR_4) { qemu_log("-net dump write error - stop dump\n"); close(s->fd); s->fd = -1; } }