Skip to content

Commit

Permalink
b2b_logic: improve function names
Browse files Browse the repository at this point in the history
  • Loading branch information
rvlad-patrascu committed Dec 21, 2022
1 parent abc5097 commit 92b7042
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 50 deletions.
4 changes: 2 additions & 2 deletions modules/b2b_logic/b2b_load.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ typedef int (*b2bl_bridge_f)(str* key, str* new_uri, str *new_proxy,
int b2bl_terminate_call(str* key);
typedef int (*b2bl_terminate_call_t)(str* key);

int b2bl_bridge(str* key,str* new_uri, str *new_proxy, str* new_from_dname,
int b2bl_api_bridge(str* key,str* new_uri, str *new_proxy, str* new_from_dname,
int entity_no);
int b2bl_set_state(str* key, int state);

Expand Down Expand Up @@ -156,7 +156,7 @@ typedef struct b2bl_api
b2bl_ctx_get_ptr_f ctx_get_ptr;
}b2bl_api_t;

str* internal_init_scenario(struct sip_msg* msg, str *scen_name,
str* b2bl_api_init(struct sip_msg* msg, str *scen_name,
b2bl_init_params_t *scen_params, b2bl_cback_f cbf, void* param,
unsigned int cb_mask, str* custom_hdrs);

Expand Down
26 changes: 13 additions & 13 deletions modules/b2b_logic/b2b_logic.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static mi_response_t *mi_b2b_terminate_call(const mi_params_t *params,
static void b2bl_clean(unsigned int ticks, void* param);
static void b2bl_db_timer_update(unsigned int ticks, void* param);

int b2b_init_request(struct sip_msg *msg, str *id, struct b2b_params *init_params,
int b2bl_script_init_request(struct sip_msg *msg, str *id, struct b2b_params *init_params,
void *req_routeid, void *reply_routeid, str *init_body, str *init_body_type);
int b2bl_server_new(struct sip_msg *msg, str *id, str *adv_contact,
pv_spec_t *hnames, pv_spec_t *hvals);
Expand All @@ -90,9 +90,9 @@ int b2b_pass_request(struct sip_msg *msg);
int b2b_delete_entity(struct sip_msg *msg);
int b2b_end_dlg_leg(struct sip_msg *msg);
int b2b_send_reply(struct sip_msg *msg, int *code, str *reason, str *headers, str *body);
int b2b_bridge_request(struct sip_msg* msg, str *key, int *entity_no,
int b2bl_script_bridge_msg(struct sip_msg* msg, str *key, int *entity_no,
str *adv_contact);
int b2b_bridge_extern(struct sip_msg* msg, str *id, str * params,
int script_trigger_scenario(struct sip_msg* msg, str *id, str * params,
str *ent1, pv_spec_t *ent1_hnames, pv_spec_t *ent1_hvals,
str *ent2, pv_spec_t *ent2_hnames, pv_spec_t *ent2_hvals);

Expand Down Expand Up @@ -186,7 +186,7 @@ struct b2b_ctx_val *local_ctx_vals;

static cmd_export_t cmds[]=
{
{"b2b_init_request", (cmd_function)b2b_init_request, {
{"b2b_init_request", (cmd_function)b2bl_script_init_request, {
{CMD_PARAM_STR, fixup_init_id, 0},
{CMD_PARAM_STR|CMD_PARAM_OPT|CMD_PARAM_FIX_NULL,
fixup_init_flags, fixup_free_init_flags},
Expand Down Expand Up @@ -226,14 +226,14 @@ static cmd_export_t cmds[]=
{0,0,0}
},
REQUEST_ROUTE},
{"b2b_bridge", (cmd_function)b2b_scenario_bridge, {
{"b2b_bridge", (cmd_function)b2b_script_bridge, {
{CMD_PARAM_STR,0,0},
{CMD_PARAM_STR,0,0},
{CMD_PARAM_STR|CMD_PARAM_OPT,0,0},
{CMD_PARAM_STR|CMD_PARAM_OPT|CMD_PARAM_FIX_NULL,
fixup_bridge_flags, fixup_free_init_flags}, {0,0,0}},
REQUEST_ROUTE},
{"b2b_trigger_scenario", (cmd_function)b2b_bridge_extern, {
{"b2b_trigger_scenario", (cmd_function)script_trigger_scenario, {
{CMD_PARAM_STR,fixup_init_id,0},
{CMD_PARAM_STR|CMD_PARAM_OPT,
0, 0},
Expand All @@ -245,7 +245,7 @@ static cmd_export_t cmds[]=
{CMD_PARAM_VAR|CMD_PARAM_OPT, fixup_check_avp, 0},
{0,0,0}},
REQUEST_ROUTE},
{"b2b_bridge_request", (cmd_function)b2b_bridge_request, {
{"b2b_bridge_request", (cmd_function)b2bl_script_bridge_msg, {
{CMD_PARAM_STR,0,0},
{CMD_PARAM_INT,0,0},
{CMD_PARAM_STR|CMD_PARAM_OPT,0,0}, {0,0,0}},
Expand Down Expand Up @@ -1118,7 +1118,7 @@ mi_response_t *mi_trigger_scenario(const mi_params_t *params,
}
}

if (b2bl_bridge_extern(&init_params, &scen_params, e1_id, e2_id,
if (b2bl_init_extern(&init_params, &scen_params, e1_id, e2_id,
0, 0, 0) == NULL) {
resp = init_mi_error(500, MI_SSTR("Failed to initialize scenario"));
goto end;
Expand All @@ -1134,7 +1134,7 @@ mi_response_t *mi_trigger_scenario(const mi_params_t *params,
return resp;
}

int b2b_bridge_request(struct sip_msg* msg, str *key, int *entity_no,
int b2bl_script_bridge_msg(struct sip_msg* msg, str *key, int *entity_no,
str *adv_contact)
{
if (cur_route_ctx.flags & (B2BL_RT_REQ_CTX|B2BL_RT_RPL_CTX)) {
Expand All @@ -1146,7 +1146,7 @@ int b2b_bridge_request(struct sip_msg* msg, str *key, int *entity_no,
return b2bl_bridge_msg(msg, key, *entity_no, adv_contact);
}

static int b2bl_bridge_msg_w(struct sip_msg* msg, str* key, int entity_no)
static int b2bl_api_bridge_msg(struct sip_msg* msg, str* key, int entity_no)
{
return b2bl_bridge_msg(msg, key, entity_no, NULL);
}
Expand Down Expand Up @@ -2164,10 +2164,10 @@ int b2b_logic_bind(b2bl_api_t* api)
LM_ERR("Invalid parameter value\n");
return -1;
}
api->init = internal_init_scenario;
api->bridge = b2bl_bridge;
api->init = b2bl_api_init;
api->bridge = b2bl_api_bridge;
api->bridge_2calls = b2bl_bridge_2calls;
api->bridge_msg = b2bl_bridge_msg_w;
api->bridge_msg = b2bl_api_bridge_msg;
api->terminate_call= b2bl_terminate_call;
api->get_stats = b2bl_get_stats;
api->register_cb = b2bl_register_cb;
Expand Down
33 changes: 16 additions & 17 deletions modules/b2b_logic/bridging.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,6 @@ int process_bridge_200OK(struct sip_msg* msg, str* extra_headers,
/* now I have finnished the BRIDGING scenario -> mark this in the record */
if(tuple->bridge_entities[2] == NULL)
{

/* if there was a renew SDP type, we have to challenge the first
* entity again with an invite, just to update its SDP info */
if (bentity0->sdp_type == B2BL_SDP_RENEW)
Expand Down Expand Up @@ -794,7 +793,7 @@ int process_bridge_200OK(struct sip_msg* msg, str* extra_headers,

#define BUF_LEN 128

int process_bridge_notify(b2bl_entity_id_t *entity, unsigned int hash_index,
int send_bridge_notify(b2bl_entity_id_t *entity, unsigned int hash_index,
struct sip_msg* msg)
{
b2b_req_data_t req_data;
Expand All @@ -805,7 +804,7 @@ int process_bridge_notify(b2bl_entity_id_t *entity, unsigned int hash_index,
static str hdrs = {buf, 0};

if (msg && msg->first_line.type != SIP_REPLY) {
LM_ERR("process_bridge_notify works only with replies!\n");
LM_ERR("send_bridge_notify works only with replies!\n");
return -1;
}

Expand Down Expand Up @@ -905,7 +904,7 @@ static struct b2bl_new_entity *get_ent_to_bridge(b2bl_tuple_t *tuple,
return new_br_ent;
}

int b2b_scenario_bridge(struct sip_msg *msg, str *br_ent1_str, str *br_ent2_str,
int b2b_script_bridge(struct sip_msg *msg, str *br_ent1_str, str *br_ent2_str,
str *provmedia_uri, struct b2b_bridge_params *params)
{
b2bl_tuple_t *tuple;
Expand Down Expand Up @@ -970,9 +969,9 @@ int b2b_scenario_bridge(struct sip_msg *msg, str *br_ent1_str, str *br_ent2_str,
goto done;

if (params->flags & B2BL_BR_FLAG_NOTIFY && entity)
process_bridge_notify(entity, cur_route_ctx.hash_index, NULL);
send_bridge_notify(entity, cur_route_ctx.hash_index, NULL);

if (process_bridge_action(msg, tuple, cur_route_ctx.hash_index,
if (b2bl_bridge(msg, tuple, cur_route_ctx.hash_index,
old_entity, new_br_ent, provmedia_uri, params->lifetime) < 0) {
LM_ERR("Failed to process bridge action\n");
goto done;
Expand Down Expand Up @@ -1009,7 +1008,7 @@ int b2b_scenario_bridge(struct sip_msg *msg, str *br_ent1_str, str *br_ent2_str,
* that this scenario is currently taking place
* */

int process_bridge_action(struct sip_msg* msg, b2bl_tuple_t* tuple,
int b2bl_bridge(struct sip_msg* msg, b2bl_tuple_t* tuple,
unsigned hash_index, b2bl_entity_id_t *old_entity,
struct b2bl_new_entity *new_br_ent[2], str *provmedia_uri, int lifetime)
{
Expand Down Expand Up @@ -1209,7 +1208,7 @@ int process_bridge_action(struct sip_msg* msg, b2bl_tuple_t* tuple,
return -1;
}

str* b2bl_bridge_extern(struct b2b_params *init_params,
str* b2bl_init_extern(struct b2b_params *init_params,
b2bl_init_params_t *scen_params, str *e1_id, str *e2_id,
b2bl_cback_f cbf, void* cb_param, unsigned int cb_mask)
{
Expand Down Expand Up @@ -1259,7 +1258,7 @@ str* b2bl_bridge_extern(struct b2b_params *init_params,
if (e2_id)
e2.id = *e2_id;

if (process_bridge_action(NULL, tuple, hash_index, NULL, new_br_ent,
if (b2bl_bridge(NULL, tuple, hash_index, NULL, new_br_ent,
NULL, 0) < 0) {
LM_ERR("Failed to process bridge action\n");
goto error;
Expand All @@ -1281,7 +1280,7 @@ str* b2bl_bridge_extern(struct b2b_params *init_params,
return 0;
}

int b2bl_bridge(str* key, str* new_dst, str *new_proxy, str* new_from_dname,
int b2bl_api_bridge(str* key, str* new_dst, str *new_proxy, str* new_from_dname,
int entity_no)
{
b2bl_tuple_t* tuple;
Expand Down Expand Up @@ -1464,7 +1463,7 @@ int b2bl_bridge(str* key, str* new_dst, str *new_proxy, str* new_from_dname,
return -1;
}

static struct b2bl_new_entity *b2b_client_new(struct sip_msg *msg, str *id,
static struct b2bl_new_entity *tmp_client_new(struct sip_msg *msg, str *id,
str *dest_uri, str *proxy, pv_spec_t *hnames, pv_spec_t *hvals, str *from_dname)
{
unsigned short type;
Expand Down Expand Up @@ -1559,7 +1558,7 @@ static struct b2bl_new_entity *b2b_client_new(struct sip_msg *msg, str *id,
return NULL;
}

int b2b_bridge_extern(struct sip_msg* msg, str *id, str * params,
int script_trigger_scenario(struct sip_msg* msg, str *id, str * params,
str *ent1, pv_spec_t *ent1_hnames, pv_spec_t *ent1_hvals,
str *ent2, pv_spec_t *ent2_hnames, pv_spec_t *ent2_hvals)
{
Expand Down Expand Up @@ -1627,7 +1626,7 @@ int b2b_bridge_extern(struct sip_msg* msg, str *id, str * params,
(e1_dname ? e1_dname->s : 0)
);

new_br_ent[0] = b2b_client_new(msg, e1_id, e1_to, e1_proxy, ent1_hnames, ent1_hvals, e1_dname);
new_br_ent[0] = tmp_client_new(msg, e1_id, e1_to, e1_proxy, ent1_hnames, ent1_hvals, e1_dname);
if (!new_br_ent[0]) {
LM_ERR("Failed to create entity 1\n");
rc = -1;
Expand Down Expand Up @@ -1674,7 +1673,7 @@ int b2b_bridge_extern(struct sip_msg* msg, str *id, str * params,
);


new_br_ent[1] = b2b_client_new(msg, e2_id, e2_to, e2_proxy, ent2_hnames, ent2_hvals, e2_dname);
new_br_ent[1] = tmp_client_new(msg, e2_id, e2_to, e2_proxy, ent2_hnames, ent2_hvals, e2_dname);
if (!new_br_ent[1]) {
LM_ERR("Failed to create entity 2\n");
rc = -1;
Expand Down Expand Up @@ -1756,7 +1755,7 @@ int b2b_bridge_extern(struct sip_msg* msg, str *id, str * params,
LM_DBG("Found entity\n");
tuple->bridge_flags = B2BL_BR_FLAG_NOTIFY | B2BL_BR_FLAG_DONT_DELETE_BRIDGE_INITIATOR;
tuple->bridge_initiator = cur_tuple->bridge_entities[remote_tuple_party];
process_bridge_notify(cur_tuple->bridge_entities[remote_tuple_party], remote_tuple_hash_index, NULL);
send_bridge_notify(cur_tuple->bridge_entities[remote_tuple_party], remote_tuple_hash_index, NULL);
}
}
lock_release(&b2bl_htable[remote_tuple_hash_index].lock);
Expand All @@ -1775,15 +1774,15 @@ int b2b_bridge_extern(struct sip_msg* msg, str *id, str * params,
LM_DBG("Found entity\n");
tuple->bridge_flags = B2BL_BR_FLAG_NOTIFY | B2BL_BR_FLAG_DONT_DELETE_BRIDGE_INITIATOR;
tuple->bridge_initiator = entity;
process_bridge_notify(entity, cur_route_ctx.hash_index, NULL);
send_bridge_notify(entity, cur_route_ctx.hash_index, NULL);
}
}
lock_release(&b2bl_htable[cur_route_ctx.hash_index].lock);
}
}
LM_DBG("Flags: %u (NOTIFY: %u)\n", tuple->bridge_flags, B2BL_BR_FLAG_NOTIFY);

if (process_bridge_action(msg, tuple, hash_index, NULL, new_br_ent,
if (b2bl_bridge(msg, tuple, hash_index, NULL, new_br_ent,
NULL, 0) < 0) {
LM_ERR("Failed to process bridge action\n");
goto error;
Expand Down
13 changes: 10 additions & 3 deletions modules/b2b_logic/bridging.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,22 @@

mi_response_t *mi_b2b_bridge(const mi_params_t *params,
int entity_no, str *prov_media);
int b2b_scenario_bridge(struct sip_msg *msg, str *br_ent1_str, str *br_ent2_str,
int b2b_script_bridge(struct sip_msg *msg, str *br_ent1_str, str *br_ent2_str,
str *provmedia_uri, struct b2b_bridge_params *params);

int process_bridge_notify(b2bl_entity_id_t *entity, unsigned int hash_index,
int send_bridge_notify(b2bl_entity_id_t *entity, unsigned int hash_index,
struct sip_msg* msg);
int process_bridge_negreply(b2bl_tuple_t* tuple,
unsigned int hash_index, b2bl_entity_id_t* entity, struct sip_msg* msg);
int process_bridge_bye(struct sip_msg* msg, b2bl_tuple_t* tuple,
unsigned int hash_index, b2bl_entity_id_t* entity);
int process_bridge_200OK(struct sip_msg* msg, str* extra_headers,
str* body, b2bl_tuple_t* tuple, unsigned int hash_index,
b2bl_entity_id_t* entity);
b2bl_entity_id_t* entity);

int b2bl_bridge(struct sip_msg* msg, b2bl_tuple_t* tuple,
unsigned hash_index, b2bl_entity_id_t *old_entity,
struct b2bl_new_entity *new_br_ent[2], str *provmedia_uri, int lifetime);
str* b2bl_init_extern(struct b2b_params *init_params,
b2bl_init_params_t *scen_params, str *e1_id, str *e2_id,
b2bl_cback_f cbf, void* cb_param, unsigned int cb_mask);
14 changes: 7 additions & 7 deletions modules/b2b_logic/logic.c
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ int _b2b_handle_reply(struct sip_msg *msg, b2bl_tuple_t *tuple,
entity == (tuple->bridge_entities[2]?tuple->bridge_entities[2]:tuple->bridge_entities[1]) &&
tuple->bridge_flags & B2BL_BR_FLAG_NOTIFY && tuple->bridge_initiator != 0)
{
process_bridge_notify(tuple->bridge_initiator, cur_route_ctx.hash_index, msg);
send_bridge_notify(tuple->bridge_initiator, cur_route_ctx.hash_index, msg);
if(statuscode == 200 || !(tuple->bridge_flags & B2BL_BR_FLAG_RETURN_AFTER_FAILURE))
{
if (!(tuple->bridge_flags & B2BL_BR_FLAG_DONT_DELETE_BRIDGE_INITIATOR)) {
Expand Down Expand Up @@ -2684,7 +2684,7 @@ str* b2b_process_scenario_init(struct sip_msg* msg, b2bl_cback_f cbf,
}


str *init_request(struct sip_msg *msg, struct b2b_params *init_params,
str *b2bl_init_request(struct sip_msg *msg, struct b2b_params *init_params,
b2bl_cback_f cbf, void* cb_param, unsigned int cb_mask, str* custom_hdrs)
{
str* key;
Expand Down Expand Up @@ -2720,7 +2720,7 @@ str *init_request(struct sip_msg *msg, struct b2b_params *init_params,
return key;
}

str* internal_init_scenario(struct sip_msg* msg, str *scen_name,
str* b2bl_api_init(struct sip_msg* msg, str *scen_name,
b2bl_init_params_t *scen_params, b2bl_cback_f cbf, void* cb_param,
unsigned int cb_mask, str* custom_hdrs)
{
Expand Down Expand Up @@ -2771,9 +2771,9 @@ str* internal_init_scenario(struct sip_msg* msg, str *scen_name,
new_entities_no = 2;
}

return init_request(msg, &init_params, cbf, cb_param, cb_mask, custom_hdrs);
return b2bl_init_request(msg, &init_params, cbf, cb_param, cb_mask, custom_hdrs);
} else {
return b2bl_bridge_extern(&init_params, scen_params, NULL, NULL,
return b2bl_init_extern(&init_params, scen_params, NULL, NULL,
cbf, cb_param, cb_mask);
}

Expand All @@ -2791,7 +2791,7 @@ str* internal_init_scenario(struct sip_msg* msg, str *scen_name,
}


int b2b_init_request(struct sip_msg *msg, str *id, struct b2b_params *init_params,
int b2bl_script_init_request(struct sip_msg *msg, str *id, struct b2b_params *init_params,
void *req_routeid, void *reply_routeid, str *init_body, str *init_body_type)
{
str* key;
Expand Down Expand Up @@ -2846,7 +2846,7 @@ int b2b_init_request(struct sip_msg *msg, str *id, struct b2b_params *init_param
(unsigned long)reply_routeid : global_reply_rtid;

/* call the scenario init processing function */
key = init_request(msg, init_params, 0, NULL, 0, cust_headers);
key = b2bl_init_request(msg, init_params, 0, NULL, 0, cust_headers);
if(key) ret = 1;

return ret;
Expand Down
8 changes: 0 additions & 8 deletions modules/b2b_logic/records.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,6 @@ int init_b2bl_htable(void);
extern b2bl_table_t b2bl_htable;
extern unsigned int b2bl_hsize;

int process_bridge_action(struct sip_msg* msg, b2bl_tuple_t* tuple,
unsigned hash_index, b2bl_entity_id_t *old_entity,
struct b2bl_new_entity *new_br_ent[2], str *provmedia_uri, int lifetime);

str* b2bl_bridge_extern(struct b2b_params *init_params,
b2bl_init_params_t *scen_params, str *e1_id, str *e2_id,
b2bl_cback_f cbf, void* cb_param, unsigned int cb_mask);

void destroy_b2bl_htable(void);

b2bl_entity_id_t* b2bl_create_new_entity(enum b2b_entity_type type, str* entity_id,
Expand Down

0 comments on commit 92b7042

Please sign in to comment.