Browse code

moved most AmBasicSipDialog attributes to protected part to force use of setter/getter

Raphael Coeffic authored on 04/02/2013 15:11:06
Showing 15 changed files
... ...
@@ -62,13 +62,13 @@ CallLeg::CallLeg(const CallLeg* caller, AmSipDialog* p_dlg):
62 62
 
63 63
   const AmSipDialog* caller_dlg = caller->dlg;
64 64
 
65
-  dlg->local_tag    = AmSession::getNewId();
66
-  dlg->callid       = AmSession::getNewId();
65
+  dlg->setLocalTag(AmSession::getNewId());
66
+  dlg->setCallid(AmSession::getNewId());
67 67
 
68 68
   // take important data from A leg
69
-  dlg->local_party  = caller_dlg->remote_party;
70
-  dlg->remote_party = caller_dlg->local_party;
71
-  dlg->remote_uri   = caller_dlg->local_uri;
69
+  dlg->setLocalParty(caller_dlg->getRemoteParty());
70
+  dlg->setRemoteParty(caller_dlg->getLocalParty());
71
+  dlg->setRemoteUri(caller_dlg->getLocalUri());
72 72
 
73 73
 /*  if (AmConfig::LogSessions) {
74 74
     INFO("Starting B2B callee session %s\n",
... ...
@@ -341,7 +341,7 @@ void CallLeg::onB2BReply(B2BSipReplyEvent *ev)
341 341
       other_legs.begin()->releaseMediaSession(); // remove reference hold by OtherLegInfo
342 342
       other_legs.clear(); // no need to remember the connected leg here
343 343
       if (media_session) {
344
-        TRACE("connecting media session: %s to %s\n", dlg->local_tag.c_str(), other_id.c_str());
344
+        TRACE("connecting media session: %s to %s\n", dlg->getLocalTag().c_str(), other_id.c_str());
345 345
         media_session->changeSession(a_leg, this);
346 346
         if (initial_sdp_stored && ev->forward) updateRemoteSdp(initial_sdp);
347 347
       }
... ...
@@ -410,9 +410,9 @@ void CallLeg::onB2BConnect(ConnectLegEvent* co_ev)
410 410
   }
411 411
 
412 412
   MONITORING_LOG3(getLocalTag().c_str(), 
413
-      "b2b_leg", other_id.c_str(),
414
-      "to", dlg->remote_party.c_str(),
415
-      "ruri", dlg->remote_uri.c_str());
413
+		  "b2b_leg", other_id.c_str(),
414
+		  "to", dlg->getRemoteParty().c_str(),
415
+		  "ruri", dlg->getRemoteUri().c_str());
416 416
 
417 417
   // This leg is marked as 'relay only' since the beginning because it might
418 418
   // need not to know on time that it is connected and thus should relay.
... ...
@@ -503,9 +503,9 @@ void CallLeg::onB2BReconnect(ReconnectLegEvent* ev)
503 503
   else rtp_relay_mode = RTP_Direct;
504 504
 
505 505
   MONITORING_LOG3(getLocalTag().c_str(),
506
-      "b2b_leg", other_id.c_str(),
507
-      "to", dlg->remote_party.c_str(),
508
-      "ruri", dlg->remote_uri.c_str());
506
+		  "b2b_leg", other_id.c_str(),
507
+		  "to", dlg->getRemoteParty().c_str(),
508
+		  "ruri", dlg->getRemoteUri().c_str());
509 509
 
510 510
   AmMimeBody r_body(ev->body);
511 511
   const AmMimeBody* body = &ev->body;
... ...
@@ -928,9 +928,9 @@ void CallLeg::addNewCallee(CallLeg *callee, ConnectLegEvent *e, AmB2BSession::RT
928 928
   AmSipDialog* callee_dlg = callee->dlg;
929 929
   MONITORING_LOG4(b.id.c_str(),
930 930
 		  "dir",  "out",
931
-		  "from", callee_dlg->local_party.c_str(),
932
-		  "to",   callee_dlg->remote_party.c_str(),
933
-		  "ruri", callee_dlg->remote_uri.c_str());
931
+		  "from", callee_dlg->getLocalParty().c_str(),
932
+		  "to",   callee_dlg->getRemoteParty().c_str(),
933
+		  "ruri", callee_dlg->getRemoteUri().c_str());
934 934
 
935 935
   callee->start();
936 936
 
... ...
@@ -180,8 +180,8 @@ SBCCallLeg::SBCCallLeg(SBCCallLeg* caller, AmSipDialog* p_dlg)
180 180
   // here (FIXME: do it on better place and better way than accessing internals
181 181
   // of caller->dlg directly)
182 182
   if (call_profile.transparent_dlg_id && caller) {
183
-    dlg->callid = caller->dlg->callid;
184
-    dlg->ext_local_tag = caller->dlg->remote_tag;
183
+    dlg->setCallid(caller->dlg->getCallid());
184
+    dlg->setExtLocalTag(caller->dlg->getRemoteTag());
185 185
   }
186 186
 
187 187
   // CC interfaces and variables should be already "evaluated" by A leg, we just
... ...
@@ -314,8 +314,8 @@ void SBCCallLeg::applyBProfile()
314 314
   }
315 315
 
316 316
   if (!call_profile.next_hop.empty()) {
317
-    dlg->next_hop = call_profile.next_hop;
318
-    dlg->next_hop_1st_req = call_profile.next_hop_1st_req;
317
+    dlg->setNextHop(call_profile.next_hop);
318
+    dlg->setNextHop1stReq(call_profile.next_hop_1st_req);
319 319
   }
320 320
 
321 321
   // was read from caller but reading directly from profile now
... ...
@@ -338,7 +338,8 @@ void SBCCallLeg::applyBProfile()
338 338
   setRtpRelayTransparentSSRC(call_profile.rtprelay_transparent_ssrc);
339 339
 
340 340
   // was read from caller but reading directly from profile now
341
-  if (!call_profile.callid.empty()) dlg->callid = call_profile.callid;
341
+  if (!call_profile.callid.empty()) 
342
+    dlg->setCallid(call_profile.callid);
342 343
 }
343 344
 
344 345
 int SBCCallLeg::relayEvent(AmEvent* ev)
... ...
@@ -370,8 +371,8 @@ int SBCCallLeg::relayEvent(AmEvent* ev)
370 371
           assert(reply_ev);
371 372
 
372 373
           if(call_profile.transparent_dlg_id &&
373
-              (reply_ev->reply.from_tag == dlg->ext_local_tag))
374
-            reply_ev->reply.from_tag = dlg->local_tag;
374
+	     (reply_ev->reply.from_tag == dlg->getExtLocalTag()))
375
+            reply_ev->reply.from_tag = dlg->getLocalTag();
375 376
 
376 377
           if (call_profile.headerfilter.size() ||
377 378
               call_profile.reply_translations.size()) {
... ...
@@ -462,7 +463,7 @@ void SBCCallLeg::setOtherId(const AmSipReply& reply)
462 463
   DBG("setting other_id to '%s'",reply.from_tag.c_str());
463 464
   CallLeg::setOtherId(reply);
464 465
   if(call_profile.transparent_dlg_id && !reply.to_tag.empty()) {
465
-    dlg->ext_local_tag = reply.to_tag;
466
+    dlg->setExtLocalTag(reply.to_tag);
466 467
   }
467 468
 }
468 469
 
... ...
@@ -132,11 +132,11 @@ class SBCCallLeg : public CallLeg, public CredentialHolder
132 132
   // SBC interface usable from CC modules
133 133
 
134 134
   void setLocalParty(const string &party, const string &uri) { 
135
-    dlg->local_party = party; dlg->local_uri = uri; 
135
+    dlg->setLocalParty(party); dlg->setLocalUri(uri);
136 136
   }
137 137
 
138 138
   void setRemoteParty(const string &party, const string &uri) { 
139
-    dlg->remote_party = party; dlg->remote_uri = uri; 
139
+    dlg->setRemoteParty(party); dlg->setRemoteUri(uri);
140 140
   }
141 141
 
142 142
   SBCCallProfile &getCallProfile() { return call_profile; }
... ...
@@ -829,14 +829,15 @@ int SBCCallProfile::apply_a_routing(ParamReplacerCtx& ctx,
829 829
 					   "aleg_next_hop", req);
830 830
 
831 831
     DBG("set next hop ip to '%s'\n", aleg_nh.c_str());
832
-    dlg.next_hop = aleg_nh;
832
+    dlg.setNextHop(aleg_nh);
833 833
   }
834 834
   else {
835 835
     dlg.nat_handling = dlg_nat_handling;
836 836
     if(dlg_nat_handling) {
837
-      dlg.next_hop = req.remote_ip;
838
-      dlg.next_hop += ":" + req.remote_port;
839
-      dlg.next_hop_1st_req = false;
837
+      string nh = req.remote_ip;
838
+      nh += ":" + req.remote_port;
839
+      dlg.setNextHop(nh);
840
+      dlg.setNextHop1stReq(false);
840 841
     }
841 842
   }
842 843
 
... ...
@@ -867,9 +868,8 @@ int SBCCallProfile::apply_b_routing(ParamReplacerCtx& ctx,
867 868
     string nh = ctx.replaceParameters(next_hop, "next_hop", req);
868 869
 
869 870
     DBG("set next hop ip to '%s'\n", nh.c_str());
870
-    dlg.next_hop = nh;
871
-
872
-    dlg.next_hop_1st_req = next_hop_1st_req;
871
+    dlg.setNextHop(nh);
872
+    dlg.setNextHop1stReq(next_hop_1st_req);
873 873
   }
874 874
 
875 875
   if (!outbound_proxy.empty()) {
... ...
@@ -322,8 +322,8 @@ int SBCSimpleRelay::start(const AmSipRequest& req, const SBCCallProfile& cp)
322 322
   a_leg->initUAS(n_req,cp);
323 323
   b_leg->initUAC(n_req,cp);
324 324
 
325
-  a_leg->setOtherDlg(b_leg->local_tag);
326
-  b_leg->setOtherDlg(a_leg->local_tag);
325
+  a_leg->setOtherDlg(b_leg->getLocalTag());
326
+  b_leg->setOtherDlg(a_leg->getLocalTag());
327 327
 
328 328
   a_leg->onRxRequest(n_req);
329 329
   if(a_leg->terminated()) {
... ...
@@ -246,8 +246,9 @@ void AmB2ABCallerSession::setupCalleeSession(AmB2ABCalleeSession* callee_session
246 246
   assert(callee_session);
247 247
 
248 248
   AmSipDialog* callee_dlg = callee_session->dlg;
249
-  callee_dlg->callid       = AmSession::getNewId();
250
-  callee_dlg->local_tag    = other_id;
249
+
250
+  callee_dlg->setCallid(AmSession::getNewId());
251
+  callee_dlg->setLocalTag(other_id);
251 252
 
252 253
 
253 254
   MONITORING_LOG(other_id.c_str(), 
... ...
@@ -298,11 +299,11 @@ void AmB2ABCalleeSession::onB2ABEvent(B2ABEvent* ev)
298 299
 		      "to",      co_ev->remote_party.c_str(),
299 300
 		      "ruri",    co_ev->remote_uri.c_str());
300 301
 
301
-      dlg->local_party  = co_ev->local_party;
302
-      dlg->local_uri    = co_ev->local_uri;
302
+      dlg->setLocalParty(co_ev->local_party);
303
+      dlg->setLocalUri(co_ev->local_uri);
303 304
 			
304
-      dlg->remote_party = co_ev->remote_party;
305
-      dlg->remote_uri   = co_ev->remote_uri;
305
+      dlg->setRemoteParty(co_ev->remote_party);
306
+      dlg->setRemoteUri(co_ev->remote_uri);
306 307
 
307 308
       setCallgroup(co_ev->callgroup);
308 309
 			
... ...
@@ -126,7 +126,7 @@ void AmB2BSession::relayError(const string &method, unsigned cseq, bool forward,
126 126
     errCode2RelayedReply(n_reply, err_code, 500);
127 127
     n_reply.cseq = cseq;
128 128
     n_reply.cseq_method = method;
129
-    n_reply.from_tag = dlg->local_tag;
129
+    n_reply.from_tag = dlg->getLocalTag();
130 130
     DBG("relaying B2B SIP error reply %u %s\n", n_reply.code, n_reply.reason.c_str());
131 131
     relayEvent(new B2BSipReplyEvent(n_reply, forward, method));
132 132
   }
... ...
@@ -140,7 +140,7 @@ void AmB2BSession::relayError(const string &method, unsigned cseq, bool forward,
140 140
     n_reply.reason = reason;
141 141
     n_reply.cseq = cseq;
142 142
     n_reply.cseq_method = method;
143
-    n_reply.from_tag = dlg->local_tag;
143
+    n_reply.from_tag = dlg->getLocalTag();
144 144
     DBG("relaying B2B SIP reply %d %s\n", sip_code, reason);
145 145
     relayEvent(new B2BSipReplyEvent(n_reply, forward, method));
146 146
   }
... ...
@@ -1093,12 +1093,12 @@ void AmB2BCallerSession::createCalleeSession() {
1093 1093
 
1094 1094
   other_id = AmSession::getNewId();
1095 1095
   
1096
-  callee_dlg->local_tag    = other_id;
1097
-  callee_dlg->callid       = AmSession::getNewId();
1096
+  callee_dlg->setLocalTag(other_id);
1097
+  callee_dlg->setCallid(AmSession::getNewId());
1098 1098
 
1099
-  callee_dlg->local_party  = dlg->remote_party;
1100
-  callee_dlg->remote_party = dlg->local_party;
1101
-  callee_dlg->remote_uri   = dlg->local_uri;
1099
+  callee_dlg->setLocalParty(dlg->getRemoteParty());
1100
+  callee_dlg->setRemoteParty(dlg->getLocalParty());
1101
+  callee_dlg->setRemoteUri(dlg->getLocalUri());
1102 1102
 
1103 1103
   if (AmConfig::LogSessions) {
1104 1104
     INFO("Starting B2B callee session %s\n",
... ...
@@ -1107,9 +1107,9 @@ void AmB2BCallerSession::createCalleeSession() {
1107 1107
 
1108 1108
   MONITORING_LOG4(other_id.c_str(), 
1109 1109
 		  "dir",  "out",
1110
-		  "from", callee_dlg->local_party.c_str(),
1111
-		  "to",   callee_dlg->remote_party.c_str(),
1112
-		  "ruri", callee_dlg->remote_uri.c_str());
1110
+		  "from", callee_dlg->getLocalParty().c_str(),
1111
+		  "to",   callee_dlg->getRemoteParty().c_str(),
1112
+		  "ruri", callee_dlg->getRemoteUri().c_str());
1113 1113
 
1114 1114
   try {
1115 1115
     initializeRTPRelay(callee_session);
... ...
@@ -1185,8 +1185,8 @@ void AmB2BCalleeSession::onB2BEvent(B2BEvent* ev)
1185 1185
 		    "ruri", co_ev->remote_uri.c_str());
1186 1186
 
1187 1187
 
1188
-    dlg->remote_party = co_ev->remote_party;
1189
-    dlg->remote_uri   = co_ev->remote_uri;
1188
+    dlg->setRemoteParty(co_ev->remote_party);
1189
+    dlg->setRemoteUri(co_ev->remote_uri);
1190 1190
 
1191 1191
     if (co_ev->relayed_invite) {
1192 1192
       AmSipRequest fake_req;
... ...
@@ -241,15 +241,16 @@ void AmBasicSipDialog::resetOutboundIf()
241 241
  */
242 242
 void AmBasicSipDialog::initFromLocalRequest(const AmSipRequest& req)
243 243
 {
244
-  updateRemoteUri(req.r_uri);
244
+  setRemoteUri(req.r_uri);
245 245
 
246
-  callid       = req.callid;
247
-  local_tag    = req.from_tag;
248 246
   user         = req.user;
249 247
   domain       = req.domain;
250
-  local_uri    = req.from_uri;
251
-  remote_party = req.to;
252
-  local_party  = req.from;
248
+
249
+  setCallid(      req.callid   );
250
+  setLocalTag(    req.from_tag );
251
+  setLocalUri(    req.from_uri );
252
+  setRemoteParty( req.to       );
253
+  setLocalParty(  req.from     );
253 254
 }
254 255
 
255 256
 bool AmBasicSipDialog::onRxReqSanity(const AmSipRequest& req)
... ...
@@ -319,26 +320,29 @@ void AmBasicSipDialog::onRxRequest(const AmSipRequest& req)
319 320
     
320 321
     // refresh the target
321 322
     if (remote_uri != req.from_uri) {
322
-      updateRemoteUri(req.from_uri);
323
+      setRemoteUri(req.from_uri);
323 324
       if(nat_handling && req.first_hop) {
324
-	updateNextHop(req.remote_ip + ":"
325
-		      + int2str(req.remote_port));
326
-	updateNextHop1stReq(false);
325
+	setNextHop(req.remote_ip + ":"
326
+		   + int2str(req.remote_port));
327
+	setNextHop1stReq(false);
327 328
       }
328 329
     }
329 330
   }
330 331
   
331 332
   // Dlg not yet initialized?
332 333
   if(callid.empty()){
333
-    callid       = req.callid;
334
-    remote_tag   = req.from_tag;
334
+
335 335
     user         = req.user;
336 336
     domain       = req.domain;
337
-    local_uri    = req.r_uri;
338
-    remote_party = req.from;
339
-    local_party  = req.to;
340
-    route        = req.route;
341
-    first_branch = req.via_branch;
337
+
338
+    setCallid(      req.callid   );
339
+    setRemoteTag(   req.from_tag );
340
+    setLocalUri(    req.r_uri    );
341
+    setRemoteParty( req.from     );
342
+    setLocalParty(  req.to       );
343
+    setRouteSet(    req.route    );
344
+    set1stBranch(   req.via_branch );
345
+
342 346
     outbound_interface = req.local_if;
343 347
   }
344 348
 
... ...
@@ -413,37 +417,17 @@ void AmBasicSipDialog::updateDialogTarget(const AmSipReply& reply)
413 417
 	 (reply.cseq_method == SIP_METH_NOTIFY))) ||
414 418
        (reply.cseq_method == SIP_METH_SUBSCRIBE)) ) {
415 419
     
416
-    updateRemoteUri(reply.to_uri);
420
+    setRemoteUri(reply.to_uri);
417 421
   }
418 422
 }
419 423
 
420
-void AmBasicSipDialog::updateRemoteUri(const string& new_remote_uri)
421
-{
422
-  remote_uri = new_remote_uri;
423
-}
424
-
425
-void AmBasicSipDialog::updateRouteSet(const string& new_rs)
426
-{
427
-  route = new_rs;
428
-}
429
-
430
-void AmBasicSipDialog::updateRemoteTag(const string& new_rt)
424
+void AmBasicSipDialog::setRemoteTag(const string& new_rt)
431 425
 {
432 426
   if(!new_rt.empty() && remote_tag.empty()){
433 427
     remote_tag = new_rt;
434 428
   }
435 429
 }
436 430
 
437
-void AmBasicSipDialog::updateNextHop(const string& new_nh)
438
-{
439
-  next_hop = new_nh;
440
-}
441
-
442
-void AmBasicSipDialog::updateNextHop1stReq(bool nh_1st_req)
443
-{
444
-  next_hop_1st_req = nh_1st_req;
445
-}
446
-
447 431
 int AmBasicSipDialog::onTxRequest(AmSipRequest& req, int& flags)
448 432
 {
449 433
   if(hdl) hdl->onSendRequest(req,flags);
... ...
@@ -87,6 +87,25 @@ private:
87 87
 protected:
88 88
   Status status;
89 89
 
90
+  string callid;
91
+
92
+  string local_tag;
93
+  string ext_local_tag;
94
+  
95
+  string remote_tag;
96
+  string first_branch;
97
+
98
+  string local_uri;    // local uri
99
+  string remote_uri;   // remote uri
100
+
101
+  string remote_party; // To/From
102
+  string local_party;  // To/From
103
+
104
+  string route;
105
+
106
+  string next_hop;
107
+  bool next_hop_1st_req;
108
+
90 109
   TransMap uas_trans;
91 110
   TransMap uac_trans;
92 111
 
... ...
@@ -159,27 +178,9 @@ public:
159 178
   string user;         // local user
160 179
   string domain;       // local domain
161 180
 
162
-  string local_uri;    // local uri
163
-  string remote_uri;   // remote uri
164
-
165
-
166
-  string callid;
167
-  string remote_tag;
168
-  string local_tag;
169
-  string ext_local_tag;
170
-
171
-  string first_branch;
172
-
173
-  string remote_party; // To/From
174
-  string local_party;  // To/From
175
-
176
-  string route;
177 181
   string outbound_proxy;
178 182
   bool   force_outbound_proxy;
179 183
 
180
-  string next_hop;
181
-  bool next_hop_1st_req;
182
-
183 184
   int  outbound_interface;
184 185
   bool nat_handling;
185 186
 
... ...
@@ -217,6 +218,51 @@ public:
217 218
   void incUsages() { usages++; }
218 219
   void decUsages() { usages--; }
219 220
 
221
+  const string& getCallid() const { return callid; }
222
+  virtual void setCallid(const string& n_callid) { callid = n_callid; }
223
+
224
+  const string& getLocalTag() const { return local_tag; }
225
+  virtual void setLocalTag(const string& n_tag) { local_tag = n_tag; }
226
+
227
+  const string& getRemoteTag() const { return remote_tag; }
228
+  virtual void setRemoteTag(const string& n_tag);
229
+
230
+  const string& get1stBranch() const { return first_branch; }
231
+  virtual void set1stBranch(const string& n_branch)
232
+  { first_branch = n_branch; }
233
+
234
+  const string& getExtLocalTag() const { return ext_local_tag; }
235
+  virtual void setExtLocalTag(const string& new_ext_tag)
236
+  { ext_local_tag = new_ext_tag; }
237
+
238
+  const string& getLocalUri() const { return local_uri; }
239
+  virtual void setLocalUri(const string& new_local_uri)
240
+  { local_uri = new_local_uri; }
241
+
242
+  const string& getRemoteUri() const { return remote_uri; }
243
+  virtual void setRemoteUri(const string& new_remote_uri)
244
+  { remote_uri = new_remote_uri; }
245
+
246
+  const string& getLocalParty() const { return local_party; }
247
+  virtual void setLocalParty(const string& new_local_party)
248
+  { local_party = new_local_party; }
249
+
250
+  const string& getRemoteParty() const { return remote_party; }
251
+  virtual void setRemoteParty(const string& new_remote_party)
252
+  { remote_party = new_remote_party; }
253
+
254
+  const string& getRouteSet() const { return route; }
255
+  virtual void setRouteSet(const string& new_rs)
256
+  { route = new_rs; }
257
+
258
+  const string& getNextHop() const { return next_hop; }
259
+  virtual void setNextHop(const string& new_nh)
260
+  { next_hop = new_nh; }
261
+
262
+  bool getNextHop1stReq() const { return next_hop_1st_req; }
263
+  virtual void setNextHop1stReq(bool nh_1st_req)
264
+  { next_hop_1st_req = nh_1st_req; }
265
+
220 266
   /**
221 267
    * Compute the Contact-HF for the next request
222 268
    */
... ...
@@ -270,12 +316,6 @@ public:
270 316
    */
271 317
   void updateDialogTarget(const AmSipReply& reply);
272 318
 
273
-  virtual void updateRemoteUri(const string& new_remote_uri);
274
-  virtual void updateRouteSet(const string& new_rs);
275
-  virtual void updateRemoteTag(const string& new_rt);
276
-  virtual void updateNextHop(const string& new_nh);
277
-  virtual void updateNextHop1stReq(bool nh_1st_req);
278
-
279 319
   /** @return 0 on success */
280 320
   virtual int reply(const AmSipRequest& req,
281 321
 		    unsigned int  code, 
... ...
@@ -199,22 +199,22 @@ void AmSession::unlockAudio()
199 199
 
200 200
 const string& AmSession::getCallID() const
201 201
 { 
202
-  return dlg->callid;
202
+  return dlg->getCallid();
203 203
 }
204 204
 
205 205
 const string& AmSession::getRemoteTag() const
206 206
 { 
207
-  return dlg->remote_tag;
207
+  return dlg->getRemoteTag();
208 208
 }
209 209
 
210 210
 const string& AmSession::getLocalTag() const
211 211
 {
212
-  return dlg->local_tag;
212
+  return dlg->getLocalTag();
213 213
 }
214 214
 
215 215
 const string& AmSession::getFirstBranch() const
216 216
 {
217
-  return dlg->first_branch;
217
+  return dlg->get1stBranch();
218 218
 }
219 219
 
220 220
 void AmSession::setUri(const string& uri)
... ...
@@ -225,17 +225,17 @@ void AmSession::setUri(const string& uri)
225 225
 
226 226
 void AmSession::setLocalTag()
227 227
 {
228
-  if (dlg->local_tag.empty()) {
229
-    dlg->local_tag = getNewId();
230
-    DBG("AmSession::setLocalTag() - session id set to %s\n", 
231
-	dlg->local_tag.c_str());
228
+  if (dlg->getLocalTag().empty()) {
229
+    string new_id = getNewId();
230
+    dlg->setLocalTag(new_id);
231
+    DBG("AmSession::setLocalTag() - session id set to %s\n", new_id.c_str());
232 232
   }
233 233
 }
234 234
 
235 235
 void AmSession::setLocalTag(const string& tag)
236 236
 {
237 237
   DBG("AmSession::setLocalTag(%s)\n",tag.c_str());
238
-  dlg->local_tag = tag;
238
+  dlg->setLocalTag(tag);
239 239
 }
240 240
 
241 241
 const vector<SdpPayload*>& AmSession::getPayloads()
... ...
@@ -371,7 +371,7 @@ bool AmSession::processEventsCatchExceptions() {
371 371
 bool AmSession::processingCycle() {
372 372
 
373 373
   DBG("vv S [%s|%s] %s, %s, %i UACTransPending, %i usages vv\n",
374
-      dlg->callid.c_str(),getLocalTag().c_str(),
374
+      dlg->getCallid().c_str(),getLocalTag().c_str(),
375 375
       dlg->getStatusStr(),
376 376
       sess_stopped.get()?"stopped":"running",
377 377
       dlg->getUACTransPending(),
... ...
@@ -390,7 +390,7 @@ bool AmSession::processingCycle() {
390 390
       bool s_stopped = sess_stopped.get();
391 391
       
392 392
       DBG("^^ S [%s|%s] %s, %s, %i UACTransPending, %i usages ^^\n",
393
-	  dlg->callid.c_str(),getLocalTag().c_str(),
393
+	  dlg->getCallid().c_str(),getLocalTag().c_str(),
394 394
 	  AmBasicSipDialog::getStatusStr(dlg_status),
395 395
 	  s_stopped?"stopped":"running",
396 396
 	  dlg->getUACTransPending(),
... ...
@@ -440,7 +440,7 @@ bool AmSession::processingCycle() {
440 440
       processing_status = SESSION_ENDED_DISCONNECTED;
441 441
 
442 442
     DBG("^^ S [%s|%s] %s, %s, %i UACTransPending, %i usages ^^\n",
443
-	dlg->callid.c_str(),getLocalTag().c_str(),
443
+	dlg->getCallid().c_str(),getLocalTag().c_str(),
444 444
 	dlg->getStatusStr(),
445 445
 	sess_stopped.get()?"stopped":"running",
446 446
 	dlg->getUACTransPending(),
... ...
@@ -1166,9 +1166,10 @@ void AmSession::onPrack2xx(const AmSipReply &reply)
1166 1166
 string AmSession::sid4dbg()
1167 1167
 {
1168 1168
   string dbg;
1169
-  dbg = dlg->callid + "/" + dlg->local_tag + "/" + dlg->remote_tag + "/" + 
1170
-      int2str(RTPStream()->getLocalPort()) + "/" + 
1171
-      RTPStream()->getRHost() + ":" + int2str(RTPStream()->getRPort());
1169
+  dbg = dlg->getCallid() + "/" + dlg->getLocalTag() + "/" 
1170
+    + dlg->getRemoteTag() + "/" 
1171
+    + int2str(RTPStream()->getLocalPort()) + "/" 
1172
+    + RTPStream()->getRHost() + ":" + int2str(RTPStream()->getRPort());
1172 1173
   return dbg;
1173 1174
 }
1174 1175
 
... ...
@@ -345,13 +345,13 @@ bool AmSipDialog::onRxReplyStatus(const AmSipReply& reply,
345 345
 	  setStatus(Proceeding);
346 346
 	else {
347 347
 	  setStatus(Early);
348
-	  updateRemoteTag(reply.to_tag);
349
-	  updateRouteSet(reply.route);
348
+	  setRemoteTag(reply.to_tag);
349
+	  setRouteSet(reply.route);
350 350
 	}
351 351
       }
352 352
       else if(reply.code < 300){
353 353
 	setStatus(Connected);
354
-	updateRouteSet(reply.route);
354
+	setRouteSet(reply.route);
355 355
 	if(reply.to_tag.empty()){
356 356
 	  DBG("received 2xx reply without to-tag "
357 357
 	      "(callid=%s): sending BYE\n",reply.callid.c_str());
... ...
@@ -359,7 +359,7 @@ bool AmSipDialog::onRxReplyStatus(const AmSipReply& reply,
359 359
 	  sendRequest(SIP_METH_BYE);
360 360
 	}
361 361
 	else {
362
-	  updateRemoteTag(reply.to_tag);
362
+	  setRemoteTag(reply.to_tag);
363 363
 	}
364 364
       }
365 365
 
... ...
@@ -377,7 +377,7 @@ bool AmSipDialog::onRxReplyStatus(const AmSipReply& reply,
377 377
       }
378 378
       else if(reply.code < 300){
379 379
 	setStatus(Connected);
380
-	updateRouteSet(reply.route);
380
+	setRouteSet(reply.route);
381 381
 	if(reply.to_tag.empty()){
382 382
 	  DBG("received 2xx reply without to-tag "
383 383
 	      "(callid=%s): sending BYE\n",reply.callid.c_str());
... ...
@@ -385,7 +385,7 @@ bool AmSipDialog::onRxReplyStatus(const AmSipReply& reply,
385 385
 	  sendRequest(SIP_METH_BYE);
386 386
 	}
387 387
 	else {
388
-	  updateRemoteTag(reply.to_tag);
388
+	  setRemoteTag(reply.to_tag);
389 389
 	}
390 390
       }
391 391
       else { // error reply
... ...
@@ -83,7 +83,7 @@ void AmSIPRegistration::setRegistrationInfo(const SIPRegistrationInfo& _info) {
83 83
   req.to_tag   = "";
84 84
 
85 85
   // to trigger setting dlg identifiers
86
-  dlg.callid.clear();
86
+  dlg.setCallid(string());
87 87
 
88 88
   dlg.initFromLocalRequest(req);
89 89
 }
... ...
@@ -106,9 +106,10 @@ bool AmSIPRegistration::doRegistration()
106 106
   unregistering = false;
107 107
 
108 108
   req.to_tag     = "";
109
-  dlg.remote_tag = "";
110 109
   req.r_uri    = "sip:"+info.domain;
111
-  dlg.remote_uri = req.r_uri;
110
+
111
+  dlg.setRemoteTag(string());
112
+  dlg.setRemoteUri(req.r_uri);
112 113
     
113 114
   // set outbound proxy as next hop 
114 115
   if (!info.proxy.empty()) {
... ...
@@ -146,9 +147,9 @@ bool AmSIPRegistration::doUnregister()
146 147
   unregistering = true;
147 148
 
148 149
   req.to_tag     = "";
149
-  dlg.remote_tag = "";
150 150
   req.r_uri      = "sip:"+info.domain;
151
-  dlg.remote_uri = req.r_uri;
151
+  dlg.setRemoteTag(string());
152
+  dlg.setRemoteUri(req.r_uri);
152 153
     
153 154
   // set outbound proxy as next hop 
154 155
   if (!info.proxy.empty()) {
... ...
@@ -166,7 +166,7 @@ public:
166 166
 void SingleSubscription::onTimer(int timer_id)
167 167
 {
168 168
   DBG("[%p] tag=%s;role=%s timer_id = %s\n",this,
169
-      dlg()->local_tag.c_str(),
169
+      dlg()->getLocalTag().c_str(),
170 170
       role ? "Notifier" : "Subscriber",
171 171
       __timer_id_str[timer_id]);
172 172
 
... ...
@@ -242,7 +242,7 @@ void SingleSubscription::requestFSM(const AmSipRequest& req)
242 242
     unlockState();
243 243
 
244 244
     // start Timer N (RFC6665/4.1.2)
245
-    DBG("setTimer(%s,RFC6665_TIMER_N)\n",dlg()->local_tag.c_str());
245
+    DBG("setTimer(%s,RFC6665_TIMER_N)\n",dlg()->getLocalTag().c_str());
246 246
     AmAppTimer::instance()->setTimer(&timer_n,RFC6665_TIMER_N_DURATION);
247 247
   }
248 248
   else if(req.method == SIP_METH_NOTIFY) {
... ...
@@ -313,9 +313,9 @@ void SingleSubscription::replyFSM(const AmSipRequest& req, const AmSipReply& rep
313 313
       // success
314 314
       
315 315
       // set dialog identifier if not yet set
316
-      if(dlg()->remote_tag.empty()) {
317
-	dlg()->updateRemoteTag(reply.to_tag);
318
-	dlg()->updateRouteSet(reply.route);
316
+      if(dlg()->getRemoteTag().empty()) {
317
+	dlg()->setRemoteTag(reply.to_tag);
318
+	dlg()->setRouteSet(reply.route);
319 319
       }
320 320
 
321 321
       // check Expires-HF
... ...
@@ -325,7 +325,7 @@ void SingleSubscription::replyFSM(const AmSipRequest& req, const AmSipReply& rep
325 325
       int sub_expires=0;
326 326
       if(!expires_txt.empty() && str2int(expires_txt,sub_expires)){
327 327
 	if(sub_expires){
328
-	  DBG("setTimer(%s,SUBSCRIPTION_EXPIRE)\n",dlg()->local_tag.c_str());
328
+	  DBG("setTimer(%s,SUBSCRIPTION_EXPIRE)\n",dlg()->getLocalTag().c_str());
329 329
 	  AmAppTimer::instance()->setTimer(&timer_expires,(double)sub_expires);
330 330
 	  expires = sub_expires;
331 331
 	}
... ...
@@ -386,7 +386,7 @@ void SingleSubscription::replyFSM(const AmSipRequest& req, const AmSipReply& rep
386 386
       str2int(expires_txt,notify_expire);
387 387
 
388 388
     // Kill timer N
389
-    DBG("removeTimer(%s,RFC6665_TIMER_N)\n",dlg()->local_tag.c_str());
389
+    DBG("removeTimer(%s,RFC6665_TIMER_N)\n",dlg()->getLocalTag().c_str());
390 390
     AmAppTimer::instance()->removeTimer(&timer_n);
391 391
 
392 392
     sub_state_txt = strip_header_params(sub_state_txt);
... ...
@@ -409,7 +409,7 @@ void SingleSubscription::replyFSM(const AmSipRequest& req, const AmSipReply& rep
409 409
     }
410 410
     
411 411
     // reset expire timer
412
-    DBG("setTimer(%s,SUBSCRIPTION_EXPIRE)\n",dlg()->local_tag.c_str());
412
+    DBG("setTimer(%s,SUBSCRIPTION_EXPIRE)\n",dlg()->getLocalTag().c_str());
413 413
     AmAppTimer::instance()->setTimer(&timer_expires,(double)notify_expire);
414 414
     expires = notify_expire;
415 415
   }
... ...
@@ -481,7 +481,9 @@ AmSipSubscription::createSubscription(const AmSipRequest& req, bool uac)
481 481
 AmSipSubscription::Subscriptions::iterator
482 482
 AmSipSubscription::matchSubscription(const AmSipRequest& req, bool uac)
483 483
 {
484
-  if(dlg->remote_tag.empty() || (req.method == SIP_METH_REFER) || subs.empty()) {
484
+  if(dlg->getRemoteTag().empty() 
485
+     || (req.method == SIP_METH_REFER) || subs.empty()) {
486
+
485 487
     DBG("no to-tag, REFER or subs empty: create new subscription\n");
486 488
     return createSubscription(req,uac);
487 489
   }
... ...
@@ -59,7 +59,7 @@ createSubscription(const AmSipSubscriptionInfo& info,
59 59
   AmSipSubscriptionDialog* new_sub = new AmSipSubscriptionDialog(info,sess_link,
60 60
 								 this);
61 61
 
62
-  string handle = new_sub->local_tag;
62
+  string handle = new_sub->getLocalTag();
63 63
 
64 64
   subscriptions_mut.lock();
65 65
   subscriptions[handle] = new_sub;
... ...
@@ -158,7 +158,7 @@ bool UACAuth::onSipReply(const AmSipRequest& req, const AmSipReply& reply,
158 158
 	  string result; 
159 159
 
160 160
 	  string auth_uri; 
161
-	  auth_uri = dlg->remote_uri;
161
+	  auth_uri = dlg->getRemoteUri();
162 162
 
163 163
 	  if (do_auth(reply.code, auth_hdr,  
164 164
 		      ri->second.method,
... ...
@@ -181,15 +181,16 @@ bool UACAuth::onSipReply(const AmSipRequest& req, const AmSipReply& reply,
181 181
 		ri->second.method != SIP_METH_BYE) {
182 182
 	      // reset remote tag so remote party 
183 183
 	      // thinks its new dlg
184
-	      dlg->remote_tag = "";
184
+	      dlg->setRemoteTag(string());
185 185
 
186 186
 	      if (AmConfig::ProxyStickyAuth) {
187 187
 		// update remote URI to resolved IP
188
-		size_t hpos = dlg->remote_uri.find("@");
188
+		size_t hpos = dlg->getRemoteUri().find("@");
189 189
 		if (hpos != string::npos && reply.remote_ip.length()) {
190
-		  dlg->remote_uri = dlg->remote_uri.substr(0, hpos+1) +
191
-		    reply.remote_ip + ":"+int2str(reply.remote_port);
192
-		  DBG("updated remote URI to '%s'\n", dlg->remote_uri.c_str());
190
+		  string remote_uri = dlg->getRemoteUri().substr(0, hpos+1) 
191
+		    + reply.remote_ip + ":"+int2str(reply.remote_port);
192
+		  dlg->setRemoteUri(remote_uri);
193
+		  DBG("updated remote URI to '%s'\n", remote_uri.c_str());
193 194
 		}
194 195
 	      }
195 196
 
... ...
@@ -229,7 +230,7 @@ bool UACAuth::onSendRequest(AmSipRequest& req, int& flags)
229 230
   if (!(flags & SIP_FLAGS_NOAUTH) &&
230 231
       !challenge.nonce.empty() &&
231 232
       do_auth(challenge, challenge_code,
232
-	      req.method, dlg->remote_uri, &req.body, result)) {
233
+	      req.method, dlg->getRemoteUri(), &req.body, result)) {
233 234
     // add headers
234 235
     if (req.hdrs == "\r\n" || req.hdrs == "\r" || req.hdrs == "\n")
235 236
       req.hdrs = result;