~ubuntu-branches/debian/sid/coturn/sid

« back to all changes in this revision

Viewing changes to src/client/ns_turn_ioaddr.c

  • Committer: Package Import Robot
  • Author(s): Oleg Moskalenko
  • Date: 2015-02-01 20:43:30 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20150201204330-xqda9awj9efhtxzn
Tags: 4.4.1.2-1
Sync to 4.4.1.2 upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
245
245
 
246
246
    beg_af:
247
247
 
248
 
    while(!found && addr_result) {
 
248
    while(addr_result) {
249
249
 
250
250
        if(addr_result->ai_family == family) {
251
 
                ns_bcopy(addr_result->ai_addr, addr, addr_result->ai_addrlen);
252
251
                if (addr_result->ai_family == AF_INET) {
 
252
                        ns_bcopy(addr_result->ai_addr, addr, addr_result->ai_addrlen);
253
253
                        addr->s4.sin_port = nswap16(port);
254
254
#if defined(TURN_HAS_SIN_LEN) /* tested when configured */
255
255
                        addr->s4.sin_len = sizeof(struct sockaddr_in);
256
256
#endif
 
257
                        found = 1;
 
258
                        break;
257
259
                } else if (addr_result->ai_family == AF_INET6) {
 
260
                        ns_bcopy(addr_result->ai_addr, addr, addr_result->ai_addrlen);
258
261
                        addr->s6.sin6_port = nswap16(port);
259
262
#if defined(SIN6_LEN) /* this define is required by IPv6 if used */
260
263
                        addr->s6.sin6_len = sizeof(struct sockaddr_in6);
261
264
#endif
262
 
                } else {
263
 
                        continue;
 
265
                        found = 1;
 
266
                        break;
264
267
                }
265
 
                found = 1;
266
268
        }
267
269
 
268
270
        addr_result = addr_result->ai_next;
322
324
 
323
325
        int ret = -1;
324
326
        int port = 0;
325
 
        char* s = strdup((const char*)saddr);
 
327
        char* s = turn_strdup((const char*)saddr);
326
328
        char *sa = get_addr_string_and_port(s,&port);
327
329
        if(sa) {
328
330
                if(port<1)
329
331
                        port = default_port;
330
332
                ret = make_ioa_addr((u08bits*)sa,port,addr);
331
333
        }
332
 
        free(s);
 
334
        turn_free(s,strlen(s)+1);
333
335
        return ret;
334
336
}
335
337
 
509
511
void ioa_addr_add_mapping(ioa_addr *apub, ioa_addr *apriv)
510
512
{
511
513
        size_t new_size = msz + sizeof(ioa_addr*);
512
 
        public_addrs = (ioa_addr**)realloc(public_addrs, new_size);
513
 
        private_addrs = (ioa_addr**)realloc(private_addrs, new_size);
514
 
        public_addrs[mcount]=(ioa_addr*)malloc(sizeof(ioa_addr));
515
 
        private_addrs[mcount]=(ioa_addr*)malloc(sizeof(ioa_addr));
 
514
        public_addrs = (ioa_addr**)turn_realloc(public_addrs, msz, new_size);
 
515
        private_addrs = (ioa_addr**)turn_realloc(private_addrs, msz, new_size);
 
516
        public_addrs[mcount]=(ioa_addr*)turn_malloc(sizeof(ioa_addr));
 
517
        private_addrs[mcount]=(ioa_addr*)turn_malloc(sizeof(ioa_addr));
516
518
        addr_cpy(public_addrs[mcount],apub);
517
519
        addr_cpy(private_addrs[mcount],apriv);
518
520
        ++mcount;