Skip to content

Commit

Permalink
b2b_sca: port script functions to new param interface
Browse files Browse the repository at this point in the history
  • Loading branch information
rvlad-patrascu committed Apr 2, 2019
1 parent 5596758 commit 5c01269
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 49 deletions.
14 changes: 9 additions & 5 deletions modules/b2b_sca/b2b_sca.c
Expand Up @@ -48,8 +48,8 @@ extern str app_state[];
static int mod_init(void);
static void mod_destroy(void);
static int child_init(int rank);
int sca_init_request(struct sip_msg* msg);
int sca_bridge_request(struct sip_msg* msg, str* arg1, str* arg2);
int sca_init_request(struct sip_msg* msg, int *shared_entity);
int sca_bridge_request(struct sip_msg* msg, str* arg1);
mi_response_t *mi_sca_list(const mi_params_t *params,
struct mi_handler *async_hdl);

Expand Down Expand Up @@ -86,9 +86,13 @@ str presence_server = {NULL, 0};
/** Exported functions */
static cmd_export_t cmds[]=
{
{"sca_init_request" ,(cmd_function)sca_init_request ,1,fixup_pvar_pvar,0,REQUEST_ROUTE},
{"sca_bridge_request",(cmd_function)sca_bridge_request,1,fixup_pvar_pvar,0,REQUEST_ROUTE},
{ 0, 0, 0 , 0 , 0, 0}
{"sca_init_request" ,(cmd_function)sca_init_request, {
{CMD_PARAM_INT,0,0}, {0,0,0}},
REQUEST_ROUTE},
{"sca_bridge_request",(cmd_function)sca_bridge_request, {
{CMD_PARAM_STR,0,0}, {0,0,0}},
REQUEST_ROUTE},
{0,0,{{0,0,0}},0}
};

/** Exported parameters */
Expand Down
53 changes: 9 additions & 44 deletions modules/b2b_sca/sca_logic.c
Expand Up @@ -635,16 +635,15 @@ int sca_logic_notify(b2bl_cb_params_t *params, unsigned int b2b_event)
}


int sca_init_request(struct sip_msg* msg, str* p1, str* p2)
int sca_init_request(struct sip_msg* msg, int *shared_entity)
{
int method_value, ret;
//unsigned int size, hash_index, shared_entity;
unsigned int hash_index, shared_entity, app_index;
unsigned int hash_index, app_index;
str *b2bl_key, *host, *port, *display, *uri, *shared_line;
//char *p;
//uri_type scheme;
struct to_body *appearance_name_addr_body;
pv_value_t pv_val;
b2b_sca_record_t *record = NULL;
b2b_sca_call_t *call = NULL;
b2bl_cb_ctx_t *cb_params;
Expand Down Expand Up @@ -673,26 +672,7 @@ int sca_init_request(struct sip_msg* msg, str* p1, str* p2)
return 0;
}

if (p1 && (pv_get_spec_value(msg, (pv_spec_t *)p1, &pv_val) == 0)) {
if (pv_val.flags & PV_VAL_INT) {
shared_entity = pv_val.ri;
LM_DBG("got shared_entity %d\n", shared_entity);
} else if (pv_val.flags & PV_VAL_STR) {
if(str2int(&(pv_val.rs), (unsigned int*)&shared_entity) != 0) {
LM_ERR("Unable to get entity_no from pv '%.*s'\n",
pv_val.rs.len, pv_val.rs.s);
return -1;
}
} else {
LM_ERR("shared entity not a str or int type\n");
return -1;
}
} else {
LM_ERR("Unable to get shared entity from pv:%p\n", p1);
return -1;
}

switch (shared_entity) {
switch (*shared_entity) {
case 0:
LM_DBG("Incoming call from shared line\n");
break;
Expand Down Expand Up @@ -740,7 +720,7 @@ int sca_init_request(struct sip_msg* msg, str* p1, str* p2)

/* Adding call to the sca_table. */
lock_get(&b2b_sca_htable[hash_index].lock);
if (b2b_sca_add_call_record(hash_index, shared_line, shared_entity, app_index,
if (b2b_sca_add_call_record(hash_index, shared_line, *shared_entity, app_index,
&call_info_uri, &call_info_apperance_uri, &record, &call) != 0) {
LM_ERR("unable to add record to sca htable\n");
goto error2;
Expand Down Expand Up @@ -813,10 +793,8 @@ int sca_init_request(struct sip_msg* msg, str* p1, str* p2)
}


int sca_bridge_request(struct sip_msg* msg, str* p1, str* p2)
int sca_bridge_request(struct sip_msg* msg, str* shared_line)
{
pv_value_t pv_val;
str shared_line = {NULL, 0};
str publish_hdr = {NULL, 0};
int method_value, ret;
//int entity_no;
Expand All @@ -826,23 +804,10 @@ int sca_bridge_request(struct sip_msg* msg, str* p1, str* p2)

unsigned int appearance;

if (p1 && (pv_get_spec_value(msg, (pv_spec_t *)p1, &pv_val) == 0)) {
if (pv_val.flags & PV_VAL_STR) {
LM_DBG("got shared_line:'%.*s'\n", pv_val.rs.len, pv_val.rs.s);
shared_line = pv_val.rs;
} else {
LM_ERR("Unable to get shared_line from PV that is not a string\n");
return -1;
}
} else {
LM_ERR("Unable to get shared_line from pv:%p\n", p1);
return -1;
}

/* Get the hash index for the shared line. */
hash_index = core_hash(&shared_line, NULL, b2b_sca_hsize);
hash_index = core_hash(shared_line, NULL, b2b_sca_hsize);
LM_DBG("got hash_index=[%d] for shared line [%.*s]\n",
hash_index, shared_line.len, shared_line.s);
hash_index, shared_line->len, shared_line->s);

if (parse_headers(msg, HDR_EOH_F, 0) < 0) {
LM_ERR("failed to parse message\n");
Expand Down Expand Up @@ -873,11 +838,11 @@ int sca_bridge_request(struct sip_msg* msg, str* p1, str* p2)
if (appearance==0) return -1;

lock_get(&b2b_sca_htable[hash_index].lock);
record = b2b_sca_search_record_safe(hash_index, &shared_line);
record = b2b_sca_search_record_safe(hash_index, shared_line);
if (record == NULL) {
lock_release(&b2b_sca_htable[hash_index].lock);
LM_ERR("record not found for shared line [%.*s] on hash index [%d]\n",
shared_line.len, shared_line.s, hash_index);
shared_line->len, shared_line->s, hash_index);
// FIXME:
/* Build an empty PUBLISH header */
//if (build_publish_call_info_header(NULL, &publish_hdr) != 0) {
Expand Down

0 comments on commit 5c01269

Please sign in to comment.