Browse code

- sessions are now terminated if no 200-ACK is received until timer H expires. - an event handler has been added to notify the app about missing non-200 ACK.

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1893 8eb893ce-cfd4-0310-b710-fb5ebe64c474

Raphael Coeffic authored on 03/05/2010 15:36:33
Showing 6 changed files
... ...
@@ -804,6 +804,17 @@ void AmSession::onInvite2xx(const AmSipReply& reply)
804 804
   if(t) dlg.send_200_ack(*t);
805 805
 }
806 806
 
807
+void AmSession::onNo2xxACK(unsigned int cseq)
808
+{
809
+  dlg.bye();
810
+  setStopped();
811
+}
812
+
813
+void AmSession::onNoErrorACK(unsigned int cseq)
814
+{
815
+  setStopped();
816
+}
817
+
807 818
 void AmSession::onAudioEvent(AmAudioEvent* audio_ev)
808 819
 {
809 820
   if (audio_ev->event_id == AmAudioEvent::cleared)
... ...
@@ -467,6 +467,11 @@ public:
467 467
 
468 468
   /** 2xx reply has been received for an INVITE transaction */
469 469
   virtual void onInvite2xx(const AmSipReply& reply);
470
+  
471
+  /** missing 2xx-ACK */
472
+  virtual void onNo2xxACK(unsigned int cseq);
473
+  /** missing non-2xx-ACK */
474
+  virtual void onNoErrorACK(unsigned int cseq);
470 475
 
471 476
   /**
472 477
    * Entry point for Audio events
... ...
@@ -300,13 +300,13 @@ void AmSipDialog::uasTimeout(AmSipTimeoutEvent* to_ev)
300 300
 
301 301
   switch(to_ev->type){
302 302
   case AmSipTimeoutEvent::no2xxACK:
303
-    //TODO
304
-    DBG("Timeout: missing 2xx-ACK received\n");
303
+    DBG("Timeout: missing 2xx-ACK\n");
304
+    if(hdl) hdl->onNo2xxACK(to_ev->cseq);
305 305
     break;
306 306
 
307 307
   case AmSipTimeoutEvent::noErrorACK:
308
-    //TODO
309 308
     DBG("Timeout: missing non-2xx-ACK\n");
309
+    if(hdl) hdl->onNoErrorACK(to_ev->cseq);
310 310
     break;
311 311
 
312 312
   case AmSipTimeoutEvent::noPRACK:
... ...
@@ -96,6 +96,12 @@ class AmSipDialogEventHandler
96 96
   /** Hook called when a local INVITE request has been replied with 2xx */
97 97
   virtual void onInvite2xx(const AmSipReply& reply)=0;
98 98
 
99
+  /** Hook called when a UAS INVITE transaction did not receive a 2xx-ACK */
100
+  virtual void onNo2xxACK(unsigned int cseq)=0;
101
+
102
+  /** Hook called when a UAS INVITE transaction did not receive a non-2xx-ACK */
103
+  virtual void onNoErrorACK(unsigned int cseq)=0;
104
+
99 105
   virtual ~AmSipDialogEventHandler() {};
100 106
 };
101 107
 
... ...
@@ -62,10 +62,9 @@ class AmSipTimeoutEvent: public AmSipEvent
62 62
 
63 63
   EvType       type;
64 64
 
65
-  unsigned int cseq_num;
66
-  string       cseq_method;
65
+  unsigned int cseq;
67 66
 
68
-  AmSipTimeoutEvent(EvType t, unsigned int cseq_num, const string& cseq_method)
67
+  AmSipTimeoutEvent(EvType t, unsigned int cseq_num)
69 68
     : AmSipEvent(), type(t)
70 69
    {}
71 70
 
... ...
@@ -493,6 +493,8 @@ void SipCtrlInterface::timer_expired(sip_trans* trans, sip_timer_type tt)
493 493
 
494 494
     AmSipTimeoutEvent::EvType ev = AmSipTimeoutEvent::_noEv;
495 495
 
496
+    DBG("tt=%i;state=%i\n",tt,trans->state);
497
+
496 498
     //TODO: send an event to the SIP Dialog
497 499
     switch(tt){
498 500
 	
... ...
@@ -511,6 +513,8 @@ void SipCtrlInterface::timer_expired(sip_trans* trans, sip_timer_type tt)
511 513
 	    ERROR("timer H expired / transaction in undefined state\n");
512 514
 	    return;
513 515
 	}
516
+	break;
517
+
514 518
     default:
515 519
 	return;
516 520
     }
... ...
@@ -527,7 +531,7 @@ void SipCtrlInterface::timer_expired(sip_trans* trans, sip_timer_type tt)
527 531
     }
528 532
  
529 533
     AmEventDispatcher::instance()->post(c2stlstr(trans->to_tag),
530
-					new AmSipTimeoutEvent(ev, cseq->num, c2stlstr(cseq->method_str)));
534
+					new AmSipTimeoutEvent(ev, cseq->num));
531 535
 }
532 536
 
533 537
 void SipCtrlInterface::prepare_routes_uac(const list<sip_header*>& routes, string& route_field)