Browse code

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 authored on 03/08/2020 11:53:39 • Henning Westerholt committed on 12/08/2020 18:44:08
Showing 2 changed files
... ...
@@ -76,6 +76,7 @@ extern usrloc_api_t ul;
76 76
 extern struct tm_binds tmb;
77 77
 
78 78
 #define IPSEC_SEND_FORCE_SOCKET		0x01 /* if set - set send force socket for request messages */
79
+#define IPSEC_REVERSE_SEARCH		0x02 /* if set - start seraching from the last element */
79 80
 
80 81
 int bind_ipsec_pcscf(ipsec_pcscf_api_t* api) {
81 82
 	if(!api){
... ...
@@ -663,7 +664,7 @@ int ipsec_create(struct sip_msg* m, udomain_t* d)
663 664
 
664 665
     ul.lock_udomain(d, &ci.via_host, ci.via_port, ci.via_prot);
665 666
 
666
-    if (ul.get_pcontact(d, &ci, &pcontact) != 0) {
667
+    if (ul.get_pcontact(d, &ci, &pcontact, 0) != 0) {
667 668
         LM_ERR("Contact doesn't exist\n");
668 669
         goto cleanup;
669 670
     }
... ...
@@ -802,7 +803,7 @@ int ipsec_forward(struct sip_msg* m, udomain_t* d, int _cflags)
802 803
 
803 804
     ul.lock_udomain(d, &ci.via_host, ci.via_port, ci.via_prot);
804 805
 
805
-    if (ul.get_pcontact(d, &ci, &pcontact) != 0) {
806
+    if (ul.get_pcontact(d, &ci, &pcontact, _cflags & IPSEC_REVERSE_SEARCH) != 0) {
806 807
         LM_ERR("Contact doesn't exist\n");
807 808
         goto cleanup;
808 809
     }
... ...
@@ -946,7 +947,7 @@ int ipsec_destroy(struct sip_msg* m, udomain_t* d)
946 947
 
947 948
     ul.lock_udomain(d, &ci.via_host, ci.via_port, ci.via_prot);
948 949
 
949
-    if (ul.get_pcontact(d, &ci, &pcontact) != 0) {
950
+    if (ul.get_pcontact(d, &ci, &pcontact, 0) != 0) {
950 951
         LM_ERR("Contact doesn't exist\n");
951 952
         goto cleanup;
952 953
     }
... ...
@@ -243,8 +243,9 @@ ipsec_create("location");
243 243
           stores the contacts.
244 244
           </para>
245 245
           <para>
246
-          <emphasis>flags</emphasis> - Set send force socket for request messages.
247
-          If 1 - set force socket for request messages. Useful for ipsec and TCP.
246
+          <emphasis>flags</emphasis> - bitwise flag:
247
+          0x01 - set force socket for request messages. Useful for ipsec and TCP.
248
+          0x02 - reverse search for a contact in the memory. Useful when contact alias is disabled.
248 249
           This is an optional parameter, default value - 0.
249 250
           </para>
250 251
         </listitem>