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,113 +0,0 @@
1
-/*
2
- * Copyright (C) 2001-2003 FhG Fokus
3
- *
4
- * This file is part of Kamailio, a free SIP server.
5
- *
6
- * Kamailio is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version
10
- *
11
- * Kamailio is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License 
17
- * along with this program; if not, write to the Free Software 
18
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19
- */
20
-
21
-/*! \file
22
- * \brief Parser :: SIP From header parsing
23
- *
24
- * \ingroup parser
25
- */
26
-
27
-#include "parse_from.h"
28
-#include "parse_to.h"
29
-#include <stdlib.h>
30
-#include <string.h>
31
-#include "../dprint.h"
32
-#include "msg_parser.h"
33
-#include "parse_uri.h"
34
-#include "../ut.h"
35
-#include "../mem/mem.h"
36
-
37
-/*! \brief
38
- * This method is used to parse the from header.
39
- *
40
- * \note It was decided not to parse
41
- * anything in core that is not *needed* so this method gets called by 
42
- * rad_acc module and any other modules that needs the FROM header.
43
- *
44
- * params: msg : sip msg
45
- * returns 0 on success,
46
- *        -1 on failure.
47
- */
48
-int parse_from_header( struct sip_msg *msg)
49
-{
50
-	struct to_body* from_b;
51
-
52
-	if ( !msg->from && ( parse_headers(msg,HDR_FROM_F,0)==-1 || !msg->from)) {
53
-		LOG(L_ERR,"ERROR:parse_from_header: bad msg or missing FROM header\n");
54
-		goto error;
55
-	}
56
-
57
-	/* maybe the header is already parsed! */
58
-	if (msg->from->parsed)
59
-		return 0;
60
-
61
-	/* bad luck! :-( - we have to parse it */
62
-	/* first, get some memory */
63
-	from_b = pkg_malloc(sizeof(struct to_body));
64
-	if (from_b == 0) {
65
-		LOG(L_ERR, "ERROR:parse_from_header: out of pkg_memory\n");
66
-		goto error;
67
-	}
68
-
69
-	/* now parse it!! */
70
-	memset(from_b, 0, sizeof(struct to_body));
71
-	parse_to(msg->from->body.s,msg->from->body.s+msg->from->body.len+1,from_b);
72
-	if (from_b->error == PARSE_ERROR) {
73
-		LOG(L_ERR, "ERROR:parse_from_header: bad from header [%.*s]\n",
74
-				msg->from->body.len, msg->from->body.s);
75
-		free_to(from_b);
76
-		goto error;
77
-	}
78
-	msg->from->parsed = from_b;
79
-
80
-	return 0;
81
-error:
82
-	return -1;
83
-}
84
-
85
-sip_uri_t *parse_from_uri(sip_msg_t *msg)
86
-{
87
-	to_body_t *tb = NULL;
88
-        
89
-	if(msg==NULL)
90
-		return NULL;
91
-
92
-	if(parse_from_header(msg)<0)
93
-	{
94
-		LM_ERR("cannot parse FROM header\n");
95
-		return NULL;
96
-	}
97
-	
98
-	if(msg->from==NULL || get_from(msg)==NULL)
99
-		return NULL;
100
-
101
-	tb = get_from(msg);
102
-	
103
-	if(tb->parsed_uri.user.s!=NULL || tb->parsed_uri.host.s!=NULL)
104
-		return &tb->parsed_uri;
105
-	
106
-	if (parse_uri(tb->uri.s, tb->uri.len , &tb->parsed_uri)<0)
107
-	{
108
-		LM_ERR("failed to parse From uri\n");
109
-		memset(&tb->parsed_uri, 0, sizeof(struct sip_uri));
110
-		return NULL;
111
-	}
112
-	return &tb->parsed_uri;
113
-}
Browse code

core parser - remove svn ID, remove history, change "ser" => "Kamailio"

Olle E. Johansson authored on 18/01/2015 19:36:18
Showing 1 changed files
... ...
@@ -1,19 +1,14 @@
1 1
 /*
2 2
  * Copyright (C) 2001-2003 FhG Fokus
3 3
  *
4
- * This file is part of ser, a free SIP server.
4
+ * This file is part of Kamailio, a free SIP server.
5 5
  *
6
- * ser is free software; you can redistribute it and/or modify
6
+ * Kamailio is free software; you can redistribute it and/or modify
7 7
  * it under the terms of the GNU General Public License as published by
8 8
  * the Free Software Foundation; either version 2 of the License, or
9 9
  * (at your option) any later version
10 10
  *
11
- * For a license to use the ser software under conditions
12
- * other than those described here, or to purchase support for this
13
- * software, please contact iptel.org by e-mail at the following addresses:
14
- *    info@iptel.org
15
- *
16
- * ser is distributed in the hope that it will be useful,
11
+ * Kamailio is distributed in the hope that it will be useful,
17 12
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 13
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 14
  * GNU General Public License for more details.
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
... ...
@@ -20,7 +20,7 @@
20 20
  *
21 21
  * You should have received a copy of the GNU General Public License 
22 22
  * along with this program; if not, write to the Free Software 
23
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
24 24
  */
25 25
 
26 26
 /*! \file
Browse code

parser: remove old $Id$ docs header from subversion times, not usable anymore

Henning Westerholt authored on 05/07/2012 21:39:51
Showing 1 changed files
... ...
@@ -1,6 +1,4 @@
1 1
 /*
2
- * $Id$
3
- *
4 2
  * Copyright (C) 2001-2003 FhG Fokus
5 3
  *
6 4
  * This file is part of ser, a free SIP server.
Browse code

parser: relocated helper functions

Daniel-Constantin Mierla authored on 10/01/2012 22:33:00
Showing 1 changed files
... ...
@@ -37,6 +37,7 @@
37 37
 #include <string.h>
38 38
 #include "../dprint.h"
39 39
 #include "msg_parser.h"
40
+#include "parse_uri.h"
40 41
 #include "../ut.h"
41 42
 #include "../mem/mem.h"
42 43
 
... ...
@@ -88,4 +89,32 @@ error:
88 89
 	return -1;
89 90
 }
90 91
 
92
+sip_uri_t *parse_from_uri(sip_msg_t *msg)
93
+{
94
+	to_body_t *tb = NULL;
95
+        
96
+	if(msg==NULL)
97
+		return NULL;
98
+
99
+	if(parse_from_header(msg)<0)
100
+	{
101
+		LM_ERR("cannot parse FROM header\n");
102
+		return NULL;
103
+	}
104
+	
105
+	if(msg->from==NULL || get_from(msg)==NULL)
106
+		return NULL;
91 107
 
108
+	tb = get_from(msg);
109
+	
110
+	if(tb->parsed_uri.user.s!=NULL || tb->parsed_uri.host.s!=NULL)
111
+		return &tb->parsed_uri;
112
+	
113
+	if (parse_uri(tb->uri.s, tb->uri.len , &tb->parsed_uri)<0)
114
+	{
115
+		LM_ERR("failed to parse From uri\n");
116
+		memset(&tb->parsed_uri, 0, sizeof(struct sip_uri));
117
+		return NULL;
118
+	}
119
+	return &tb->parsed_uri;
120
+}
Browse code

core: some adjustments to two debug messages

Daniel-Constantin Mierla authored on 03/10/2011 21:51:16
Showing 1 changed files
... ...
@@ -76,7 +76,8 @@ int parse_from_header( struct sip_msg *msg)
76 76
 	memset(from_b, 0, sizeof(struct to_body));
77 77
 	parse_to(msg->from->body.s,msg->from->body.s+msg->from->body.len+1,from_b);
78 78
 	if (from_b->error == PARSE_ERROR) {
79
-		LOG(L_ERR, "ERROR:parse_from_header: bad from header\n");
79
+		LOG(L_ERR, "ERROR:parse_from_header: bad from header [%.*s]\n",
80
+				msg->from->body.len, msg->from->body.s);
80 81
 		free_to(from_b);
81 82
 		goto error;
82 83
 	}
Browse code

parser: switch pkg_free(tob) to free_to(tob) to free To header structure

- this takes care of freeing parameters in case of paring error of
To-like headers
- patch by Walter Doekes, closes FS#155

Daniel-Constantin Mierla authored on 19/09/2011 11:29:44
Showing 1 changed files
... ...
@@ -77,7 +77,7 @@ int parse_from_header( struct sip_msg *msg)
77 77
 	parse_to(msg->from->body.s,msg->from->body.s+msg->from->body.len+1,from_b);
78 78
 	if (from_b->error == PARSE_ERROR) {
79 79
 		LOG(L_ERR, "ERROR:parse_from_header: bad from header\n");
80
-		pkg_free(from_b);
80
+		free_to(from_b);
81 81
 		goto error;
82 82
 	}
83 83
 	msg->from->parsed = from_b;
Browse code

More parser/ doxygen changes

oej authored on 25/10/2009 17:26:46
Showing 1 changed files
... ...
@@ -25,6 +25,11 @@
25 25
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26 26
  */
27 27
 
28
+/*! \file
29
+ * \brief Parser :: SIP From header parsing
30
+ *
31
+ * \ingroup parser
32
+ */
28 33
 
29 34
 #include "parse_from.h"
30 35
 #include "parse_to.h"
... ...
@@ -35,8 +40,10 @@
35 40
 #include "../ut.h"
36 41
 #include "../mem/mem.h"
37 42
 
38
-/*
39
- * This method is used to parse the from header. It was decided not to parse
43
+/*! \brief
44
+ * This method is used to parse the from header.
45
+ *
46
+ * \note It was decided not to parse
40 47
  * anything in core that is not *needed* so this method gets called by 
41 48
  * rad_acc module and any other modules that needs the FROM header.
42 49
  *
Browse code

- changed parse_headers api, HDR_xxx split into HDR_xxx_F (hdr_flags_t) and HDR_xxx_T (hdr_types_t), for more info read doc/parse_headers.txt. The header flags were extended top 64 bits. Be carefull not to mix types with flags, they won't work!

Andrei Pelinescu-Onciul authored on 23/02/2005 17:16:01
Showing 1 changed files
... ...
@@ -48,7 +48,7 @@ int parse_from_header( struct sip_msg *msg)
48 48
 {
49 49
 	struct to_body* from_b;
50 50
 
51
-	if ( !msg->from && ( parse_headers(msg,HDR_FROM,0)==-1 || !msg->from)) {
51
+	if ( !msg->from && ( parse_headers(msg,HDR_FROM_F,0)==-1 || !msg->from)) {
52 52
 		LOG(L_ERR,"ERROR:parse_from_header: bad msg or missing FROM header\n");
53 53
 		goto error;
54 54
 	}
Browse code

- Spelling checked

Jan Janak authored on 24/08/2004 09:01:24
Showing 1 changed files
... ...
@@ -1,7 +1,7 @@
1 1
 /*
2 2
  * $Id$
3 3
  *
4
- * Copyright (C) 2001-2003 Fhg Fokus
4
+ * Copyright (C) 2001-2003 FhG Fokus
5 5
  *
6 6
  * This file is part of ser, a free SIP server.
7 7
  *
Browse code

parse_to() - accept also \0 as EOH; don't write anymore 0 into the header during parsing. parse_from_header() - rebuilded according with the new parse_to()

Bogdan-Andrei Iancu authored on 03/12/2002 11:45:52
Showing 1 changed files
... ...
@@ -1,5 +1,4 @@
1 1
 /*
2
- * @author Stelios Sidiroglou-Douskos <ssi@fokus.gmd.de>
3 2
  * $Id$
4 3
  *
5 4
  * Copyright (C) 2001-2003 Fhg Fokus
... ...
@@ -41,39 +40,44 @@
41 40
  * anything in core that is not *needed* so this method gets called by 
42 41
  * rad_acc module and any other modules that needs the FROM header.
43 42
  *
44
- * params: hdr : Hook to the from header
43
+ * params: msg : sip msg
45 44
  * returns 0 on success,
46
- *		   -1 on failure.
45
+ *        -1 on failure.
47 46
  */
48
-int parse_from_header(struct hdr_field* hdr) 
47
+int parse_from_header( struct sip_msg *msg)
49 48
 {
50 49
 	struct to_body* from_b;
51
-	
50
+
51
+	if ( !msg->from && ( parse_headers(msg,HDR_FROM,0)==-1 || !msg->from)) {
52
+		LOG(L_ERR,"ERROR:parse_from_header: bad msg or missing FROM header\n");
53
+		goto error;
54
+	}
55
+
56
+	/* maybe the header is already parsed! */
57
+	if (msg->from->parsed)
58
+		return 0;
59
+
60
+	/* bad luck! :-( - we have to parse it */
61
+	/* first, get some memory */
52 62
 	from_b = pkg_malloc(sizeof(struct to_body));
53 63
 	if (from_b == 0) {
54
-		LOG(L_ERR, "parse_from_header: out of memory\n");
64
+		LOG(L_ERR, "ERROR:parse_from_header: out of pkg_memory\n");
55 65
 		goto error;
56 66
 	}
57
-			
67
+
68
+	/* now parse it!! */
58 69
 	memset(from_b, 0, sizeof(struct to_body));
59
-	parse_to(hdr->body.s, hdr->body.s + hdr->body.len + 1, from_b);
70
+	parse_to(msg->from->body.s,msg->from->body.s+msg->from->body.len+1,from_b);
60 71
 	if (from_b->error == PARSE_ERROR) {
61
-		LOG(L_ERR, "ERROR: parse_from_header: bad from header\n");
72
+		LOG(L_ERR, "ERROR:parse_from_header: bad from header\n");
62 73
 		pkg_free(from_b);
63 74
 		goto error;
64 75
 	}
65
-	hdr->parsed = from_b;	
66
-	DBG("DEBUG: parse_from_header: <%s> [%d]; uri=[%.*s] \n",
67
-		hdr->name.s, hdr->body.len, from_b->uri.len, from_b->uri.s);
68
-	DBG("DEBUG: from body [%.*s]\n",from_b->body.len, from_b->body.s);	
76
+	msg->from->parsed = from_b;
69 77
 
70 78
 	return 0;
71
-
72
-	error:
73
-	/* more debugging, msg->orig is/should be null terminated*/
74
-	LOG(L_ERR, "ERROR: parse_from_header: \n");
79
+error:
75 80
 	return -1;
76
-
77 81
 }
78 82
 
79 83
 
Browse code

GPLization banner introduced to *.[hc] files

Jiri Kuthan authored on 19/09/2002 12:23:52
Showing 1 changed files
... ...
@@ -1,8 +1,32 @@
1 1
 /*
2 2
  * @author Stelios Sidiroglou-Douskos <ssi@fokus.gmd.de>
3 3
  * $Id$
4
+ *
5
+ * Copyright (C) 2001-2003 Fhg Fokus
6
+ *
7
+ * This file is part of ser, a free SIP server.
8
+ *
9
+ * ser 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
+ * For a license to use the ser software under conditions
15
+ * other than those described here, or to purchase support for this
16
+ * software, please contact iptel.org by e-mail at the following addresses:
17
+ *    info@iptel.org
18
+ *
19
+ * ser is distributed in the hope that it will be useful,
20
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
+ * GNU General Public License for more details.
23
+ *
24
+ * You should have received a copy of the GNU General Public License 
25
+ * along with this program; if not, write to the Free Software 
26
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
4 27
  */
5 28
 
29
+
6 30
 #include "parse_from.h"
7 31
 #include "parse_to.h"
8 32
 #include <stdlib.h>
Browse code

wrapper function for FROM header. ssi

ssi authored on 08/08/2002 17:15:18
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,55 @@
1
+/*
2
+ * @author Stelios Sidiroglou-Douskos <ssi@fokus.gmd.de>
3
+ * $Id$
4
+ */
5
+
6
+#include "parse_from.h"
7
+#include "parse_to.h"
8
+#include <stdlib.h>
9
+#include <string.h>
10
+#include "../dprint.h"
11
+#include "msg_parser.h"
12
+#include "../ut.h"
13
+#include "../mem/mem.h"
14
+
15
+/*
16
+ * This method is used to parse the from header. It was decided not to parse
17
+ * anything in core that is not *needed* so this method gets called by 
18
+ * rad_acc module and any other modules that needs the FROM header.
19
+ *
20
+ * params: hdr : Hook to the from header
21
+ * returns 0 on success,
22
+ *		   -1 on failure.
23
+ */
24
+int parse_from_header(struct hdr_field* hdr) 
25
+{
26
+	struct to_body* from_b;
27
+	
28
+	from_b = pkg_malloc(sizeof(struct to_body));
29
+	if (from_b == 0) {
30
+		LOG(L_ERR, "parse_from_header: out of memory\n");
31
+		goto error;
32
+	}
33
+			
34
+	memset(from_b, 0, sizeof(struct to_body));
35
+	parse_to(hdr->body.s, hdr->body.s + hdr->body.len + 1, from_b);
36
+	if (from_b->error == PARSE_ERROR) {
37
+		LOG(L_ERR, "ERROR: parse_from_header: bad from header\n");
38
+		pkg_free(from_b);
39
+		goto error;
40
+	}
41
+	hdr->parsed = from_b;	
42
+	DBG("DEBUG: parse_from_header: <%s> [%d]; uri=[%.*s] \n",
43
+		hdr->name.s, hdr->body.len, from_b->uri.len, from_b->uri.s);
44
+	DBG("DEBUG: from body [%.*s]\n",from_b->body.len, from_b->body.s);	
45
+
46
+	return 0;
47
+
48
+	error:
49
+	/* more debugging, msg->orig is/should be null terminated*/
50
+	LOG(L_ERR, "ERROR: parse_from_header: \n");
51
+	return -1;
52
+
53
+}
54
+
55
+