Skip to content

Commit 45cdcda

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

File tree

10 files changed

+351
-176
lines changed

10 files changed

+351
-176
lines changed

modules/compression/gz_helpers.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,6 @@ int gzip_compress(unsigned char* in, unsigned long ilen, str* out, unsigned long
109109
return -1;
110110
}
111111

112-
static inline int is_gzip_compressed(unsigned char *data, int len)
113-
{
114-
if (len < 3)
115-
return 0;
116-
117-
return (data[0] == 0x1f && data[1] == 0x8b && data[2] == 0x08);
118-
}
119-
120112
/*
121113
*
122114
*/
@@ -130,11 +122,6 @@ int gzip_uncompress(unsigned char* in, unsigned long ilen, str* out, unsigned lo
130122
return -1;
131123
}
132124

133-
if (is_gzip_compressed(in, ilen) != 1) {
134-
LM_ERR("Not gzip decompressable\n");
135-
return -1;
136-
}
137-
138125
/* Gzip holds the length of the original message
139126
in the last 4 bytes */
140127
*olen = ((unsigned long)in[ilen-1] << 24) +

modules/rr/api.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ int load_rr( struct rr_binds *rrb )
5151
rrb->loose_route = loose_route;
5252
rrb->record_route = record_route;
5353
rrb->append_fromtag = append_fromtag;
54-
rrb->enable_double_rr = enable_double_rr;
5554

5655
return 1;
5756
}

modules/rr/api.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ struct rr_binds {
6363
loose_route_t loose_route;
6464
record_route_t record_route;
6565
int append_fromtag;
66-
int enable_double_rr;
6766
};
6867

6968
typedef int (*load_rr_f)( struct rr_binds* );

modules/tm/t_hooks.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ typedef void (release_tmcb_param) (void *param);
216216
/* register callback function prototype */
217217
typedef int (*register_tmcb_f)(struct sip_msg* p_msg, struct cell *t,
218218
int cb_types, transaction_cb f, void *param, release_tmcb_param func);
219-
typedef void (*set_tmcb_flags_f)(unsigned int flags);
220219

221220
struct tm_callback {
222221
int id; /* id of this callback - useless */

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: 24 additions & 24 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
}
@@ -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

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)