int s6a_parse_experimental_result(struct avp *avp, s6a_experimental_result_t *ptr) { struct avp_hdr *hdr; struct avp *child_avp = NULL; if (!avp) { return EINVAL; } CHECK_FCT(fd_msg_avp_hdr(avp, &hdr)); DevAssert(hdr->avp_code == AVP_CODE_EXPERIMENTAL_RESULT); CHECK_FCT(fd_msg_browse(avp, MSG_BRW_FIRST_CHILD, &child_avp, NULL)); while(child_avp) { CHECK_FCT(fd_msg_avp_hdr(child_avp, &hdr)); switch(hdr->avp_code) { case AVP_CODE_EXPERIMENTAL_RESULT_CODE: S6A_ERROR("Got experimental error %u:%s\n", hdr->avp_value->u32, experimental_retcode_2_string(hdr->avp_value->u32)); if (ptr) { *ptr = (s6a_experimental_result_t)hdr->avp_value->u32; } break; case AVP_CODE_VENDOR_ID: DevCheck(hdr->avp_value->u32 == 10415, hdr->avp_value->u32, AVP_CODE_VENDOR_ID, 10415); break; default: return -1; } /* Go to next AVP in the grouped AVP */ CHECK_FCT(fd_msg_browse(child_avp, MSG_BRW_NEXT, &child_avp, NULL)); } return 0; }
int s6a_init(const mme_config_t *mme_config_p) { int ret; S6A_DEBUG("Initializing S6a interface\n"); memset(&s6a_fd_cnf, 0, sizeof(s6a_fd_cnf_t)); /*if (strcmp(fd_core_version(), FREE_DIAMETER_MINIMUM_VERSION) != 0) { S6A_ERROR("Freediameter version %s found, expecting %s\n", fd_core_version(), FREE_DIAMETER_MINIMUM_VERSION); return -1; } else { S6A_DEBUG("Freediameter version %s\n", fd_core_version()); }*/ /* Initializing freeDiameter core */ S6A_DEBUG("Initializing freeDiameter core...\n"); ret = fd_core_initialize(); if (ret != 0) { S6A_ERROR("An error occurred during freeDiameter core library initialization: %d\n",ret); return ret; } else { S6A_DEBUG("Initializing freeDiameter core done\n"); } S6A_DEBUG("Default ext path: %s\n", DEFAULT_EXTENSIONS_PATH); ret = fd_core_parseconf(mme_config_p->s6a_config.conf_file); if (ret != 0) { S6A_ERROR("An error occurred during fd_core_parseconf file :%s.\n", mme_config_p->s6a_config.conf_file); return ret; } /* Set gnutls debug level ? */ if (gnutls_debug) { gnutls_global_set_log_function((gnutls_log_func)fd_gnutls_debug); gnutls_global_set_log_level (gnutls_debug); S6A_DEBUG("Enabled GNUTLS debug at level %d", gnutls_debug); } /* Starting freeDiameter core */ ret = fd_core_start(); if (ret != 0) { S6A_ERROR("An error occurred during freeDiameter core library start\n"); return ret; } ret = fd_core_waitstartcomplete(); if (ret != 0) { S6A_ERROR("An error occurred during fd_core_waitstartcomplete.\n"); return ret; } ret = s6a_fd_init_dict_objs(); if (ret != 0) { S6A_ERROR("An error occurred during s6a_fd_init_dict_objs.\n"); return ret; } /* Trying to connect to peers */ CHECK_FCT(s6a_fd_new_peer()); if (itti_create_task(TASK_S6A, &s6a_thread, NULL) < 0) { S6A_ERROR("s6a create task\n"); return -1; } S6A_DEBUG("Initializing S6a interface: DONE\n"); return 0; }