浏览代码

ims_ipsec_pcscf: extend get_pcontact with the new parameter.

- added a new bitwise value for _cflags in ipsec_forward.
- performing a reverse search for a contact in ipsec_forward
  if the new flag IPSEC_REVERSE_SEARCH is set.
Aleksandar Yosifov 5 年之前
父节点
当前提交
e10dc0db1b
共有 2 个文件被更改,包括 7 次插入5 次删除
  1. 4 3
      src/modules/ims_ipsec_pcscf/cmd.c
  2. 3 2
      src/modules/ims_ipsec_pcscf/doc/ims_ipsec_pcscf_admin.xml

+ 4 - 3
src/modules/ims_ipsec_pcscf/cmd.c

@@ -76,6 +76,7 @@ extern usrloc_api_t ul;
 extern struct tm_binds tmb;
 extern struct tm_binds tmb;
 
 
 #define IPSEC_SEND_FORCE_SOCKET		0x01 /* if set - set send force socket for request messages */
 #define IPSEC_SEND_FORCE_SOCKET		0x01 /* if set - set send force socket for request messages */
+#define IPSEC_REVERSE_SEARCH		0x02 /* if set - start seraching from the last element */
 
 
 int bind_ipsec_pcscf(ipsec_pcscf_api_t* api) {
 int bind_ipsec_pcscf(ipsec_pcscf_api_t* api) {
 	if(!api){
 	if(!api){
@@ -663,7 +664,7 @@ int ipsec_create(struct sip_msg* m, udomain_t* d)
 
 
     ul.lock_udomain(d, &ci.via_host, ci.via_port, ci.via_prot);
     ul.lock_udomain(d, &ci.via_host, ci.via_port, ci.via_prot);
 
 
-    if (ul.get_pcontact(d, &ci, &pcontact) != 0) {
+    if (ul.get_pcontact(d, &ci, &pcontact, 0) != 0) {
         LM_ERR("Contact doesn't exist\n");
         LM_ERR("Contact doesn't exist\n");
         goto cleanup;
         goto cleanup;
     }
     }
@@ -802,7 +803,7 @@ int ipsec_forward(struct sip_msg* m, udomain_t* d, int _cflags)
 
 
     ul.lock_udomain(d, &ci.via_host, ci.via_port, ci.via_prot);
     ul.lock_udomain(d, &ci.via_host, ci.via_port, ci.via_prot);
 
 
-    if (ul.get_pcontact(d, &ci, &pcontact) != 0) {
+    if (ul.get_pcontact(d, &ci, &pcontact, _cflags & IPSEC_REVERSE_SEARCH) != 0) {
         LM_ERR("Contact doesn't exist\n");
         LM_ERR("Contact doesn't exist\n");
         goto cleanup;
         goto cleanup;
     }
     }
@@ -946,7 +947,7 @@ int ipsec_destroy(struct sip_msg* m, udomain_t* d)
 
 
     ul.lock_udomain(d, &ci.via_host, ci.via_port, ci.via_prot);
     ul.lock_udomain(d, &ci.via_host, ci.via_port, ci.via_prot);
 
 
-    if (ul.get_pcontact(d, &ci, &pcontact) != 0) {
+    if (ul.get_pcontact(d, &ci, &pcontact, 0) != 0) {
         LM_ERR("Contact doesn't exist\n");
         LM_ERR("Contact doesn't exist\n");
         goto cleanup;
         goto cleanup;
     }
     }

+ 3 - 2
src/modules/ims_ipsec_pcscf/doc/ims_ipsec_pcscf_admin.xml

@@ -243,8 +243,9 @@ ipsec_create("location");
           stores the contacts.
           stores the contacts.
           </para>
           </para>
           <para>
           <para>
-          <emphasis>flags</emphasis> - Set send force socket for request messages.
-          If 1 - set force socket for request messages. Useful for ipsec and TCP.
+          <emphasis>flags</emphasis> - bitwise flag:
+          0x01 - set force socket for request messages. Useful for ipsec and TCP.
+          0x02 - reverse search for a contact in the memory. Useful when contact alias is disabled.
           This is an optional parameter, default value - 0.
           This is an optional parameter, default value - 0.
           </para>
           </para>
         </listitem>
         </listitem>