static int net_dump_init(VLANState *vlan, const char *device,

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

{

    struct pcap_file_hdr hdr;

    DumpState *s;



    s = qemu_malloc(sizeof(DumpState));



    s->fd = open(filename, O_CREAT | O_WRONLY | O_BINARY, 0644);

    if (s->fd < 0) {

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

        return -1;

    }



    s->pcap_caplen = len;



    hdr.magic = PCAP_MAGIC;

    hdr.version_major = 2;

    hdr.version_minor = 4;

    hdr.thiszone = 0;

    hdr.sigfigs = 0;

    hdr.snaplen = s->pcap_caplen;

    hdr.linktype = 1;



    if (write(s->fd, &hdr, sizeof(hdr)) < sizeof(hdr)) {

        qemu_error("-net dump write error: %s\n", strerror(errno));

        close(s->fd);

        qemu_free(s);

        return -1;

    }



    s->pcap_vc = qemu_new_vlan_client(NET_CLIENT_TYPE_DUMP,

                                      vlan, NULL, device, name, NULL,

                                      dump_receive, NULL, NULL,

                                      net_dump_cleanup, s);

    snprintf(s->pcap_vc->info_str, sizeof(s->pcap_vc->info_str),

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

    return 0;

}

static int net_dump_init(VLANState *vlan, const char *device,

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

{

    struct pcap_file_hdr hdr;

    DumpState *s;



    s = qemu_malloc(sizeof(DumpState));



    s->fd = open(filename, O_CREAT | O_WRONLY | O_BINARY, 0644);

    if (s->fd < 0) {

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

        return -1;

    }



    s->pcap_caplen = len;



    hdr.magic = PCAP_MAGIC;

    hdr.version_major = 2;

    hdr.version_minor = 4;

    hdr.thiszone = 0;

    hdr.sigfigs = 0;

    hdr.snaplen = s->pcap_caplen;

    hdr.linktype = 1;



    if (write(s->fd, &hdr, sizeof(hdr)) < sizeof(hdr)) {

        qemu_error("-net dump write error: %s\n", strerror(errno));

        close(s->fd);

        qemu_free(s);

        return -1;

    }



    s->pcap_vc = qemu_new_vlan_client(NET_CLIENT_TYPE_DUMP,

                                      vlan, NULL, device, name, NULL,

                                      dump_receive, NULL, NULL,

                                      net_dump_cleanup, s);

    snprintf(s->pcap_vc->info_str, sizeof(s->pcap_vc->info_str),

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

    return 0;

}

    s = qemu_malloc(sizeof(DumpState));     s->fd = open(filename, O_CREAT | O_WRONLY | O_BINARY, 0644);     if (s->fd < 0) {     s->pcap_caplen = len;     hdr.snaplen = s->pcap_caplen;     if (write(s->fd, &hdr, sizeof(hdr)) < sizeof(hdr)) {         close(s->fd);         qemu_free(s);     s->pcap_vc = qemu_new_vlan_client(NET_CLIENT_TYPE_DUMP,                                       vlan, NULL, device, name, NULL,                                       dump_receive, NULL, NULL,                                       net_dump_cleanup, s);     snprintf(s->pcap_vc->info_str, sizeof(s->pcap_vc->info_str),
static int FUNC_0(VLANState *VAR_0, const char *VAR_1,

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

{

    struct pcap_file_hdr VAR_5;

    DumpState *s;



    s = qemu_malloc(sizeof(DumpState));



    s->fd = open(VAR_3, O_CREAT | O_WRONLY | O_BINARY, 0644);

    if (s->fd < 0) {

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

        return -1;

    }



    s->pcap_caplen = VAR_4;



    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 = s->pcap_caplen;

    VAR_5.linktype = 1;



    if (write(s->fd, &VAR_5, sizeof(VAR_5)) < sizeof(VAR_5)) {

        qemu_error("-net dump write error: %s\n", strerror(errno));

        close(s->fd);

        qemu_free(s);

        return -1;

    }



    s->pcap_vc = qemu_new_vlan_client(NET_CLIENT_TYPE_DUMP,

                                      VAR_0, NULL, VAR_1, VAR_2, NULL,

                                      dump_receive, NULL, NULL,

                                      net_dump_cleanup, s);

    snprintf(s->pcap_vc->info_str, sizeof(s->pcap_vc->info_str),

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

    return 0;

}

static int FUNC_0(VLANState *VAR_0, const char *VAR_1,
const char *VAR_2, const char *VAR_3, int VAR_4)
{ struct pcap_file_hdr VAR_5; DumpState *s; s = qemu_malloc(sizeof(DumpState)); s->fd = open(VAR_3, O_CREAT | O_WRONLY | O_BINARY, 0644); if (s->fd < 0) { qemu_error("-net dump: can't open %s\n", VAR_3); return -1; } s->pcap_caplen = VAR_4; 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 = s->pcap_caplen; VAR_5.linktype = 1; if (write(s->fd, &VAR_5, sizeof(VAR_5)) < sizeof(VAR_5)) { qemu_error("-net dump write error: %s\n", strerror(errno)); close(s->fd); qemu_free(s); return -1; } s->pcap_vc = qemu_new_vlan_client(NET_CLIENT_TYPE_DUMP,
VAR_0, NULL, VAR_1, VAR_2, NULL,
dump_receive, NULL, NULL,
net_dump_cleanup, s); snprintf(s->pcap_vc->info_str, sizeof(s->pcap_vc->info_str),
"dump to %s (VAR_4=%d)", VAR_3, VAR_4); return 0; }