Revision 85bb6d36 net.c

b/net.c
94 94
    return 0;
95 95
}
96 96

  
97
int parse_host_src_port(struct sockaddr_in *haddr,
98
                        struct sockaddr_in *saddr,
99
                        const char *input_str)
100
{
101
    char *str = qemu_strdup(input_str);
102
    char *host_str = str;
103
    char *src_str;
104
    const char *src_str2;
105
    char *ptr;
106

  
107
    /*
108
     * Chop off any extra arguments at the end of the string which
109
     * would start with a comma, then fill in the src port information
110
     * if it was provided else use the "any address" and "any port".
111
     */
112
    if ((ptr = strchr(str,',')))
113
        *ptr = '\0';
114

  
115
    if ((src_str = strchr(input_str,'@'))) {
116
        *src_str = '\0';
117
        src_str++;
118
    }
119

  
120
    if (parse_host_port(haddr, host_str) < 0)
121
        goto fail;
122

  
123
    src_str2 = src_str;
124
    if (!src_str || *src_str == '\0')
125
        src_str2 = ":0";
126

  
127
    if (parse_host_port(saddr, src_str2) < 0)
128
        goto fail;
129

  
130
    free(str);
131
    return(0);
132

  
133
fail:
134
    free(str);
135
    return -1;
136
}
137

  
138 97
int parse_host_port(struct sockaddr_in *saddr, const char *str)
139 98
{
140 99
    char buf[512];

Also available in: Unified diff