Browse code

Merge 10d27ab2d7992df04d5da4e8615e16156eb10734 into 34300dd8db7d52c639307f4121f8e61619a53f99

LaurenČ›iu Nicola authored on 15/11/2021 15:59:29 • GitHub committed on 15/11/2021 15:59:29
Showing 4 changed files
... ...
@@ -792,7 +792,7 @@ modparam("presence", "subs_remove_match", 1)
792 792
 			so newer documents have higher priority.</para>
793 793
         </listitem>
794 794
         <listitem>
795
-			<para><emphasis>delete_subscription</emphasis> - integer value to 
795
+			<para><emphasis>delete_subscription</emphasis> - integer value to
796 796
 			give extra control of deleting the subscription after processing of
797 797
 			event_route[presence:notify-reply]. If value = 1, it deletes the subscription.
798 798
 			If xavp_cfg parameter is set but this attribute is not in the avp,
... ...
@@ -980,6 +980,29 @@ modparam("presence", "timer_mode", 0)
980 980
 	</example>
981 981
 </section>
982 982
 
983
+<section id="presence.p.subs_respond_200">
984
+	<title><varname>subs_respond_200</varname> (integer)</title>
985
+	<para>
986
+	Specify the response code for accepted SUBSCRIBE requests.
987
+	If set to 0, 202 Accepted will be returned.
988
+	If set to 1, 200 OK will be returned instead, in conformance to RFC6665
989
+	which prohibits 202 responses.
990
+	</para>
991
+	<para>
992
+		<emphasis>
993
+			Default value is 0.
994
+		</emphasis>
995
+	</para>
996
+	<example>
997
+		<title>Set <varname>subs_respond_200</varname> parameter</title>
998
+		<programlisting format="linespecific">
999
+...
1000
+modparam("presence", "subs_respond_200", 1)
1001
+...
1002
+</programlisting>
1003
+	</example>
1004
+</section>
1005
+
983 1006
 </section>
984 1007
 
985 1008
 <section>
... ...
@@ -166,6 +166,7 @@ int pres_retrieve_order = 0;
166 166
 str pres_retrieve_order_by = str_init("priority");
167 167
 int pres_enable_dmq = 0;
168 168
 int pres_delete_same_subs = 0;
169
+int pres_subs_respond_200 = 0;
169 170
 
170 171
 int pres_db_table_lock_type = 1;
171 172
 db_locking_t pres_db_table_lock = DB_LOCKING_WRITE;
... ...
@@ -243,6 +244,7 @@ static param_export_t params[]={
243 244
 	{ "pres_subs_mode",         PARAM_INT, &_pres_subs_mode},
244 245
 	{ "delete_same_subs",       PARAM_INT, &pres_delete_same_subs},
245 246
 	{ "timer_mode",             PARAM_INT, &pres_timer_mode},
247
+	{ "subs_respond_200",       PARAM_INT, &pres_subs_respond_200},
246 248
 
247 249
 	{0,0,0}
248 250
 };
... ...
@@ -99,6 +99,7 @@ extern str pres_xavp_cfg;
99 99
 extern int pres_retrieve_order;
100 100
 extern str pres_retrieve_order_by;
101 101
 extern int pres_enable_dmq;
102
+extern int pres_subs_respond_200;
102 103
 
103 104
 extern int phtable_size;
104 105
 extern phtable_t *pres_htable;
... ...
@@ -56,6 +56,10 @@ static str pu_500_rpl = str_init("Server Internal Error");
56 56
 static str pu_489_rpl = str_init("Bad Event");
57 57
 static str pu_423_rpl = str_init("Interval Too Brief");
58 58
 
59
+static int get_ok_reply_code() {
60
+	return pres_subs_respond_200 ? 200 : 202;
61
+}
62
+
59 63
 static int send_2XX_reply(sip_msg_t *msg, int reply_code, unsigned int lexpire,
60 64
 		str *local_contact)
61 65
 {
... ...
@@ -498,6 +502,7 @@ int update_subscription_notifier(
498 502
 		struct sip_msg *msg, subs_t *subs, int to_tag_gen, int *sent_reply)
499 503
 {
500 504
 	int num_peers = 0;
505
+	int reply_code;
501 506
 
502 507
 	*sent_reply = 0;
503 508
 
... ...
@@ -539,11 +544,9 @@ int update_subscription_notifier(
539 544
 		}
540 545
 	}
541 546
 
542
-	if(send_2XX_reply(msg, subs->event->type & PUBL_TYPE ? 202 : 200,
543
-			   subs->expires, &subs->local_contact)
544
-			< 0) {
545
-		LM_ERR("sending %d response\n",
546
-				subs->event->type & PUBL_TYPE ? 202 : 200);
547
+	reply_code = subs->event->type & PUBL_TYPE ? get_ok_reply_code() : 200;
548
+	if(send_2XX_reply(msg, reply_code, subs->expires, &subs->local_contact) < 0) {
549
+		LM_ERR("sending %d response\n", reply_code);
547 550
 		goto error;
548 551
 	}
549 552
 	*sent_reply = 1;
... ...
@@ -558,6 +561,7 @@ int update_subscription(
558 561
 		struct sip_msg *msg, subs_t *subs, int to_tag_gen, int *sent_reply)
559 562
 {
560 563
 	unsigned int hash_code;
564
+	int reply_code;
561 565
 
562 566
 	LM_DBG("update subscription\n");
563 567
 	printf_subs(subs);
... ...
@@ -573,9 +577,10 @@ int update_subscription(
573 577
 					&subs->from_tag, &subs->callid);
574 578
 
575 579
 			if(subs->event->type & PUBL_TYPE) {
576
-				if(send_2XX_reply(msg, 202, subs->expires, &subs->local_contact)
580
+				reply_code = get_ok_reply_code();
581
+				if(send_2XX_reply(msg, reply_code, subs->expires, &subs->local_contact)
577 582
 						< 0) {
578
-					LM_ERR("sending 202 OK\n");
583
+					LM_ERR("sending %d OK\n", reply_code);
579 584
 					goto error;
580 585
 				}
581 586
 				*sent_reply = 1;
... ...
@@ -656,8 +661,9 @@ int update_subscription(
656 661
 	/* reply_and_notify  */
657 662
 
658 663
 	if(subs->event->type & PUBL_TYPE) {
659
-		if(send_2XX_reply(msg, 202, subs->expires, &subs->local_contact) < 0) {
660
-			LM_ERR("sending 202 OK reply\n");
664
+		reply_code = get_ok_reply_code();
665
+		if(send_2XX_reply(msg, reply_code, subs->expires, &subs->local_contact) < 0) {
666
+			LM_ERR("sending %d OK\n", reply_code);
661 667
 			goto error;
662 668
 		}
663 669
 		*sent_reply = 1;