Skip to content

Commit

Permalink
cgrates: align return codes with documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
razvancrainea committed Jan 25, 2017
1 parent 53c2c75 commit 258263c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions modules/cgrates/cgrates_acc.c
Expand Up @@ -430,18 +430,18 @@ int w_cgr_acc(struct sip_msg* msg, char *flag_c, char* acc_c, char *dst_c)

if (!cgr_dlgb.get_dlg) {
LM_ERR("cannot do cgrates accounting without dialog support!\n");
return -3;
return -2;
}

if ((acc = cgr_get_acc(msg, acc_c)) == NULL)
return -4;
return -2;
if ((dst = cgr_get_dst(msg, dst_c)) == NULL)
return -4;
return -2;

/* get the dialog */
if (!cgr_dlgb.get_dlg() && cgr_dlgb.create_dlg(msg, 0) < 0) {
LM_ERR("Cannot create dialog!\n");
return -2;
return -1;
}

ctx = cgr_get_acc_ctx();
Expand Down
6 changes: 3 additions & 3 deletions modules/cgrates/cgrates_acc.h
Expand Up @@ -29,9 +29,9 @@
* - destination (optional)
* Returns:
* - 1: user is allowed to call
* - -1: cgrates error
* - -2: internal error
* - -3: no suitable cgrates server found
* - -1: internal error
* - -2: cgrates error
* - -3: invalid message type
* - -4: invalid message
*/
int w_cgr_acc(struct sip_msg* msg, char *flag_c, char* acc_c, char *dst_c);
Expand Down
12 changes: 6 additions & 6 deletions modules/cgrates/cgrates_auth.c
Expand Up @@ -31,15 +31,15 @@ static int cgr_proc_auth_reply(struct cgr_conn *c, json_object *jobj,
val.s.len = strlen(error);
if (cgrates_set_reply(CGR_KVF_TYPE_STR, &val) < 0) {
LM_ERR("cannot set the reply code!\n");
return -2;
return -1;
}
return -1;
return -2;
}

if (json_object_get_type(jobj) != json_type_int) {
LM_ERR("CGRateS returned a non-int type in Auth reply: %d %s\n",
json_object_get_type(jobj), json_object_to_json_string(jobj));
return -4;
return -5;
}
val.n = json_object_get_int(jobj);
/* -1: always allowed (postpaid)
Expand All @@ -48,9 +48,9 @@ static int cgr_proc_auth_reply(struct cgr_conn *c, json_object *jobj,
*/
if (cgrates_set_reply(CGR_KVF_TYPE_INT, &val) < 0) {
LM_ERR("cannot set the reply value!\n");
return -2;
return -1;
}
return ((val.n == 0) ? -1: 1);
return ((val.n == 0) ? -2: 1);
}

static json_object *cgr_get_auth_msg(struct sip_msg *msg, str *acc, str *dst)
Expand Down Expand Up @@ -120,7 +120,7 @@ int w_cgr_auth(struct sip_msg* msg, char* acc_c, char *dst_c)
jmsg = cgr_get_auth_msg(msg, acc, dst);
if (!jmsg) {
LM_ERR("cannot build the json to send to cgrates\n");
return -2;
return -1;
}

return cgr_handle_cmd(msg, jmsg, cgr_proc_auth_reply, NULL);
Expand Down
5 changes: 3 additions & 2 deletions modules/cgrates/cgrates_auth.h
Expand Up @@ -29,10 +29,11 @@
* - destination (optional)
* Returns:
* - 1: user is allowed to call
* - -1: cgrates error
* - -2: internal error
* - -1: internal error
* - -2: cgrates error
* - -3: no suitable cgrates server found
* - -4: invalid message
* - -5: invalid CGRateS message
*/
int w_cgr_auth(struct sip_msg* msg, char* acc_c, char *dst_c);

Expand Down
7 changes: 3 additions & 4 deletions modules/cgrates/cgrates_common.c
Expand Up @@ -224,7 +224,7 @@ int cgrates_set_reply(int type, int_str *value)
ctx = pkg_malloc(sizeof(*ctx));
if (!ctx) {
LM_ERR("out of pkg memory\n");
return -2;
return -1;
}
memset(ctx, 0, sizeof(*ctx));
CGR_PUT_LOCAL_CTX(ctx);
Expand All @@ -234,7 +234,7 @@ int cgrates_set_reply(int type, int_str *value)
((type & CGR_KVF_TYPE_STR)?value->s.len:0));
if (!ctx->reply) {
LM_ERR("out of memory!\n");
return -2;
return -1;
}
ctx->reply_flags = type;
if (type & CGR_KVF_TYPE_STR) {
Expand Down Expand Up @@ -422,7 +422,6 @@ struct cgr_ctx *cgr_ctx_new(void)

/* CGR logic */
/* Returns:
* 2 - if cgrates already engaged by a different call
* 1 - if cgrates successfully engaged
* -1 - cgrates returned error
* -2 - internal error
Expand Down Expand Up @@ -555,7 +554,7 @@ int cgrc_async_read(struct cgr_conn *c,
disable:
cgrc_close(c, 0);
async_status = ASYNC_DONE_CLOSE_FD;
return -1;
return -2;
}


Expand Down

0 comments on commit 258263c

Please sign in to comment.