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

« back to all changes in this revision

Viewing changes to modules/dialog/dlg_req_within.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:
34
34
#include "../../dprint.h"
35
35
#include "../../config.h"
36
36
#include "../../socket_info.h"
 
37
#include "../../dset.h"
37
38
#include "../../modules/tm/dlg.h"
38
39
#include "../../modules/tm/tm_load.h"
39
40
#include "../../lib/kmi/tree.h"
70
71
        dlg_t* td = NULL;
71
72
        str cseq;
72
73
        unsigned int loc_seq;
 
74
        char nbuf[MAX_URI_SIZE];
 
75
        char dbuf[80];
 
76
        str nuri;
 
77
        str duri;
 
78
        size_t sz;
 
79
        char *p;
73
80
 
74
 
        td = (dlg_t*)pkg_malloc(sizeof(dlg_t));
 
81
        /*remote target--- Request URI*/
 
82
        if(cell->contact[dir].s==0 || cell->contact[dir].len==0){
 
83
                LM_ERR("no contact available\n");
 
84
                goto error;
 
85
        }
 
86
        /*restore alias parameter*/
 
87
        nuri.s = nbuf;
 
88
        nuri.len = MAX_URI_SIZE;
 
89
        duri.s = dbuf;
 
90
        duri.len = 80;
 
91
        if(uri_restore_rcv_alias(&cell->contact[dir], &nuri, &duri)<0) {
 
92
                nuri.len = 0;
 
93
                duri.len = 0;
 
94
        }
 
95
        if(nuri.len>0 && duri.len>0) {
 
96
                sz = sizeof(dlg_t) + (nuri.len+duri.len+2)*sizeof(char);
 
97
        } else {
 
98
                sz = sizeof(dlg_t);
 
99
        }
 
100
        td = (dlg_t*)pkg_malloc(sz);
75
101
        if(!td){
76
102
        
77
103
                LM_ERR("out of pkg memory\n");
78
104
                return NULL;
79
105
        }
80
 
        memset(td, 0, sizeof(dlg_t));
 
106
        memset(td, 0, sz);
81
107
 
82
108
        /*local sequence number*/
83
109
        cseq = (dir == DLG_CALLER_LEG) ?        cell->cseq[DLG_CALLEE_LEG]:
100
126
                }
101
127
        } 
102
128
 
103
 
        /*remote target--- Request URI*/
104
 
        if(cell->contact[dir].s==0 || cell->contact[dir].len==0){
105
 
 
106
 
                LM_ERR("no contact available\n");
107
 
                goto error;
 
129
        if(nuri.len>0 && duri.len>0) {
 
130
                /* req uri */
 
131
                p = (char*)td + sizeof(dlg_t);
 
132
                strncpy(p, nuri.s, nuri.len);
 
133
                p[nuri.len] = '\0';
 
134
                td->rem_target.s = p;
 
135
                td->rem_target.len = nuri.len;
 
136
                /* dst uri */
 
137
                p += nuri.len + 1;
 
138
                strncpy(p, duri.s, duri.len);
 
139
                p[duri.len] = '\0';
 
140
                td->dst_uri.s = p;
 
141
                td->dst_uri.len = duri.len;
 
142
        } else {
 
143
                td->rem_target = cell->contact[dir];
108
144
        }
109
 
        td->rem_target = cell->contact[dir];
110
145
 
111
146
        td->rem_uri     =   (dir == DLG_CALLER_LEG)?    cell->from_uri: cell->to_uri;
112
147
        td->loc_uri     =       (dir == DLG_CALLER_LEG)?        cell->to_uri: cell->from_uri;
308
343
                goto err;
309
344
        }
310
345
 
311
 
        memset(&uac_r,'\0', sizeof(uac_req_t));
312
346
        set_uac_req(&uac_r, &met, hdrs, NULL, dialog_info, TMCB_LOCAL_COMPLETED,
313
347
                                bye_reply_cb, (void*)iuid);
314
348
        result = d_tmb.t_request_within(&uac_r);
363
397
        else
364
398
                di->loc_seq.value -= 1;
365
399
 
366
 
        LM_DBG("sending BYE to %s\n", (dir==DLG_CALLER_LEG)?"caller":"callee");
 
400
        LM_DBG("sending OPTIONS to %s\n", (dir==DLG_CALLER_LEG)?"caller":"callee");
367
401
 
368
402
        iuid = dlg_get_iuid_shm_clone(dlg);
369
403
        if(iuid==NULL)
372
406
                goto err;
373
407
        }
374
408
 
375
 
        memset(&uac_r,'\0', sizeof(uac_req_t));
376
409
        set_uac_req(&uac_r, &met, hdrs, NULL, di, TMCB_LOCAL_COMPLETED,
377
410
                                dlg_ka_cb, (void*)iuid);
378
411
        result = d_tmb.t_request_within(&uac_r);
379
412
 
380
413
        if(result < 0){
381
 
                LM_ERR("failed to send the BYE request\n");
 
414
                LM_ERR("failed to send the OPTIONS request\n");
382
415
                goto err;
383
416
        }
384
417