2727#include "../rr/loose.h"
2828#include "../rr/api.h"
2929#include "../compression/compression_api.h"
30- #include "th_binary_encoder .h"
30+ #include "thinfo_codec .h"
3131#include <stdint.h>
3232#include <string.h>
3333
9191
9292extern struct tm_binds tm_api ;
9393
94- static encoded_uri_t encoded_uri_buf = { 0 };
95- static encoded_uri_t decoded_uri_buf = { 0 };
94+ static thinfo_encoded_t encoded_uri_buf = { 0 };
95+ static thinfo_encoded_t decoded_uri_buf = { 0 };
9696
9797struct th_no_dlg_param {
9898 str routes ;
@@ -221,17 +221,17 @@ static int th_no_dlg_auto_route_seq_handling(struct sip_msg *msg, rr_t auto_rout
221221 for (i = 0 ; i < dec_len ; i ++ )
222222 decoded_uri_buf .buf [i ] ^= topo_hiding_ct_encode_pw .s [i % topo_hiding_ct_encode_pw .len ];
223223
224- if (get_uri_count (& decoded_uri_buf ) != 0 ) {
224+ if (thinfo_get_uri_count (& decoded_uri_buf ) != 0 ) {
225225 LM_ERR ("Encoded URI count is invalid, can only be 0 in auto Route\n" );
226226 return TOPOH_MATCH_FAILURE ;
227227 }
228228
229- flags = get_flags (& decoded_uri_buf );
229+ flags = thinfo_get_flags (& decoded_uri_buf );
230230
231231 decoded_uri_buf .len = dec_len ;
232232 decoded_uri_buf .pos = 0 ;
233233
234- if (decode_socket (& decoded_uri_buf , & proto , & host , & port ) <= 0 ) {
234+ if (thinfo_decode_socket (& decoded_uri_buf , & proto , & host , & port ) <= 0 ) {
235235 LM_ERR ("Failed to decode socket 0\n" );
236236 return -1 ;
237237 }
@@ -556,9 +556,9 @@ static char* build_encoded_contact_suffix_legacy(struct sip_msg* msg, str *route
556556 const struct socket_info * rr_sock = NULL ;
557557 int params_len = 0 ;
558558 int local_len = sizeof (short ) /* RR length */ +
559- sizeof (short ) /* Contact length */ +
560- sizeof (short ) /* RR length */ +
561- sizeof (short ) /* bind addr */ ;
559+ sizeof (short ) /* Contact length */ +
560+ sizeof (short ) /* RR length */ +
561+ sizeof (short ) /* bind addr */ ;
562562
563563 /* parse all headers as we can have multiple
564564 RR headers in the same message */
@@ -567,10 +567,10 @@ static char* build_encoded_contact_suffix_legacy(struct sip_msg* msg, str *route
567567 return NULL ;
568568 }
569569
570- if (routes ) {
570+ if (routes && routes -> len > 0 ) {
571571 rr_set = * routes ;
572572 rr_len = (short )routes -> len ;
573- LM_INFO ("XXX: adding [%.*s]\n" , routes -> len , routes -> s );
573+ LM_DBG ("XXX: adding [%.*s]\n" , routes -> len , routes -> s );
574574 } else if (msg -> record_route ){
575575 if (print_rr_body (msg -> record_route , & rr_set , !is_req , 0 , & rrs_to_ignore ) != 0 ){
576576 LM_ERR ("failed to print route records \n" );
@@ -740,7 +740,7 @@ static char* build_encoded_contact_suffix_legacy(struct sip_msg* msg, str *route
740740 if (rr_set_free_str )
741741 pkg_free (rr_set_free_str );
742742 if (routes )
743- pkg_free (routes );
743+ shm_free (routes );
744744 return NULL ;
745745}
746746
@@ -767,7 +767,7 @@ static char* build_encoded_thinfo_suffix(struct sip_msg* msg, str *routes, unsig
767767 return NULL ;
768768 }
769769
770- reset_encode_buffer (& encoded_uri_buf );
770+ thinfo_buffer_reset (& encoded_uri_buf );
771771
772772 if (socket_only == 1 ) {
773773 goto socket_only ;
@@ -805,7 +805,7 @@ static char* build_encoded_thinfo_suffix(struct sip_msg* msg, str *routes, unsig
805805 }
806806 }
807807
808- if (encode_uri (& encoded_uri_buf , & ctu , param_count , ct_uri_params_skip ) == -1 ) {
808+ if (thinfo_encode_uri (& encoded_uri_buf , & ctu , param_count , ct_uri_params_skip ) == -1 ) {
809809 LM_ERR ("Error encoding Contact URI\n" );
810810 goto error ;
811811 }
@@ -841,7 +841,7 @@ static char* build_encoded_thinfo_suffix(struct sip_msg* msg, str *routes, unsig
841841
842842 if (!th_no_dlg_one_way_hiding (rr_sock )) {
843843 if (!is_2rr (& rr_uri .params )) {
844- if (encode_uri (& encoded_uri_buf , & rr_uri , 0 , NULL ) == -1 ) {
844+ if (thinfo_encode_uri (& encoded_uri_buf , & rr_uri , 0 , NULL ) == -1 ) {
845845 LM_ERR ("Error encoding Route URI\n" );
846846 goto error ;
847847 }
@@ -861,17 +861,17 @@ static char* build_encoded_thinfo_suffix(struct sip_msg* msg, str *routes, unsig
861861 }
862862
863863 if (is_2rr (& rr_uri_r2 .params ) && str_match (& rr_uri .host , & rr_uri_r2 .host )) {
864- if (encode_dual_uri (& encoded_uri_buf , & rr_uri , & rr_uri_r2 ) == -1 ) {
864+ if (thinfo_encode_dual_uri (& encoded_uri_buf , & rr_uri , & rr_uri_r2 ) == -1 ) {
865865 LM_ERR ("Error encoding Route URI\n" );
866866 goto error ;
867867 }
868868 } else {
869- if (encode_uri (& encoded_uri_buf , & rr_uri , 0 , NULL ) == -1 ) {
869+ if (thinfo_encode_uri (& encoded_uri_buf , & rr_uri , 0 , NULL ) == -1 ) {
870870 LM_ERR ("Error encoding Route URI\n" );
871871 goto error ;
872872 }
873873
874- if (encode_uri (& encoded_uri_buf , & rr_uri_r2 , 0 , NULL ) == -1 ) {
874+ if (thinfo_encode_uri (& encoded_uri_buf , & rr_uri_r2 , 0 , NULL ) == -1 ) {
875875 LM_ERR ("Error encoding Route URI\n" );
876876 goto error ;
877877 }
@@ -893,15 +893,15 @@ static char* build_encoded_thinfo_suffix(struct sip_msg* msg, str *routes, unsig
893893 LM_DBG ("Encoding %u URIs\n" , encoded_uris );
894894
895895socket_only :
896- if (encode_socket (& encoded_uri_buf , msg -> rcv .bind_address ) < 0 ) {
896+ if (thinfo_encode_socket (& encoded_uri_buf , msg -> rcv .bind_address ) < 0 ) {
897897 LM_ERR ("Error encoding socket\n" );
898898 goto error ;
899899 }
900900
901901 enc_len = th_ct_enc_scheme == ENC_BASE64 ?
902902 calc_word64_encode_len (encoded_uri_buf .len ) : calc_word32_encode_len (encoded_uri_buf .len );
903903
904- finalize_encode_buffer (& encoded_uri_buf , flags , encoded_uris );
904+ thinfo_buffer_finalize (& encoded_uri_buf , flags , encoded_uris );
905905
906906 for (i = 0 ; i < encoded_uri_buf .len ; i ++ )
907907 encoded_uri_buf .buf [i ] ^= topo_hiding_ct_encode_pw .s [i % topo_hiding_ct_encode_pw .len ];
@@ -1216,16 +1216,16 @@ static int decode_info_buffer(str *info, str rr_buf[static 1], str ct_buf[static
12161216 decoded_uri_buf .len = dec_len ;
12171217 decoded_uri_buf .pos = 0 ;
12181218
1219- uri_count = get_uri_count (& decoded_uri_buf );
1219+ uri_count = thinfo_get_uri_count (& decoded_uri_buf );
12201220 if (uri_count == 0 || uri_count > MAX_ENCODED_SIP_URIS ) {
12211221 LM_ERR ("Encoded URI count is invalid, count=%u\n" , uri_count );
12221222 return -1 ;
12231223 }
12241224
12251225 LM_DBG ("Decoded URI count %u\n" , uri_count );
12261226
1227- * flags = get_flags (& decoded_uri_buf );
1228- decoded_len = decode_uris (& decoded_uri_buf , decoded_uri_str , uri_count , decoded_uris );
1227+ * flags = thinfo_get_flags (& decoded_uri_buf );
1228+ decoded_len = thinfo_decode_uris (& decoded_uri_buf , decoded_uri_str , uri_count , decoded_uris );
12291229
12301230 decoded_uris_count = uri_count ;
12311231 ctx_decoded_routes_set_valid ();
@@ -1235,7 +1235,7 @@ static int decode_info_buffer(str *info, str rr_buf[static 1], str ct_buf[static
12351235 return -1 ;
12361236 }
12371237
1238- if (decode_socket (& decoded_uri_buf , & proto , & host , & port ) <= 0 ) {
1238+ if (thinfo_decode_socket (& decoded_uri_buf , & proto , & host , & port ) <= 0 ) {
12391239 LM_ERR ("Failed to decode socket 0\n" );
12401240 return -1 ;
12411241 }
0 commit comments