static int slirp_hostfwd(SlirpState *s, const char *redir_str,

                         int legacy_format)

{

    struct in_addr host_addr = { .s_addr = INADDR_ANY };

    struct in_addr guest_addr = { .s_addr = 0 };

    int host_port, guest_port;

    const char *p;

    char buf[256];

    int is_udp;

    char *end;



    p = redir_str;

    if (!p || get_str_sep(buf, sizeof(buf), &p, ':') < 0) {

        goto fail_syntax;

    }

    if (!strcmp(buf, "tcp") || buf[0] == '\0') {

        is_udp = 0;

    } else if (!strcmp(buf, "udp")) {

        is_udp = 1;

    } else {

        goto fail_syntax;

    }



    if (!legacy_format) {

        if (get_str_sep(buf, sizeof(buf), &p, ':') < 0) {

            goto fail_syntax;

        }

        if (buf[0] != '\0' && !inet_aton(buf, &host_addr)) {

            goto fail_syntax;

        }

    }



    if (get_str_sep(buf, sizeof(buf), &p, legacy_format ? ':' : '-') < 0) {

        goto fail_syntax;

    }

    host_port = strtol(buf, &end, 0);

    if (*end != '\0' || host_port < 1 || host_port > 65535) {

        goto fail_syntax;

    }



    if (get_str_sep(buf, sizeof(buf), &p, ':') < 0) {

        goto fail_syntax;

    }

    if (buf[0] != '\0' && !inet_aton(buf, &guest_addr)) {

        goto fail_syntax;

    }



    guest_port = strtol(p, &end, 0);

    if (*end != '\0' || guest_port < 1 || guest_port > 65535) {

        goto fail_syntax;

    }



    if (slirp_add_hostfwd(s->slirp, is_udp, host_addr, host_port, guest_addr,

                          guest_port) < 0) {

        error_report("could not set up host forwarding rule '%s'",

                     redir_str);

        return -1;

    }

    return 0;



 fail_syntax:

    error_report("invalid host forwarding rule '%s'", redir_str);

    return -1;

}

static int slirp_hostfwd(SlirpState *s, const char *redir_str,

                         int legacy_format)

{

    struct in_addr host_addr = { .s_addr = INADDR_ANY };

    struct in_addr guest_addr = { .s_addr = 0 };

    int host_port, guest_port;

    const char *p;

    char buf[256];

    int is_udp;

    char *end;



    p = redir_str;

    if (!p || get_str_sep(buf, sizeof(buf), &p, ':') < 0) {

        goto fail_syntax;

    }

    if (!strcmp(buf, "tcp") || buf[0] == '\0') {

        is_udp = 0;

    } else if (!strcmp(buf, "udp")) {

        is_udp = 1;

    } else {

        goto fail_syntax;

    }



    if (!legacy_format) {

        if (get_str_sep(buf, sizeof(buf), &p, ':') < 0) {

            goto fail_syntax;

        }

        if (buf[0] != '\0' && !inet_aton(buf, &host_addr)) {

            goto fail_syntax;

        }

    }



    if (get_str_sep(buf, sizeof(buf), &p, legacy_format ? ':' : '-') < 0) {

        goto fail_syntax;

    }

    host_port = strtol(buf, &end, 0);

    if (*end != '\0' || host_port < 1 || host_port > 65535) {

        goto fail_syntax;

    }



    if (get_str_sep(buf, sizeof(buf), &p, ':') < 0) {

        goto fail_syntax;

    }

    if (buf[0] != '\0' && !inet_aton(buf, &guest_addr)) {

        goto fail_syntax;

    }



    guest_port = strtol(p, &end, 0);

    if (*end != '\0' || guest_port < 1 || guest_port > 65535) {

        goto fail_syntax;

    }



    if (slirp_add_hostfwd(s->slirp, is_udp, host_addr, host_port, guest_addr,

                          guest_port) < 0) {

        error_report("could not set up host forwarding rule '%s'",

                     redir_str);

        return -1;

    }

    return 0;



 fail_syntax:

    error_report("invalid host forwarding rule '%s'", redir_str);

    return -1;

}

static int FUNC_0(SlirpState *VAR_0, const char *VAR_1,

                         int VAR_2)

{

    struct in_addr VAR_3 = { .s_addr = INADDR_ANY };

    struct in_addr VAR_4 = { .s_addr = 0 };

    int VAR_5, VAR_6;

    const char *VAR_7;

    char VAR_8[256];

    int VAR_9;

    char *VAR_10;



    VAR_7 = VAR_1;

    if (!VAR_7 || get_str_sep(VAR_8, sizeof(VAR_8), &VAR_7, ':') < 0) {

        goto fail_syntax;

    }

    if (!strcmp(VAR_8, "tcp") || VAR_8[0] == '\0') {

        VAR_9 = 0;

    } else if (!strcmp(VAR_8, "udp")) {

        VAR_9 = 1;

    } else {

        goto fail_syntax;

    }



    if (!VAR_2) {

        if (get_str_sep(VAR_8, sizeof(VAR_8), &VAR_7, ':') < 0) {

            goto fail_syntax;

        }

        if (VAR_8[0] != '\0' && !inet_aton(VAR_8, &VAR_3)) {

            goto fail_syntax;

        }

    }



    if (get_str_sep(VAR_8, sizeof(VAR_8), &VAR_7, VAR_2 ? ':' : '-') < 0) {

        goto fail_syntax;

    }

    VAR_5 = strtol(VAR_8, &VAR_10, 0);

    if (*VAR_10 != '\0' || VAR_5 < 1 || VAR_5 > 65535) {

        goto fail_syntax;

    }



    if (get_str_sep(VAR_8, sizeof(VAR_8), &VAR_7, ':') < 0) {

        goto fail_syntax;

    }

    if (VAR_8[0] != '\0' && !inet_aton(VAR_8, &VAR_4)) {

        goto fail_syntax;

    }



    VAR_6 = strtol(VAR_7, &VAR_10, 0);

    if (*VAR_10 != '\0' || VAR_6 < 1 || VAR_6 > 65535) {

        goto fail_syntax;

    }



    if (slirp_add_hostfwd(VAR_0->slirp, VAR_9, VAR_3, VAR_5, VAR_4,

                          VAR_6) < 0) {

        error_report("could not set up host forwarding rule '%VAR_0'",

                     VAR_1);

        return -1;

    }

    return 0;



 fail_syntax:

    error_report("invalid host forwarding rule '%VAR_0'", VAR_1);

    return -1;

}

static int FUNC_0(SlirpState *VAR_0, const char *VAR_1,
int VAR_2)
{ struct in_addr VAR_3 = { .s_addr = INADDR_ANY }; struct in_addr VAR_4 = { .s_addr = 0 }; int VAR_5, VAR_6; const char *VAR_7; char VAR_8[256]; int VAR_9; char *VAR_10; VAR_7 = VAR_1; if (!VAR_7 || get_str_sep(VAR_8, sizeof(VAR_8), &VAR_7, ':') < 0) { goto fail_syntax; } if (!strcmp(VAR_8, "tcp") || VAR_8[0] == '\0') { VAR_9 = 0; } else if (!strcmp(VAR_8, "udp")) { VAR_9 = 1; } else { goto fail_syntax; } if (!VAR_2) { if (get_str_sep(VAR_8, sizeof(VAR_8), &VAR_7, ':') < 0) { goto fail_syntax; } if (VAR_8[0] != '\0' && !inet_aton(VAR_8, &VAR_3)) { goto fail_syntax; } } if (get_str_sep(VAR_8, sizeof(VAR_8), &VAR_7, VAR_2 ? ':' : '-') < 0) { goto fail_syntax; } VAR_5 = strtol(VAR_8, &VAR_10, 0); if (*VAR_10 != '\0' || VAR_5 < 1 || VAR_5 > 65535) { goto fail_syntax; } if (get_str_sep(VAR_8, sizeof(VAR_8), &VAR_7, ':') < 0) { goto fail_syntax; } if (VAR_8[0] != '\0' && !inet_aton(VAR_8, &VAR_4)) { goto fail_syntax; } VAR_6 = strtol(VAR_7, &VAR_10, 0); if (*VAR_10 != '\0' || VAR_6 < 1 || VAR_6 > 65535) { goto fail_syntax; } if (slirp_add_hostfwd(VAR_0->slirp, VAR_9, VAR_3, VAR_5, VAR_4,
VAR_6) < 0) { error_report("could not set up host forwarding rule '%VAR_0'",
VAR_1); return -1; } return 0; fail_syntax:
error_report("invalid host forwarding rule '%VAR_0'", VAR_1); return -1; }