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,149 +0,0 @@
1
-#ifdef SER
2
-
3
-#include <cds/sip_utils.h>
4
-#include <cds/sstr.h>
5
-#include <parser/parse_expires.h>
6
-#include <parser/parse_subscription_state.h>
7
-#include <parser/parser_f.h>
8
-#include <parser/parse_to.h>
9
-#include <trim.h>
10
-
11
-
12
-int get_expiration_value(struct sip_msg *m, int *value)
13
-{
14
-	exp_body_t *expires = NULL;
15
-	int res = 1;
16
-
17
-	if (parse_headers(m, HDR_EXPIRES_F, 0) == -1) {
18
-		/* can't parse expires header */
19
-		return -1;
20
-	}
21
-	if (m->expires) {
22
-		if (parse_expires(m->expires) < 0) {
23
-			return -1;
24
-		}
25
-
26
-		res = 0;
27
-		expires = (exp_body_t *)m->expires->parsed;
28
-		if (expires) if (expires->valid && value) *value = expires->val;
29
-	}
30
-	/* ERR("subscription will expire in %d secs\n", e); */
31
-	return res;
32
-}
33
-
34
-int is_terminating_notify(struct sip_msg *m)
35
-{
36
-	subscription_state_t *ss;
37
-
38
-	if (parse_headers(m, HDR_SUBSCRIPTION_STATE_F, 0) == -1) {
39
-		ERR("Error while parsing headers\n");
40
-		return 0; /* ignore */
41
-	}
42
-	if (!m->subscription_state) {
43
-		ERR("Invalid NOTIFY request (without Subscription-State)\n");
44
-		return 0; /* ignore */
45
-	}
46
-	if (parse_subscription_state(m->subscription_state) < 0) {
47
-		ERR("can't parse Subscription-State\n");
48
-		return 0; /* ignore */
49
-	}
50
-	ss = (subscription_state_t*)m->subscription_state->parsed;
51
-	if (!ss) {
52
-		ERR("invalid Subscription-State\n");
53
-		return 0; /* ignore */
54
-	}
55
-	
56
-	if (ss->value == ss_terminated) return 1;
57
-
58
-	return 0;
59
-}
60
-
61
-static inline int contains_extension_support(struct hdr_field *h, 
62
-		str *extension)
63
-{
64
-	/* "parses" Supported header and looks for extension */
65
-	str s, val;
66
-	char *c;
67
-	
68
-	if (!h) return 0;
69
-
70
-	s = h->body;
71
-	while (s.len > 0) {
72
-		c = find_not_quoted(&s, ',');
73
-		if (c) {
74
-			val.s = s.s;
75
-			val.len = c - val.s;
76
-			trim(&val);
77
-			if (str_case_equals(&val, extension) == 0) return 1;
78
-			s.len = s.len - (c - s.s) - 1;
79
-			s.s = c + 1;
80
-		}
81
-		else {
82
-			trim(&s);
83
-			if (str_case_equals(&s, extension) == 0) return 1;
84
-			break;
85
-		}
86
-	}
87
-	return 0;
88
-}
89
-
90
-int supports_extension(struct sip_msg *m, str *extension)
91
-{
92
-	/* walk through all Supported headers */
93
-	struct hdr_field *h;
94
-	int res;
95
-
96
-	/* we need all Supported headers */
97
-	res = parse_headers(m, HDR_EOH_F, 0);
98
-	if (res == -1) {
99
-		ERR("Error while parsing headers (%d)\n", res);
100
-		return 0; /* what to return here ? */
101
-	}
102
-	
103
-	h = m->supported;
104
-	while (h) {
105
-		if (h->type == HDR_SUPPORTED_T) {
106
-			if (contains_extension_support(h, extension)) return 1;
107
-		}
108
-		h = h->next;
109
-	}
110
-	return 0;
111
-}
112
-
113
-int requires_extension(struct sip_msg *m, str *extension)
114
-{
115
-	/* walk through all Require headers */
116
-	struct hdr_field *h;
117
-	int res;
118
-
119
-	/* we need all Require headers */
120
-	res = parse_headers(m, HDR_EOH_F, 0);
121
-	if (res == -1) {
122
-		ERR("Error while parsing headers (%d)\n", res);
123
-		return 0; /* what to return here ? */
124
-	}
125
-	
126
-	h = m->require;
127
-	while (h) {
128
-		if (h->type == HDR_REQUIRE_T) {
129
-			if (contains_extension_support(h, extension)) return 1;
130
-		}
131
-		h = h->next;
132
-	}
133
-	return 0;
134
-}
135
-
136
-/**
137
- * Verifies presence of the To-tag in message. Returns 1 if
138
- * the tag is present, 0 if not, -1 on error.
139
- */
140
-int has_to_tag(struct sip_msg *_m)
141
-{
142
-	struct to_body *to = (struct to_body*)_m->to->parsed;
143
-	if (!to) return -1;
144
-	if (to->tag_value.len > 0) return 1;
145
-	return 0;
146
-}
147
-
148
-
149
-#endif
Browse code

libcds: added missing parse_to.h include

Andrei Pelinescu-Onciul authored on 15/04/2009 18:24:04
Showing 1 changed files
... ...
@@ -5,6 +5,7 @@
5 5
 #include <parser/parse_expires.h>
6 6
 #include <parser/parse_subscription_state.h>
7 7
 #include <parser/parser_f.h>
8
+#include <parser/parse_to.h>
8 9
 #include <trim.h>
9 10
 
10 11
 
Browse code

added function has_to_tag into common libs

Vaclav Kubart authored on 11/07/2006 05:55:38
Showing 1 changed files
... ...
@@ -132,4 +132,17 @@ int requires_extension(struct sip_msg *m, str *extension)
132 132
 	return 0;
133 133
 }
134 134
 
135
+/**
136
+ * Verifies presence of the To-tag in message. Returns 1 if
137
+ * the tag is present, 0 if not, -1 on error.
138
+ */
139
+int has_to_tag(struct sip_msg *_m)
140
+{
141
+	struct to_body *to = (struct to_body*)_m->to->parsed;
142
+	if (!to) return -1;
143
+	if (to->tag_value.len > 0) return 1;
144
+	return 0;
145
+}
146
+
147
+
135 148
 #endif
Browse code

added parsing of Require header field

Vaclav Kubart authored on 23/06/2006 08:51:37
Showing 1 changed files
... ...
@@ -92,8 +92,7 @@ int supports_extension(struct sip_msg *m, str *extension)
92 92
 	struct hdr_field *h;
93 93
 	int res;
94 94
 
95
-	/* we need all Supported headers, Min-SE, 
96
-	 * Session-Expires */
95
+	/* we need all Supported headers */
97 96
 	res = parse_headers(m, HDR_EOH_F, 0);
98 97
 	if (res == -1) {
99 98
 		ERR("Error while parsing headers (%d)\n", res);
... ...
@@ -110,5 +109,27 @@ int supports_extension(struct sip_msg *m, str *extension)
110 109
 	return 0;
111 110
 }
112 111
 
112
+int requires_extension(struct sip_msg *m, str *extension)
113
+{
114
+	/* walk through all Require headers */
115
+	struct hdr_field *h;
116
+	int res;
117
+
118
+	/* we need all Require headers */
119
+	res = parse_headers(m, HDR_EOH_F, 0);
120
+	if (res == -1) {
121
+		ERR("Error while parsing headers (%d)\n", res);
122
+		return 0; /* what to return here ? */
123
+	}
124
+	
125
+	h = m->require;
126
+	while (h) {
127
+		if (h->type == HDR_REQUIRE_T) {
128
+			if (contains_extension_support(h, extension)) return 1;
129
+		}
130
+		h = h->next;
131
+	}
132
+	return 0;
133
+}
113 134
 
114 135
 #endif
Browse code

added function supports_extension for search within Supported headers

Vaclav Kubart authored on 22/06/2006 10:24:24
Showing 1 changed files
... ...
@@ -4,6 +4,9 @@
4 4
 #include <cds/sstr.h>
5 5
 #include <parser/parse_expires.h>
6 6
 #include <parser/parse_subscription_state.h>
7
+#include <parser/parser_f.h>
8
+#include <trim.h>
9
+
7 10
 
8 11
 int get_expiration_value(struct sip_msg *m, int *value)
9 12
 {
... ...
@@ -54,4 +57,58 @@ int is_terminating_notify(struct sip_msg *m)
54 57
 	return 0;
55 58
 }
56 59
 
60
+static inline int contains_extension_support(struct hdr_field *h, 
61
+		str *extension)
62
+{
63
+	/* "parses" Supported header and looks for extension */
64
+	str s, val;
65
+	char *c;
66
+	
67
+	if (!h) return 0;
68
+
69
+	s = h->body;
70
+	while (s.len > 0) {
71
+		c = find_not_quoted(&s, ',');
72
+		if (c) {
73
+			val.s = s.s;
74
+			val.len = c - val.s;
75
+			trim(&val);
76
+			if (str_case_equals(&val, extension) == 0) return 1;
77
+			s.len = s.len - (c - s.s) - 1;
78
+			s.s = c + 1;
79
+		}
80
+		else {
81
+			trim(&s);
82
+			if (str_case_equals(&s, extension) == 0) return 1;
83
+			break;
84
+		}
85
+	}
86
+	return 0;
87
+}
88
+
89
+int supports_extension(struct sip_msg *m, str *extension)
90
+{
91
+	/* walk through all Supported headers */
92
+	struct hdr_field *h;
93
+	int res;
94
+
95
+	/* we need all Supported headers, Min-SE, 
96
+	 * Session-Expires */
97
+	res = parse_headers(m, HDR_EOH_F, 0);
98
+	if (res == -1) {
99
+		ERR("Error while parsing headers (%d)\n", res);
100
+		return 0; /* what to return here ? */
101
+	}
102
+	
103
+	h = m->supported;
104
+	while (h) {
105
+		if (h->type == HDR_SUPPORTED_T) {
106
+			if (contains_extension_support(h, extension)) return 1;
107
+		}
108
+		h = h->next;
109
+	}
110
+	return 0;
111
+}
112
+
113
+
57 114
 #endif
Browse code

"hacked" version of is_terminating_notify replaced by correct one

Vaclav Kubart authored on 21/06/2006 13:59:01
Showing 1 changed files
... ...
@@ -3,6 +3,7 @@
3 3
 #include <cds/sip_utils.h>
4 4
 #include <cds/sstr.h>
5 5
 #include <parser/parse_expires.h>
6
+#include <parser/parse_subscription_state.h>
6 7
 
7 8
 int get_expiration_value(struct sip_msg *m, int *value)
8 9
 {
... ...
@@ -28,26 +29,29 @@ int get_expiration_value(struct sip_msg *m, int *value)
28 29
 
29 30
 int is_terminating_notify(struct sip_msg *m)
30 31
 {
31
-	int res = 0;
32
-	struct hdr_field *h;
33
-	static str ss = STR_STATIC_INIT("Subscription-State");
34
-	static str terminated = STR_STATIC_INIT("terminated");
35
-
36
-	if (parse_headers(m, HDR_EOH_F, 0) == -1) {
37
-		ERR("can't parse NOTIFY message\n");
38
-		return 0;
32
+	subscription_state_t *ss;
33
+
34
+	if (parse_headers(m, HDR_SUBSCRIPTION_STATE_F, 0) == -1) {
35
+		ERR("Error while parsing headers\n");
36
+		return 0; /* ignore */
39 37
 	}
40
-	h = m->headers;
41
-	while (h) {
42
-		/* try to find Subscription-Status with "terminated" */
43
-		if (str_nocase_equals(&h->name, &ss) == 0) {
44
-			if (str_str(&h->body, &terminated)) return 1;
45
-			else return 0;
46
-		}
47
-		h = h->next;
38
+	if (!m->subscription_state) {
39
+		ERR("Invalid NOTIFY request (without Subscription-State)\n");
40
+		return 0; /* ignore */
41
+	}
42
+	if (parse_subscription_state(m->subscription_state) < 0) {
43
+		ERR("can't parse Subscription-State\n");
44
+		return 0; /* ignore */
48 45
 	}
46
+	ss = (subscription_state_t*)m->subscription_state->parsed;
47
+	if (!ss) {
48
+		ERR("invalid Subscription-State\n");
49
+		return 0; /* ignore */
50
+	}
51
+	
52
+	if (ss->value == ss_terminated) return 1;
49 53
 
50
-	return res;
54
+	return 0;
51 55
 }
52 56
 
53 57
 #endif
Browse code

corrected bug in get_expiration_value

Vaclav Kubart authored on 21/06/2006 08:25:41
Showing 1 changed files
... ...
@@ -18,6 +18,7 @@ int get_expiration_value(struct sip_msg *m, int *value)
18 18
 			return -1;
19 19
 		}
20 20
 
21
+		res = 0;
21 22
 		expires = (exp_body_t *)m->expires->parsed;
22 23
 		if (expires) if (expires->valid && value) *value = expires->val;
23 24
 	}
Browse code

few common SIP/SER helper functions moved into CDS (needed elsewhere)

Vaclav Kubart authored on 13/06/2006 08:11:04
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,52 @@
1
+#ifdef SER
2
+
3
+#include <cds/sip_utils.h>
4
+#include <cds/sstr.h>
5
+#include <parser/parse_expires.h>
6
+
7
+int get_expiration_value(struct sip_msg *m, int *value)
8
+{
9
+	exp_body_t *expires = NULL;
10
+	int res = 1;
11
+
12
+	if (parse_headers(m, HDR_EXPIRES_F, 0) == -1) {
13
+		/* can't parse expires header */
14
+		return -1;
15
+	}
16
+	if (m->expires) {
17
+		if (parse_expires(m->expires) < 0) {
18
+			return -1;
19
+		}
20
+
21
+		expires = (exp_body_t *)m->expires->parsed;
22
+		if (expires) if (expires->valid && value) *value = expires->val;
23
+	}
24
+	/* ERR("subscription will expire in %d secs\n", e); */
25
+	return res;
26
+}
27
+
28
+int is_terminating_notify(struct sip_msg *m)
29
+{
30
+	int res = 0;
31
+	struct hdr_field *h;
32
+	static str ss = STR_STATIC_INIT("Subscription-State");
33
+	static str terminated = STR_STATIC_INIT("terminated");
34
+
35
+	if (parse_headers(m, HDR_EOH_F, 0) == -1) {
36
+		ERR("can't parse NOTIFY message\n");
37
+		return 0;
38
+	}
39
+	h = m->headers;
40
+	while (h) {
41
+		/* try to find Subscription-Status with "terminated" */
42
+		if (str_nocase_equals(&h->name, &ss) == 0) {
43
+			if (str_str(&h->body, &terminated)) return 1;
44
+			else return 0;
45
+		}
46
+		h = h->next;
47
+	}
48
+
49
+	return res;
50
+}
51
+
52
+#endif