Created
December 17, 2013 17:27
-
-
Save caruizdiaz/8008968 to your computer and use it in GitHub Desktop.
return code as alphanumeric AVP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static int create_cca_return_code(int result) { | |
int rc; | |
int_str avp_val, avp_name; | |
avp_name.s.s = RO_AVP_CCA_RETURN_CODE; | |
avp_name.s.len = RO_AVP_CCA_RETURN_CODE_LENGTH; | |
avp_val.n = result; | |
avp_val.s.s = RO_RETURN_TRUE_STR; //assume true | |
avp_val.s.len = 1; | |
switch(result) { | |
case RO_RETURN_FALSE: | |
avp_val.s.s = RO_RETURN_FALSE_STR; | |
break; | |
case RO_RETURN_ERROR: | |
avp_val.s.s = RO_RETURN_ERROR_STR; | |
break; | |
default: | |
if (result >= 0) | |
break; | |
LM_ERR("Unknown result code: %d", result); | |
avp_val.s.s = "??"; | |
} | |
if (result < 0) | |
avp_val.s.len = 2; | |
rc = add_avp(AVP_NAME_STR|AVP_VAL_STR, avp_name, avp_val); | |
if (rc < 0) | |
LM_ERR("Couldn't create ["RO_AVP_CCA_RETURN_CODE"] AVP\n"); | |
else | |
LM_DBG("Created AVP ["RO_AVP_CCA_RETURN_CODE"] successfully: value=[%d]\n", result); | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment