Skip to content

Commit e368a19

Browse files
Renamed th_binary_encoder to thinfo_codec and renamed the types and function names
1 parent a63b15a commit e368a19

File tree

5 files changed

+326
-135
lines changed

5 files changed

+326
-135
lines changed

modules/topology_hiding/th_binary_encoder.h

Lines changed: 0 additions & 62 deletions
This file was deleted.

modules/topology_hiding/th_no_dlg_logic.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
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

@@ -91,8 +91,8 @@
9191

9292
extern 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

9797
struct 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
}
@@ -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

895895
socket_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
}

modules/topology_hiding/th_no_dlg_logic.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ enum encode_scheme {ENC_BASE64, ENC_BASE32};
3131
// Need to think about the flags so they don't clash with dlg flags
3232
#define TOPOH_USE_BINARY_ENCODING (1 << 7)
3333

34-
/* Decoded routes buffer - shared between topology_hiding.c and th_no_dlg_logic.c */
3534
extern str decoded_uris[12];
3635
extern int decoded_uris_count;
3736
extern int ctx_decoded_routes_valid_idx;

0 commit comments

Comments
 (0)