~ubuntu-branches/debian/sid/kamailio/sid

« back to all changes in this revision

Viewing changes to forward.c

  • Committer: Package Import Robot
  • Author(s): Victor Seva
  • Date: 2014-01-06 11:47:13 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20140106114713-t8xidp4arzrnyeya
Tags: 4.1.1-1
* New upstream release
* debian/patches:
  - add upstream fixes
* Added tls outbound websocket autheph dnssec modules
  - openssl exception added to their license
* removing sparc and ia64 from supported archs
  for mono module (Closes: #728915)

Show diffs side-by-side

added added

removed removed

Lines of Context:
120
120
 
121
121
static int mhomed_sock_cache_disabled = 0;
122
122
static int sock_inet = -1;
123
 
#ifdef USE_IPV6
124
123
static int sock_inet6 = -1;
125
 
#endif /* USE_IPV6 */
126
124
 
127
125
static void apply_force_send_socket(struct dest_info* dst, struct sip_msg* msg);
128
126
 
155
153
                temp_sock = &sock_inet;
156
154
                break;
157
155
        }
158
 
#ifdef USE_IPV6
159
156
        case AF_INET6 : {
160
157
                if(unlikely(sock_inet6 < 0)){
161
158
                        sock_inet6 = socket(AF_INET6, SOCK_DGRAM, 0);
167
164
                temp_sock = &sock_inet6;
168
165
                break;
169
166
        }
170
 
#endif /* USE_IPV6 */
171
167
        default: {
172
168
                LM_ERR("Unknown protocol family \n");
173
169
                return 0;
189
185
                                close(sock_inet);
190
186
                                sock_inet=-1;
191
187
                        }
192
 
#ifdef USE_IPV6
193
188
                        if (sock_inet6>=0){
194
189
                                close(sock_inet6);
195
190
                                sock_inet6=-1;
196
191
                        }
197
 
#endif /* USE_IPV6 */
198
192
                        goto retry;
199
193
                }
200
194
                LOG(L_ERR, "ERROR: get_out_socket: connect failed: %s\n",
332
326
                                /* FIXME */
333
327
                                case AF_INET:   send_sock=sendipv4_tcp;
334
328
                                                                break;
335
 
#ifdef USE_IPV6
336
329
                                case AF_INET6:  send_sock=sendipv6_tcp;
337
330
                                                                break;
338
 
#endif
339
331
                                default:        LOG(L_ERR, "get_send_socket: BUG: don't know how"
340
332
                                                                        " to forward to af %d\n", to->s.sa_family);
341
333
                        }
348
340
                                /* FIXME */
349
341
                                case AF_INET:   send_sock=sendipv4_tls;
350
342
                                                                break;
351
 
#ifdef USE_IPV6
352
343
                                case AF_INET6:  send_sock=sendipv6_tls;
353
344
                                                                break;
354
 
#endif
355
345
                                default:        LOG(L_ERR, "get_send_socket: BUG: don't know how"
356
346
                                                                        " to forward to af %d\n", to->s.sa_family);
357
347
                        }
365
355
                                switch(to->s.sa_family){
366
356
                                        case AF_INET:   send_sock=sendipv4_sctp;
367
357
                                                                        break;
368
 
#ifdef USE_IPV6
369
358
                                        case AF_INET6:  send_sock=sendipv6_sctp;
370
359
                                                                        break;
371
 
#endif
372
360
                                        default:        LOG(L_ERR, "get_send_socket: BUG: don't know"
373
361
                                                                                " how to forward to af %d\n",
374
362
                                                                                to->s.sa_family);
383
371
                                switch(to->s.sa_family){
384
372
                                        case AF_INET:   send_sock=sendipv4;
385
373
                                                                        break;
386
 
#ifdef USE_IPV6
387
374
                                        case AF_INET6:  send_sock=sendipv6;
388
375
                                                                        break;
389
 
#endif
390
376
                                        default:        LOG(L_ERR, "get_send_socket: BUG: don't know"
391
377
                                                                                " how to forward to af %d\n",
392
378
                                                                                to->s.sa_family);
549
535
                }
550
536
        }/* dst */
551
537
        send_info->send_flags=msg->fwd_send_flags;
552
 
        /* calculate branch for outbound request;  if syn_branch is turned off,
 
538
        /* calculate branch for outbound request;
553
539
           calculate is from transaction key, i.e., as an md5 of From/To/CallID/
554
540
           CSeq exactly the same way as TM does; good for reboot -- than messages
555
541
           belonging to transaction lost due to reboot will still be forwarded
556
542
           with the same branch parameter and will be match-able downstream
557
 
        
558
 
           if it is turned on, we don't care about reboot; we simply put a simple
559
 
           value in there; better for performance
560
543
        */
561
 
        if (syn_branch ) {
562
 
                memcpy(msg->add_to_branch_s, "z9hG4bKcydzigwkX", 16);
563
 
                msg->add_to_branch_len=16;
564
 
        } else {
565
 
                if (!char_msg_val( msg, md5 ))  { /* parses transaction key */
566
 
                        LOG(L_ERR, "ERROR: forward_request: char_msg_val failed\n");
567
 
                        ret=E_UNSPEC;
568
 
                        goto error;
569
 
                }
570
 
                msg->hash_index=hash( msg->callid->body, get_cseq(msg)->number);
571
 
                if (!branch_builder( msg->hash_index, 0, md5, 0 /* 0-th branch */,
572
 
                                        msg->add_to_branch_s, &msg->add_to_branch_len )) {
573
 
                        LOG(L_ERR, "ERROR: forward_request: branch_builder failed\n");
574
 
                        ret=E_UNSPEC;
575
 
                        goto error;
576
 
                }
 
544
        if (!char_msg_val( msg, md5 ))  { /* parses transaction key */
 
545
                LOG(L_ERR, "ERROR: forward_request: char_msg_val failed\n");
 
546
                ret=E_UNSPEC;
 
547
                goto error;
 
548
        }
 
549
        msg->hash_index=hash( msg->callid->body, get_cseq(msg)->number);
 
550
        if (!branch_builder( msg->hash_index, 0, md5, 0 /* 0-th branch */,
 
551
                                msg->add_to_branch_s, &msg->add_to_branch_len )) {
 
552
                LOG(L_ERR, "ERROR: forward_request: branch_builder failed\n");
 
553
                ret=E_UNSPEC;
 
554
                goto error;
577
555
        }
578
556
        /* try to send the message until success or all the ips are exhausted
579
557
         *  (if dns lookup is performed && the dns cache used ) */