Browse code

ims_usrloc_pcscf: added a reverse searchin get_pcontact

- added a new parameter for reverse search in get_pcontact.

Aleksandar Yosifov authored on 03/08/2020 11:45:01 • Henning Westerholt committed on 12/08/2020 18:44:08
Showing 1 changed files
... ...
@@ -444,9 +444,10 @@ error:
444 444
  * @udomain_t* _d - domain to search in
445 445
  * @str* _contact - contact to search for - should be a SIP URI
446 446
  * @struct pontact** _c - contact to return to if found (null if not found)
447
+ * @int reverse_search - reverse search for a contact in the memory
447 448
  * @return 0 if found <>0 if not
448 449
  */
449
-int get_pcontact(udomain_t* _d, pcontact_info_t* contact_info, struct pcontact** _c) {
450
+int get_pcontact(udomain_t* _d, pcontact_info_t* contact_info, struct pcontact** _c, int reverse_search) {
450 451
 	unsigned int sl, i, j, aorhash, params_len, has_rinstance=0;
451 452
 	struct pcontact* c;
452 453
 	struct sip_uri needle_uri;
... ...
@@ -454,9 +455,10 @@ int get_pcontact(udomain_t* _d, pcontact_info_t* contact_info, struct pcontact**
454 455
 	char *params, *sep;
455 456
 	str rinstance = {0, 0};
456 457
         
457
-	LM_DBG("Searching for contact with AOR [%.*s] in P-CSCF usrloc based on VIA [%d://%.*s:%d] Received [%d://%.*s:%d], Search flag is %d\n",
458
+	LM_DBG("Searching for contact with AOR [%.*s] in P-CSCF usrloc based on VIA [%d://%.*s:%d] Received [%d://%.*s:%d], Search flag is %d, reverse_search %d\n",
458 459
 		contact_info->aor.len, contact_info->aor.s, contact_info->via_prot, contact_info->via_host.len, contact_info->via_host.s, contact_info->via_port,
459
-		contact_info->received_proto, contact_info->received_host.len, contact_info->received_host.s, contact_info->received_port, contact_info->searchflag);
460
+		contact_info->received_proto, contact_info->received_host.len, contact_info->received_host.s, contact_info->received_port, contact_info->searchflag,
461
+		reverse_search);
460 462
 
461 463
 	/* parse the uri in the NOTIFY */
462 464
 	if (contact_info->aor.len>0 && contact_info->aor.s){
... ...
@@ -501,7 +503,7 @@ int get_pcontact(udomain_t* _d, pcontact_info_t* contact_info, struct pcontact**
501 503
 	sl = aorhash & (_d->size - 1);
502 504
         
503 505
 	LM_DBG("get_pcontact slot is [%d]\n", sl);
504
-	c = _d->table[sl].first;
506
+	c = reverse_search ? _d->table[sl].last : _d->table[sl].first;
505 507
 
506 508
 	for (i = 0; i < _d->table[sl].n; i++) {
507 509
 		LM_DBG("comparing contact with aorhash [%u], aor [%.*s]\n", c->aorhash, c->aor.len, c->aor.s);
... ...
@@ -563,7 +565,7 @@ int get_pcontact(udomain_t* _d, pcontact_info_t* contact_info, struct pcontact**
563 565
 							c->rinstance.len, c->rinstance.s);
564 566
 					if ((rinstance.len == c->rinstance.len) && memcmp(rinstance.s, c->rinstance.s, rinstance.len) != 0) {
565 567
 						LM_DBG("rinstance does not match - no match here...\n");
566
-						c = c->next;
568
+						c = reverse_search ? c->prev : c->next;
567 569
 						continue;
568 570
 					}
569 571
 				}
... ...
@@ -571,7 +573,7 @@ int get_pcontact(udomain_t* _d, pcontact_info_t* contact_info, struct pcontact**
571 573
 				if ((contact_info->extra_search_criteria & SEARCH_SERVICE_ROUTES) && contact_info->num_service_routes > 0) {
572 574
 					LM_DBG("have %d service routes to search for\n", contact_info->num_service_routes);
573 575
 					if (contact_info->num_service_routes != c->num_service_routes) {
574
-						c = c->next;
576
+						c = reverse_search ? c->prev : c->next;
575 577
 						LM_DBG("number of service routes do not match - failing\n");
576 578
 						continue;
577 579
 					} 
... ...
@@ -588,7 +590,7 @@ int get_pcontact(udomain_t* _d, pcontact_info_t* contact_info, struct pcontact**
588 590
 						}
589 591
 					}
590 592
 					if (serviceroutematch == 0) {
591
-						c = c->next;
593
+						c = reverse_search ? c->prev : c->next;
592 594
 						continue;
593 595
 					}
594 596
 				}
... ...
@@ -596,14 +598,14 @@ int get_pcontact(udomain_t* _d, pcontact_info_t* contact_info, struct pcontact**
596 598
 				//finally check state being searched for
597 599
 				if ( (contact_info->reg_state != PCONTACT_ANY) && ((contact_info->reg_state & c->reg_state) == 0)) {
598 600
 					LM_DBG("can't find contact for requested reg state [%d] - (have [%d])\n", contact_info->reg_state, c->reg_state);
599
-					c = c->next;
601
+					c = reverse_search ? c->prev : c->next;
600 602
 					continue;
601 603
 				}
602 604
 				*_c = c;
603 605
 				return 0;
604 606
 			}
605 607
 		}
606
-		c = c->next;
608
+		c = reverse_search ? c->prev : c->next;
607 609
 	}
608 610
         
609 611
 	LM_DBG("contact not found in memory\n");
Browse code

core: remove stats_name_separator from cfg_group_core

Federico Cabiddu authored on 02/05/2020 08:14:23
Showing 1 changed files
... ...
@@ -82,7 +82,7 @@ static char *build_stat_name( str* domain, char *var_name)
82 82
 	}
83 83
 	memcpy( s, domain->s, domain->len);
84 84
 	p = s + domain->len;
85
-	*(p++) = *cfg_get(core, core_cfg, stats_name_separator);
85
+	*(p++) = *ksr_stats_namesep;
86 86
 	memcpy( p , var_name, strlen(var_name));
87 87
 	p += strlen(var_name);
88 88
 	*(p++) = 0;
Browse code

core: new core parameter stats_name_separator

Federico Cabiddu authored on 01/05/2020 11:02:39
Showing 1 changed files
... ...
@@ -82,7 +82,7 @@ static char *build_stat_name( str* domain, char *var_name)
82 82
 	}
83 83
 	memcpy( s, domain->s, domain->len);
84 84
 	p = s + domain->len;
85
-	*(p++) = KSR_STATS_NAMESEP;
85
+	*(p++) = *cfg_get(core, core_cfg, stats_name_separator);
86 86
 	memcpy( p , var_name, strlen(var_name));
87 87
 	p += strlen(var_name);
88 88
 	*(p++) = 0;
Browse code

ims_usrloc_pcscf, p_usrloc, usrloc: use KSR_STATS_NAMESEP for stats names

Federico Cabiddu authored on 28/04/2020 14:24:24
Showing 1 changed files
... ...
@@ -82,7 +82,7 @@ static char *build_stat_name( str* domain, char *var_name)
82 82
 	}
83 83
 	memcpy( s, domain->s, domain->len);
84 84
 	p = s + domain->len;
85
-	*(p++) = '_';
85
+	*(p++) = KSR_STATS_NAMESEP;
86 86
 	memcpy( p , var_name, strlen(var_name));
87 87
 	p += strlen(var_name);
88 88
 	*(p++) = 0;
Browse code

p_usrloc, ims_usrloc_pcscf: change "-" for "_" in stats name to be prometheus compliant

Federico Cabiddu authored on 28/04/2020 12:48:59
Showing 1 changed files
... ...
@@ -82,7 +82,7 @@ static char *build_stat_name( str* domain, char *var_name)
82 82
 	}
83 83
 	memcpy( s, domain->s, domain->len);
84 84
 	p = s + domain->len;
85
-	*(p++) = '-';
85
+	*(p++) = '_';
86 86
 	memcpy( p , var_name, strlen(var_name));
87 87
 	p += strlen(var_name);
88 88
 	*(p++) = 0;
Browse code

ims_usrloc_pcscf: fix code formatting after merge commit 57961c9f

Henning Westerholt authored on 15/07/2019 19:03:39
Showing 1 changed files
... ...
@@ -451,61 +451,61 @@ int get_pcontact(udomain_t* _d, pcontact_info_t* contact_info, struct pcontact**
451 451
 	struct pcontact* c;
452 452
 	struct sip_uri needle_uri;
453 453
 	int serviceroutematch;
454
-        char *params, *sep;
455
-        str rinstance = {0, 0};
454
+	char *params, *sep;
455
+	str rinstance = {0, 0};
456 456
         
457
-        LM_DBG("Searching for contact with AOR [%.*s] in P-CSCF usrloc based on VIA [%d://%.*s:%d] Received [%d://%.*s:%d], Search flag is %d\n",
458
-				contact_info->aor.len, contact_info->aor.s, contact_info->via_prot, contact_info->via_host.len, contact_info->via_host.s, contact_info->via_port,
459
-                contact_info->received_proto, contact_info->received_host.len, contact_info->received_host.s, contact_info->received_port, contact_info->searchflag);
460
-	
461
-            /* parse the uri in the NOTIFY */
462
-        if (contact_info->aor.len>0 && contact_info->aor.s){
463
-            LM_DBG("Have an AOR to search for\n");
464
-            if (parse_uri(contact_info->aor.s, contact_info->aor.len, &needle_uri) != 0) {
465
-                LM_ERR("Unable to parse contact aor in get_pcontact [%.*s]\n", contact_info->aor.len, contact_info->aor.s);
466
-                return 0;
467
-            }
468
-            LM_DBG("checking for rinstance");
469
-            /*check for alias - NAT */
470
-            params = needle_uri.sip_params.s;
471
-            params_len = needle_uri.sip_params.len;
472
-
473
-            while (params_len >= RINSTANCE_LEN) {
474
-                if (strncmp(params, RINSTANCE, RINSTANCE_LEN) == 0) {
475
-                    has_rinstance = 1;
476
-                    break;
477
-                }
478
-                sep = memchr(params, 59 /* ; */, params_len);
479
-                if (sep == NULL) {
480
-                    LM_DBG("no rinstance param\n");
481
-                    break;
482
-                } else {
483
-                    params_len = params_len - (sep - params + 1);
484
-                    params = sep + 1;
485
-                }
486
-            }
487
-            if (has_rinstance) {
488
-                rinstance.s = params + RINSTANCE_LEN;
489
-                rinstance.len = params_len - RINSTANCE_LEN;
490
-                sep = (char*)memchr(rinstance.s, 59 /* ; */, rinstance.len);
491
-                if (sep != NULL){
492
-                    rinstance.len = (sep-rinstance.s);
493
-                }
494
-                LM_DBG("rinstance found [%.*s]\n", rinstance.len, rinstance.s);
495
-            }
496
-        }
457
+	LM_DBG("Searching for contact with AOR [%.*s] in P-CSCF usrloc based on VIA [%d://%.*s:%d] Received [%d://%.*s:%d], Search flag is %d\n",
458
+		contact_info->aor.len, contact_info->aor.s, contact_info->via_prot, contact_info->via_host.len, contact_info->via_host.s, contact_info->via_port,
459
+		contact_info->received_proto, contact_info->received_host.len, contact_info->received_host.s, contact_info->received_port, contact_info->searchflag);
460
+
461
+	/* parse the uri in the NOTIFY */
462
+	if (contact_info->aor.len>0 && contact_info->aor.s){
463
+		LM_DBG("Have an AOR to search for\n");
464
+		if (parse_uri(contact_info->aor.s, contact_info->aor.len, &needle_uri) != 0) {
465
+			LM_ERR("Unable to parse contact aor in get_pcontact [%.*s]\n", contact_info->aor.len, contact_info->aor.s);
466
+			return 0;
467
+		}
468
+		LM_DBG("checking for rinstance");
469
+		/*check for alias - NAT */
470
+		params = needle_uri.sip_params.s;
471
+		params_len = needle_uri.sip_params.len;
472
+
473
+		while (params_len >= RINSTANCE_LEN) {
474
+			if (strncmp(params, RINSTANCE, RINSTANCE_LEN) == 0) {
475
+				has_rinstance = 1;
476
+				break;
477
+			}
478
+			sep = memchr(params, 59 /* ; */, params_len);
479
+			if (sep == NULL) {
480
+				LM_DBG("no rinstance param\n");
481
+				break;
482
+			} else {
483
+				params_len = params_len - (sep - params + 1);
484
+				params = sep + 1;
485
+			}
486
+		}
487
+		if (has_rinstance) {
488
+			rinstance.s = params + RINSTANCE_LEN;
489
+			rinstance.len = params_len - RINSTANCE_LEN;
490
+			sep = (char*)memchr(rinstance.s, 59 /* ; */, rinstance.len);
491
+			if (sep != NULL){
492
+				rinstance.len = (sep-rinstance.s);
493
+			}
494
+			LM_DBG("rinstance found [%.*s]\n", rinstance.len, rinstance.s);
495
+		}
496
+	}
497 497
              
498 498
     
499 499
 	/* search in cache */
500 500
 	aorhash = get_aor_hash(_d, &contact_info->via_host, contact_info->via_port, contact_info->via_prot);
501 501
 	sl = aorhash & (_d->size - 1);
502 502
         
503
-        LM_DBG("get_pcontact slot is [%d]\n", sl);
503
+	LM_DBG("get_pcontact slot is [%d]\n", sl);
504 504
 	c = _d->table[sl].first;
505 505
 
506 506
 	for (i = 0; i < _d->table[sl].n; i++) {
507
-            LM_DBG("comparing contact with aorhash [%u], aor [%.*s]\n", c->aorhash, c->aor.len, c->aor.s);
508
-            LM_DBG("  contact host [%.*s:%d]\n", c->contact_host.len, c->contact_host.s, c->contact_port);
507
+		LM_DBG("comparing contact with aorhash [%u], aor [%.*s]\n", c->aorhash, c->aor.len, c->aor.s);
508
+		LM_DBG("  contact host [%.*s:%d]\n", c->contact_host.len, c->contact_host.s, c->contact_port);
509 509
 		LM_DBG("contact received [%d:%.*s:%d]\n", c->received_proto, c->received_host.len, c->received_host.s, c->received_port);
510 510
 
511 511
 		if(c->aorhash == aorhash){
... ...
@@ -606,8 +606,8 @@ int get_pcontact(udomain_t* _d, pcontact_info_t* contact_info, struct pcontact**
606 606
 		c = c->next;
607 607
 	}
608 608
         
609
-        LM_DBG("contact not found in memory\n");
610
-       	// Default: Not found.
609
+	LM_DBG("contact not found in memory\n");
610
+	// Default: Not found.
611 611
 	*_c = NULL;
612 612
         
613 613
 	return 1; /* Nothing found */
... ...
@@ -680,7 +680,7 @@ int assert_identity(udomain_t* _d, str * _host, unsigned short _port, unsigned s
680 680
 int delete_pcontact(udomain_t* _d, /*str* _aor, str* _received_host, int _received_port,*/ struct pcontact* _c)
681 681
 {
682 682
 	if (_c==0) {
683
-            return 0;
683
+		return 0;
684 684
 	}
685 685
 
686 686
 	if (exists_ulcb_type(PCSCF_CONTACT_DELETE)) {
... ...
@@ -817,7 +817,7 @@ static inline pcontact_info_t* dbrow2info( db_val_t *vals, str *contact)
817 817
 
818 818
 	memset( &ci, 0, sizeof(pcontact_info_t));
819 819
 
820
-        host.s = (char*) VAL_STRING(vals + 1);
820
+	host.s = (char*) VAL_STRING(vals + 1);
821 821
 	if (VAL_NULL(vals+1) || !host.s || !host.s[0]) {
822 822
 		host.len = 0;
823 823
 		host.s = 0;
... ...
@@ -825,8 +825,8 @@ static inline pcontact_info_t* dbrow2info( db_val_t *vals, str *contact)
825 825
 		host.len = strlen(host.s);
826 826
 	}
827 827
 	ci.via_host = host;
828
-        ci.via_port = VAL_INT(vals + 2);
829
-        ci.via_prot = VAL_INT(vals + 3);
828
+	ci.via_port = VAL_INT(vals + 2);
829
+	ci.via_prot = VAL_INT(vals + 3);
830 830
 	received.s = (char*) VAL_STRING(vals + 4);
831 831
 	if (VAL_NULL(vals+4) || !received.s || !received.s[0]) {
832 832
 		LM_DBG("Empty received for contact [%.*s]....\n", contact->len, contact->s);	/*this could happen if you have been notified about a contact from S-CSCF*/
... ...
@@ -964,9 +964,9 @@ int preload_udomain(db1_con_t* _c, udomain_t* _d)
964 964
 
965 965
 	columns[0] = &domain_col;
966 966
 	columns[1] = &aor_col;
967
-        columns[2] = &host_col;
968
-        columns[3] = &port_col;
969
-        columns[4] = &protocol_col;
967
+	columns[2] = &host_col;
968
+	columns[3] = &port_col;
969
+	columns[4] = &protocol_col;
970 970
 	columns[5] = &received_col;
971 971
 	columns[6] = &received_port_col;
972 972
 	columns[7] = &received_proto_col;
... ...
@@ -1023,11 +1023,11 @@ int preload_udomain(db1_con_t* _c, udomain_t* _d)
1023 1023
 				continue;
1024 1024
 			}
1025 1025
 			aor.len = strlen(aor.s);
1026
-                        ci = dbrow2info(ROW_VALUES(row) + 1, &aor);
1027
-                        if (!ci) {
1028
-                            LM_WARN("Failed to get contact info from DB.... continuing...\n");
1029
-                            continue;
1030
-                        }
1026
+			ci = dbrow2info(ROW_VALUES(row) + 1, &aor);
1027
+			if (!ci) {
1028
+				LM_WARN("Failed to get contact info from DB.... continuing...\n");
1029
+				continue;
1030
+			}
1031 1031
 			lock_udomain(_d, &ci->via_host, ci->via_port, ci->via_prot);
1032 1032
 
1033 1033
 			if ( (mem_insert_pcontact(_d, &aor, ci, &c)) != 0) {
... ...
@@ -1035,8 +1035,8 @@ int preload_udomain(db1_con_t* _c, udomain_t* _d)
1035 1035
 				unlock_udomain(_d, &ci->via_host, ci->via_port, ci->via_prot);
1036 1036
 				goto error1;
1037 1037
 			}
1038
-                        //c->flags = c->flags|(1<<FLAG_READFROMDB);
1039
-                        //TODO: need to subscribe to s-cscf for first public identity
1038
+			//c->flags = c->flags|(1<<FLAG_READFROMDB);
1039
+			//TODO: need to subscribe to s-cscf for first public identity
1040 1040
 			unlock_udomain(_d, &ci->via_host, ci->via_port, ci->via_prot);
1041 1041
 		}
1042 1042
 
... ...
@@ -1074,7 +1074,7 @@ pcontact_t* db_load_pcontact(db1_con_t* _c, udomain_t* _d, str *_aor)
1074 1074
 	db1_res_t* res = NULL;
1075 1075
 	db_row_t *row;
1076 1076
 	int i;
1077
-        str aor;
1077
+	str aor;
1078 1078
 
1079 1079
 	pcontact_t* c;
1080 1080
 
... ...
@@ -1083,11 +1083,11 @@ pcontact_t* db_load_pcontact(db1_con_t* _c, udomain_t* _d, str *_aor)
1083 1083
 	vals[0].nul = 0;
1084 1084
 	vals[0].val.str_val = *_aor;
1085 1085
 
1086
-        columns[0] = &domain_col;
1086
+	columns[0] = &domain_col;
1087 1087
 	columns[1] = &aor_col;
1088
-        columns[2] = &host_col;
1089
-        columns[3] = &port_col;
1090
-        columns[4] = &protocol_col;
1088
+	columns[2] = &host_col;
1089
+	columns[3] = &port_col;
1090
+	columns[4] = &protocol_col;
1091 1091
 	columns[5] = &received_col;
1092 1092
 	columns[6] = &received_port_col;
1093 1093
 	columns[7] = &received_proto_col;
... ...
@@ -1099,7 +1099,7 @@ pcontact_t* db_load_pcontact(db1_con_t* _c, udomain_t* _d, str *_aor)
1099 1099
 	columns[13] = &public_ids_col;
1100 1100
 	columns[14] = &path_col;
1101 1101
         
1102
-        LM_DBG("Querying database for P-CSCF contact [%.*s]\n", _aor->len, _aor->s);
1102
+	LM_DBG("Querying database for P-CSCF contact [%.*s]\n", _aor->len, _aor->s);
1103 1103
         
1104 1104
 	if (ul_dbf.use_table(_c, _d->name) < 0) {
1105 1105
 		LM_ERR("failed to use table %.*s\n", _d->name->len, _d->name->s);
... ...
@@ -1118,29 +1118,27 @@ pcontact_t* db_load_pcontact(db1_con_t* _c, udomain_t* _d, str *_aor)
1118 1118
 	}
1119 1119
 
1120 1120
 	for(i = 0; i < RES_ROW_N(res); i++) {
1121
-                        row = RES_ROWS(res) + i;
1122
-
1123
-			aor.s = (char*) VAL_STRING(ROW_VALUES(row) + 1);
1124
-			if (VAL_NULL(ROW_VALUES(row) + 1) || aor.s == 0 || aor.s[0] == 0) {
1125
-				LM_CRIT("empty aor record in table %s...skipping\n", _d->name->s);
1126
-				continue;
1127
-			}
1128
-			aor.len = strlen(aor.s);
1129
-                        ci = dbrow2info(ROW_VALUES(row) + 1, &aor);
1130
-                        if (!ci) {
1131
-                            LM_WARN("Failed to get contact info from DB.... continuing...\n");
1132
-                            continue;
1133
-                        }
1134
-			lock_udomain(_d, &ci->via_host, ci->via_port, ci->via_prot);
1135
-
1121
+		row = RES_ROWS(res) + i;
1122
+		aor.s = (char*) VAL_STRING(ROW_VALUES(row) + 1);
1123
+		if (VAL_NULL(ROW_VALUES(row) + 1) || aor.s == 0 || aor.s[0] == 0) {
1124
+			LM_CRIT("empty aor record in table %s...skipping\n", _d->name->s);
1125
+			continue;
1126
+		}
1127
+		aor.len = strlen(aor.s);
1128
+		ci = dbrow2info(ROW_VALUES(row) + 1, &aor);
1129
+		if (!ci) {
1130
+			LM_WARN("Failed to get contact info from DB.... continuing...\n");
1131
+			continue;
1132
+		}
1133
+		lock_udomain(_d, &ci->via_host, ci->via_port, ci->via_prot);
1136 1134
 			if ( (mem_insert_pcontact(_d, &aor, ci, &c)) != 0) {
1137
-				LM_ERR("inserting contact failed\n");
1138
-				unlock_udomain(_d, &ci->via_host, ci->via_port, ci->via_prot);
1139
-				goto error;
1140
-			}
1141
-                        //c->flags = c->flags|(1<<FLAG_READFROMDB);
1142
-                        //TODO: need to subscribe to s-cscf for first public identity
1135
+			LM_ERR("inserting contact failed\n");
1143 1136
 			unlock_udomain(_d, &ci->via_host, ci->via_port, ci->via_prot);
1137
+			goto error;
1138
+		}
1139
+		//c->flags = c->flags|(1<<FLAG_READFROMDB);
1140
+		//TODO: need to subscribe to s-cscf for first public identity
1141
+		unlock_udomain(_d, &ci->via_host, ci->via_port, ci->via_prot);
1144 1142
 	}
1145 1143
 
1146 1144
 	ul_dbf.free_result(_c, res);
... ...
@@ -1148,7 +1146,7 @@ pcontact_t* db_load_pcontact(db1_con_t* _c, udomain_t* _d, str *_aor)
1148 1146
 	return c;
1149 1147
 
1150 1148
 error:
1151
-        free_pcontact(c);
1149
+	free_pcontact(c);
1152 1150
 
1153 1151
 	ul_dbf.free_result(_c, res);
1154 1152
 	return 0;
Browse code

ims_usrloc_pcscf: added a new match key for ipsec location tbl

- ipsec location table: added a new match key for ipsec location
table. The added key is "received_port" column. It's necessary
because after successful re-registration into the table are
stored two contacts withe the same AOR. Before the changes only
the AOR was contact's match key.
- ul callbacks: added a method delete_ulcb(), wich is used to delete
the pending IPSEC tunnels for the unsuccessfuly registered contacts.
- udomain: adde a new method unreg_pending_contacts_cb(). Used to search
and delete user callbacks for all pending contacts with default SIP
port (5060) after successful contact registration.
- ipsec structure: added a new vars in ipsec_t - port_pc (port proxy
client) and port_ps (port proxy server). Used to keep proxy ports
for already created IPSEC tunnels.

Aleksandar Yosifov authored on 28/06/2019 14:37:15
Showing 1 changed files
... ...
@@ -3,6 +3,7 @@
3 3
  *
4 4
  * Copyright (C) 2012 Smile Communications, jason.penton@smilecoms.com
5 5
  * Copyright (C) 2012 Smile Communications, richard.good@smilecoms.com
6
+ * Copyright (C) 2019 Aleksandar Yosifov
6 7
  * 
7 8
  * The initial version of this code was written by Dragos Vingarzan
8 9
  * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
... ...
@@ -696,6 +697,106 @@ int delete_pcontact(udomain_t* _d, /*str* _aor, str* _received_host, int _receiv
696 697
 	return 0;
697 698
 }
698 699
 
700
+int unreg_pending_contacts_cb(udomain_t* _d, pcontact_t* _c, int type)
701
+{
702
+	pcontact_t*		c;
703
+	pcontact_info_t	contact_info;
704
+	unsigned int	aorhash, sl, i;
705
+
706
+	contact_info.via_host = _c->via_host;
707
+	contact_info.via_port = SIP_PORT;
708
+	contact_info.via_prot = _c->via_proto;
709
+	contact_info.reg_state = PCONTACT_ANY;
710
+
711
+	LM_DBG("Searching for contact in P-CSCF usrloc based on VIA [%d://%.*s:%d], reg state 0x%02X\n",
712
+			contact_info.via_prot, contact_info.via_host.len, contact_info.via_host.s, contact_info.via_port, contact_info.reg_state);
713
+	
714
+	aorhash = get_aor_hash(_d, &contact_info.via_host, contact_info.via_port, contact_info.via_prot);
715
+	sl = aorhash & (_d->size - 1);
716
+        
717
+    LM_DBG("get_pcontact slot is [%d]\n", sl);
718
+	c = _d->table[sl].first;
719
+
720
+	for(i = 0; i < _d->table[sl].n; i++){
721
+		LM_DBG("comparing contact with aorhash [%u], aor [%.*s]\n", c->aorhash, c->aor.len, c->aor.s);
722
+		LM_DBG("contact host [%.*s:%d]\n", c->contact_host.len, c->contact_host.s, c->contact_port);
723
+
724
+		if(c->aorhash == aorhash){
725
+			ip_addr_t c_ip_addr;
726
+			ip_addr_t ci_ip_addr;
727
+
728
+			// convert 'contact->contact host' ip string to ip_addr_t
729
+			if (str2ipxbuf(&c->contact_host, &c_ip_addr) < 0){
730
+				LM_ERR("Unable to convert c->contact_host [%.*s]\n", c->contact_host.len, c->contact_host.s);
731
+				return 1;
732
+			}
733
+
734
+			// convert 'contact info->via host' ip string to ip_addr_t
735
+			if(str2ipxbuf(&contact_info.via_host, &ci_ip_addr) < 0){
736
+				LM_ERR("Unable to convert contact_info.via_host [%.*s]\n", contact_info.via_host.len, contact_info.via_host.s);
737
+				return 1;
738
+			}
739
+
740
+			// compare 'contact->contact host' and 'contact info->via host'
741
+			if(ip_addr_cmp(&c_ip_addr, &ci_ip_addr) && (c->contact_port == contact_info.via_port)){
742
+				LM_DBG("found contact with URI [%.*s]\n", c->aor.len, c->aor.s);
743
+
744
+				// finally check state being searched for
745
+				if((contact_info.reg_state != PCONTACT_ANY) && ((contact_info.reg_state & c->reg_state) == 0)){
746
+					LM_DBG("can't find contact for requested reg state [%d] - (have [%d])\n", contact_info.reg_state, c->reg_state);
747
+					c = c->next;
748
+					continue;
749
+				}
750
+
751
+				// check for equal ipsec parameters
752
+				if(c->security_temp == NULL || _c->security_temp == NULL){
753
+					LM_DBG("Invalid temp security\n");
754
+					c = c->next;
755
+					continue;
756
+				}
757
+
758
+				if(c->security_temp->type != SECURITY_IPSEC){
759
+					LM_DBG("Invalid temp security type\n");
760
+					c = c->next;
761
+					continue;
762
+				}
763
+
764
+				if(c->security_temp->data.ipsec == NULL || _c->security_temp->data.ipsec == NULL){
765
+					LM_DBG("Invalid ipsec\n");
766
+					c = c->next;
767
+					continue;
768
+				}
769
+
770
+				LM_DBG("=========== c->reg_state 0x%02X, %u-%u | %u-%u | %u-%u | %u-%u | %u-%u | %u-%u | %u-%u | %u-%u |",
771
+					c->reg_state,
772
+					c->security_temp->data.ipsec->port_pc, _c->security_temp->data.ipsec->port_pc,
773
+				    c->security_temp->data.ipsec->port_ps, _c->security_temp->data.ipsec->port_ps,
774
+				    c->security_temp->data.ipsec->port_uc, _c->security_temp->data.ipsec->port_uc,
775
+				    c->security_temp->data.ipsec->port_us, _c->security_temp->data.ipsec->port_us,
776
+				    c->security_temp->data.ipsec->spi_pc, _c->security_temp->data.ipsec->spi_pc,
777
+				    c->security_temp->data.ipsec->spi_ps, _c->security_temp->data.ipsec->spi_ps,
778
+				    c->security_temp->data.ipsec->spi_uc, _c->security_temp->data.ipsec->spi_uc,
779
+				    c->security_temp->data.ipsec->spi_us, _c->security_temp->data.ipsec->spi_us);
780
+
781
+				if(c->security_temp->data.ipsec->port_pc == _c->security_temp->data.ipsec->port_pc &&
782
+				   c->security_temp->data.ipsec->port_ps == _c->security_temp->data.ipsec->port_ps &&
783
+				   c->security_temp->data.ipsec->port_uc == _c->security_temp->data.ipsec->port_uc &&
784
+				   c->security_temp->data.ipsec->port_us == _c->security_temp->data.ipsec->port_us &&
785
+				   c->security_temp->data.ipsec->spi_pc == _c->security_temp->data.ipsec->spi_pc &&
786
+				   c->security_temp->data.ipsec->spi_ps == _c->security_temp->data.ipsec->spi_ps &&
787
+				   c->security_temp->data.ipsec->spi_uc == _c->security_temp->data.ipsec->spi_uc &&
788
+				   c->security_temp->data.ipsec->spi_us == _c->security_temp->data.ipsec->spi_us){
789
+					// deregister user callback only for contacts with exact sec parameters like registerd contact
790
+					delete_ulcb(c, type);
791
+				}
792
+			}
793
+		}
794
+		c = c->next;
795
+	}
796
+
797
+	return 0;
798
+}
799
+
699 800
 /*!
700 801
  * \brief Convert database values into pcontact_info
701 802
  *
Browse code

ims_usrloc_pcscf: get_pcontact changes for IPv6

- Sometimes IPv6 address is coming with square brackets
and can not be found in userloc database. The search
algorithm is not changed, only used methods are changed.

Aleksandar Yosifov authored on 03/06/2019 14:37:03
Showing 1 changed files
... ...
@@ -507,61 +507,101 @@ int get_pcontact(udomain_t* _d, pcontact_info_t* contact_info, struct pcontact**
507 507
             LM_DBG("  contact host [%.*s:%d]\n", c->contact_host.len, c->contact_host.s, c->contact_port);
508 508
 		LM_DBG("contact received [%d:%.*s:%d]\n", c->received_proto, c->received_host.len, c->received_host.s, c->received_port);
509 509
 
510
-		if ((c->aorhash == aorhash) && 
511
-				(((c->contact_host.len == contact_info->via_host.len) 
512
-				&& (memcmp(contact_info->via_host.s, c->contact_host.s, c->contact_host.len) == 0) 
513
-				&& (c->contact_port == contact_info->via_port)
514
-				&& !(contact_info->searchflag & SEARCH_RECEIVED)) 
515
-		|| ((contact_info->searchflag & SEARCH_RECEIVED)
516
-				&& ((c->received_host.len == contact_info->received_host.len) && (memcmp(c->received_host.s, contact_info->received_host.s, contact_info->received_host.len) == 0))
517
-				&& ((c->received_port == contact_info->received_port) || (c->contact_port == contact_info->received_port))))) { /*volte comes from a different port.... typically uses 4060*/
518
-			LM_DBG("found contact with URI [%.*s]\n", c->aor.len, c->aor.s);
519
-			if (has_rinstance) {
520
-				LM_DBG("confirming rinstance is the same - search has [%.*s] and proposed found contact has [%.*s]",
521
-						rinstance.len, rinstance.s,
522
-						c->rinstance.len, c->rinstance.s);
523
-				if ((rinstance.len == c->rinstance.len) && memcmp(rinstance.s, c->rinstance.s, rinstance.len) != 0) {
524
-					LM_DBG("rinstance does not match - no match here...\n");
525
-					c = c->next;
526
-					continue;
510
+		if(c->aorhash == aorhash){
511
+			int check1_passed = 0;
512
+			int check2_passed = 0;
513
+			ip_addr_t c_ip_addr;
514
+			ip_addr_t ci_ip_addr;
515
+
516
+			// convert 'contact->contact host' ip string to ip_addr_t
517
+			if (str2ipxbuf(&c->contact_host, &c_ip_addr) < 0){
518
+				LM_ERR("Unable to convert c->contact_host [%.*s]\n", c->contact_host.len, c->contact_host.s);
519
+				return 1;
520
+			}
521
+
522
+			// convert 'contact info->via host' ip string to ip_addr_t
523
+			if(str2ipxbuf(&contact_info->via_host, &ci_ip_addr) < 0){
524
+				LM_ERR("Unable to convert contact_info->via_host [%.*s]\n", contact_info->via_host.len, contact_info->via_host.s);
525
+				return 1;
526
+			}
527
+
528
+			// compare 'contact->contact host' and 'contact info->via host'
529
+			if(ip_addr_cmp(&c_ip_addr, &ci_ip_addr) &&
530
+				(c->contact_port == contact_info->via_port) &&
531
+				!(contact_info->searchflag & SEARCH_RECEIVED))
532
+			{
533
+				check1_passed = 1;
534
+			}
535
+
536
+			if(contact_info->searchflag & SEARCH_RECEIVED){
537
+				// convert 'contact->received host' ip string to ip_addr_t
538
+				if (str2ipxbuf(&c->received_host, &c_ip_addr) < 0){
539
+					LM_ERR("Unable to convert c->received_host [%.*s]\n", c->received_host.len, c->received_host.s);
540
+					return 1;
541
+				}
542
+
543
+				// convert 'contact info->received host' ip string to ip_addr_t
544
+				if(str2ipxbuf(&contact_info->received_host, &ci_ip_addr) < 0){
545
+					LM_ERR("Unable to convert contact_info->received_host [%.*s]\n", contact_info->received_host.len, contact_info->received_host.s);
546
+					return 1;
547
+				}
548
+
549
+				// compare 'contact->received host' and 'contact info->received host'
550
+				if(ip_addr_cmp(&c_ip_addr, &ci_ip_addr) &&
551
+					((c->received_port == contact_info->received_port) ||
552
+					 (c->contact_port == contact_info->received_port))){ /*volte comes from a different port.... typically uses 4060*/
553
+					check2_passed = 1;
527 554
 				}
528 555
 			}
556
+
557
+			if(check1_passed || check2_passed){
558
+				LM_DBG("found contact with URI [%.*s]\n", c->aor.len, c->aor.s);
559
+				if (has_rinstance) {
560
+					LM_DBG("confirming rinstance is the same - search has [%.*s] and proposed found contact has [%.*s]",
561
+							rinstance.len, rinstance.s,
562
+							c->rinstance.len, c->rinstance.s);
563
+					if ((rinstance.len == c->rinstance.len) && memcmp(rinstance.s, c->rinstance.s, rinstance.len) != 0) {
564
+						LM_DBG("rinstance does not match - no match here...\n");
565
+						c = c->next;
566
+						continue;
567
+					}
568
+				}
529 569
 			
530
-			if ((contact_info->extra_search_criteria & SEARCH_SERVICE_ROUTES) && contact_info->num_service_routes > 0) {
531
-				LM_DBG("have %d service routes to search for\n", contact_info->num_service_routes);
532
-				if (contact_info->num_service_routes != c->num_service_routes) {
533
-					c = c->next;
534
-					LM_DBG("number of service routes do not match - failing\n");
535
-					continue;
536
-				} 
570
+				if ((contact_info->extra_search_criteria & SEARCH_SERVICE_ROUTES) && contact_info->num_service_routes > 0) {
571
+					LM_DBG("have %d service routes to search for\n", contact_info->num_service_routes);
572
+					if (contact_info->num_service_routes != c->num_service_routes) {
573
+						c = c->next;
574
+						LM_DBG("number of service routes do not match - failing\n");
575
+						continue;
576
+					} 
537 577
 				
538
-				serviceroutematch = 1;
539
-				for (j=0; j<contact_info->num_service_routes; j++) {
540
-					if (contact_info->service_routes[j].len != c->service_routes[j].len || memcmp(contact_info->service_routes[j].s, c->service_routes[j].s, c->service_routes[j].len) != 0) {
541
-						LM_DBG("service route at position %d does not match - looking for [%.*s] and contact has [%.*s]... continuing to next contact check\n", 
542
-							j,
543
-							contact_info->service_routes[j].len, contact_info->service_routes[j].s,
544
-							c->service_routes[j].len, c->service_routes[j].s);
545
-						serviceroutematch = 0;
546
-						break;
578
+					serviceroutematch = 1;
579
+					for (j=0; j<contact_info->num_service_routes; j++) {
580
+						if (contact_info->service_routes[j].len != c->service_routes[j].len || memcmp(contact_info->service_routes[j].s, c->service_routes[j].s, c->service_routes[j].len) != 0) {
581
+							LM_DBG("service route at position %d does not match - looking for [%.*s] and contact has [%.*s]... continuing to next contact check\n", 
582
+							    j,
583
+								contact_info->service_routes[j].len, contact_info->service_routes[j].s,
584
+								c->service_routes[j].len, c->service_routes[j].s);
585
+							serviceroutematch = 0;
586
+							break;
587
+						}
588
+					}
589
+					if (serviceroutematch == 0) {
590
+						c = c->next;
591
+						continue;
547 592
 					}
548 593
 				}
549
-				if (serviceroutematch == 0) {
594
+			
595
+				//finally check state being searched for
596
+				if ( (contact_info->reg_state != PCONTACT_ANY) && ((contact_info->reg_state & c->reg_state) == 0)) {
597
+					LM_DBG("can't find contact for requested reg state [%d] - (have [%d])\n", contact_info->reg_state, c->reg_state);
550 598
 					c = c->next;
551 599
 					continue;
552 600
 				}
601
+				*_c = c;
602
+				return 0;
553 603
 			}
554
-			
555
-			//finally check state being searched for
556
-			if ( (contact_info->reg_state != PCONTACT_ANY) && ((contact_info->reg_state & c->reg_state) == 0)) {
557
-				LM_DBG("can't find contact for requested reg state [%d] - (have [%d])\n", contact_info->reg_state, c->reg_state);
558
-				c = c->next;
559
-				continue;
560
-			}
561
-			*_c = c;
562
-			return 0;
563 604
 		}
564
-		
565 605
 		c = c->next;
566 606
 	}
567 607
         
Browse code

ims_usrloc_pcscf: Remove unused parameter from docs and module

Carsten Bock authored on 28/03/2017 08:44:21
Showing 1 changed files
... ...
@@ -64,7 +64,6 @@
64 64
 
65 65
 extern int db_mode;
66 66
 extern int db_mode_ext;
67
-extern unsigned int hashing_type;
68 67
 extern int match_contact_host_port;
69 68
 
70 69
 #ifdef STATISTICS
Browse code

ims_usrloc_pcscf: Rename module interface file #82

Victor Seva authored on 13/02/2017 14:42:54
Showing 1 changed files
... ...
@@ -52,7 +52,7 @@
52 52
 #include "../../lib/srdb1/db.h"
53 53
 #include "../../core/socket_info.h"
54 54
 #include "../../core/ut.h"
55
-#include "ul_mod.h"            /* usrloc module parameters */
55
+#include "ims_usrloc_pcscf_mod.h"            /* usrloc module parameters */
56 56
 #include "usrloc.h"
57 57
 #include "utime.h"
58 58
 #include "usrloc.h"
Browse code

IMS-USRLOC-PCSCF: Set contact to NULL for safety, if not found

Carsten Bock authored on 12/01/2017 13:22:30
Showing 1 changed files
... ...
@@ -567,6 +567,8 @@ int get_pcontact(udomain_t* _d, pcontact_info_t* contact_info, struct pcontact**
567 567
 	}
568 568
         
569 569
         LM_DBG("contact not found in memory\n");
570
+       	// Default: Not found.
571
+	*_c = NULL;
570 572
         
571 573
 	return 1; /* Nothing found */
572 574
 }
Browse code

core, lib, modules: updated include paths for header files

Daniel-Constantin Mierla authored on 07/12/2016 11:07:22
Showing 1 changed files
... ...
@@ -45,19 +45,19 @@
45 45
 
46 46
 #include "udomain.h"
47 47
 #include <string.h>
48
-#include "../../hashes.h"
49
-#include "../../parser/parse_methods.h"
50
-#include "../../mem/shm_mem.h"
51
-#include "../../dprint.h"
48
+#include "../../core/hashes.h"
49
+#include "../../core/parser/parse_methods.h"
50
+#include "../../core/mem/shm_mem.h"
51
+#include "../../core/dprint.h"
52 52
 #include "../../lib/srdb1/db.h"
53
-#include "../../socket_info.h"
54
-#include "../../ut.h"
53
+#include "../../core/socket_info.h"
54
+#include "../../core/ut.h"
55 55
 #include "ul_mod.h"            /* usrloc module parameters */
56 56
 #include "usrloc.h"
57 57
 #include "utime.h"
58 58
 #include "usrloc.h"
59 59
 #include "usrloc_db.h"
60
-#include "../../parser/parse_uri.h"
60
+#include "../../core/parser/parse_uri.h"
61 61
 
62 62
 #include "../../lib/ims/useful_defs.h"
63 63
 #include "../../modules/presence/presence.h"
Browse code

core, lib, modules: restructured source code tree

- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)

Daniel-Constantin Mierla authored on 07/12/2016 11:03:51
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,1015 @@
1
+/*
2
+ * $Id$
3
+ *
4
+ * Copyright (C) 2012 Smile Communications, jason.penton@smilecoms.com
5
+ * Copyright (C) 2012 Smile Communications, richard.good@smilecoms.com
6
+ * 
7
+ * The initial version of this code was written by Dragos Vingarzan
8
+ * (dragos(dot)vingarzan(at)fokus(dot)fraunhofer(dot)de and the
9
+ * Fruanhofer Institute. It was and still is maintained in a separate
10
+ * branch of the original SER. We are therefore migrating it to
11
+ * Kamailio/SR and look forward to maintaining it from here on out.
12
+ * 2011/2012 Smile Communications, Pty. Ltd.
13
+ * ported/maintained/improved by 
14
+ * Jason Penton (jason(dot)penton(at)smilecoms.com and
15
+ * Richard Good (richard(dot)good(at)smilecoms.com) as part of an 
16
+ * effort to add full IMS support to Kamailio/SR using a new and
17
+ * improved architecture
18
+ * 
19
+ * NB: Alot of this code was originally part of OpenIMSCore,
20
+ * FhG Fokus. 
21
+ * Copyright (C) 2004-2006 FhG Fokus
22
+ * Thanks for great work! This is an effort to 
23
+ * break apart the various CSCF functions into logically separate
24
+ * components. We hope this will drive wider use. We also feel
25
+ * that in this way the architecture is more complete and thereby easier
26
+ * to manage in the Kamailio/SR environment
27
+ *
28
+ * This file is part of Kamailio, a free SIP server.
29
+ *
30
+ * Kamailio is free software; you can redistribute it and/or modify
31
+ * it under the terms of the GNU General Public License as published by
32
+ * the Free Software Foundation; either version 2 of the License, or
33
+ * (at your option) any later version
34
+ *
35
+ * Kamailio is distributed in the hope that it will be useful,
36
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
37
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
38
+ * GNU General Public License for more details.
39
+ *
40
+ * You should have received a copy of the GNU General Public License 
41
+ * along with this program; if not, write to the Free Software 
42
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
43
+ * 
44
+ */
45
+
46
+#include "udomain.h"
47
+#include <string.h>
48
+#include "../../hashes.h"
49
+#include "../../parser/parse_methods.h"
50
+#include "../../mem/shm_mem.h"
51
+#include "../../dprint.h"
52
+#include "../../lib/srdb1/db.h"
53
+#include "../../socket_info.h"
54
+#include "../../ut.h"
55
+#include "ul_mod.h"            /* usrloc module parameters */
56
+#include "usrloc.h"
57
+#include "utime.h"
58
+#include "usrloc.h"
59
+#include "usrloc_db.h"
60
+#include "../../parser/parse_uri.h"
61
+
62
+#include "../../lib/ims/useful_defs.h"
63
+#include "../../modules/presence/presence.h"
64
+
65
+extern int db_mode;
66
+extern int db_mode_ext;
67
+extern unsigned int hashing_type;
68
+extern int match_contact_host_port;
69
+
70
+#ifdef STATISTICS
71
+static char *build_stat_name( str* domain, char *var_name)
72
+{
73
+	int n;
74
+	char *s;
75
+	char *p;
76
+
77
+	n = domain->len + 1 + strlen(var_name) + 1;
78
+	s = (char*)shm_malloc( n );
79
+	if (s==0) {
80
+		LM_ERR("no more shm mem\n");
81
+		return 0;
82
+	}
83
+	memcpy( s, domain->s, domain->len);
84
+	p = s + domain->len;
85
+	*(p++) = '-';
86
+	memcpy( p , var_name, strlen(var_name));
87
+	p += strlen(var_name);
88
+	*(p++) = 0;
89
+	return s;
90
+}
91
+#endif
92
+
93
+int new_udomain(str* _n, int _s, udomain_t** _d)
94
+{
95
+	int i;
96
+#ifdef STATISTICS
97
+	char *name;
98
+#endif
99
+
100
+	/* Must be always in shared memory, since
101
+	 * the cache is accessed from timer which
102
+	 * lives in a separate process
103
+	 */
104
+	*_d = (udomain_t*)shm_malloc(sizeof(udomain_t));
105
+	if (!(*_d)) {
106
+		LM_ERR("new_udomain(): No memory left\n");
107
+		goto error0;
108
+	}
109
+	memset(*_d, 0, sizeof(udomain_t));
110
+
111
+	(*_d)->table = (hslot_t*)shm_malloc(sizeof(hslot_t) * _s);
112
+	if (!(*_d)->table) {
113
+		LM_ERR("no memory left 2\n");
114
+		goto error1;
115
+	}
116
+
117
+	(*_d)->name = _n;
118
+
119
+	for(i = 0; i < _s; i++) {
120
+		init_slot(*_d, &((*_d)->table[i]), i);
121
+	}
122
+
123
+	(*_d)->size = _s;
124
+
125
+#ifdef STATISTICS
126
+	/* register the statistics */
127
+	if ( (name=build_stat_name(_n,"contacts"))==0 || register_stat("usrloc",
128
+	name, &(*_d)->contacts, STAT_NO_RESET|STAT_SHM_NAME)!=0 ) {
129
+		LM_ERR("failed to add stat variable\n");
130
+		goto error2;
131
+	}
132
+	if ( (name=build_stat_name(_n,"expires"))==0 || register_stat("usrloc",
133
+	name, &(*_d)->expired, STAT_SHM_NAME)!=0 ) {
134
+		LM_ERR("failed to add stat variable\n");
135
+		goto error2;
136
+	}
137
+#endif
138
+
139
+	return 0;
140
+#ifdef STATISTICS
141
+error2:
142
+	shm_free((*_d)->table);
143
+#endif
144
+error1:
145
+	shm_free(*_d);
146
+error0:
147
+	return -1;
148
+}
149
+
150
+void free_udomain(udomain_t* _d)
151
+{
152
+	int i;
153
+
154
+	if (_d->table) {
155
+		for(i = 0; i < _d->size; i++) {
156
+			lock_ulslot(_d, i);
157
+			deinit_slot(_d->table + i);
158
+			unlock_ulslot(_d, i);
159
+		}
160
+		shm_free(_d->table);
161
+	}
162
+	shm_free(_d);
163
+}
164
+
165
+void print_udomain(FILE* _f, udomain_t* _d)
166
+{
167
+	int i;
168
+	int max=0, slot=0, n=0;
169
+	struct pcontact* r;
170
+	fprintf(_f, "---Domain---\n");
171
+	fprintf(_f, "name : '%.*s'\n", _d->name->len, ZSW(_d->name->s));
172
+	fprintf(_f, "size : %d\n", _d->size);
173
+	fprintf(_f, "table: %p\n", _d->table);
174
+	/*fprintf(_f, "lock : %d\n", _d->lock); -- can be a structure --andrei*/
175
+	fprintf(_f, "\n");
176
+	for(i=0; i<_d->size; i++)
177
+	{
178
+		r = _d->table[i].first;
179
+		n += _d->table[i].n;
180
+