/** * Adds the Applications to a Capability Exchange message. * \note Must be called with a lock on the peer. * @param msg - the message to add to (request/answer) * @param p - the peer to add applications from */ static inline void Snd_CE_add_applications(AAAMessage *msg,peer *p) { int i; app_config *app; char x[4]; AAA_AVP *avp1,*avp2; AAA_AVP_LIST list; str group; list.head=0;list.tail=0; for(i=0;i<config->applications_cnt;i++){ app = config->applications+i; if (app->vendor==0){ set_4bytes(x,app->id); AAACreateAndAddAVPToMessage(msg, (app->type==DP_AUTHORIZATION?AVP_Auth_Application_Id:AVP_Acct_Application_Id), AAA_AVP_FLAG_MANDATORY,0,x,4); }else{ set_4bytes(x,app->vendor); avp1 = AAACreateAVP(AVP_Vendor_Id,AAA_AVP_FLAG_MANDATORY,0,x,4, AVP_DUPLICATE_DATA); AAAAddAVPToList(&list,avp1); set_4bytes(x,app->id); avp2 = AAACreateAVP((app->type==DP_AUTHORIZATION?AVP_Auth_Application_Id:AVP_Acct_Application_Id), AAA_AVP_FLAG_MANDATORY,0,x,4,AVP_DUPLICATE_DATA); AAAAddAVPToList(&list,avp2); group = AAAGroupAVPS(list); AAAFreeAVPList(&list); AAACreateAndAddAVPToMessage(msg, AVP_Vendor_Specific_Application_Id, AAA_AVP_FLAG_MANDATORY,0,group.s,group.len); shm_free(group.s); } } for(i=0;i<config->supported_vendors_cnt;i++){ set_4bytes(x,config->supported_vendors[i]); AAACreateAndAddAVPToMessage(msg,AVP_Supported_Vendor_Id,AAA_AVP_FLAG_MANDATORY,0,x,4); } }
int add_vendor_specific_application_id_group(AAAMessage * msg, unsigned int vendor_id, unsigned int auth_app_id) { char x[4]; AAA_AVP_LIST list_grp = {0, 0}; AAA_AVP *avp; str group = {0, 0}; set_4bytes(x, vendor_id); if (!(avp = AAACreateAVP(AVP_Vendor_Id, AAA_AVP_FLAG_MANDATORY, 0, x, 4, AVP_DUPLICATE_DATA))) goto error; AAAAddAVPToList(&list_grp, avp); set_4bytes(x, auth_app_id); if (!(avp = AAACreateAVP(AVP_Auth_Application_Id, AAA_AVP_FLAG_MANDATORY, 0, x, 4, AVP_DUPLICATE_DATA))) goto error; AAAAddAVPToList(&list_grp, avp); group = AAAGroupAVPS(list_grp); if (!group.s || !group.len) goto error; if (!(avp = AAACreateAVP(AVP_Vendor_Specific_Application_Id, AAA_AVP_FLAG_MANDATORY, 0, group.s, group.len, AVP_DUPLICATE_DATA))) goto error; if (AAAAddAVPToMessage(msg, avp, msg->avpList.tail) != AAA_ERR_SUCCESS) goto error; AAAFreeAVPList(&list_grp); shm_free(group.s); group.s = NULL; return 1; error: AAAFreeAVPList(&list_grp); if (group.s) shm_free(group.s); return 0; }