Browse Source

modules/registrar: added 'q' xavp_cfg name

Juha Heinanen 10 years ago
parent
commit
cbce3372cd

+ 45 - 39
modules/registrar/README

@@ -8,6 +8,10 @@ Daniel-Constantin Mierla
 
 
    <[email protected]>
    <[email protected]>
 
 
+Juha Heinanen
+
+   <[email protected]>
+
 Edited by
 Edited by
 
 
 Jan Janak
 Jan Janak
@@ -16,7 +20,7 @@ Edited by
 
 
 Bogdan-Andre Iancu
 Bogdan-Andre Iancu
 
 
-   Copyright © 2003 FhG FOKUS
+   Copyright (c) 2003 FhG FOKUS
      __________________________________________________________________
      __________________________________________________________________
 
 
    Table of Contents
    Table of Contents
@@ -628,6 +632,8 @@ modparam("registrar", "reg_callid_avp", "$avp(s:avp)")
        parameter value.
        parameter value.
      * socket - the string representing the socket on which the register
      * socket - the string representing the socket on which the register
        rquest was received, as alternative to using the sock_hdr.
        rquest was received, as alternative to using the sock_hdr.
+     * q - q value of contact (integer 0-1000). It overrides q value given
+       in contact header and default_q parameter.
 
 
    For example. if this parameter is set to 'reg', then the number of
    For example. if this parameter is set to 'reg', then the number of
    maximum contacts can be set in $xavp(reg=>max_contacts).
    maximum contacts can be set in $xavp(reg=>max_contacts).
@@ -754,7 +760,7 @@ modparam("registrar", "flow_timer", 25)
    4.7. reg_fetch_contacts(domain, uri, profile)
    4.7. reg_fetch_contacts(domain, uri, profile)
    4.8. reg_free_contacts(profile)
    4.8. reg_free_contacts(profile)
 
 
-4.1. save(domain, [, flags [, uri]])
+4.1.  save(domain, [, flags [, uri]])
 
 
    The function processes a REGISTER message. It can add, remove or modify
    The function processes a REGISTER message. It can add, remove or modify
    location records (in usrloc) depending on Contact and Expires HFs in
    location records (in usrloc) depending on Contact and Expires HFs in
@@ -799,7 +805,7 @@ save("location", "0x01");
 save("location", "0x00", "sip:[email protected]");
 save("location", "0x00", "sip:[email protected]");
 ...
 ...
 
 
-4.2. lookup(domain [, uri])
+4.2.  lookup(domain [, uri])
 
 
    The lookup function extracts username and/or domain from Request-URI
    The lookup function extracts username and/or domain from Request-URI
    and tries to find all contacts for the username in usrloc. If there are
    and tries to find all contacts for the username in usrloc. If there are
@@ -839,7 +845,7 @@ switch ($retcode) {
 };
 };
 ...
 ...
 
 
-4.3. lookup_branches(domain)
+4.3.  lookup_branches(domain)
 
 
    The function performs lookup(domain) on r-uri and additional branches
    The function performs lookup(domain) on r-uri and additional branches
    (only branches that have no other attributes set than uri).
    (only branches that have no other attributes set than uri).
@@ -856,7 +862,7 @@ switch ($retcode) {
 lookup_branches("location");
 lookup_branches("location");
 ...
 ...
 
 
-4.4. registered(domain [, uri])
+4.4.  registered(domain [, uri])
 
 
    The function returns true if the AOR in the Request-URI is registered,
    The function returns true if the AOR in the Request-URI is registered,
    false otherwise. The function does not modify the message being
    false otherwise. The function does not modify the message being
@@ -878,7 +884,7 @@ if (registered("location")) {
 };
 };
 ...
 ...
 
 
-4.5. add_sock_hdr(hdr_name)
+4.5.  add_sock_hdr(hdr_name)
 
 
    Adds a new header to the current REGISTER request with "hdr_name" which
    Adds a new header to the current REGISTER request with "hdr_name" which
    contains the description of the received socket (proto:ip:port)
    contains the description of the received socket (proto:ip:port)
@@ -895,7 +901,7 @@ if (registered("location")) {
 add_sock_hdr("Sock-Info");
 add_sock_hdr("Sock-Info");
 ...
 ...
 
 
-4.6. unregister(domain, uri[, ruid])
+4.6.  unregister(domain, uri[, ruid])
 
 
    The function removes contacts associated with 'uri' from the location
    The function removes contacts associated with 'uri' from the location
    database. If 'ruid' is provided a specific contact is removed, if
    database. If 'ruid' is provided a specific contact is removed, if
@@ -922,7 +928,7 @@ unregister("location", "$ru", "$ulc(caller=>ruid)");
 unregister("location", "", "$ruid");
 unregister("location", "", "$ruid");
 ...
 ...
 
 
-4.7. reg_fetch_contacts(domain, uri, profile)
+4.7.  reg_fetch_contacts(domain, uri, profile)
 
 
    The function fetches the contacts for 'uri' from table 'domain' to
    The function fetches the contacts for 'uri' from table 'domain' to
    pseudo-variable $ulc(profile).
    pseudo-variable $ulc(profile).
@@ -944,7 +950,7 @@ reg_fetch_contacts("location", "$ru", "callee");
 reg_fetch_contacts("location", "sip:[email protected]", "caller");
 reg_fetch_contacts("location", "sip:[email protected]", "caller");
 ...
 ...
 
 
-4.8. reg_free_contacts(profile)
+4.8.  reg_free_contacts(profile)
 
 
    The function frees the contacts from pseudo-variable $ulc(profile).
    The function frees the contacts from pseudo-variable $ulc(profile).
    Should be called to release the content of a profile. Anyhow, fetching
    Should be called to release the content of a profile. Anyhow, fetching
@@ -1087,60 +1093,60 @@ Chapter 2. Frequently Asked Questions
 
 
    2.1.
    2.1.
 
 
-   What happend with the old "nat_flag" module parameter?
+       What happend with the old "nat_flag" module parameter?
 
 
-   In was removed, as the module internally loads this value from the
-   "USRLOC" module (see the "nat_bflag" USRLOC parameter).
+       In was removed, as the module internally loads this value from the
+       "USRLOC" module (see the "nat_bflag" USRLOC parameter).
 
 
    2.2.
    2.2.
 
 
-   What happend with the old "use_domain" module parameter?
+       What happend with the old "use_domain" module parameter?
 
 
-   In was removed, as the module internally loads this option from the
-   "USRLOC" module. This was done in order to simplify the configuration.
+       In was removed, as the module internally loads this option from the
+       "USRLOC" module. This was done in order to simplify the configuration.
 
 
    2.3.
    2.3.
 
 
-   What happened with the old "save_noreply" and "save_memory" functions?
+       What happened with the old "save_noreply" and "save_memory" functions?
 
 
-   There functions were merged into the new "save(domain,flags)"
-   functions. If a reply should be sent or if the DB should be updated
-   also is controlled via the flags.
+       There functions were merged into the new "save(domain,flags)"
+       functions. If a reply should be sent or if the DB should be updated
+       also is controlled via the flags.
 
 
    2.4.
    2.4.
 
 
-   Where can I find more about Kamailio?
+       Where can I find more about Kamailio?
 
 
-   Take a look at http://www.kamailio.org/.
+       Take a look at http://www.kamailio.org/.
 
 
    2.5.
    2.5.
 
 
-   Where can I post a question about this module?
+       Where can I post a question about this module?
 
 
-   First at all check if your question was already answered on one of our
-   mailing lists:
-     * User Mailing List -
-       http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
-     * Developer Mailing List -
-       http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
+       First at all check if your question was already answered on one of our
+       mailing lists:
+         * User Mailing List -
+           http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
+         * Developer Mailing List -
+           http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
 
 
-   E-mails regarding any stable Kamailio release should be sent to
-   <[email protected]> and e-mails regarding development
-   versions should be sent to <[email protected]>.
+       E-mails regarding any stable Kamailio release should be sent to
+       <[email protected]> and e-mails regarding development
+       versions should be sent to <[email protected]>.
 
 
-   If you want to keep the mail private, send it to
-   <[email protected]>.
+       If you want to keep the mail private, send it to
+       <[email protected]>.
 
 
    2.6.
    2.6.
 
 
-   How can I report a bug?
+       How can I report a bug?
 
 
-   Please follow the guidelines provided at:
-   http://sip-router.org/tracker.
+       Please follow the guidelines provided at:
+       http://sip-router.org/tracker.
 
 
    2.7.
    2.7.
 
 
-   What happened to the desc_time_order parameter?
+       What happened to the desc_time_order parameter?
 
 
-   It was removed, as its functionality was migrated into usrloc module,
-   were there is a parameter with the same name.
+       It was removed, as its functionality was migrated into usrloc module,
+       were there is a parameter with the same name.

+ 5 - 0
modules/registrar/doc/registrar.xml

@@ -26,6 +26,11 @@
 		<surname>Mierla</surname>
 		<surname>Mierla</surname>
 		<email>[email protected]</email>
 		<email>[email protected]</email>
 		</author>
 		</author>
+		<author>
+		<firstname>Juha</firstname>
+		<surname>Heinanen</surname>
+		<email>[email protected]</email>
+		</author>
 		<editor>
 		<editor>
 		<firstname>Jan</firstname>
 		<firstname>Jan</firstname>
 		<surname>Janak</surname>
 		<surname>Janak</surname>

+ 8 - 0
modules/registrar/doc/registrar_admin.xml

@@ -671,6 +671,14 @@ modparam("registrar", "reg_callid_avp", "$avp(s:avp)")
 				to using the sock_hdr.
 				to using the sock_hdr.
 			</para>
 			</para>
 		</listitem>
 		</listitem>
+		<listitem>
+			<para>
+				<emphasis>q</emphasis> - q value of contact
+				(integer 0-1000). It
+				overrides q value given in contact header and
+				default_q parameter.
+			</para>
+		</listitem>
 		</itemizedlist>
 		</itemizedlist>
 		<para>
 		<para>
 			For example. if this parameter is set to 'reg', then the number
 			For example. if this parameter is set to 'reg', then the number

+ 21 - 2
modules/registrar/sip_msg.c

@@ -283,11 +283,29 @@ void calc_contact_expires(struct sip_msg* _m, param_t* _ep, int* _e)
 
 
 /*! \brief
 /*! \brief
  * Calculate contact q value as follows:
  * Calculate contact q value as follows:
- * 1) If q parameter exists, use it
- * 2) If the parameter doesn't exist, use the default value
+ * 1) If xavp_cfg q has been defined, use it
+ * 2) If q parameter exists in contact, use it
+ * 3) If the parameter doesn't exist in contact, use the default value
  */
  */
 int calc_contact_q(param_t* _q, qvalue_t* _r)
 int calc_contact_q(param_t* _q, qvalue_t* _r)
 {
 {
+	sr_xavp_t *vavp = NULL;
+	str xqname = str_init("q");
+
+	if (reg_xavp_cfg.s != NULL)
+		vavp = xavp_get_child_with_ival(&reg_xavp_cfg, &xqname);
+
+	if (vavp != NULL) {
+		if ((vavp->val.v.i >= 0) && (vavp->val.v.i <= 1000)) {
+			*_r = vavp->val.v.i;
+			return 0;
+		} else {
+			rerrno = R_INV_Q; /* Invalid q parameter */
+			LM_ERR("invalid q parameter\n");
+			return -1;
+		}
+	}
+
 	if (!_q || (_q->body.len == 0)) {
 	if (!_q || (_q->body.len == 0)) {
 		*_r = cfg_get(registrar, registrar_cfg, default_q);
 		*_r = cfg_get(registrar, registrar_cfg, default_q);
 	} else {
 	} else {
@@ -297,5 +315,6 @@ int calc_contact_q(param_t* _q, qvalue_t* _r)
 			return -1;
 			return -1;
 		}
 		}
 	}
 	}
+
 	return 0;
 	return 0;
 }
 }