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
deleted file mode 100644
... ...
@@ -1,383 +0,0 @@
1
-/*
2
- * utilities
3
- *
4
- *
5
- * Copyright (C) 2001-2003 FhG Fokus
6
- *
7
- * This file is part of Kamailio, a free SIP server.
8
- *
9
- * Kamailio is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License as published by
11
- * the Free Software Foundation; either version 2 of the License, or
12
- * (at your option) any later version
13
- *
14
- * Kamailio is distributed in the hope that it will be useful,
15
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
- * GNU General Public License for more details.
18
- *
19
- * You should have received a copy of the GNU General Public License
20
- * along with this program; if not, write to the Free Software
21
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22
- *
23
- */
24
-
25
-
26
-#ifndef _TM_UT_H
27
-#define _TM_UT_H
28
-
29
-
30
-#include "../../proxy.h"
31
-#include "../../str.h"
32
-#include "../../parser/parse_uri.h"
33
-#include "../../dprint.h"
34
-#include "../../ut.h"
35
-#include "../../ip_addr.h"
36
-#include "../../error.h"
37
-#include "../../forward.h"
38
-#include "../../mem/mem.h"
39
-#include "../../parser/msg_parser.h"
40
-#include "../../resolve.h"
41
-#ifdef USE_DNS_FAILOVER
42
-#include "../../dns_cache.h"
43
-#include "../../cfg_core.h" /* cfg_get(core, core_cfg, use_dns_failover) */
44
-#endif
45
-
46
-
47
-/*! Which header fields should be skipped */
48
-#define tm_skip_hf(_hf) \
49
-	(((_hf)->type == HDR_FROM_T)  || \
50
-	((_hf)->type == HDR_TO_T)     || \
51
-	((_hf)->type == HDR_CALLID_T) || \
52
-	((_hf)->type == HDR_CSEQ_T))
53
-
54
-
55
-/* a forced_proto takes precedence if != PROTO_NONE */
56
-inline static enum sip_protos get_proto(enum sip_protos force_proto,
57
-										enum sip_protos proto)
58
-{
59
-	/* calculate transport protocol */
60
-	switch(force_proto) {
61
-		case PROTO_NONE: /* no protocol has been forced -- look at proto */
62
-			switch(proto) {
63
-				case PROTO_NONE: /* leave it to dns */
64
-						return PROTO_NONE;
65
-				case PROTO_UDP:/* transport specified explicitly */
66
-#ifdef USE_TCP
67
-				case PROTO_TCP:
68
-				case PROTO_WS:
69
-#endif
70
-#ifdef USE_TLS
71
-				case PROTO_TLS:
72
-#endif
73
-#ifdef USE_SCTP
74
-				case PROTO_SCTP:
75
-#endif
76
-						return proto;
77
-				case PROTO_WSS:	/* should never see ;transport=wss */
78
-				default:
79
-						LOG(L_ERR, "ERROR: get_proto: unsupported transport:"
80
-								" %d\n", proto );
81
-						return PROTO_NONE;
82
-			}
83
-		case PROTO_UDP: /* some protocol has been forced -- take it */
84
-#ifdef USE_TCP
85
-		case PROTO_TCP:
86
-		case PROTO_WS:
87
-#endif
88
-#ifdef USE_TLS
89
-		case PROTO_TLS:
90
-		case PROTO_WSS:
91
-#endif
92
-#ifdef USE_SCTP
93
-		case PROTO_SCTP:
94
-#endif
95
-			return force_proto;
96
-		default:
97
-			LOG(L_ERR, "ERROR: get_proto: unsupported forced protocol: "
98
-					"%d\n", force_proto);
99
-			return PROTO_NONE;
100
-	}
101
-}
102
-
103
-
104
-
105
-/*
106
- * Convert a URI into a proxy structure
107
- */
108
-inline static struct proxy_l *uri2proxy( str *uri, int proto )
109
-{
110
-	struct sip_uri parsed_uri;
111
-	struct proxy_l *p;
112
-	enum sip_protos uri_proto;
113
-
114
-	if (parse_uri(uri->s, uri->len, &parsed_uri) < 0) {
115
-		LOG(L_ERR, "ERROR: uri2proxy: bad_uri: [%.*s]\n",
116
-				uri->len, uri->s );
117
-		return 0;
118
-	}
119
-
120
-	if (parsed_uri.type==SIPS_URI_T){
121
-		if (parsed_uri.proto==PROTO_UDP) {
122
-			LOG(L_ERR, "ERROR: uri2proxy: bad transport for sips uri: %d\n",
123
-					parsed_uri.proto);
124
-			return 0;
125
-		}else if (parsed_uri.proto != PROTO_WS)
126
-			uri_proto=PROTO_TLS;
127
-		else
128
-			uri_proto=PROTO_WS;
129
-	}else
130
-		uri_proto=parsed_uri.proto;
131
-#ifdef HONOR_MADDR
132
-	if (parsed_uri.maddr_val.s && parsed_uri.maddr_val.len) {
133
-		p = mk_proxy(&parsed_uri.maddr_val,
134
-				parsed_uri.port_no,
135
-				get_proto(proto, uri_proto));
136
-		if (p == 0) {
137
-			LOG(L_ERR, "ERROR: uri2proxy: bad maddr param in URI <%.*s>\n",
138
-				uri->len, ZSW(uri->s));
139
-			return 0;
140
-		}
141
-	} else
142
-#endif
143
-	p = mk_proxy(&parsed_uri.host,
144
-			parsed_uri.port_no,
145
-			get_proto(proto, uri_proto));
146
-	if (p == 0) {
147
-		LOG(L_ERR, "ERROR: uri2proxy: bad host name in URI <%.*s>\n",
148
-				uri->len, ZSW(uri->s));
149
-		return 0;
150
-	}
151
-
152
-	return p;
153
-}
154
-
155
-
156
-
157
-/*
158
- * parse uri and return send related information
159
- * params: uri - uri in string form
160
- *         host - filled with the uri host part
161
- *         port - filled with the uri port
162
- *         proto - if != PROTO_NONE, this protocol will be forced over the
163
- *                 uri_proto, otherwise the uri proto will be used
164
- *                 (value/return)
165
- *         comp - compression (if used)
166
- * returns 0 on success, < 0 on error
167
- */
168
-inline static int get_uri_send_info(str* uri, str* host, unsigned short* port,
169
-									char* proto, short* comp)
170
-{
171
-	struct sip_uri parsed_uri;
172
-	enum sip_protos uri_proto;
173
-
174
-	if (parse_uri(uri->s, uri->len, &parsed_uri) < 0) {
175
-		LOG(L_ERR, "ERROR: get_uri_send_info: bad_uri: %.*s\n",
176
-					uri->len, uri->s );
177
-		return -1;
178
-	}
179
-
180
-	if (parsed_uri.type==SIPS_URI_T){
181
-		if (parsed_uri.proto==PROTO_UDP) {
182
-			LOG(L_ERR, "ERROR: get_uri_send_info: bad transport for"
183
-						" sips uri: %d\n", parsed_uri.proto);
184
-			return -1;
185
-		}else if (parsed_uri.proto != PROTO_WS)
186
-			uri_proto=PROTO_TLS;
187
-		else
188
-			uri_proto=PROTO_WS;
189
-	}else
190
-		uri_proto=parsed_uri.proto;
191
-
192
-	*proto= get_proto(*proto, uri_proto);
193
-#ifdef USE_COMP
194
-	*comp=parsed_uri.comp;
195
-#endif
196
-#ifdef HONOR_MADDR
197
-	if (parsed_uri.maddr_val.s && parsed_uri.maddr_val.len) {
198
-		*host=parsed_uri.maddr_val;
199
-		DBG("maddr dst: %.*s:%d\n", parsed_uri.maddr_val.len,
200
-				parsed_uri.maddr_val.s, parsed_uri.port_no);
201
-	} else
202
-#endif
203
-		*host=parsed_uri.host;
204
-	*port=parsed_uri.port_no;
205
-	return 0;
206
-}
207
-
208
-
209
-
210
-/*
211
- * Convert a URI into a dest_info structure.
212
- * Same as uri2dst, but uses directly force_send_socket instead of msg.
213
- * If the uri host resolves to multiple ips and dns_h!=0 the first ip for
214
- *  which a send socket is found will be used. If no send_socket are found,
215
- *  the first ip is selected.
216
- *
217
- * params: dns_h - pointer to a valid dns_srv_handle structure (initialized!) or
218
- *                 null. If null or use_dns_failover==0 normal dns lookup will
219
- *                 be performed (no failover).
220
- *         dst   - will be filled
221
- *         force_send_sock - if 0 dst->send_sock will be set to the default
222
- *                 (see get_send_socket2())
223
- *         sflags - send flags
224
- *         uri   - uri in str form
225
- *         proto - if != PROTO_NONE, this protocol will be forced over the
226
- *                 uri_proto, otherwise the uri proto will be used if set or
227
- *                 the proto obtained from the dns lookup
228
- * returns 0 on error, dst on success
229
- */
230
-#ifdef USE_DNS_FAILOVER
231
-inline static struct dest_info *uri2dst2(struct dns_srv_handle* dns_h,
232
-										struct dest_info* dst,
233
-										struct socket_info *force_send_socket,
234
-										snd_flags_t sflags,
235
-										str *uri, int proto )
236
-#else
237
-inline static struct dest_info *uri2dst2(struct dest_info* dst,
238
-										struct socket_info *force_send_socket,
239
-										snd_flags_t sflags,
240
-										str *uri, int proto )
241
-#endif
242
-{
243
-	struct sip_uri parsed_uri;
244
-	enum sip_protos uri_proto;
245
-	str* host;
246
-#ifdef USE_DNS_FAILOVER
247
-	int ip_found;
248
-	union sockaddr_union to;
249
-	int err;
250
-#endif
251
-
252
-	if (parse_uri(uri->s, uri->len, &parsed_uri) < 0) {
253
-		LOG(L_ERR, "ERROR: uri2dst: bad_uri: [%.*s]\n",
254
-				uri->len, uri->s );
255
-		return 0;
256
-	}
257
-
258
-	if (parsed_uri.type==SIPS_URI_T){
259
-		if (parsed_uri.proto==PROTO_UDP) {
260
-			LOG(L_ERR, "ERROR: uri2dst: bad transport for sips uri: %d\n",
261
-					parsed_uri.proto);
262
-			return 0;
263
-		}else if (parsed_uri.proto!=PROTO_WS)
264
-			uri_proto=PROTO_TLS;
265
-		else
266
-			uri_proto=PROTO_WS;
267
-	}else
268
-		uri_proto=parsed_uri.proto;
269
-
270
-	init_dest_info(dst);
271
-	dst->proto= get_proto(proto, uri_proto);
272
-#ifdef USE_COMP
273
-	dst->comp=parsed_uri.comp;
274
-#endif
275
-	dst->send_flags=sflags;
276
-#ifdef HONOR_MADDR
277
-	if (parsed_uri.maddr_val.s && parsed_uri.maddr_val.len) {
278
-		host=&parsed_uri.maddr_val;
279
-		DBG("maddr dst: [%.*s:%d]\n", parsed_uri.maddr_val.len,
280
-								parsed_uri.maddr_val.s, parsed_uri.port_no);
281
-	} else
282
-#endif
283
-		host=&parsed_uri.host;
284
-#ifdef USE_DNS_FAILOVER
285
-	if (cfg_get(core, core_cfg, use_dns_failover) && dns_h){
286
-		ip_found=0;
287
-		do{
288
-			/* try all the ips until we find a good send socket */
289
-			err=dns_sip_resolve2su(dns_h, &to, host,
290
-								parsed_uri.port_no, &dst->proto, dns_flags);
291
-			if (err!=0){
292
-				if (ip_found==0){
293
-					if (err!=-E_DNS_EOR)
294
-						LOG(L_ERR, "ERROR: uri2dst: failed to resolve \"%.*s\" :"
295
-								"%s (%d)\n", host->len, ZSW(host->s),
296
-									dns_strerror(err), err);
297
-					return 0; /* error, no ip found */
298
-				}
299
-				break;
300
-			}
301
-			if (ip_found==0){
302
-				dst->to=to;
303
-				ip_found=1;
304
-			}
305
-			dst->send_sock = get_send_socket2(force_send_socket, &to,
306
-												dst->proto, 0);
307
-			if (dst->send_sock){
308
-				dst->to=to;
309
-				return dst; /* found a good one */
310
-			}
311
-		}while(dns_srv_handle_next(dns_h, err));
312
-		ERR("no corresponding socket for \"%.*s\" af %d\n", host->len,
313
-				ZSW(host->s), dst->to.s.sa_family);
314
-		/* try to continue */
315
-		return dst;
316
-	}
317
-#endif
318
-	if (sip_hostport2su(&dst->to, host, parsed_uri.port_no, &dst->proto)!=0){
319
-		ERR("failed to resolve \"%.*s\"\n", host->len, ZSW(host->s));
320
-		return 0;
321
-	}
322
-	dst->send_sock = get_send_socket2(force_send_socket, &dst->to,
323
-										dst->proto, 0);
324
-	if (dst->send_sock==0) {
325
-		ERR("no corresponding socket found for \"%.*s\" af %d (%s:%s)\n",
326
-			host->len, ZSW(host->s), dst->to.s.sa_family,
327
-			proto2a(dst->proto), su2a(&dst->to, sizeof(dst->to)));
328
-		/* ser_error = E_NO_SOCKET;*/
329
-		/* try to continue */
330
-	}
331
-	return dst;
332
-}
333
-
334
-
335
-
336
-/*
337
- * Convert a URI into a dest_info structure
338
- * If the uri host resolves to multiple ips and dns_h!=0 the first ip for
339
- *  which a send socket is found will be used. If no send_socket are found,
340
- *  the first ip is selected.
341
- *
342
- * params: dns_h - pointer to a valid dns_srv_handle structure (initialized!) or
343
- *                 null. If null or use_dns_failover==0 normal dns lookup will
344
- *                 be performed (no failover).
345
- *         dst   - will be filled
346
- *         msg   -  sip message used to set dst->send_sock and dst->send_flags,
347
- *                 if 0 dst->send_sock will be set to the default w/o using
348
- *                  msg->force_send_socket (see get_send_socket()) and the
349
- *                  send_flags will be set to 0.
350
- *         uri   - uri in str form
351
- *         proto - if != PROTO_NONE, this protocol will be forced over the
352
- *                 uri_proto, otherwise the uri proto will be used if set or
353
- *                 the proto obtained from the dns lookup
354
- * returns 0 on error, dst on success
355
- */
356
-#ifdef USE_DNS_FAILOVER
357
-inline static struct dest_info *uri2dst(struct dns_srv_handle* dns_h,
358
-										struct dest_info* dst,
359
-										struct sip_msg *msg, str *uri,
360
-											int proto )
361
-{
362
-	snd_flags_t sflags;
363
-	if (msg)
364
-		return uri2dst2(dns_h, dst, msg->force_send_socket,
365
-							msg->fwd_send_flags, uri, proto);
366
-	SND_FLAGS_INIT(&sflags);
367
-	return uri2dst2(dns_h, dst, 0, sflags, uri, proto);
368
-}
369
-#else
370
-inline static struct dest_info *uri2dst(struct dest_info* dst,
371
-										struct sip_msg *msg, str *uri,
372
-											int proto )
373
-{
374
-	snd_flags_t sflags;
375
-	if (msg)
376
-		return uri2dst2(dst, msg->force_send_socket, msg->fwd_send_flags,
377
-						uri, proto);
378
-	SND_FLAGS_INIT(&sflags);
379
-	return uri2dst2(dst, 0, sflags, uri, proto);
380
-}
381
-#endif /* USE_DNS_FAILOVER */
382
-
383
-#endif /* _TM_UT_H */
Browse code

tm: wrap uri values in brackets inside error messages

- easier to spot invalid empty chars
- useless spaces removed

Daniel-Constantin Mierla authored on 14/07/2016 06:43:05
Showing 1 changed files
... ...
@@ -16,8 +16,8 @@
16 16
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 17
  * GNU General Public License for more details.
18 18
  *
19
- * You should have received a copy of the GNU General Public License 
20
- * along with this program; if not, write to the Free Software 
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with this program; if not, write to the Free Software
21 21
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 22
  *
23 23
  */
... ...
@@ -112,11 +112,11 @@ inline static struct proxy_l *uri2proxy( str *uri, int proto )
112 112
 	enum sip_protos uri_proto;
113 113
 
114 114
 	if (parse_uri(uri->s, uri->len, &parsed_uri) < 0) {
115
-		LOG(L_ERR, "ERROR: uri2proxy: bad_uri: %.*s\n",
116
-		    uri->len, uri->s );
115
+		LOG(L_ERR, "ERROR: uri2proxy: bad_uri: [%.*s]\n",
116
+				uri->len, uri->s );
117 117
 		return 0;
118 118
 	}
119
-	
119
+
120 120
 	if (parsed_uri.type==SIPS_URI_T){
121 121
 		if (parsed_uri.proto==PROTO_UDP) {
122 122
 			LOG(L_ERR, "ERROR: uri2proxy: bad transport for sips uri: %d\n",
... ...
@@ -130,9 +130,9 @@ inline static struct proxy_l *uri2proxy( str *uri, int proto )
130 130
 		uri_proto=parsed_uri.proto;
131 131
 #ifdef HONOR_MADDR
132 132
 	if (parsed_uri.maddr_val.s && parsed_uri.maddr_val.len) {
133
-		p = mk_proxy(&parsed_uri.maddr_val, 
134
-					  parsed_uri.port_no, 
135
-					  get_proto(proto, uri_proto));
133
+		p = mk_proxy(&parsed_uri.maddr_val,
134
+				parsed_uri.port_no,
135
+				get_proto(proto, uri_proto));
136 136
 		if (p == 0) {
137 137
 			LOG(L_ERR, "ERROR: uri2proxy: bad maddr param in URI <%.*s>\n",
138 138
 				uri->len, ZSW(uri->s));
... ...
@@ -140,15 +140,15 @@ inline static struct proxy_l *uri2proxy( str *uri, int proto )
140 140
 		}
141 141
 	} else
142 142
 #endif
143
-	p = mk_proxy(&parsed_uri.host, 
144
-				  parsed_uri.port_no, 
145
-				  get_proto(proto, uri_proto));
143
+	p = mk_proxy(&parsed_uri.host,
144
+			parsed_uri.port_no,
145
+			get_proto(proto, uri_proto));
146 146
 	if (p == 0) {
147 147
 		LOG(L_ERR, "ERROR: uri2proxy: bad host name in URI <%.*s>\n",
148
-		    uri->len, ZSW(uri->s));
148
+				uri->len, ZSW(uri->s));
149 149
 		return 0;
150 150
 	}
151
-	
151
+
152 152
 	return p;
153 153
 }
154 154
 
... ...
@@ -160,7 +160,7 @@ inline static struct proxy_l *uri2proxy( str *uri, int proto )
160 160
  *         host - filled with the uri host part
161 161
  *         port - filled with the uri port
162 162
  *         proto - if != PROTO_NONE, this protocol will be forced over the
163
- *                 uri_proto, otherwise the uri proto will be used 
163
+ *                 uri_proto, otherwise the uri proto will be used
164 164
  *                 (value/return)
165 165
  *         comp - compression (if used)
166 166
  * returns 0 on success, < 0 on error
... ...
@@ -170,13 +170,13 @@ inline static int get_uri_send_info(str* uri, str* host, unsigned short* port,
170 170
 {
171 171
 	struct sip_uri parsed_uri;
172 172
 	enum sip_protos uri_proto;
173
-	
173
+
174 174
 	if (parse_uri(uri->s, uri->len, &parsed_uri) < 0) {
175 175
 		LOG(L_ERR, "ERROR: get_uri_send_info: bad_uri: %.*s\n",
176 176
 					uri->len, uri->s );
177 177
 		return -1;
178 178
 	}
179
-	
179
+
180 180
 	if (parsed_uri.type==SIPS_URI_T){
181 181
 		if (parsed_uri.proto==PROTO_UDP) {
182 182
 			LOG(L_ERR, "ERROR: get_uri_send_info: bad transport for"
... ...
@@ -188,7 +188,7 @@ inline static int get_uri_send_info(str* uri, str* host, unsigned short* port,
188 188
 			uri_proto=PROTO_WS;
189 189
 	}else
190 190
 		uri_proto=parsed_uri.proto;
191
-	
191
+
192 192
 	*proto= get_proto(*proto, uri_proto);
193 193
 #ifdef USE_COMP
194 194
 	*comp=parsed_uri.comp;
... ...
@@ -196,7 +196,7 @@ inline static int get_uri_send_info(str* uri, str* host, unsigned short* port,
196 196
 #ifdef HONOR_MADDR
197 197
 	if (parsed_uri.maddr_val.s && parsed_uri.maddr_val.len) {
198 198
 		*host=parsed_uri.maddr_val;
199
-		DBG("maddr dst: %.*s:%d\n", parsed_uri.maddr_val.len, 
199
+		DBG("maddr dst: %.*s:%d\n", parsed_uri.maddr_val.len,
200 200
 				parsed_uri.maddr_val.s, parsed_uri.port_no);
201 201
 	} else
202 202
 #endif
... ...
@@ -210,7 +210,7 @@ inline static int get_uri_send_info(str* uri, str* host, unsigned short* port,
210 210
 /*
211 211
  * Convert a URI into a dest_info structure.
212 212
  * Same as uri2dst, but uses directly force_send_socket instead of msg.
213
- * If the uri host resolves to multiple ips and dns_h!=0 the first ip for 
213
+ * If the uri host resolves to multiple ips and dns_h!=0 the first ip for
214 214
  *  which a send socket is found will be used. If no send_socket are found,
215 215
  *  the first ip is selected.
216 216
  *
... ...
@@ -218,8 +218,8 @@ inline static int get_uri_send_info(str* uri, str* host, unsigned short* port,
218 218
  *                 null. If null or use_dns_failover==0 normal dns lookup will
219 219
  *                 be performed (no failover).
220 220
  *         dst   - will be filled
221
- *         force_send_sock - if 0 dst->send_sock will be set to the default 
222
- *                 (see get_send_socket2()) 
221
+ *         force_send_sock - if 0 dst->send_sock will be set to the default
222
+ *                 (see get_send_socket2())
223 223
  *         sflags - send flags
224 224
  *         uri   - uri in str form
225 225
  *         proto - if != PROTO_NONE, this protocol will be forced over the
... ...
@@ -250,11 +250,11 @@ inline static struct dest_info *uri2dst2(struct dest_info* dst,
250 250
 #endif
251 251
 
252 252
 	if (parse_uri(uri->s, uri->len, &parsed_uri) < 0) {
253
-		LOG(L_ERR, "ERROR: uri2dst: bad_uri: %.*s\n",
254
-		    uri->len, uri->s );
253
+		LOG(L_ERR, "ERROR: uri2dst: bad_uri: [%.*s]\n",
254
+				uri->len, uri->s );
255 255
 		return 0;
256 256
 	}
257
-	
257
+
258 258
 	if (parsed_uri.type==SIPS_URI_T){
259 259
 		if (parsed_uri.proto==PROTO_UDP) {
260 260
 			LOG(L_ERR, "ERROR: uri2dst: bad transport for sips uri: %d\n",
... ...
@@ -266,7 +266,7 @@ inline static struct dest_info *uri2dst2(struct dest_info* dst,
266 266
 			uri_proto=PROTO_WS;
267 267
 	}else
268 268
 		uri_proto=parsed_uri.proto;
269
-	
269
+
270 270
 	init_dest_info(dst);
271 271
 	dst->proto= get_proto(proto, uri_proto);
272 272
 #ifdef USE_COMP
... ...
@@ -276,7 +276,7 @@ inline static struct dest_info *uri2dst2(struct dest_info* dst,
276 276
 #ifdef HONOR_MADDR
277 277
 	if (parsed_uri.maddr_val.s && parsed_uri.maddr_val.len) {
278 278
 		host=&parsed_uri.maddr_val;
279
-		DBG("maddr dst: %.*s:%d\n", parsed_uri.maddr_val.len, 
279
+		DBG("maddr dst: [%.*s:%d]\n", parsed_uri.maddr_val.len,
280 280
 								parsed_uri.maddr_val.s, parsed_uri.port_no);
281 281
 	} else
282 282
 #endif
... ...
@@ -309,7 +309,7 @@ inline static struct dest_info *uri2dst2(struct dest_info* dst,
309 309
 				return dst; /* found a good one */
310 310
 			}
311 311
 		}while(dns_srv_handle_next(dns_h, err));
312
-		ERR("no corresponding socket for \"%.*s\" af %d\n", host->len, 
312
+		ERR("no corresponding socket for \"%.*s\" af %d\n", host->len,
313 313
 				ZSW(host->s), dst->to.s.sa_family);
314 314
 		/* try to continue */
315 315
 		return dst;
... ...
@@ -335,7 +335,7 @@ inline static struct dest_info *uri2dst2(struct dest_info* dst,
335 335
 
336 336
 /*
337 337
  * Convert a URI into a dest_info structure
338
- * If the uri host resolves to multiple ips and dns_h!=0 the first ip for 
338
+ * If the uri host resolves to multiple ips and dns_h!=0 the first ip for
339 339
  *  which a send socket is found will be used. If no send_socket are found,
340 340
  *  the first ip is selected.
341 341
  *
... ...
@@ -344,8 +344,8 @@ inline static struct dest_info *uri2dst2(struct dest_info* dst,
344 344
  *                 be performed (no failover).
345 345
  *         dst   - will be filled
346 346
  *         msg   -  sip message used to set dst->send_sock and dst->send_flags,
347
- *                 if 0 dst->send_sock will be set to the default w/o using 
348
- *                  msg->force_send_socket (see get_send_socket()) and the 
347
+ *                 if 0 dst->send_sock will be set to the default w/o using
348
+ *                  msg->force_send_socket (see get_send_socket()) and the
349 349
  *                  send_flags will be set to 0.
350 350
  *         uri   - uri in str form
351 351
  *         proto - if != PROTO_NONE, this protocol will be forced over the
... ...
@@ -356,7 +356,7 @@ inline static struct dest_info *uri2dst2(struct dest_info* dst,
356 356
 #ifdef USE_DNS_FAILOVER
357 357
 inline static struct dest_info *uri2dst(struct dns_srv_handle* dns_h,
358 358
 										struct dest_info* dst,
359
-										struct sip_msg *msg, str *uri, 
359
+										struct sip_msg *msg, str *uri,
360 360
 											int proto )
361 361
 {
362 362
 	snd_flags_t sflags;
... ...
@@ -368,7 +368,7 @@ inline static struct dest_info *uri2dst(struct dns_srv_handle* dns_h,
368 368
 }
369 369
 #else
370 370
 inline static struct dest_info *uri2dst(struct dest_info* dst,
371
-										struct sip_msg *msg, str *uri, 
371
+										struct sip_msg *msg, str *uri,
372 372
 											int proto )
373 373
 {
374 374
 	snd_flags_t sflags;
Browse code

tm: fix spelling errors catched by lintian #688

Victor Seva authored on 29/06/2016 15:06:41
Showing 1 changed files
... ...
@@ -214,7 +214,7 @@ inline static int get_uri_send_info(str* uri, str* host, unsigned short* port,
214 214
  *  which a send socket is found will be used. If no send_socket are found,
215 215
  *  the first ip is selected.
216 216
  *
217
- * params: dns_h - pointer to a valid dns_srv_handle structure (intialized!) or
217
+ * params: dns_h - pointer to a valid dns_srv_handle structure (initialized!) or
218 218
  *                 null. If null or use_dns_failover==0 normal dns lookup will
219 219
  *                 be performed (no failover).
220 220
  *         dst   - will be filled
... ...
@@ -339,7 +339,7 @@ inline static struct dest_info *uri2dst2(struct dest_info* dst,
339 339
  *  which a send socket is found will be used. If no send_socket are found,
340 340
  *  the first ip is selected.
341 341
  *
342
- * params: dns_h - pointer to a valid dns_srv_handle structure (intialized!) or
342
+ * params: dns_h - pointer to a valid dns_srv_handle structure (initialized!) or
343 343
  *                 null. If null or use_dns_failover==0 normal dns lookup will
344 344
  *                 be performed (no failover).
345 345
  *         dst   - will be filled
Browse code

tm Remove svn ID, remove history, rename "ser" to "kamailio"

Olle E. Johansson authored on 03/01/2015 15:48:29
Showing 1 changed files
... ...
@@ -1,24 +1,17 @@
1 1
 /*
2
- * $Id$
3
- *
4 2
  * utilities
5 3
  *
6 4
  *
7 5
  * Copyright (C) 2001-2003 FhG Fokus
8 6
  *
9
- * This file is part of ser, a free SIP server.
7
+ * This file is part of Kamailio, a free SIP server.
10 8
  *
11
- * ser is free software; you can redistribute it and/or modify
9
+ * Kamailio is free software; you can redistribute it and/or modify
12 10
  * it under the terms of the GNU General Public License as published by
13 11
  * the Free Software Foundation; either version 2 of the License, or
14 12
  * (at your option) any later version
15 13
  *
16
- * For a license to use the ser software under conditions
17
- * other than those described here, or to purchase support for this
18
- * software, please contact iptel.org by e-mail at the following addresses:
19
- *    info@iptel.org
20
- *
21
- * ser is distributed in the hope that it will be useful,
14
+ * Kamailio is distributed in the hope that it will be useful,
22 15
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 16
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24 17
  * GNU General Public License for more details.
... ...
@@ -27,17 +20,6 @@
27 20
  * along with this program; if not, write to the Free Software 
28 21
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
29 22
  *
30
- * History:
31
- * -------
32
- *  2003-02-13  added proto to uri2proxy (andrei)
33
- *  2003-04-09  uri2sock moved from uac.c (janakj)
34
- *  2003-04-14  added get_proto to determine protocol from uri unless
35
- *              specified explicitly (jiri)
36
- *  2003-07-07  get_proto takes now two protos as arguments (andrei)
37
- *              tls/sips support for get_proto & uri2proxy (andrei)
38
- *  2006-04-13  added uri2dst(), simplified uri2sock() (andrei)
39
- *  2006-08-11  dns failover support: uri2dst uses the dns cache and tries to 
40
- *               get the first ip for which there is a send sock. (andrei)
41 23
  */
42 24
 
43 25
 
Browse code

tm: more verbose debug when failing to find socket for forwarding

Daniel-Constantin Mierla authored on 02/10/2014 14:34:02
Showing 1 changed files
... ...
@@ -340,7 +340,9 @@ inline static struct dest_info *uri2dst2(struct dest_info* dst,
340 340
 	dst->send_sock = get_send_socket2(force_send_socket, &dst->to,
341 341
 										dst->proto, 0);
342 342
 	if (dst->send_sock==0) {
343
-		ERR("no corresponding socket for af %d\n", dst->to.s.sa_family);
343
+		ERR("no corresponding socket found for \"%.*s\" af %d (%s:%s)\n",
344
+			host->len, ZSW(host->s), dst->to.s.sa_family,
345
+			proto2a(dst->proto), su2a(&dst->to, sizeof(dst->to)));
344 346
 		/* ser_error = E_NO_SOCKET;*/
345 347
 		/* try to continue */
346 348
 	}
Browse code

all: updated FSF address in GPL text

Anthony Messina authored on 04/07/2014 09:36:37 • Daniel-Constantin Mierla committed on 04/07/2014 09:37:36
Showing 1 changed files
... ...
@@ -25,7 +25,7 @@
25 25
  *
26 26
  * You should have received a copy of the GNU General Public License 
27 27
  * along with this program; if not, write to the Free Software 
28
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
29 29
  *
30 30
  * History:
31 31
  * -------
Browse code

everything: shotgun attempt to put PROTO_WS and PROTO_WSS across core and in modules I use

- Bound to have missed something and lots of testing required.

Peter Dunkley authored on 29/06/2012 23:01:07
Showing 1 changed files
... ...
@@ -92,6 +92,7 @@ inline static enum sip_protos get_proto(enum sip_protos force_proto,
92 92
 				case PROTO_SCTP:
93 93
 #endif
94 94
 						return proto;
95
+				case PROTO_WSS:	/* should never see ;transport=wss */
95 96
 				default:
96 97
 						LOG(L_ERR, "ERROR: get_proto: unsupported transport:"
97 98
 								" %d\n", proto );
... ...
@@ -104,6 +105,7 @@ inline static enum sip_protos get_proto(enum sip_protos force_proto,
104 105
 #endif
105 106
 #ifdef USE_TLS
106 107
 		case PROTO_TLS:
108
+		case PROTO_WSS:
107 109
 #endif
108 110
 #ifdef USE_SCTP
109 111
 		case PROTO_SCTP:
... ...
@@ -138,8 +140,10 @@ inline static struct proxy_l *uri2proxy( str *uri, int proto )
138 140
 			LOG(L_ERR, "ERROR: uri2proxy: bad transport for sips uri: %d\n",
139 141
 					parsed_uri.proto);
140 142
 			return 0;
141
-		}else
143
+		}else if (parsed_uri.proto != PROTO_WS)
142 144
 			uri_proto=PROTO_TLS;
145
+		else
146
+			uri_proto=PROTO_WS;
143 147
 	}else
144 148
 		uri_proto=parsed_uri.proto;
145 149
 #ifdef HONOR_MADDR
... ...
@@ -196,8 +200,10 @@ inline static int get_uri_send_info(str* uri, str* host, unsigned short* port,
196 200
 			LOG(L_ERR, "ERROR: get_uri_send_info: bad transport for"
197 201
 						" sips uri: %d\n", parsed_uri.proto);
198 202
 			return -1;
199
-		}else
203
+		}else if (parsed_uri.proto != PROTO_WS)
200 204
 			uri_proto=PROTO_TLS;
205
+		else
206
+			uri_proto=PROTO_WS;
201 207
 	}else
202 208
 		uri_proto=parsed_uri.proto;
203 209
 	
... ...
@@ -272,8 +278,10 @@ inline static struct dest_info *uri2dst2(struct dest_info* dst,
272 278
 			LOG(L_ERR, "ERROR: uri2dst: bad transport for sips uri: %d\n",
273 279
 					parsed_uri.proto);
274 280
 			return 0;
275
-		}else
281
+		}else if (parsed_uri.proto!=PROTO_WS)
276 282
 			uri_proto=PROTO_TLS;
283
+		else
284
+			uri_proto=PROTO_WS;
277 285
 	}else
278 286
 		uri_proto=parsed_uri.proto;
279 287
 	
Browse code

modules/tm: Added PROTO_WS support

Peter Dunkley authored on 29/06/2012 16:46:36
Showing 1 changed files
... ...
@@ -83,6 +83,7 @@ inline static enum sip_protos get_proto(enum sip_protos force_proto,
83 83
 				case PROTO_UDP:/* transport specified explicitly */
84 84
 #ifdef USE_TCP
85 85
 				case PROTO_TCP:
86
+				case PROTO_WS:
86 87
 #endif
87 88
 #ifdef USE_TLS
88 89
 				case PROTO_TLS:
... ...
@@ -99,6 +100,7 @@ inline static enum sip_protos get_proto(enum sip_protos force_proto,
99 100
 		case PROTO_UDP: /* some protocol has been forced -- take it */
100 101
 #ifdef USE_TCP
101 102
 		case PROTO_TCP:
103
+		case PROTO_WS:
102 104
 #endif
103 105
 #ifdef USE_TLS
104 106
 		case PROTO_TLS:
Browse code

tm: delete obselete uri2sock function, its not compiled since almost 5 years

Henning Westerholt authored on 05/07/2011 21:50:10
Showing 1 changed files
... ...
@@ -386,38 +386,4 @@ inline static struct dest_info *uri2dst(struct dest_info* dst,
386 386
 }
387 387
 #endif /* USE_DNS_FAILOVER */
388 388
 
389
-
390
-
391
-#if 0
392
-/*
393
- * Convert a URI into the corresponding sockaddr_union (address to send to) and
394
- *  send socket_info (socket/address from which to send)
395
- *  to_su is filled with the destination and the socket_info that will be 
396
- *  used for sending is returned.
397
- *  On error return 0.
398
- *
399
- *  NOTE: this function is deprecated, you should use uri2dst instead
400
- */
401
-static inline struct socket_info *uri2sock(struct sip_msg* msg, str *uri,
402
-									union sockaddr_union *to_su, int proto)
403
-{
404
-	struct dest_info dst;
405
-
406
-	if (uri2dst(&dst, msg, uri, proto)==0){
407
-		LOG(L_ERR, "ERROR: uri2sock: Can't create a dst proxy\n");
408
-		ser_error=E_BAD_ADDRESS;
409
-		return 0;
410
-	}
411
-	*to_su=dst.to; /* copy su */
412
-	
413
-	/* we use dst->send_socket since uri2dst just set it correctly*/
414
-	if (dst.send_sock==0) {
415
-		LOG(L_ERR, "ERROR: uri2sock: no corresponding socket for af %d\n", 
416
-		    to_su->s.sa_family);
417
-		ser_error = E_NO_SOCKET;
418
-	}
419
-	return dst.send_sock;
420
-}
421
-#endif
422
-
423 389
 #endif /* _TM_UT_H */
Browse code

tm, tmx: move small redundant skip_hf macro to ut.h

- move small redundant skip_hf macro in in tm and tmx to tm/ut.h file
- this header is already included from the callers
- rename macro to a bit more descriptive name, no other changes

Henning Westerholt authored on 05/07/2011 21:44:11
Showing 1 changed files
... ...
@@ -61,6 +61,15 @@
61 61
 #include "../../cfg_core.h" /* cfg_get(core, core_cfg, use_dns_failover) */
62 62
 #endif
63 63
 
64
+
65
+/*! Which header fields should be skipped */
66
+#define tm_skip_hf(_hf) \
67
+	(((_hf)->type == HDR_FROM_T)  || \
68
+	((_hf)->type == HDR_TO_T)     || \
69
+	((_hf)->type == HDR_CALLID_T) || \
70
+	((_hf)->type == HDR_CSEQ_T))
71
+
72
+
64 73
 /* a forced_proto takes precedence if != PROTO_NONE */
65 74
 inline static enum sip_protos get_proto(enum sip_protos force_proto,
66 75
 										enum sip_protos proto)
Browse code

tm: updated to the new snd_flags_t structure

Andrei Pelinescu-Onciul authored on 17/12/2009 12:29:50
Showing 1 changed files
... ...
@@ -356,16 +356,24 @@ inline static struct dest_info *uri2dst(struct dns_srv_handle* dns_h,
356 356
 										struct sip_msg *msg, str *uri, 
357 357
 											int proto )
358 358
 {
359
-	return uri2dst2(dns_h, dst, msg?msg->force_send_socket:0,
360
-						msg?msg->fwd_send_flags:0, uri, proto);
359
+	snd_flags_t sflags;
360
+	if (msg)
361
+		return uri2dst2(dns_h, dst, msg->force_send_socket,
362
+							msg->fwd_send_flags, uri, proto);
363
+	SND_FLAGS_INIT(&sflags);
364
+	return uri2dst2(dns_h, dst, 0, sflags, uri, proto);
361 365
 }
362 366
 #else
363 367
 inline static struct dest_info *uri2dst(struct dest_info* dst,
364 368
 										struct sip_msg *msg, str *uri, 
365 369
 											int proto )
366 370
 {
367
-	return uri2dst2(dst, msg?msg->force_send_socket:0,
368
-						msg?msg->fwd_send_flags:0, uri, proto);
371
+	snd_flags_t sflags;
372
+	if (msg)
373
+		return uri2dst2(dst, msg->force_send_socket, msg->fwd_send_flags,
374
+						uri, proto);
375
+	SND_FLAGS_INIT(&sflags);
376
+	return uri2dst2(dst, 0, sflags, uri, proto);
369 377
 }
370 378
 #endif /* USE_DNS_FAILOVER */
371 379
 
Browse code

tm: support for send_flags

The send_flags are taken from the current message and added to the
retr_bufs (for branch uacs and replies).

Andrei Pelinescu-Onciul authored on 15/09/2009 15:43:24
Showing 1 changed files
... ...
@@ -221,6 +221,7 @@ inline static int get_uri_send_info(str* uri, str* host, unsigned short* port,
221 221
  *         dst   - will be filled
222 222
  *         force_send_sock - if 0 dst->send_sock will be set to the default 
223 223
  *                 (see get_send_socket2()) 
224
+ *         sflags - send flags
224 225
  *         uri   - uri in str form
225 226
  *         proto - if != PROTO_NONE, this protocol will be forced over the
226 227
  *                 uri_proto, otherwise the uri proto will be used if set or
... ...
@@ -231,10 +232,12 @@ inline static int get_uri_send_info(str* uri, str* host, unsigned short* port,
231 232
 inline static struct dest_info *uri2dst2(struct dns_srv_handle* dns_h,
232 233
 										struct dest_info* dst,
233 234
 										struct socket_info *force_send_socket,
235
+										snd_flags_t sflags,
234 236
 										str *uri, int proto )
235 237
 #else
236 238
 inline static struct dest_info *uri2dst2(struct dest_info* dst,
237 239
 										struct socket_info *force_send_socket,
240
+										snd_flags_t sflags,
238 241
 										str *uri, int proto )
239 242
 #endif
240 243
 {
... ...
@@ -268,6 +271,7 @@ inline static struct dest_info *uri2dst2(struct dest_info* dst,
268 271
 #ifdef USE_COMP
269 272
 	dst->comp=parsed_uri.comp;
270 273
 #endif
274
+	dst->send_flags=sflags;
271 275
 #ifdef HONOR_MADDR
272 276
 	if (parsed_uri.maddr_val.s && parsed_uri.maddr_val.len) {
273 277
 		host=&parsed_uri.maddr_val;
... ...
@@ -336,9 +340,10 @@ inline static struct dest_info *uri2dst2(struct dest_info* dst,
336 340
  *                 null. If null or use_dns_failover==0 normal dns lookup will
337 341
  *                 be performed (no failover).
338 342
  *         dst   - will be filled
339
- *         msg   -  sip message used to set dst->send_sock, if 0 dst->send_sock
340
- *                 will be set to the default w/o using msg->force_send_socket 
341
- *                 (see get_send_socket()) 
343
+ *         msg   -  sip message used to set dst->send_sock and dst->send_flags,
344
+ *                 if 0 dst->send_sock will be set to the default w/o using 
345
+ *                  msg->force_send_socket (see get_send_socket()) and the 
346
+ *                  send_flags will be set to 0.
342 347
  *         uri   - uri in str form
343 348
  *         proto - if != PROTO_NONE, this protocol will be forced over the
344 349
  *                 uri_proto, otherwise the uri proto will be used if set or
... ...
@@ -351,14 +356,16 @@ inline static struct dest_info *uri2dst(struct dns_srv_handle* dns_h,
351 356
 										struct sip_msg *msg, str *uri, 
352 357
 											int proto )
353 358
 {
354
-	return uri2dst2(dns_h, dst, msg?msg->force_send_socket:0, uri, proto);
359
+	return uri2dst2(dns_h, dst, msg?msg->force_send_socket:0,
360
+						msg?msg->fwd_send_flags:0, uri, proto);
355 361
 }
356 362
 #else
357 363
 inline static struct dest_info *uri2dst(struct dest_info* dst,
358 364
 										struct sip_msg *msg, str *uri, 
359 365
 											int proto )
360 366
 {
361
-	return uri2dst2(dst, msg?msg->force_send_socket:0, uri, proto);
367
+	return uri2dst2(dst, msg?msg->force_send_socket:0,
368
+						msg?msg->fwd_send_flags:0, uri, proto);
362 369
 }
363 370
 #endif /* USE_DNS_FAILOVER */
364 371
 
Browse code

tm: new uri2dst() version

- new uri2dst2() function which can have the send_socket passed
directly to it.
- uri2dst() is now a wrapper over uri2dst2().

Andrei Pelinescu-Onciul authored on 20/07/2009 23:15:02
Showing 1 changed files
... ...
@@ -209,7 +209,8 @@ inline static int get_uri_send_info(str* uri, str* host, unsigned short* port,
209 209
 
210 210
 
211 211
 /*
212
- * Convert a URI into a dest_info structure
212
+ * Convert a URI into a dest_info structure.
213
+ * Same as uri2dst, but uses directly force_send_socket instead of msg.
213 214
  * If the uri host resolves to multiple ips and dns_h!=0 the first ip for 
214 215
  *  which a send socket is found will be used. If no send_socket are found,
215 216
  *  the first ip is selected.
... ...
@@ -218,9 +219,8 @@ inline static int get_uri_send_info(str* uri, str* host, unsigned short* port,
218 219
  *                 null. If null or use_dns_failover==0 normal dns lookup will
219 220
  *                 be performed (no failover).
220 221
  *         dst   - will be filled
221
- *         msg   -  sip message used to set dst->send_sock, if 0 dst->send_sock