Преглед изворни кода

examples/pcscf and scscf: Changed config file to use new P-CSCF subscription and publish reg event

Richard Good пре 11 година
родитељ
комит
e697c6c912
3 измењених фајлова са 181 додато и 8 уклоњено
  1. 49 1
      examples/pcscf/kamailio.cfg
  2. 4 0
      examples/pcscf/pcscf.cfg
  3. 128 7
      examples/scscf/kamailio.cfg

+ 49 - 1
examples/pcscf/kamailio.cfg

@@ -170,9 +170,11 @@ loadmodule "xmlrpc"
 #!endif
 
 #!ifdef WITH_RX
+loadmodule "db_mysql.so"
 loadmodule "cdp"
 loadmodule "cdp_avp"
 loadmodule "ims_qos"
+loadmodule "pua.so"
 #!endif
 
 #!ifdef CAPTURE_NODE
@@ -241,11 +243,30 @@ modparam("ims_usrloc_pcscf", "usrloc_debug_file", "/var/log/usrloc_debug")
 modparam("ims_usrloc_pcscf", "enable_debug_file", 0)
 #!endif
 
+
+# -- ims-registrar-pcscf params --
+modparam("ims_registrar_pcscf", "pcscf_uri", "sip:_SMILE_FQDN_:4060")
+modparam("ims_registrar_pcscf", "subscription_expires", 7200)
+
+#!ifdef WITH_P_SUBSCRIPTION_TO_REG_EVENT
+modparam("ims_registrar_pcscf", "subscribe_to_reginfo", 1)
+modparam("ims_registrar_pcscf", "publish_reginfo", 1)
+
+# -- pua params --
+modparam("pua", "hash_size", 15)
+modparam("pua", "db_url", ""mysql://ser:heslo@dbhost/pcscf")
+modparam("pua", "db_mode", 2)
+modparam("pua", "update_period", 10)
+modparam("pua", "check_remote_contact", 0)
+#!endif
+
 #!ifdef WITH_RX
 # -- CDP params --
 modparam("cdp","config_file","/etc/kamailio/pcscf.xml")
 # -- diameter_rx params --
 modparam("ims_qos", "rx_dest_realm", "NETWORKNAME")
+modparam("ims_qos", "rx_auth_expiry", 800000)
+
 #!endif
 
 # -- dialog_ng params --
@@ -807,6 +828,21 @@ failure_route[REGISTER_failure]
 		send_reply("504","Server Time-Out");
 }
 
+#####################################################################
+# Notify Route:                                                     #
+#####################################################################
+route[NOTIFY]
+{
+        xlog("L_DBG", "IMS: INSIDE NOTIFY\n");
+       if (reginfo_handle_notify("location")) {
+                t_reply("200","OK - P-CSCF processed notification");
+                break;
+        }else{
+                t_reply("500","Error encountered while processing notification");
+                break;
+        }
+}
+
 ######################################################################
 # Originating, Intial Requests
 ######################################################################
@@ -876,7 +912,7 @@ onreply_route[Orig_Initial_reply]
 	if (t_check_status("180|183|200")){
 		xlog("L_DBG","Diameter: Orig authorizing media via Rx\n");	
 		Rx_AAR("orig");
-		if ($avp(s:aar_return_code) != 1) {
+		if ($avp(s:aar_return_code) < 0) {
 			xlog("L_ERR", "IMS: AAR failed Orig\n");
 			dlg_terminate("all", "Sorry no QoS available");
 		} else {
@@ -959,6 +995,18 @@ route[Orig_Standalone]
 	xlog("L_DBG", "IMS: INSIDE ORIG_STANDALONE\n");
 	loose_route();
 	t_newtran();
+
+	if (is_method("NOTIFY")) {
+                if(uri==myself){
+                        route(NOTIFY);
+                } else {
+                        t_relay();
+                }
+                break;
+        } else {
+                xlog("L_DBG", "method is $rm from $si with contact: $ct\n");
+        }
+
 	if (!pcscf_is_registered("location")) {
 		send_reply("403","Forbidden - You must register first with a S-CSCF");
 		break;

+ 4 - 0
examples/pcscf/pcscf.cfg

@@ -62,6 +62,9 @@
 #     - Configure Rx-Diameter-Interface in pcscf.xml
 #     - define WITH_RX
 #
+# *** To enable P SUBSCRIPTION TO REG EVENT:
+#     - define WITH_P_SUBSCRIPTION_TO_REG_EVENT
+#
 # *** To enable a Homer SIP-Capter-Node:
 #     - define CAPTURE_NODE with a proper address
 #
@@ -75,5 +78,6 @@
 ##!define WITH_RX
 ##!define WITH_TCP
 ##!define WITH_RTPIPV4
+##!define WITH_P_SUBSCRIPTION_TO_REG_EVENT
 
 

+ 128 - 7
examples/scscf/kamailio.cfg

@@ -242,10 +242,16 @@ modparam("ims_auth", "av_check_only_impu", 1)
 modparam("ims_registrar_scscf", "default_expires", 60)
 modparam("ims_registrar_scscf", "min_expires", 60)
 modparam("ims_registrar_scscf", "max_expires", 60)
+modparam("ims_registrar_scscf", "subscription_default_expires", 80)
+modparam("ims_registrar_scscf", "subscription_min_expires", 80)
+modparam("ims_registrar_scscf", "subscription_max_expires", 80)
 #!else
 modparam("ims_registrar_scscf", "default_expires",  604800)
 modparam("ims_registrar_scscf", "min_expires", 3600)
 modparam("ims_registrar_scscf", "max_expires",  604800)
+modparam("ims_registrar_scscf", "subscription_default_expires", 654800)
+modparam("ims_registrar_scscf", "subscription_min_expires", 3700)
+modparam("ims_registrar_scscf", "subscription_max_expires", 605800)
 #!endif
 modparam("ims_registrar_scscf", "use_path", 1)
 modparam("ims_registrar_scscf", "support_wildcardPSI",1)
@@ -309,9 +315,14 @@ route {
 
 	# we need to support subscription to reg event
         if (is_method("SUBSCRIBE") && search("^(Event|o)([ \t]*):([ \t]*)reg")) {
-		route(subscribe);
+		route(SUBSCRIBE);
 		break;
         }
+
+	if (is_method("PUBLISH") && search("^(Event|o)([ \t]*):([ \t]*)reg")) {
+                route(PUBLISH);
+                break;
+        }
 	
 	#Set DLG flag to track dialogs using dialog2
 	if (!is_method("REGISTER|SUBSCRIBE"))
@@ -427,16 +438,126 @@ route[REQINIT] {
 }
 
 ######################################################################
-# Handle Subscribes to the REG-INFO event
+# Publish route
 ######################################################################
-route[subscribe]
+route[PUBLISH]
 {
-	#we need to deal with subs to reg event!
-	# handle_subscribe();
-	sl_send_reply("403", "Forbidden... for now");
-	exit;
+        if (!t_newtran()) {
+                #absorb retransmissions
+                sl_reply("500","Could not create transaction");
+                exit;
+        }
+
+        if (can_publish_reg("location")){
+                $var(ret)= publish_reg("location");        
+                switch ($var(ret)){
+                        case 1: #success
+                                xlog("L_DBG", "Publish reg successful");
+                                break;
+                        case -1: #failure
+                                xlog("L_ERR", "Publish reg failure - sending 500 Error now\n");
+                                t_reply("500","Server Error publishing subscription");
+                                break;
+                        default:
+                                xlog("L_ERR", "Unknown return code from publish reg event alue is [$var(ret)]\n");
+                                break;
+                }
+        } else {
+                t_reply("403","Forbidden to PUBLISH");
+                exit;
+        }
 }
 
+######################################################################
+# Subscribe route
+######################################################################
+route[SUBSCRIBE]
+{
+        if (!t_newtran()) {    
+                #absorb retransmissions
+                sl_reply("500","Could not create transaction");
+                exit;
+        }
+
+        if (!has_totag()) {
+                xlog("L_DBG", "This is an initial SUBSCRIBE\n");
+                if (!term_impu_registered("location")) {
+                        xlog("L_DBG", "We need to do an UNREG server SAR assignment\n");
+                        assign_server_unreg("SUBSCRIBE_UNREG_SAR_REPLY", "location", "term");
+                        exit;
+                }
+                if (!can_subscribe_to_reg("location")){
+                        t_reply("403","Forbidden to SUBSCRIBE");
+                        exit;
+                }
+        }else{
+                xlog("L_DBG", "This is a subsequent SUBSCRIBE\n");      
+        }
+
+        $var(ret)= subscribe_to_reg("location");        
+        switch ($var(ret)){
+        case 1: #success
+                xlog("L_DBG", "Subscribe to reg successful");
+                break;
+        case -1: #failure
+                xlog("L_ERR", "Subscribe to reg failure - sending 500 Error now\n");
+                t_reply("500","Server Error saving subscription");
+                break;
+        case -2: #error
+                xlog("L_ERR", "Subscribe to reg error sending notify - 200 OK so subscription already sent\n");
+                break;
+        default:
+                xlog("L_ERR", "Unknown return code from subscribe to reg event alue is [$var(ret)]\n");
+                break;
+        }
+}
+
+route[SUBSCRIBE_UNREG_SAR_REPLY]
+{
+        
+        xlog("L_DBG","saa_return code is $avp(s:saa_return_code)\n");
+        switch ($avp(s:saa_return_code)){
+                case 1: #success
+                        xlog("L_DBG", "SAR success - will process subscribe\n");
+                        if (can_subscribe_to_reg("location")){
+                                $var(ret)= subscribe_to_reg("location");        
+                                switch ($var(ret)){
+                                case 1: #success
+                                        xlog("L_DBG", "Subscribe to reg successful");
+                                        break;
+                                case -1: #failure
+                                        xlog("L_ERR", "Subscribe to reg failure - sending 500 Error now\n");
+                                        t_reply("500","Server Error saving subscription");
+                                        break;
+                                case -2: #error
+                                        xlog("L_ERR", "Subscribe to reg error sending notify - 200 OK so subscription already sent\n");
+                                        break;
+                                default:
+                                        xlog("L_ERR", "Unknown return code from subscribe to reg event alue is [$var(ret)]\n");
+                                        break;
+                                }
+                        }else{
+                                t_reply("403","Forbidden to SUBSCRIBE");
+                                exit;
+                        }
+                        break;
+                case -1: #failure
+                        xlog("L_ERR", "SAR failure - Sending 403 Forbidden\n");
+                        t_reply("403","Forbidden to SUBSCRIBE");
+                        break;
+                case -2: #error
+                        xlog("L_ERR", "SAR error - Sending 403 Forbidden\n");
+                        t_reply("403","Forbidden to SUBSCRIBE");
+                        break;
+                default:
+                        xlog("L_ERR", "Unknown return code from SAR, value is [$avp(s:saa_return_code)] - sending 403 Forbidden\n");
+                        t_reply("403","Forbidden to SUBSCRIBE");
+                        break;
+        }
+        exit;
+}
+
+
 ######################################################################
 # XMLRPC routing
 ######################################################################