static void slirp_hostfwd(SlirpState *s, Monitor *mon, 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) {

        config_error(mon, "could not set up host forwarding rule '%s'\n",

                     redir_str);

    }

    return;



 fail_syntax:

    config_error(mon, "invalid host forwarding rule '%s'\n", redir_str);

}

static void slirp_hostfwd(SlirpState *s, Monitor *mon, 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) {

        config_error(mon, "could not set up host forwarding rule '%s'\n",

                     redir_str);

    }

    return;



 fail_syntax:

    config_error(mon, "invalid host forwarding rule '%s'\n", redir_str);

}

static void slirp_hostfwd(SlirpState *s, Monitor *mon, const char *redir_str, static void slirp_hostfwd(SlirpState *s, Monitor *mon, const char *redir_str,                           int legacy_format)
static void FUNC_0(SlirpState *VAR_0, Monitor *VAR_1, const char *VAR_2,

                          int VAR_3)

{

    struct in_addr VAR_4 = { .s_addr = INADDR_ANY };

    struct in_addr VAR_5 = { .s_addr = 0 };

    int VAR_6, VAR_7;

    const char *VAR_8;

    char VAR_9[256];

    int VAR_10;

    char *VAR_11;



    VAR_8 = VAR_2;

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

        goto fail_syntax;

    }

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

        VAR_10 = 0;

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

        VAR_10 = 1;

    } else {

        goto fail_syntax;

    }



    if (!VAR_3) {

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

            goto fail_syntax;

        }

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

            goto fail_syntax;

        }

    }



    if (get_str_sep(VAR_9, sizeof(VAR_9), &VAR_8, VAR_3 ? ':' : '-') < 0) {

        goto fail_syntax;

    }

    VAR_6 = strtol(VAR_9, &VAR_11, 0);

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

        goto fail_syntax;

    }



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

        goto fail_syntax;

    }

    if (VAR_9[0] != '\0' && !inet_aton(VAR_9, &VAR_5)) {

        goto fail_syntax;

    }



    VAR_7 = strtol(VAR_8, &VAR_11, 0);

    if (*VAR_11 != '\0' || VAR_7 < 1 || VAR_7 > 65535) {

        goto fail_syntax;

    }



    if (slirp_add_hostfwd(VAR_0->slirp, VAR_10, VAR_4, VAR_6, VAR_5,

                          VAR_7) < 0) {

        config_error(VAR_1, "could not set up host forwarding rule '%VAR_0'\n",

                     VAR_2);

    }

    return;



 fail_syntax:

    config_error(VAR_1, "invalid host forwarding rule '%VAR_0'\n", VAR_2);

}

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