Browse code

updates related to the new lump_rpl changes

Bogdan-Andrei Iancu authored on 11/11/2003 19:37:16
Showing 11 changed files
... ...
@@ -31,6 +31,7 @@
31 31
  * 2003-03-15: In case of HDR_PROXYAUTH we always extract realm from From,
32 32
  *             even for REGISTERS
33 33
  * 2003-09-11: updated to new build_lump_rpl() interface (bogdan)
34
+ * 2003-11-11: build_lump_rpl() removed, add_lump_rpl() has flags (bogdan)
34 35
  */
35 36
 
36 37
 
... ...
@@ -86,13 +87,13 @@ int get_realm(struct sip_msg* _m, int _hftype, struct sip_uri* _u)
86 87
 int send_resp(struct sip_msg* _m, int _code, char* _reason,
87 88
 					char* _hdr, int _hdr_len)
88 89
 {
89
-	struct lump_rpl* ptr;
90
-	
91
-	     /* Add new headers if there are any */
90
+	/* Add new headers if there are any */
92 91
 	if ((_hdr) && (_hdr_len)) {
93
-		ptr = build_lump_rpl(_hdr, _hdr_len, LUMP_RPL_HDR);
94
-		add_lump_rpl(_m, ptr);
92
+		if (add_lump_rpl( _m, _hdr, _hdr_len, LUMP_RPL_HDR)==0) {
93
+			LOG(L_ERR,"ERROR:auth:send_resp: unable to append hdr\n");
94
+			return -1;
95
+		}
95 96
 	}
96
-	
97
+
97 98
 	return sl_reply(_m, (char*)(long)_code, _reason);
98 99
 }
... ...
@@ -160,10 +160,12 @@ static int mod_child_init(int r)
160 160
 	return 0;
161 161
 }
162 162
 
163
+#if 0
163 164
 static void destroy(void)
164 165
 {
165 166
 	close_tcp_connection(sockfd);
166 167
 }
168
+#endif
167 169
 
168 170
 
169 171
 /*
... ...
@@ -29,7 +29,7 @@
29 29
  * History:
30 30
  * -------
31 31
  * 2003-09-11: updated to new build_lump_rpl() interface (bogdan)
32
- *
32
+ * 2003-11-11: build_lump_rpl() removed, add_lump_rpl() has flags  (bogdan)
33 33
  */
34 34
 
35 35
 #include <stdio.h>
... ...
@@ -728,15 +728,14 @@ int srv_response(struct sip_msg* msg, rd_buf_t * rb, int hftype)
728 728
 int send_resp(struct sip_msg* m, int code, char* reason,
729 729
 					char* hdr, int hdr_len)
730 730
 {
731
-	struct lump_rpl* ptr;
732
-	
733 731
 	/* Add new headers if there are any */
734
-	if ((hdr) && (hdr_len)) 
735
-	{
736
-		ptr = build_lump_rpl(hdr, hdr_len, LUMP_RPL_HDR);
737
-		add_lump_rpl(m, ptr);
732
+	if ((hdr) && (hdr_len)) {
733
+		if (add_lump_rpl( m, hdr, hdr_len, LUMP_RPL_HDR)==0) {
734
+			LOG(L_ERR,"ERROR:auth_diamter:send_resp: unable to append hdr\n");
735
+			return -1;
736
+		}
738 737
 	}
739
-	
738
+
740 739
 	return sl_reply(m, (char*)(long)code, reason);
741 740
 }
742 741
 
... ...
@@ -28,6 +28,7 @@
28 28
  * -------
29 29
  * 2003-03-11: New module interface (janakj)
30 30
  * 2003-03-16: flags export parameter added (janakj)
31
+ * 2003-11-11: build_lump_rpl() removed, add_lump_rpl() has flags (bogdan)
31 32
  */
32 33
 
33 34
 
... ...
@@ -666,8 +667,6 @@ error:
666 667
 
667 668
 static inline int do_script_download(struct sip_msg *msg)
668 669
 {
669
-	struct lump_rpl *ct_type;
670
-	struct lump_rpl *body;
671 670
 	str  user  = {0,0};
672 671
 	str script = {0,0};
673 672
 
... ...
@@ -680,21 +679,18 @@ static inline int do_script_download(struct sip_msg *msg)
680 679
 		goto error;
681 680
 
682 681
 	/* add a lump with content-type hdr */
683
-	ct_type = build_lump_rpl( CONTENT_TYPE_HDR, CONTENT_TYPE_HDR_LEN,
684
-		LUMP_RPL_HDR);
685
-	if (ct_type==0) {
682
+	if (add_lump_rpl( msg, CONTENT_TYPE_HDR, CONTENT_TYPE_HDR_LEN,
683
+	LUMP_RPL_HDR)==0) {
686 684
 		LOG(L_ERR,"ERROR:cpl-c:do_script_download: cannot build hdr lump\n");
687 685
 		cpl_err = &intern_err;
688 686
 		goto error;
689 687
 	}
690
-	add_lump_rpl(  msg, ct_type);
691 688
 
692 689
 	if (script.s!=0) {
693 690
 		/*DBG("script len=%d\n--------\n%.*s\n--------\n",
694 691
 			script.len, script.len, script.s);*/
695 692
 		/* user has a script -> add a body lump */
696
-		body = build_lump_rpl( script.s, script.len, LUMP_RPL_BODY);
697
-		if (body==0) {
693
+		if ( add_lump_rpl( msg, script.s, script.len, LUMP_RPL_BODY)==0) {
698 694
 			LOG(L_ERR,"ERROR:cpl-c:do_script_download: cannot build "
699 695
 				"body lump\n");
700 696
 			cpl_err = &intern_err;
... ...
@@ -702,13 +698,6 @@ static inline int do_script_download(struct sip_msg *msg)
702 698
 		}
703 699
 		/* build_lump_rpl duplicates the added text, so free the original */
704 700
 		shm_free( script.s );
705
-		/* add the lump */
706
-		if (add_lump_rpl( msg, body)==-1) {
707
-			LOG(L_CRIT,"BUG:cpl-c:do_script_download: body lump "
708
-				"already added\n");
709
-			cpl_err = &intern_err;
710
-			goto error;
711
-		}
712 701
 	}
713 702
 
714 703
 	return 0;
... ...
@@ -23,7 +23,12 @@
23 23
  * You should have received a copy of the GNU General Public License
24 24
  * along with this program; if not, write to the Free Software
25 25
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
- */
26
+ *
27
+ * History:
28
+ * -------
29
+ * 2003-01-23 : created (bogdan)
30
+ * 2003-09-11 : build_lump_rpl() merged into add_lump_rpl() (bogdan)
31
+*/
27 32
 
28 33
 #include <stdio.h>
29 34
 #include <string.h>
... ...
@@ -662,13 +667,12 @@ static inline char *run_redirect( struct cpl_interpreter *intr )
662 667
 	memcpy(cp,CRLF,CRLF_LEN);
663 668
 
664 669
 	/* add the lump to the reply */
665
-	lump = build_lump_rpl( lump_str.s , lump_str.len , LUMP_RPL_HDR);
670
+	lump = add_lump_rpl( intr->msg, lump_str.s , lump_str.len , LUMP_RPL_HDR);
666 671
 	if(!lump) {
667
-		LOG(L_ERR,"ERROR:cpl-c:run_redirect: unable to build lump_rpl! \n");
672
+		LOG(L_ERR,"ERROR:cpl-c:run_redirect: unable to add lump_rpl! \n");
668 673
 		pkg_free( lump_str.s );
669 674
 		goto runtime_error;
670 675
 	}
671
-	add_lump_rpl( intr->msg , lump );
672 676
 
673 677
 	/* send the reply */
674 678
 	if (permanent)
... ...
@@ -676,7 +680,7 @@ static inline char *run_redirect( struct cpl_interpreter *intr )
676 680
 	else
677 681
 		i = cpl_tmb.t_reply( intr->msg, (int)302, "Moved temporarily" );
678 682
 
679
-	/* msg which I'm working with can be in private memory or is a clone into
683
+	/* msg which I'm working on can be in private memory or is a clone into
680 684
 	 * shared memory (if I'm after a failed proxy); So, it's better to removed
681 685
 	 * by myself the lump that I added previosly */
682 686
 	unlink_lump_rpl( intr->msg, lump);
... ...
@@ -24,13 +24,14 @@
24 24
  * You should have received a copy of the GNU General Public License 
25 25
  * along with this program; if not, write to the Free Software 
26 26
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27
- */
28
-
29
-/*
30
- * 2003-01-23 switched from t_uac to t_uac_dlg, adapted to new way of
31
- * parsing for Content-Type; by bogdan
32
- * 2003-08-05 adapted to the new parse_content_type_hdr function (bogdan)
27
+ *
28
+ * History:
29
+ * --------
30
+ * 2003-01-23: switched from t_uac to t_uac_dlg, adapted to new way of
31
+ *             parsing for Content-Type (bogdan)
32
+ * 2003-08-05: adapted to the new parse_content_type_hdr function (bogdan)
33 33
  * 2003-09-11: updated to new build_lump_rpl() interface (bogdan)
34
+ * 2003-11-11: build_lump_rpl() removed, add_lump_rpl() has flags (bogdan)
34 35
  */
35 36
 
36 37
 
... ...
@@ -25,6 +25,10 @@
25 25
  * You should have received a copy of the GNU General Public License
26 26
  * along with this program; if not, write to the Free Software
27 27
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28
+ *
29
+ * History:
30
+ * -------
31
+ * 2003-11-11: build_lump_rpl() removed, add_lump_rpl() has flags (bogdan)
28 32
  */
29 33
 
30 34
 #include "mod_options.h"
... ...
@@ -131,7 +135,6 @@ static int mod_init(void) {
131 135
 static int opt_reply(struct sip_msg* _msg, char* _foo, char* _bar) {
132 136
 	str rpl_hf;
133 137
 	int offset = 0;
134
-	struct lump_rpl *p;
135 138
 
136 139
 	/* check if it is called for an OPTIONS request */
137 140
 	if ((_msg->REQ_METHOD==METHOD_OTHER) &&
... ...
@@ -192,19 +195,18 @@ static int opt_reply(struct sip_msg* _msg, char* _foo, char* _bar) {
192 195
 #endif
193 196
 
194 197
 
195
-	p = build_lump_rpl(rpl_hf.s, rpl_hf.len, LUMP_RPL_HDR);
196
-	pkg_free(rpl_hf.s);
197
-	if (p) {
198
-		add_lump_rpl(_msg, p);
198
+	if (add_lump_rpl( _msg, rpl_hf.s, rpl_hf.len,
199
+	LUMP_RPL_HDR|LUMP_RPL_NODUP)!=0) {
199 200
 		if (sl_reply(_msg, (char*)200, "OK") == -1) {
200 201
 			LOG(L_ERR, "options_reply(): failed to send 200 via send_reply\n");
201 202
 			return -1;
202 203
 		}
203 204
 		else
204 205
 			return 0;
206
+	} else {
207
+		pkg_free(rpl_hf.s);
208
+		LOG(L_ERR, "options_reply(): add_lump_rpl failed\n");
205 209
 	}
206
-	else
207
-		LOG(L_ERR, "options_reply(): build_lump_rpl failed\n");
208 210
 
209 211
 error:
210 212
 	if (sl_reply(_msg, (char*)500, "Server internal error") == -1) {
... ...
@@ -107,8 +107,6 @@ int send_reply(struct sip_msg* _m)
107 107
 	int code;
108 108
 	char* msg = MSG_200; /* makes gcc shut up */
109 109
 
110
-	struct lump_rpl  *ei;
111
-
112 110
 	code = codes[paerrno];
113 111
 	switch(code) {
114 112
 	case 200: msg = MSG_200; break;
... ...
@@ -117,8 +115,11 @@ int send_reply(struct sip_msg* _m)
117 115
 	}
118 116
 	
119 117
 	if (code != 200) {
120
-		ei = build_lump_rpl(error_info[paerrno].s, error_info[paerrno].len, LUMP_RPL_HDR);
121
-		add_lump_rpl(_m, ei);
118
+		if (add_lump_rpl( _m, error_info[paerrno].s, error_info[paerrno].len,
119
+		LUMP_RPL_HDR|LUMP_RPL_NODUP|LUMP_RPL_NOFREE)==0) {
120
+			LOG(L_ERR, "ERROR:pa:send_reply: cannot add rpl_lump hdr\n");
121
+			return -1;
122
+		}
122 123
 	}
123 124
 
124 125
 	if (tmb.t_reply(_m, code, msg) == -1) {
... ...
@@ -31,6 +31,7 @@
31 31
  * 2003-01-18: buffer overflow patch committed (Jan on behalf of Maxim)
32 32
  * 2003-01-21: Errors reported via Error-Info header field - janakj
33 33
  * 2003-09-11: updated to new build_lump_rpl() interface (bogdan)
34
+ * 2003-11-11: build_lump_rpl() removed, add_lump_rpl() has flags (bogdan)
34 35
  */
35 36
 
36 37
 #include <stdio.h>
... ...
@@ -216,11 +217,8 @@ int send_reply(struct sip_msg* _m)
216 217
 	char* msg = MSG_200; /* makes gcc shut up */
217 218
 	char* buf;
218 219
 
219
-	struct lump_rpl* p, *ei;
220
-
221 220
 	if (l > 0) {
222
-		p = build_lump_rpl(b, l, LUMP_RPL_HDR);
223
-		add_lump_rpl(_m, p);
221
+		add_lump_rpl( _m, b, l, LUMP_RPL_HDR|LUMP_RPL_NODUP|LUMP_RPL_NOFREE);
224 222
 		l = 0;
225 223
 	}
226 224
 
... ...
@@ -240,10 +238,8 @@ int send_reply(struct sip_msg* _m)
240 238
 		memcpy(buf, E_INFO, E_INFO_LEN);
241 239
 		memcpy(buf + E_INFO_LEN, error_info[rerrno].s, error_info[rerrno].len);
242 240
 		memcpy(buf + E_INFO_LEN + error_info[rerrno].len, CRLF, CRLF_LEN);
243
-		ei = build_lump_rpl(buf, E_INFO_LEN + error_info[rerrno].len + CRLF_LEN,
244
-			LUMP_RPL_HDR);
245
-		add_lump_rpl(_m, ei);
246
-		pkg_free(buf);
241
+		add_lump_rpl( _m, buf, E_INFO_LEN + error_info[rerrno].len + CRLF_LEN,
242
+			LUMP_RPL_HDR|LUMP_RPL_NODUP);
247 243
 	}
248 244
 
249 245
 	if (sl_reply(_m, (char*)code, msg) == -1) {
... ...
@@ -37,6 +37,7 @@
37 37
   * 2003-09-11: updated to new build_lump_rpl() interface (bogdan)
38 38
   * 2003-09-11: sl_tag converted to str to fit to the new
39 39
   *               build_res_buf_from_sip_req() interface (bogdan)
40
+  * 2003-11-11: build_lump_rpl() removed, add_lump_rpl() has flags (bogdan)
40 41
   */
41 42
 
42 43
 
... ...
@@ -120,7 +121,6 @@ int sl_send_reply(struct sip_msg *msg ,int code ,char *text )
120 121
 	unsigned int       len;
121 122
 	union sockaddr_union to;
122 123
 	char *dset;
123
-	struct lump_rpl *dset_lump;
124 124
 	int dset_len;
125 125
 	struct bookmark dummy_bm;
126 126
 
... ...
@@ -149,8 +149,7 @@ int sl_send_reply(struct sip_msg *msg ,int code ,char *text )
149 149
 	if (code>=300 && code<400) {
150 150
 		dset=print_dset(msg, &dset_len);
151 151
 		if (dset) {
152
-			dset_lump=build_lump_rpl(dset, dset_len, LUMP_RPL_HDR);
153
-			add_lump_rpl(msg, dset_lump);
152
+			add_lump_rpl(msg, dset, dset_len, LUMP_RPL_HDR);
154 153
 		}
155 154
 	}
156 155
 
... ...
@@ -51,6 +51,7 @@
51 51
  *  2003-08-19  subst added (support for sed like res:s/re/repl/flags) (andrei)
52 52
  *  2003-08-20  subst_uri added (like above for uris) (andrei)
53 53
  *  2003-09-11  updated to new build_lump_rpl() interface (bogdan)
54
+ *  2003-11-11: build_lump_rpl() removed, add_lump_rpl() has flags (bogdan)
54 55
  */
55 56
 
56 57
 
... ...
@@ -449,15 +450,11 @@ static int fixup_substre(void** param, int param_no)
449 450
 
450 451
 static int append_to_reply_f(struct sip_msg* msg, char* key, char* str)
451 452
 {
452
-	struct lump_rpl *lump;
453
-
454
-	lump = build_lump_rpl( key, strlen(key), LUMP_RPL_HDR);
455
-	if (!lump)
453
+	if ( add_lump_rpl( msg, key, strlen(key), LUMP_RPL_HDR)==0 )
456 454
 	{
457
-		LOG(L_ERR,"ERROR:append_to_reply : unable to create lump_rl\n");
455
+		LOG(L_ERR,"ERROR:append_to_reply : unable to add lump_rl\n");
458 456
 		return -1;
459 457
 	}
460
-	add_lump_rpl( msg , lump );
461 458
 
462 459
 	return 1;
463 460
 }