static int net_dump_init(NetClientState *peer, const char *device,

                         const char *name, const char *filename, int len)

{

    struct pcap_file_hdr hdr;

    NetClientState *nc;

    DumpState *s;

    struct tm tm;

    int fd;



    fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0644);

    if (fd < 0) {

        error_report("-net dump: can't open %s", filename);

        return -1;

    }



    hdr.magic = PCAP_MAGIC;

    hdr.version_major = 2;

    hdr.version_minor = 4;

    hdr.thiszone = 0;

    hdr.sigfigs = 0;

    hdr.snaplen = len;

    hdr.linktype = 1;



    if (write(fd, &hdr, sizeof(hdr)) < sizeof(hdr)) {

        error_report("-net dump write error: %s", strerror(errno));

        close(fd);

        return -1;

    }



    nc = qemu_new_net_client(&net_dump_info, peer, device, name);



    snprintf(nc->info_str, sizeof(nc->info_str),

             "dump to %s (len=%d)", filename, len);



    s = DO_UPCAST(DumpState, nc, nc);



    s->fd = fd;

    s->pcap_caplen = len;



    qemu_get_timedate(&tm, 0);

    s->start_ts = mktime(&tm);



    return 0;

}

static int net_dump_init(NetClientState *peer, const char *device,

                         const char *name, const char *filename, int len)

{

    struct pcap_file_hdr hdr;

    NetClientState *nc;

    DumpState *s;

    struct tm tm;

    int fd;



    fd = open(filename, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0644);

    if (fd < 0) {

        error_report("-net dump: can't open %s", filename);

        return -1;

    }



    hdr.magic = PCAP_MAGIC;

    hdr.version_major = 2;

    hdr.version_minor = 4;

    hdr.thiszone = 0;

    hdr.sigfigs = 0;

    hdr.snaplen = len;

    hdr.linktype = 1;



    if (write(fd, &hdr, sizeof(hdr)) < sizeof(hdr)) {

        error_report("-net dump write error: %s", strerror(errno));

        close(fd);

        return -1;

    }



    nc = qemu_new_net_client(&net_dump_info, peer, device, name);



    snprintf(nc->info_str, sizeof(nc->info_str),

             "dump to %s (len=%d)", filename, len);



    s = DO_UPCAST(DumpState, nc, nc);



    s->fd = fd;

    s->pcap_caplen = len;



    qemu_get_timedate(&tm, 0);

    s->start_ts = mktime(&tm);



    return 0;

}

                         const char *name, const char *filename, int len)         error_report("-net dump: can't open %s", filename);         error_report("-net dump write error: %s", strerror(errno));
static int FUNC_0(NetClientState *VAR_0, const char *VAR_1,

                         const char *VAR_2, const char *VAR_3, int VAR_4)

{

    struct pcap_file_hdr VAR_5;

    NetClientState *nc;

    DumpState *s;

    struct VAR_6 VAR_6;

    int VAR_7;



    VAR_7 = open(VAR_3, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0644);

    if (VAR_7 < 0) {

        error_report("-net dump: can't open %s", VAR_3);

        return -1;

    }



    VAR_5.magic = PCAP_MAGIC;

    VAR_5.version_major = 2;

    VAR_5.version_minor = 4;

    VAR_5.thiszone = 0;

    VAR_5.sigfigs = 0;

    VAR_5.snaplen = VAR_4;

    VAR_5.linktype = 1;



    if (write(VAR_7, &VAR_5, sizeof(VAR_5)) < sizeof(VAR_5)) {

        error_report("-net dump write error: %s", strerror(errno));

        close(VAR_7);

        return -1;

    }



    nc = qemu_new_net_client(&net_dump_info, VAR_0, VAR_1, VAR_2);



    snprintf(nc->info_str, sizeof(nc->info_str),

             "dump to %s (VAR_4=%d)", VAR_3, VAR_4);



    s = DO_UPCAST(DumpState, nc, nc);



    s->VAR_7 = VAR_7;

    s->pcap_caplen = VAR_4;



    qemu_get_timedate(&VAR_6, 0);

    s->start_ts = mktime(&VAR_6);



    return 0;

}

static int FUNC_0(NetClientState *VAR_0, const char *VAR_1,
const char *VAR_2, const char *VAR_3, int VAR_4)
{ struct pcap_file_hdr VAR_5; NetClientState *nc; DumpState *s; struct VAR_6 VAR_6; int VAR_7; VAR_7 = open(VAR_3, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0644); if (VAR_7 < 0) { error_report("-net dump: can't open %s", VAR_3); return -1; } VAR_5.magic = PCAP_MAGIC; VAR_5.version_major = 2; VAR_5.version_minor = 4; VAR_5.thiszone = 0; VAR_5.sigfigs = 0; VAR_5.snaplen = VAR_4; VAR_5.linktype = 1; if (write(VAR_7, &VAR_5, sizeof(VAR_5)) < sizeof(VAR_5)) { error_report("-net dump write error: %s", strerror(errno)); close(VAR_7); return -1; } nc = qemu_new_net_client(&net_dump_info, VAR_0, VAR_1, VAR_2); snprintf(nc->info_str, sizeof(nc->info_str),
"dump to %s (VAR_4=%d)", VAR_3, VAR_4); s = DO_UPCAST(DumpState, nc, nc); s->VAR_7 = VAR_7; s->pcap_caplen = VAR_4; qemu_get_timedate(&VAR_6, 0); s->start_ts = mktime(&VAR_6); return 0; }