Browse code

core/sbc: added support for subscription-less NOTIFY forwarding

For the moment, it is only implemented for NOTIFY requests within a dialog.

Raphael Coeffic authored on 20/12/2013 14:36:31
Showing 4 changed files
... ...
@@ -119,6 +119,8 @@ SBCCallLeg::SBCCallLeg(const SBCCallProfile& call_profile, AmSipDialog* p_dlg,
119 119
 				     1000);
120 120
     rtp_relay_rate_limit.reset(limit);
121 121
   }
122
+
123
+  subs->allowUnsolicitedNotify(call_profile.allow_subless_notify);
122 124
 }
123 125
 
124 126
 // B leg constructor (from SBCCalleeSession)
... ...
@@ -164,6 +166,8 @@ SBCCallLeg::SBCCallLeg(SBCCallLeg* caller, AmSipDialog* p_dlg,
164 166
   initCCExtModules();
165 167
 
166 168
   setLogger(caller->getLogger());
169
+
170
+  subs->allowUnsolicitedNotify(call_profile.allow_subless_notify);
167 171
 }
168 172
 
169 173
 SBCCallLeg::SBCCallLeg(AmSipDialog* p_dlg, AmSipSubscription* p_subs)
... ...
@@ -146,6 +146,8 @@ struct SBCCallProfile
146 146
 
147 147
   string aleg_next_hop;
148 148
 
149
+  bool allow_subless_notify;
150
+
149 151
   vector<FilterEntry> headerfilter;
150 152
   vector<FilterEntry> messagefilter;
151 153
 
... ...
@@ -339,7 +341,8 @@ struct SBCCallProfile
339 341
     log_rtp(false),
340 342
     log_sip(false),
341 343
     patch_ruri_next_hop(false),
342
-    next_hop_1st_req(false)
344
+    next_hop_1st_req(false),
345
+    allow_subless_notify(false)
343 346
   { }
344 347
 
345 348
   ~SBCCallProfile()
... ...
@@ -562,6 +562,12 @@ bool AmSipSubscription::onRequestIn(const AmSipRequest& req)
562 562
   // UAS side
563 563
   Subscriptions::iterator sub_it = matchSubscription(req,false);
564 564
   if((sub_it == subs.end()) || (*sub_it)->terminated()) {
565
+
566
+    if((sub_it == subs.end()) && (req.method == SIP_METH_NOTIFY)
567
+       && allow_subless_notify) {
568
+      return true;
569
+    }
570
+
565 571
     dlg->reply(req, 481, SIP_REPLY_NOT_EXIST);
566 572
     return false;
567 573
   }
... ...
@@ -576,6 +582,12 @@ void AmSipSubscription::onRequestSent(const AmSipRequest& req)
576 582
   // UAC side
577 583
   Subscriptions::iterator sub_it = matchSubscription(req,true);
578 584
   if(sub_it == subs.end()){
585
+
586
+    if((req.method == SIP_METH_NOTIFY)
587
+       && allow_subless_notify) {
588
+      return;
589
+    }
590
+
579 591
     // should we exclude this case in onSendRequest???
580 592
     ERROR("we just sent a request for which we could obtain no subscription\n");
581 593
     return;
... ...
@@ -592,6 +604,12 @@ bool AmSipSubscription::onReplyIn(const AmSipRequest& req,
592 604
   // UAC side
593 605
   CSeqMap::iterator cseq_it = uac_cseq_map.find(req.cseq);
594 606
   if(cseq_it == uac_cseq_map.end()){
607
+
608
+    if((req.method == SIP_METH_NOTIFY)
609
+       && allow_subless_notify) {
610
+      return true;
611
+    }
612
+
595 613
     DBG("could not find %i in our uac_cseq_map\n",req.cseq);
596 614
     return false;
597 615
   }
... ...
@@ -164,6 +164,8 @@ protected:
164 164
   CSeqMap  uas_cseq_map;
165 165
   CSeqMap  uac_cseq_map;
166 166
 
167
+  bool allow_subless_notify;
168
+
167 169
   SingleSubscription* makeSubscription(const AmSipRequest& req, bool uac);
168 170
   Subscriptions::iterator createSubscription(const AmSipRequest& req, bool uac);
169 171
   Subscriptions::iterator matchSubscription(const AmSipRequest& req, bool uac);
... ...
@@ -184,6 +186,10 @@ public:
184 186
   AmSipSubscription(AmBasicSipDialog* dlg, AmEventQueue* ev_q);
185 187
   virtual ~AmSipSubscription();
186 188
 
189
+  void allowUnsolicitedNotify(bool allow) {
190
+    allow_subless_notify = allow;
191
+  }
192
+
187 193
   /**
188 194
    * Is there at least one active subscription?
189 195
    */