/** * Returns the Visited-Network-ID AVP from a Diameter message. * @param msg - the Diameter message * @returns the AVP payload on success or an empty string on error */ inline str Cx_get_visited_network_id(AAAMessage *msg) { return Cx_get_avp(msg, AVP_IMS_Visited_Network_Identifier, IMS_vendor_id_3GPP, __FUNCTION__); }
/** * Returns the Destination-Host from a Diameter message. * @param msg - the Diameter message * @returns the AVP payload on success or an empty string on error */ inline str Cx_get_destination_host(AAAMessage *msg) { return Cx_get_avp(msg, AVP_Destination_Host, 0, __FUNCTION__); }
/** * Returns the User-Name AVP from a Diameter message. * @param msg - the Diameter message * @returns the AVP payload on success or an empty string on error */ inline str Cx_get_user_name(AAAMessage *msg) { return Cx_get_avp(msg, AVP_User_Name, 0, __FUNCTION__); }
/** * Returns the Public-Identity AVP from a Diameter message. * @param msg - the Diameter message * @returns the AVP payload on success or an empty string on error */ inline str Cx_get_public_identity(AAAMessage *msg) { return Cx_get_avp(msg, AVP_IMS_Public_Identity, IMS_vendor_id_3GPP, __FUNCTION__); }
/** * Returns the Session-Id AVP of a Diameter message. * @param msg - the Diameter message * @returns AVP payload on success or an empty string on error */ inline str Cx_get_session_id(AAAMessage *msg) { return Cx_get_avp(msg, AVP_Session_Id, 0, __FUNCTION__); }
/** * Returns the Server-Name AVP from a Diameter message. * @param msg - the Diameter message * @returns the AVP payload on success or an empty string on error */ inline str Cx_get_server_name(AAAMessage *msg) { return Cx_get_avp(msg, AVP_IMS_Server_Name, IMS_vendor_id_3GPP, __FUNCTION__); }
/** * Returns the User-Data from a Diameter message. * @param msg - the Diameter message * @returns the AVP payload on success or an empty string on error */ inline str Cx_get_user_data(AAAMessage *msg) { return Cx_get_avp(msg, AVP_IMS_User_Data, IMS_vendor_id_3GPP, __FUNCTION__); }
/** * Returns the Auth-Data-Item from a Diameter Request message. * @param msg - the Diameter message * @param auth_scheme - the string to fill with the authorization scheme * @param authorization - the string to fill with the authorization * @returns the AVP payload on success or an empty string on error */ inline int Cx_get_auth_data_item_request(AAAMessage *msg, str *auth_scheme, str *authorization) { AAA_AVP_LIST list; AAA_AVP *avp; str grp; grp = Cx_get_avp(msg, AVP_IMS_SIP_Auth_Data_Item, IMS_vendor_id_3GPP, __FUNCTION__); if (!grp.s) return 0; list = cdpb.AAAUngroupAVPS(grp); avp = cdpb.AAAFindMatchingAVPList(list,0,AVP_IMS_SIP_Authentication_Scheme, IMS_vendor_id_3GPP,0); if (!avp||!avp->data.s) { cdpb.AAAFreeAVPList(&list); return 0; } *auth_scheme = avp->data; avp = cdpb.AAAFindMatchingAVPList(list,0,AVP_IMS_SIP_Authorization, IMS_vendor_id_3GPP,0); if (avp) *authorization = avp->data; else {authorization->s=0;authorization->len=0;} cdpb.AAAFreeAVPList(&list); return 1; }
/** * Returns the User-Data-Available AVP from a Diameter message. * @param msg - the Diameter message * @returns the AVP payload on success or an empty string on error */ inline int Cx_get_userdata_available(AAAMessage *msg, int *data) { str s; s = Cx_get_avp(msg, AVP_IMS_User_Data_Already_Available, IMS_vendor_id_3GPP, __FUNCTION__); if (!s.s) return 0; *data = get_4bytes(s.s); return 1; }
/** * Returns the Server-Assignment-Type AVP from a Diameter message. * @param msg - the Diameter message * @returns the AVP payload on success or an empty string on error */ inline int Cx_get_server_assignment_type(AAAMessage *msg, int *data) { str s; s = Cx_get_avp(msg, AVP_IMS_Server_Assignment_Type, IMS_vendor_id_3GPP, __FUNCTION__); if (!s.s) return 0; *data = get_4bytes(s.s); return 1; }
/** * Returns the Result-Code AVP from a Diameter message. * @param msg - the Diameter message * @returns the AVP payload on success or an empty string on error */ inline int Cx_get_result_code(AAAMessage *msg, int *data) { str s; s = Cx_get_avp(msg, AVP_Result_Code, 0, __FUNCTION__); if (!s.s) return 0; *data = get_4bytes(s.s); return 1; }
/** * Returns the Authorization-Type AVP from a Diameter message. * @param msg - the Diameter message * @returns the AVP payload on success or an empty string on error */ inline int Cx_get_authorization_type(AAAMessage *msg, int *data) { str s; s = Cx_get_avp(msg, AVP_IMS_User_Authorization_Type, IMS_vendor_id_3GPP, __FUNCTION__); if (!s.s) return 0; *data = get_4bytes(s.s); return 1; }
/** * Returns the SIP-Number-Auth-Items AVP from a Diameter message. * @param msg - the Diameter message * @returns the number or 0 on error */ inline int Cx_get_sip_number_auth_items(AAAMessage *msg, int *data) { str s; s = Cx_get_avp(msg, AVP_IMS_SIP_Number_Auth_Items, IMS_vendor_id_3GPP, __FUNCTION__); if (!s.s) return 0; *data = get_4bytes(s.s); return 1; }
/** * Returns the Charging-Information from a Diameter message. * @param msg - the Diameter message * @returns the AVP payload on success or an empty string on error */ inline int Cx_get_charging_info(AAAMessage *msg,str *ccf1,str *ccf2,str *ecf1,str *ecf2) { AAA_AVP_LIST list; AAA_AVP *avp; str grp; grp = Cx_get_avp(msg, AVP_IMS_Charging_Information, IMS_vendor_id_3GPP, __FUNCTION__); if (!grp.s) return 0; list = cdpb.AAAUngroupAVPS(grp); if (ccf1){ avp = cdpb.AAAFindMatchingAVPList(list,0,AVP_IMS_Primary_Charging_Collection_Function_Name, IMS_vendor_id_3GPP,0); if (avp) *ccf1 = avp->data; } if (ccf2){ avp = cdpb.AAAFindMatchingAVPList(list,0,AVP_IMS_Secondary_Charging_Collection_Function_Name, IMS_vendor_id_3GPP,0); if (avp) *ccf2 = avp->data; } if (ecf1){ avp = cdpb.AAAFindMatchingAVPList(list,0,AVP_IMS_Primary_Event_Charging_Function_Name, IMS_vendor_id_3GPP,0); if (avp) *ecf1 = avp->data; } if (ecf2){ avp = cdpb.AAAFindMatchingAVPList(list,0,AVP_IMS_Secondary_Event_Charging_Function_Name, IMS_vendor_id_3GPP,0); if (avp) *ecf2 = avp->data; } cdpb.AAAFreeAVPList(&list); return 1; }
/** * Returns the Capabilities from the grouped AVP from a Diameter message. * @param msg - the Diameter message * @param m - array to be filled with the retrieved mandatory capabilities * @param m_cnt - size of the array above to be filled * @param o - array to be filled with the retrieved optional capabilities * @param o_cnt - size of the array above to be filled * @returns 1 on success 0 on fail */ inline int Cx_get_capabilities(AAAMessage *msg,int **m,int *m_cnt,int **o,int *o_cnt) { AAA_AVP_LIST list; AAA_AVP *avp; str grp; grp = Cx_get_avp(msg, AVP_IMS_Server_Capabilities, IMS_vendor_id_3GPP, __FUNCTION__); if (!grp.s) return 0; list = cdpb.AAAUngroupAVPS(grp); avp = list.head; *m_cnt=0; *o_cnt=0; while(avp){ if (avp->code == AVP_IMS_Mandatory_Capability) (*m_cnt)++; if (avp->code == AVP_IMS_Optional_Capability) (*o_cnt)++; avp = avp->next; } avp = list.head; *m=shm_malloc(sizeof(int)*(*m_cnt)); *o=shm_malloc(sizeof(int)*(*o_cnt)); *m_cnt=0; *o_cnt=0; while(avp){ if (avp->code == AVP_IMS_Mandatory_Capability) (*m)[(*m_cnt)++]=get_4bytes(avp->data.s); if (avp->code == AVP_IMS_Optional_Capability) (*o)[(*o_cnt)++]=get_4bytes(avp->data.s); avp = avp->next; } cdpb.AAAFreeAVPList(&list); return 1; }
/** * Returns the Experimental-Result-Code AVP from a Diameter message. * @param msg - the Diameter message * @returns the AVP payload on success or an empty string on error */ inline int Cx_get_experimental_result_code(AAAMessage *msg, int *data) { AAA_AVP_LIST list; AAA_AVP *avp; str grp; grp = Cx_get_avp(msg, AVP_IMS_Experimental_Result, 0, __FUNCTION__); if (!grp.s) return 0; list = cdpb.AAAUngroupAVPS(grp); avp = cdpb.AAAFindMatchingAVPList(list,0,AVP_IMS_Experimental_Result_Code,0,0); if (!avp||!avp->data.s) { cdpb.AAAFreeAVPList(&list); return 0; } *data = get_4bytes(avp->data.s); cdpb.AAAFreeAVPList(&list); return 1; }
/** * Returns the Capabilities from the grouped AVP from a Diameter message. * @param msg - the Diameter message * @param m - array to be filled with the retrieved mandatory capabilities * @param m_cnt - size of the array above to be filled * @param o - array to be filled with the retrieved optional capabilities * @param o_cnt - size of the array above to be filled * @returns 1 on success 0 on fail */ inline int Cx_get_capabilities(AAAMessage *msg,int **m,int *m_cnt,int **o,int *o_cnt, str **p,int *p_cnt) { AAA_AVP_LIST list; AAA_AVP *avp; str grp; grp = Cx_get_avp(msg, AVP_IMS_Server_Capabilities, IMS_vendor_id_3GPP, __FUNCTION__); if (!grp.s) return 0; list = cdpb.AAAUngroupAVPS(grp); avp = list.head; *m_cnt=0; *o_cnt=0; *p_cnt=0; while(avp){ if (avp->code == AVP_IMS_Mandatory_Capability) (*m_cnt)++; if (avp->code == AVP_IMS_Optional_Capability) (*o_cnt)++; if (avp->code == AVP_IMS_Server_Name) (*p_cnt)++; avp = avp->next; } avp = list.head; *m=shm_malloc(sizeof(int)*(*m_cnt)); if (!*m){ LOG(L_ERR,"ERROR:"M_NAME":Cx_get_capabilities(): cannot allocated %d bytes of shm.\n", sizeof(int)*(*m_cnt)); goto error; } *o=shm_malloc(sizeof(int)*(*o_cnt)); if (!*o){ LOG(L_ERR,"ERROR:"M_NAME":Cx_get_capabilities(): cannot allocated %d bytes of shm.\n", sizeof(int)*(*o_cnt)); goto error; } *p=shm_malloc(sizeof(str)*(*p_cnt)); if (!*p){ LOG(L_ERR,"ERROR:"M_NAME":Cx_get_capabilities(): cannot allocated %d bytes of shm.\n", sizeof(str)*(*p_cnt)); goto error; } *m_cnt=0; *o_cnt=0; *p_cnt=0; while(avp){ if (avp->code == AVP_IMS_Mandatory_Capability) (*m)[(*m_cnt)++]=get_4bytes(avp->data.s); if (avp->code == AVP_IMS_Optional_Capability) (*o)[(*o_cnt)++]=get_4bytes(avp->data.s); if (avp->code == AVP_IMS_Server_Name) (*p)[(*p_cnt)++]=avp->data; avp = avp->next; } cdpb.AAAFreeAVPList(&list); return 1; error: cdpb.AAAFreeAVPList(&list); if (*m) shm_free(*m); if (*o) shm_free(*o); if (*p) shm_free(*p); *m_cnt=0; *o_cnt=0; *p_cnt=0; return 0; }