Sfoglia il codice sorgente

registrar Add expiry value to the xavp.

Quite handy if Kamailio for some reason changes the expiry value (min, max
or variations caused by expiry_range)
Olle E. Johansson 9 anni fa
parent
commit
780a37d9c2

+ 9 - 0
modules/registrar/README

@@ -3,6 +3,7 @@ registrar Module
 Jan Janak
 
    FhG FOKUS
+   <[email protected]>
 
 Daniel-Constantin Mierla
 
@@ -12,10 +13,17 @@ Juha Heinanen
 
    <[email protected]>
 
+Olle E. Johansson
+
+   Edvina AB
+   <[email protected]>
+
 Edited by
 
 Jan Janak
 
+   <[email protected]>
+
 Edited by
 
 Bogdan-Andre Iancu
@@ -679,6 +687,7 @@ modparam("registrar", "xavp_cfg", "reg")
    $xavp(class[0]=>attribute). Valid inner XAVP names:
      * ruid - the record's internal unique id.
      * contact - the record's contact value.
+     * expires - the record's expires value.
      * received - the record's received value.
 
    For example. if this parameter is set to 'ulrcd', then values are set

+ 8 - 6
modules/registrar/doc/registrar.xml

@@ -17,9 +17,7 @@
 		<firstname>Jan</firstname>
 		<surname>Janak</surname>
 		<affiliation><orgname>&fhg;</orgname></affiliation>
-		<address>
-			<email>[email protected]</email>
-		</address>
+		<email>[email protected]</email>
 		</author>
 		<author>
 		<firstname>Daniel-Constantin</firstname>
@@ -31,12 +29,16 @@
 		<surname>Heinanen</surname>
 		<email>[email protected]</email>
 		</author>
+		<author>
+		<firstname>Olle E.</firstname>
+		<surname>Johansson</surname>
+		<affiliation><orgname>Edvina AB</orgname></affiliation>
+		<email>[email protected]</email>
+		</author>
 		<editor>
 		<firstname>Jan</firstname>
 		<surname>Janak</surname>
-		<address>
-			<email>[email protected]</email>
-		</address>
+		<email>[email protected]</email>
 		</editor>
 		<editor>
 		<firstname>Bogdan-Andre</firstname>

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

@@ -753,6 +753,11 @@ modparam("registrar", "xavp_cfg", "reg")
 				<emphasis>contact</emphasis> - the record's contact value.
 			</para>
 		</listitem>
+		<listitem>
+			<para>
+				<emphasis>expires</emphasis> - the record's expires value.
+			</para>
+		</listitem>
 		<listitem>
 			<para>
 				<emphasis>received</emphasis> - the record's received value.

+ 10 - 0
modules/registrar/reply.c

@@ -176,6 +176,7 @@ int build_contact(sip_msg_t *msg, ucontact_t* c, str *host)
 	sr_xavp_t *xavp=NULL;
 	sr_xavp_t *list=NULL;
 	str xname = {"ruid", 4};
+	str ename = {"expires", 7};
 	sr_xval_t xval;
 
 
@@ -334,9 +335,18 @@ int build_contact(sip_msg_t *msg, ucontact_t* c, str *host)
 				memset(&xval, 0, sizeof(sr_xval_t));
 				xval.type = SR_XTYPE_STR;
 				xval.v.s = c->ruid;
+
 				if(xavp_add_value(&xname, &xval, &xavp)==NULL) {
 					LM_ERR("cannot add ruid value to xavp\n");
 				}
+				/* Add contact expiry */
+				memset(&xval, 0, sizeof(sr_xval_t));
+				xval.type = SR_XTYPE_INT;
+				xval.v.i = (int)(c->expires - act_time);
+
+				if(xavp_add_value(&ename, &xval, &xavp)==NULL) {
+					LM_ERR("cannot add expires value to xavp\n");
+				}
 			}
 		}