@@ -64,7 +64,7 @@ static void topo_dlg_initial_reply (struct dlg_cell* dlg, int type,
6464static void th_down_onreply (struct cell * t , int type ,struct tmcb_params * param );
6565static void th_up_onreply (struct cell * t , int type , struct tmcb_params * param );
6666static void th_no_dlg_onreply (struct cell * t , int type , struct tmcb_params * param );
67- static int topo_no_dlg_encode_contact (struct sip_msg * req , unsigned int flags , str * routes , str * ct_user );
67+ static int topo_no_dlg_encode_contact (struct sip_msg * req , unsigned int flags , str * routes , str * rrs_to_ignore , str * ct_user );
6868static int topo_no_dlg_seq_handling (struct sip_msg * msg ,str * info );
6969static inline int th_no_dlg_one_way_hiding (struct sip_msg * msg , struct socket_info * socket );
7070static int dlg_th_onreply (struct dlg_cell * dlg , struct sip_msg * rpl , struct sip_msg * req ,
@@ -934,7 +934,7 @@ static void th_no_dlg_onreply(struct cell* t, int type, struct tmcb_params *para
934934 int do_rr = 0 ;
935935 int one_way_hiding = th_no_dlg_one_way_hiding (rpl , t -> uas .response .dst .send_sock );
936936
937- LM_DBG ("Response callback with flags %u" , flags );
937+ LM_DBG ("Response callback with flags %u\n " , flags );
938938
939939 /* parse all headers to be sure that all RR and Contact hdrs are found */
940940 if (parse_headers (rpl , HDR_EOH_F , 0 )< 0 ) {
@@ -958,6 +958,7 @@ static void th_no_dlg_onreply(struct cell* t, int type, struct tmcb_params *para
958958 }
959959
960960 route_sets [route_size ++ ] = & rpl_rr_set ;
961+ LM_DBG ("Reply Record-Routes %.*s\n" , rpl_rr_set .len , rpl_rr_set .s );
961962 }
962963
963964 if (do_rr && req -> record_route ) {
@@ -967,6 +968,7 @@ static void th_no_dlg_onreply(struct cell* t, int type, struct tmcb_params *para
967968 }
968969
969970 route_sets [route_size ++ ] = & req_rr_set ;
971+ LM_DBG ("Request Record-Routes %.*s\n" , req_rr_set .len , req_rr_set .s );
970972 }
971973
972974 if (topo_delete_record_routes (rpl ) < 0 ) {
@@ -980,11 +982,9 @@ static void th_no_dlg_onreply(struct cell* t, int type, struct tmcb_params *para
980982 }
981983
982984 if (!one_way_hiding ) {
983- LM_DBG ("No topology hiding on response for this socket\n" );
984-
985985 if (!(rpl -> REPLY_STATUS >= 300 && rpl -> REPLY_STATUS < 400 ) ) {
986986 if (topo_no_dlg_encode_contact (rpl , flags ,
987- (p ? & p -> routes : NULL ), (p ? & p -> username : NULL )) < 0 ) {
987+ (p ? & p -> routes : NULL ), & req_rr_set , (p ? & p -> username : NULL )) < 0 ) {
988988 LM_ERR ("Failed to encode contact header \n" );
989989 return ;
990990 }
@@ -1030,7 +1030,7 @@ static inline int _th_no_dlg_onrequest(struct sip_msg *req, union sockaddr_union
10301030 return -1 ;
10311031 }
10321032
1033- if (topo_no_dlg_encode_contact (req , flags , NULL , ct_user ) < 0 ) {
1033+ if (topo_no_dlg_encode_contact (req , flags , NULL , NULL , ct_user ) < 0 ) {
10341034 LM_ERR ("Failed to encode contact header \n" );
10351035 return -1 ;
10361036 }
@@ -1774,7 +1774,7 @@ int topo_callid_post_raw(str *data, struct sip_msg* foo)
17741774
17751775/* We encode the RR headers, the actual Contact and the socket str for this leg */
17761776/* Via headers will be restored using the TM module, no need to save anything for them */
1777- static char * build_encoded_contact_suffix (struct sip_msg * msg , str * routes , int * suffix_len , int flags )
1777+ static char * build_encoded_contact_suffix (struct sip_msg * msg , str * routes , str * rrs_to_ignore , int * suffix_len , int flags )
17781778{
17791779 short rr_len ,ct_len ,addr_len ,flags_len ,enc_len ;
17801780 char * suffix_plain ,* suffix_enc ,* p ,* s ;
@@ -1785,6 +1785,7 @@ static char* build_encoded_contact_suffix(struct sip_msg* msg, str *routes, int
17851785 struct sip_uri ctu ;
17861786 struct th_ct_params * el ;
17871787 param_t * it ;
1788+ rr_t * head = NULL ;
17881789 int is_req = (msg -> first_line .type == SIP_REQUEST )?1 :0 ;
17891790 int local_len = sizeof (short ) /* RR length */ +
17901791 sizeof (short ) /* Contact length */ +
@@ -1802,7 +1803,7 @@ static char* build_encoded_contact_suffix(struct sip_msg* msg, str *routes, int
18021803 rr_set = * routes ;
18031804 rr_len = (short )routes -> len ;
18041805 } else if (msg -> record_route ){
1805- if ( print_rr_body (msg -> record_route , & rr_set , !is_req , 0 , NULL ) != 0 ){
1806+ if ( print_rr_body_ignore (msg -> record_route , & rr_set , !is_req , 0 , rrs_to_ignore ) != 0 ){
18061807 LM_ERR ("failed to print route records \n" );
18071808 return NULL ;
18081809 }
@@ -1953,7 +1954,7 @@ static char* build_encoded_contact_suffix(struct sip_msg* msg, str *routes, int
19531954}
19541955
19551956static int topo_no_dlg_encode_contact (struct sip_msg * msg , unsigned int flags ,
1956- str * routes , str * ct_user )
1957+ str * routes , str * rrs_to_ignore , str * ct_user )
19571958{
19581959 struct lump * lump ;
19591960 char * prefix = NULL ,* suffix = NULL ,* ct_username = NULL ;
@@ -2020,7 +2021,7 @@ static int topo_no_dlg_encode_contact(struct sip_msg *msg, unsigned int flags,
20202021 /* make sure we do not free this string in case of a further error */
20212022 prefix = NULL ;
20222023
2023- if (!(suffix = build_encoded_contact_suffix (msg , routes , & suffix_len , flags ))) {
2024+ if (!(suffix = build_encoded_contact_suffix (msg , routes , rrs_to_ignore , & suffix_len , flags ))) {
20242025 LM_ERR ("Failed to build suffix \n" );
20252026 goto error ;
20262027 }
@@ -2058,7 +2059,7 @@ static inline void topo_no_dlg_seq_free(void *p)
20582059static inline int th_no_dlg_one_way_hiding (struct sip_msg * msg , struct socket_info * socket ) {
20592060 int one_way_hiding = 0 ;
20602061
2061- if (socket -> tag .len > 0 ) {
2062+ if (socket != NULL && socket -> tag .len > 0 ) {
20622063 one_way_hiding = socket -> tag .len == th_internal_trusted_tag .len
20632064 && strncmp (socket -> tag .s , th_internal_trusted_tag .s , th_internal_trusted_tag .len ) == 0 ;
20642065
@@ -2367,7 +2368,7 @@ static int topo_no_dlg_seq_handling(struct sip_msg *msg, str *info)
23672368 pkg_free (dec_buf );
23682369
23692370 if (sock && !th_no_dlg_one_way_hiding (msg , sock ) &&
2370- topo_no_dlg_encode_contact (msg , flags , NULL , NULL ) < 0 ) {
2371+ topo_no_dlg_encode_contact (msg , flags , NULL , NULL , NULL ) < 0 ) {
23712372 LM_ERR ("Failed to encode contact header \n" );
23722373 return -1 ;
23732374 }
0 commit comments