int net_init_dump(const NetClientOptions *opts, const char *name,

                  NetClientState *peer, Error **errp)

{

    int len, rc;

    const char *file;

    char def_file[128];

    const NetdevDumpOptions *dump;

    NetClientState *nc;

    DumpNetClient *dnc;



    assert(opts->type == NET_CLIENT_OPTIONS_KIND_DUMP);

    dump = opts->u.dump;



    assert(peer);



    if (dump->has_file) {

        file = dump->file;

    } else {

        int id;

        int ret;



        ret = net_hub_id_for_client(peer, &id);

        assert(ret == 0); /* peer must be on a hub */



        snprintf(def_file, sizeof(def_file), "qemu-vlan%d.pcap", id);

        file = def_file;

    }



    if (dump->has_len) {

        if (dump->len > INT_MAX) {

            error_setg(errp, "invalid length: %"PRIu64, dump->len);

            return -1;

        }

        len = dump->len;

    } else {

        len = 65536;

    }



    nc = qemu_new_net_client(&net_dump_info, peer, "dump", name);

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

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



    dnc = DO_UPCAST(DumpNetClient, nc, nc);

    rc = net_dump_state_init(&dnc->ds, file, len, errp);

    if (rc) {

        qemu_del_net_client(nc);

    }

    return rc;

}

int net_init_dump(const NetClientOptions *opts, const char *name,

                  NetClientState *peer, Error **errp)

{

    int len, rc;

    const char *file;

    char def_file[128];

    const NetdevDumpOptions *dump;

    NetClientState *nc;

    DumpNetClient *dnc;



    assert(opts->type == NET_CLIENT_OPTIONS_KIND_DUMP);

    dump = opts->u.dump;



    assert(peer);



    if (dump->has_file) {

        file = dump->file;

    } else {

        int id;

        int ret;



        ret = net_hub_id_for_client(peer, &id);

        assert(ret == 0); 



        snprintf(def_file, sizeof(def_file), "qemu-vlan%d.pcap", id);

        file = def_file;

    }



    if (dump->has_len) {

        if (dump->len > INT_MAX) {

            error_setg(errp, "invalid length: %"PRIu64, dump->len);

            return -1;

        }

        len = dump->len;

    } else {

        len = 65536;

    }



    nc = qemu_new_net_client(&net_dump_info, peer, "dump", name);

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

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



    dnc = DO_UPCAST(DumpNetClient, nc, nc);

    rc = net_dump_state_init(&dnc->ds, file, len, errp);

    if (rc) {

        qemu_del_net_client(nc);

    }

    return rc;

}

int FUNC_0(const NetClientOptions *VAR_0, const char *VAR_1,

                  NetClientState *VAR_2, Error **VAR_3)

{

    int VAR_4, VAR_5;

    const char *VAR_6;

    char VAR_7[128];

    const NetdevDumpOptions *VAR_8;

    NetClientState *nc;

    DumpNetClient *dnc;



    assert(VAR_0->type == NET_CLIENT_OPTIONS_KIND_DUMP);

    VAR_8 = VAR_0->u.VAR_8;



    assert(VAR_2);



    if (VAR_8->has_file) {

        VAR_6 = VAR_8->VAR_6;

    } else {

        int VAR_9;

        int VAR_10;



        VAR_10 = net_hub_id_for_client(VAR_2, &VAR_9);

        assert(VAR_10 == 0); 



        snprintf(VAR_7, sizeof(VAR_7), "qemu-vlan%d.pcap", VAR_9);

        VAR_6 = VAR_7;

    }



    if (VAR_8->has_len) {

        if (VAR_8->VAR_4 > INT_MAX) {

            error_setg(VAR_3, "invalid length: %"PRIu64, VAR_8->VAR_4);

            return -1;

        }

        VAR_4 = VAR_8->VAR_4;

    } else {

        VAR_4 = 65536;

    }



    nc = qemu_new_net_client(&net_dump_info, VAR_2, "VAR_8", VAR_1);

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

             "VAR_8 to %s (VAR_4=%d)", VAR_6, VAR_4);



    dnc = DO_UPCAST(DumpNetClient, nc, nc);

    VAR_5 = net_dump_state_init(&dnc->ds, VAR_6, VAR_4, VAR_3);

    if (VAR_5) {

        qemu_del_net_client(nc);

    }

    return VAR_5;

}

int FUNC_0(const NetClientOptions *VAR_0, const char *VAR_1,
NetClientState *VAR_2, Error **VAR_3)
{ int VAR_4, VAR_5; const char *VAR_6; char VAR_7[128]; const NetdevDumpOptions *VAR_8; NetClientState *nc; DumpNetClient *dnc; assert(VAR_0->type == NET_CLIENT_OPTIONS_KIND_DUMP); VAR_8 = VAR_0->u.VAR_8; assert(VAR_2); if (VAR_8->has_file) { VAR_6 = VAR_8->VAR_6; } else { int VAR_9; int VAR_10; VAR_10 = net_hub_id_for_client(VAR_2, &VAR_9); assert(VAR_10 == 0); snprintf(VAR_7, sizeof(VAR_7), "qemu-vlan%d.pcap", VAR_9); VAR_6 = VAR_7; } if (VAR_8->has_len) { if (VAR_8->VAR_4 > INT_MAX) { error_setg(VAR_3, "invalid length: %"PRIu64, VAR_8->VAR_4); return -1; } VAR_4 = VAR_8->VAR_4; } else { VAR_4 = 65536; } nc = qemu_new_net_client(&net_dump_info, VAR_2, "VAR_8", VAR_1); snprintf(nc->info_str, sizeof(nc->info_str),
"VAR_8 to %s (VAR_4=%d)", VAR_6, VAR_4); dnc = DO_UPCAST(DumpNetClient, nc, nc); VAR_5 = net_dump_state_init(&dnc->ds, VAR_6, VAR_4, VAR_3); if (VAR_5) { qemu_del_net_client(nc); } return VAR_5; }