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
... ...
@@ -138,6 +139,49 @@ int register_ulcb( struct pcontact *c, int types, ul_cb f, void *param )
138 139
 	return 1;
139 140
 }
140 141
 
142
+void delete_ulcb(struct pcontact* c, int type)
143
+{
144
+	struct ul_callback* cur;
145
+	struct ul_callback* prev;
146
+
147
+	if(c->cbs.first == 0 || ((c->cbs.reg_types) & type) == 0){
148
+		return;
149
+	}
150
+
151
+	// if the target is the first callback
152
+	cur = c->cbs.first;
153
+	if(cur->types & type){
154
+		if(cur->param){
155
+			if(*((unsigned short*)cur->param) == c->received_port){
156
+				LM_DBG("Removed ulcb from the head for contact: aor[%.*s], via port %u, received port %u, types 0x%02X\n", c->aor.len, c->aor.s, c->via_port, c->received_port, cur->types);
157
+				c->cbs.first = cur->next;
158
+				shm_free(cur);
159
+				return;
160
+			}
161
+		}
162
+	}
163
+
164
+	prev = c->cbs.first;
165
+	cur = c->cbs.first->next;
166
+	while(cur){
167
+		if(cur->types & type){
168
+			if(cur->param){
169
+				if(*((unsigned short*)cur->param) == c->received_port){
170
+					prev->next = cur->next;
171
+					LM_DBG("Removed ulcb for contact: aor[%.*s], via port %u, received port %u, types 0x%02X\n", c->aor.len, c->aor.s, c->via_port, c->received_port, cur->types);
172
+					shm_free(cur);
173
+					return;
174
+				}
175
+			}
176
+		}
177
+
178
+		prev = cur;
179
+		cur = cur->next;
180
+	}
181
+
182
+	LM_DBG("No ulcb has been deleted for contact: aor[%.*s], via port %u, received port %u\n", c->aor.len, c->aor.s, c->via_port, c->received_port);
183
+}
184
+
141 185
 /*! \brief run all transaction callbacks for an event type */
142 186
 void run_ul_callbacks( int type , struct pcontact *c)
143 187
 {
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,9 +45,9 @@
45 45
 
46 46
 #include <stdlib.h>
47 47
 
48
-#include "../../dprint.h"
49
-#include "../../error.h"
50
-#include "../../mem/shm_mem.h"
48
+#include "../../core/dprint.h"
49
+#include "../../core/error.h"
50
+#include "../../core/mem/shm_mem.h"
51 51
 #include "ul_callback.h"
52 52
 #include "usrloc.h"
53 53
 
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,167 @@
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 <stdlib.h>
47
+
48
+#include "../../dprint.h"
49
+#include "../../error.h"
50
+#include "../../mem/shm_mem.h"
51
+#include "ul_callback.h"
52
+#include "usrloc.h"
53
+
54
+struct ulcb_head_list* ulcb_list = 0;			/*<! list for create callbacks */
55
+
56
+int init_ulcb_list(void)
57
+{
58
+	ulcb_list = (struct ulcb_head_list*)shm_malloc( sizeof(struct ulcb_head_list) );
59
+	if (ulcb_list==0) {
60
+		LM_CRIT("no more shared mem\n");
61
+		return -1;
62
+	}
63
+	ulcb_list->first = 0;
64
+	ulcb_list->reg_types = 0;
65
+	return 1;
66
+}
67
+
68
+void destroy_ulcb_list(void)
69
+{
70
+	struct ul_callback *cbp, *cbp_tmp;
71
+
72
+	if (!ulcb_list)
73
+		return;
74
+
75
+	for( cbp=ulcb_list->first; cbp ; ) {
76
+		cbp_tmp = cbp;
77
+		cbp = cbp->next;
78
+		if (cbp_tmp->param) shm_free( cbp_tmp->param );
79
+		shm_free( cbp_tmp );
80
+	}
81
+
82
+	shm_free(ulcb_list);
83
+}
84
+
85
+void destroy_ul_callbacks_list(struct ul_callback* cb) {
86
+
87
+	struct ul_callback *cb_t;
88
+
89
+	while (cb) {
90
+		cb_t = cb;
91
+		cb = cb->next;
92
+//		if (cb_t->callback_param_free && cb_t->param) {
93
+//			cb_t->callback_param_free(cb_t->param);
94
+//			cb_t->param = NULL;
95
+//		} //TODO: this is if we need/require a freeparam function
96
+		shm_free(cb_t);
97
+	}
98
+}
99
+
100
+int register_ulcb( struct pcontact *c, int types, ul_cb f, void *param )
101
+{
102
+	struct ul_callback *cbp;
103
+
104
+	/* are the callback types valid?... */
105
+	if ( types<0 || types>PCSCF_MAX ) {
106
+		LM_CRIT("invalid callback types: mask=%d\n",types);
107
+		return E_BUG;
108
+	}
109
+	/* we don't register null functions */
110
+	if (f==0) {
111
+		LM_CRIT("null callback function\n");
112
+		return E_BUG;
113
+	}
114
+
115
+	/* build a new callback structure */
116
+	if (!(cbp=(struct ul_callback*)shm_malloc(sizeof( struct ul_callback)))) {
117
+		LM_ERR("no more share mem\n");
118
+		return E_OUT_OF_MEM;
119
+	}
120
+
121
+	cbp->callback = f;
122
+	cbp->param = param;
123
+	cbp->types = types;
124
+
125
+	if ( types==PCSCF_CONTACT_INSERT ) {
126
+		LM_DBG("TODO: check for registering callback before/after init\n");
127
+		/* link it into the proper place... */
128
+		cbp->next = ulcb_list->first;
129
+		ulcb_list->first = cbp;
130
+		ulcb_list->reg_types |= types;
131
+	} else {
132
+		/* link it into pcontact structure */
133
+		cbp->next = c->cbs.first;
134
+		c->cbs.first = cbp;
135
+		c->cbs.reg_types |= types;
136
+	}
137
+
138
+	return 1;
139
+}
140
+
141
+/*! \brief run all transaction callbacks for an event type */
142
+void run_ul_callbacks( int type , struct pcontact *c)
143
+{
144
+	struct ul_callback *cbp;
145
+
146
+	if (c->cbs.first == 0 || ((c->cbs.reg_types) & type) == 0)
147
+		return;
148
+
149
+	for (cbp=c->cbs.first; cbp; cbp=cbp->next) {
150
+		if ((cbp->types) & type) {
151
+			LM_DBG("contact=%p, callback type %d/%d entered\n", c, type, cbp->types);
152
+			cbp->callback( c, type, cbp->param );
153
+		}
154
+	}
155
+	return;
156
+}
157
+
158
+void run_ul_create_callbacks(struct pcontact *c)
159
+{
160
+	struct ul_callback *cbp;
161
+
162
+	for (cbp = ulcb_list->first; cbp; cbp = cbp->next) {
163
+			LM_DBG("contact=%p, callback type PCSCF_CONTACT_INSERT entered\n", c);
164
+		cbp->callback(c, PCSCF_CONTACT_INSERT, cbp->param);
165
+	}
166
+}
167
+