Browse code

textops(k): msg_apply_changes() moved to textops

Daniel-Constantin Mierla authored on 29/07/2010 16:53:42
Showing 3 changed files
... ...
@@ -76,7 +76,6 @@ Juha Heinanen
76 76
               3.31. cmp_str(str1, str2)
77 77
               3.32. cmp_istr(str1, str2)
78 78
               3.33. starts_with(str1, str2)
79
-              3.34. msg_apply_changes()
80 79
 
81 80
         4. Known Limitations
82 81
 
... ...
@@ -121,7 +120,6 @@ Juha Heinanen
121 120
    1.31. cmp_str usage
122 121
    1.32. cmp_str usage
123 122
    1.33. starts_with usage
124
-   1.34. msg_apply_changes() usage
125 123
 
126 124
 Chapter 1. Admin Guide
127 125
 
... ...
@@ -171,7 +169,6 @@ Chapter 1. Admin Guide
171 169
         3.31. cmp_str(str1, str2)
172 170
         3.32. cmp_istr(str1, str2)
173 171
         3.33. starts_with(str1, str2)
174
-        3.34. msg_apply_changes()
175 172
 
176 173
    4. Known Limitations
177 174
 
... ...
@@ -244,7 +241,6 @@ From: medabeda
244 241
    3.31. cmp_str(str1, str2)
245 242
    3.32. cmp_istr(str1, str2)
246 243
    3.33. starts_with(str1, str2)
247
-   3.34. msg_apply_changes()
248 244
 
249 245
 3.1.  search(re)
250 246
 
... ...
@@ -888,29 +884,6 @@ if (starts_with("$rU", "+358"))
888 884
 }
889 885
 ...
890 886
 
891
-3.34.  msg_apply_changes()
892
-
893
-   Use this function to apply changes done on SIP request content. Be
894
-   careful when using this function -- due to special handling of changes
895
-   done to SIM message buffer so far, using this function might change the
896
-   behaviour of your config as it was so far -- do test properly your
897
-   config!
898
-
899
-   This function can be used from REQUEST_ROUTE.
900
-
901
-   Example 1.34. msg_apply_changes() usage
902
-...
903
-append_hf("My-Header: yes\r\n");
904
-if(msg_apply_changes())
905
-{
906
-    # msg buffer has a new content
907
-        if(is_present_hf("My-Header"))
908
-        {
909
-        # will get here always
910
-    }
911
-}
912
-...
913
-
914 887
 4. Known Limitations
915 888
 
916 889
    Search functions are applied to the original request, i.e., they ignore
... ...
@@ -1233,38 +1233,6 @@ if (starts_with("$rU", "+358"))
1233 1233
 		</example>
1234 1234
 	</section>
1235 1235
 
1236
-	<section>
1237
-		<title>
1238
-		<function moreinfo="none">msg_apply_changes()</function>
1239
-		</title>
1240
-		<para>
1241
-		Use this function to apply changes done on SIP request content. Be
1242
-		careful when using this function -- due to special handling of changes
1243
-		done to SIM message buffer so far, using this function might change
1244
-		the behaviour of your config as it was so far -- do test properly
1245
-		your config!
1246
-		</para>
1247
-   		<para>
1248
-		This function can be used from REQUEST_ROUTE.
1249
-		</para>
1250
-		<example>
1251
-		<title><function>msg_apply_changes()</function> usage</title>
1252
-		<programlisting format="linespecific">
1253
-...
1254
-append_hf("My-Header: yes\r\n");
1255
-if(msg_apply_changes())
1256
-{
1257
-    # msg buffer has a new content
1258
-	if(is_present_hf("My-Header"))
1259
-	{
1260
-        # will get here always
1261
-    }
1262
-}
1263
-...
1264
-</programlisting>
1265
-		</example>
1266
-	</section>
1267
-
1268 1236
 	</section>
1269 1237
 	<section>
1270 1238
 		<title>Known Limitations</title>
... ...
@@ -124,7 +124,6 @@ static int cmp_istr_f(struct sip_msg *msg, char *str1, char *str2 );
124 124
 static int starts_with_f(struct sip_msg *msg, char *str1, char *str2 );
125 125
 static int remove_hf_re_f(struct sip_msg* msg, char* key, char* foo);
126 126
 static int is_present_hf_re_f(struct sip_msg* msg, char* key, char* foo);
127
-static int msg_apply_changes_f(sip_msg_t *msg, char *str1, char *str2);
128 127
 
129 128
 static int fixup_substre(void**, int);
130 129
 static int hname_fixup(void** param, int param_no);
... ...
@@ -247,9 +246,6 @@ static cmd_export_t cmds[]={
247 246
 	{"starts_with",  (cmd_function)starts_with_f, 2,
248 247
 		fixup_spve_spve, 0,
249 248
 		REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE|LOCAL_ROUTE},
250
-	{"msg_apply_changes",      (cmd_function)msg_apply_changes_f,     0,
251
-		0, 0,
252
-		REQUEST_ROUTE },
253 249
 
254 250
 	{0,0,0,0,0,0}
255 251
 };
... ...
@@ -1878,84 +1874,6 @@ static int starts_with_f(struct sip_msg *msg, char *str1, char *str2 )
1878 1874
 	return -2;
1879 1875
 }
1880 1876
 
1881
-static int msg_apply_changes_f(sip_msg_t *msg, char *str1, char *str2)
1882
-{
1883
-	struct dest_info dst;
1884
-	str obuf;
1885
-	sip_msg_t tmp;
1886
-
1887
-	if(get_route_type()!=REQUEST_ROUTE)
1888
-	{
1889
-		LM_ERR("invalid usage - not in request route\n");
1890
-		return -1;
1891
-	}
1892
-
1893
-	init_dest_info(&dst);
1894
-	dst.proto = PROTO_UDP;
1895
-	obuf.s = build_req_buf_from_sip_req(msg,
1896
-			(unsigned int*)&obuf.len, &dst,
1897
-			BUILD_NO_LOCAL_VIA|BUILD_NO_VIA1_UPDATE);
1898
-	if(obuf.s == NULL)
1899
-	{
1900
-		LM_ERR("couldn't update msg buffer content\n");
1901
-		return -1;
1902
-	}
1903
-	if(obuf.len>=BUF_SIZE)
1904
-	{
1905
-		LM_ERR("new buffer overflow (%d)\n", obuf.len);
1906
-		pkg_free(obuf.s);
1907
-		return -1;
1908
-	}
1909
-	/* temporary copy */
1910
-	memcpy(&tmp, msg, sizeof(sip_msg_t));
1911
-
1912
-	/* reset dst uri and path vector to avoid freeing - restored later */
1913
-	if(msg->dst_uri.s!=NULL)
1914
-	{
1915
-		msg->dst_uri.s = NULL;
1916
-		msg->dst_uri.len = 0;
1917
-	}
1918
-	if(msg->path_vec.s!=NULL)
1919
-	{
1920
-		msg->path_vec.s = NULL;
1921
-		msg->path_vec.len = 0;
1922
-	}
1923
-
1924
-	/* free old msg structure */
1925
-	free_sip_msg(msg);
1926
-	memset(msg, 0, sizeof(sip_msg_t));
1927
-
1928
-	/* restore msg fields */
1929
-	msg->buf                = tmp.buf;
1930
-	msg->id                 = tmp.id;
1931
-	msg->rcv                = tmp.rcv;
1932
-	msg->set_global_address = tmp.set_global_address;
1933
-	msg->set_global_port    = tmp.set_global_port;
1934
-	msg->flags              = tmp.flags;
1935
-	msg->msg_flags          = tmp.msg_flags;
1936
-	msg->force_send_socket  = tmp.force_send_socket;
1937
-	msg->fwd_send_flags     = tmp.fwd_send_flags;
1938
-	msg->rpl_send_flags     = tmp.rpl_send_flags;
1939
-	msg->dst_uri            = tmp.dst_uri;
1940
-	msg->path_vec           = tmp.path_vec;
1941
-
1942
-	memcpy(msg->buf, obuf.s, obuf.len);
1943
-	msg->len = obuf.len;
1944
-	msg->buf[msg->len] = '\0';
1945
-
1946
-	/* free new buffer - copied in the static buffer from old sip_msg_t */
1947
-	pkg_free(obuf.s);
1948
-
1949
-	/* reparse the message */
1950
-	LM_DBG("SIP Request content updated - reparsing\n");
1951
-	if (parse_msg(msg->buf, msg->len, msg)!=0){
1952
-		LM_ERR("parse_msg failed\n");
1953
-		return -1;
1954
-	}
1955
-
1956
-	return 1;
1957
-}
1958
-
1959 1877
 int fixup_regexpNL_none(void** param, int param_no)
1960 1878
 {
1961 1879
 	regex_t* re;