Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sobomax committed Dec 1, 2023
1 parent f91a308 commit d143a0c
Show file tree
Hide file tree
Showing 73 changed files with 297 additions and 283 deletions.
5 changes: 3 additions & 2 deletions core_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ static int fixup_f_send_sock(void** param)
str host, host_nt;
int proto=PROTO_NONE, port;
struct hostent* he;
struct socket_info* si;
const struct socket_info* si;
struct ip_addr ip;

if (parse_phostport(s->s, s->len, &host.s, &host.len, &port, &proto) != 0) {
Expand Down Expand Up @@ -526,7 +526,8 @@ static int fixup_f_send_sock(void** param)

pkg_free(host_nt.s);

*param = si;
const void **_param = (const void **)param;
*_param = si;
return 0;

error:
Expand Down
6 changes: 3 additions & 3 deletions dset.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct branch
unsigned int path_len;

int q; /* Preference of the contact among contact within the array */
struct socket_info* force_send_socket;
const struct socket_info* force_send_socket;
unsigned int flags;
};

Expand Down Expand Up @@ -220,7 +220,7 @@ void set_dset_state(unsigned char enable)
* more branches
*/
char* get_branch(unsigned int idx, int* len, qvalue_t* q, str* dst_uri,
str* path, unsigned int *flags, struct socket_info** force_socket)
str* path, unsigned int *flags, const struct socket_info** force_socket)
{
struct dset_ctx *dsct = get_dset_ctx();
struct branch *branches;
Expand Down Expand Up @@ -275,7 +275,7 @@ void clear_branches(void)
* Add a new branch to current transaction
*/
int append_branch(struct sip_msg* msg, str* uri, str* dst_uri, str* path,
qvalue_t q, unsigned int flags, struct socket_info* force_socket)
qvalue_t q, unsigned int flags, const struct socket_info* force_socket)
{
str luri;
int nr_branches;
Expand Down
4 changes: 2 additions & 2 deletions dset.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ int init_dset(void);
* Add a new branch to current transaction
*/
int append_branch(struct sip_msg* msg, str* uri, str* dst_uri, str* path,
qvalue_t q, unsigned int flags, struct socket_info* force_socket);
qvalue_t q, unsigned int flags, const struct socket_info* force_socket);



Expand All @@ -58,7 +58,7 @@ int update_branch(unsigned int idx, str** uri, str** dst_uri, str** path,
* Get the next branch in the current transaction
*/
char* get_branch( unsigned int idx, int* len, qvalue_t* q, str* dst_uri,
str* path, unsigned int *flags, struct socket_info** force_socket);
str* path, unsigned int *flags, const struct socket_info** force_socket);


/*! \brief
Expand Down
14 changes: 7 additions & 7 deletions forward.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@
* be very likely noticeably slower, but it can deal better with
* multihomed hosts
*/
struct socket_info* get_out_socket(const union sockaddr_union* to, int proto)
const struct socket_info* get_out_socket(const union sockaddr_union* to, int proto)
{
int temp_sock;
socklen_t len;
union sockaddr_union from;
struct socket_info* si;
const struct socket_info* si;
struct ip_addr ip, ip_dst;

if (proto!=PROTO_UDP) {
Expand Down Expand Up @@ -142,10 +142,10 @@ struct socket_info* get_out_socket(const union sockaddr_union* to, int proto)
*
* \note if msg!=null and msg->force_send_socket, the force_send_socket will be used
*/
struct socket_info* get_send_socket(struct sip_msg *msg,
const struct socket_info* get_send_socket(struct sip_msg *msg,
const union sockaddr_union* to, int proto)
{
struct socket_info* send_sock;
const struct socket_info* send_sock;

/* check if send interface is not forced */
if (msg && msg->force_send_socket){
Expand Down Expand Up @@ -308,8 +308,8 @@ int forward_request( struct sip_msg* msg, struct proxy_l * p)
{
union sockaddr_union to;
str buf;
struct socket_info* send_sock;
struct socket_info* last_sock;
const struct socket_info* send_sock;
const struct socket_info* last_sock;

buf.s=NULL;

Expand Down Expand Up @@ -473,7 +473,7 @@ int forward_reply(struct sip_msg* msg)
struct sr_module *mod;
int proto;
unsigned int id; /* used only by tcp*/
struct socket_info *send_sock;
const struct socket_info *send_sock;
char* s;
int len;

Expand Down
6 changes: 3 additions & 3 deletions forward.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
#include "net/trans.h"
#include "socket_info.h"

struct socket_info* get_send_socket(struct sip_msg* msg,
const struct socket_info* get_send_socket(struct sip_msg* msg,
const union sockaddr_union* su, int proto);
struct socket_info* get_out_socket(const union sockaddr_union* to, int proto);
const struct socket_info* get_out_socket(const union sockaddr_union* to, int proto);
int check_self(str* host, unsigned short port, unsigned short proto);
int forward_request( struct sip_msg* msg, struct proxy_l* p);
int update_sock_struct_from_via( union sockaddr_union* to,
Expand Down Expand Up @@ -81,7 +81,7 @@ int forward_reply( struct sip_msg* msg);
* \param len - the length of the message to be sent
* \return 0 if ok, -1 on error
*/
static inline int msg_send( struct socket_info* send_sock, int proto,
static inline int msg_send( const struct socket_info* send_sock, int proto,
union sockaddr_union* to, unsigned int id,
char* buf, int len, struct sip_msg* msg)
{
Expand Down
2 changes: 1 addition & 1 deletion globals.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ int mcast_ttl = -1; /* if -1, don't touch it, use the default (usually 1) */

int tos = IPTOS_LOWDELAY; // lgtm [cpp/short-global-name]

struct socket_info* bind_address=NULL; /* pointer to the crt. proc.
const struct socket_info* bind_address=NULL; /* pointer to the crt. proc.
listening address*/

/* if aliases should be automatically discovered and added
Expand Down
2 changes: 1 addition & 1 deletion globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ extern char *stat_file;
extern char* pid_file;
extern char* pgid_file;

extern struct socket_info* bind_address; /*!< pointer to the crt. proc. listening address */
extern const struct socket_info* bind_address; /*!< pointer to the crt. proc. listening address */

extern int auto_aliases;

Expand Down
6 changes: 3 additions & 3 deletions ip_addr.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ struct receive_info {
unsigned int proto_reserved1; /*!< tcp stores the connection id here */
unsigned int proto_reserved2;
union sockaddr_union src_su; /*!< useful for replies*/
struct socket_info* bind_address; /*!< sock_info structure on which the msg was received*/
const struct socket_info* bind_address; /*!< sock_info structure on which the msg was received*/
/* no need for dst_su yet */
};

Expand All @@ -109,7 +109,7 @@ struct dest_info {
int proto;
unsigned int proto_reserved1; /*!< tcp stores the connection id here */
union sockaddr_union to;
struct socket_info* send_sock;
const struct socket_info* send_sock;
};


Expand Down Expand Up @@ -326,7 +326,7 @@ static inline void su2ip_addr(struct ip_addr* ip, const union sockaddr_union* su
* \return 0 if ok, -1 on error (unknown address family)
* \note the port number is in host byte order */
static inline int init_su( union sockaddr_union* su,
struct ip_addr* ip,
const struct ip_addr* ip,
unsigned short port )
{
memset(su, 0, sizeof(union sockaddr_union));/*needed on freebsd*/
Expand Down
2 changes: 1 addition & 1 deletion mi/mi_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ char* generate_correlation_id(int* len)
}


int trace_mi_message(union sockaddr_union* src, union sockaddr_union* dst,
int trace_mi_message(const union sockaddr_union* src, const union sockaddr_union* dst,
struct mi_trace_param* pld_param, str* correlation_val, trace_dest trace_dst)
{
/* FIXME is this the case for all mi impelementations?? */
Expand Down
6 changes: 3 additions & 3 deletions mi/mi_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ extern struct mi_trace_param mi_tparam;

void try_load_trace_api(void);

int trace_mi_message(union sockaddr_union* src, union sockaddr_union* dst,
int trace_mi_message(const union sockaddr_union* src, const union sockaddr_union* dst,
struct mi_trace_param* pld_param, str* correlation_value, trace_dest trace_dst);

struct mi_trace_req* build_mi_trace_request(str *cmd, mi_item_t *params,
Expand All @@ -65,7 +65,7 @@ str *build_mi_trace_reply(str *rpl_msg);
char* generate_correlation_id(int* len);;
int load_correlation_id(void);

static inline void mi_trace_reply( union sockaddr_union* src, union sockaddr_union* dst,
static inline void mi_trace_reply( const union sockaddr_union* src, const union sockaddr_union* dst,
str* message, trace_dest t_dst)
{
/* trace disabled */
Expand All @@ -91,7 +91,7 @@ static inline void mi_trace_reply( union sockaddr_union* src, union sockaddr_uni
}


static inline void mi_trace_request( union sockaddr_union* src, union sockaddr_union* dst,
static inline void mi_trace_request( const union sockaddr_union* src, const union sockaddr_union* dst,
char* command, int len, mi_item_t *params, str* backend, trace_dest t_dst )
{
str comm_s = { command, len };
Expand Down
4 changes: 2 additions & 2 deletions modules/b2b_entities/b2be_load.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ typedef struct client_info
str local_contact;
unsigned int cseq;
unsigned int maxfwd;
struct socket_info* send_sock;
struct socket_info* pref_sock;
const struct socket_info* send_sock;
const struct socket_info* pref_sock;
struct usr_avp *avps;
}client_info_t;

Expand Down
2 changes: 1 addition & 1 deletion modules/b2b_entities/dlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ typedef struct b2b_dlg
struct cell* prack_tran;
struct cell* cancel_tm_tran;
dlg_leg_t* legs;
struct socket_info* send_sock;
const struct socket_info* send_sock;
unsigned int last_reply_code;
int db_flag;
int replicated;
Expand Down
2 changes: 1 addition & 1 deletion modules/b2b_logic/logic.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ void b2b_mark_todel( b2bl_tuple_t* tuple)
int b2b_get_local_contact(struct sip_msg *msg, str *from_uri, str *local_contact)
{
struct sip_uri ct_uri;
struct socket_info *send_sock = msg ?
const struct socket_info *send_sock = msg ?
(msg->force_send_socket?msg->force_send_socket:msg->rcv.bind_address):NULL;

if (server_address.len) {
Expand Down
4 changes: 2 additions & 2 deletions modules/b2b_sdp_demux/b2b_sdp_demux.c
Original file line number Diff line number Diff line change
Expand Up @@ -1673,8 +1673,8 @@ static int b2b_sdp_demux_start(struct sip_msg *msg, str *uri,
struct list_head *it;
struct b2b_sdp_client *client;
client_info_t ci;
struct socket_info *si;
str *sess_ip;
const struct socket_info *si;
const str *sess_ip;

if (!msg->force_send_socket) {
si = uri2sock(msg, uri, &tmp_su, PROTO_NONE);
Expand Down
6 changes: 3 additions & 3 deletions modules/dialog/dlg_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,15 +393,15 @@ int dlg_clone_callee_leg(struct dlg_cell *dlg, int cloned_leg_idx)
}


static inline int translate_contact_ipport( str *ct, struct socket_info *sock,
static inline int translate_contact_ipport( str *ct, const struct socket_info *sock,
str *dst)
{
struct hdr_field ct_hdr;
struct contact_body *cb;
contact_t *c;
struct sip_uri puri;
str hostport;
str *send_address_str, *send_port_str;
const str *send_address_str, *send_port_str;
char *p;

/* rely on the fact that the replicated hdr is well formated, so
Expand Down Expand Up @@ -487,7 +487,7 @@ static inline int translate_contact_ipport( str *ct, struct socket_info *sock,
be no leg allocated, so automatically CALLER gets the first position, while
the CALLEE legs will follow into the array in the same order they came */
int dlg_update_leg_info(int leg_idx, struct dlg_cell *dlg, str* tag, str *rr,
str *contact, str *adv_ct, str *cseq, struct socket_info *sock,
str *contact, str *adv_ct, str *cseq, const struct socket_info *sock,
str *mangled_from,str *mangled_to,str *in_sdp, str *out_sdp)
{
struct dlg_leg *leg;
Expand Down
4 changes: 2 additions & 2 deletions modules/dialog/dlg_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ struct dlg_leg {
struct dlg_leg_cseq_map *cseq_maps; /* used when translating ACKs */
char reply_received;
char reinvite_confirmed;
struct socket_info *bind_addr;
const struct socket_info *bind_addr;
};

#define leg_is_answered(dlg_leg) ((dlg_leg)->tag.s)
Expand Down Expand Up @@ -409,7 +409,7 @@ struct dlg_cell* build_new_dlg(str *callid, str *from_uri,
int dlg_clone_callee_leg(struct dlg_cell *dlg, int cloned_leg_idx);

int dlg_update_leg_info(int leg_idx, struct dlg_cell *dlg, str* tag, str *rr,
str *contact, str *adv_ct, str *cseq, struct socket_info *sock,
str *contact, str *adv_ct, str *cseq, const struct socket_info *sock,
str *mangled_from,str *mangled_to,str *in_sdp, str *out_sdp);

int dlg_update_cseq(struct dlg_cell *dlg, unsigned int leg, str *cseq,
Expand Down
16 changes: 8 additions & 8 deletions modules/media_exchange/media_exchange.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ static int fixup_media_leg_both(void **param)
return 0;
}

static inline client_info_t *media_get_client_info(struct socket_info *si,
static inline client_info_t *media_get_client_info(const struct socket_info *si,
str *uri, str *hdrs, str *body)
{
static client_info_t ci;
Expand All @@ -291,7 +291,7 @@ static inline client_info_t *media_get_client_info(struct socket_info *si,
return &ci;
}

static int handle_media_fork_to_uri(struct media_session_leg *msl, struct socket_info *si,
static int handle_media_fork_to_uri(struct media_session_leg *msl, const struct socket_info *si,
str *uri, str *headers, int medianum)
{
static client_info_t *ci;
Expand Down Expand Up @@ -342,7 +342,7 @@ static int handle_media_fork_to_uri(struct media_session_leg *msl, struct socket

struct media_fork_params {
struct media_session_leg *msl;
struct socket_info *si;
const struct socket_info *si;
str uri;
str headers;
int medianum;
Expand Down Expand Up @@ -371,7 +371,7 @@ static int media_fork_to_uri(struct sip_msg *msg,
str *uri, int leg, str *headers, int *medianum)
{
struct dlg_cell *dlg;
struct socket_info *si;
const struct socket_info *si;
struct media_session_leg *msl;
struct media_fork_params *mp;

Expand Down Expand Up @@ -585,7 +585,7 @@ static void media_session_tm_free(struct media_session_tm_param *p)
shm_free(p);
}

static int handle_media_exchange_from_uri(struct socket_info *si, struct dlg_cell *dlg,
static int handle_media_exchange_from_uri(const struct socket_info *si, struct dlg_cell *dlg,
str *uri, int leg, str *body, str *headers, int nohold,
rtp_ctx ctx, struct media_session_tm_param *p)
{
Expand Down Expand Up @@ -641,7 +641,7 @@ static int media_exchange_from_uri(struct sip_msg *msg, str *uri, int leg,
struct cell *t = NULL;
struct dlg_cell *dlg;
int req_leg;
struct socket_info *si;
const struct socket_info *si;
struct media_session_tm_param *p = NULL;
rtp_ctx ctx = NULL;
int release = 0;
Expand Down Expand Up @@ -1506,7 +1506,7 @@ static mi_response_t *mi_media_fork_from_call_to_uri(const mi_params_t *params,
str shdrs, *hdrs;
str callid, leg, uri;
struct dlg_cell *dlg;
struct socket_info *si;
const struct socket_info *si;
union sockaddr_union tmp;
struct media_session_leg *msl;
rtp_ctx ctx = NULL;
Expand Down Expand Up @@ -1572,7 +1572,7 @@ static mi_response_t *mi_media_exchange_from_call_to_uri(const mi_params_t *para
str callid, leg, uri;
str body, shdrs, *hdrs, *pbody;
struct dlg_cell *dlg;
struct socket_info *si;
const struct socket_info *si;
union sockaddr_union tmp;
rtp_ctx ctx = NULL;
int release = 0;
Expand Down
Loading

0 comments on commit d143a0c

Please sign in to comment.