00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #include "pana_provider_info.h"
00035
00036 void PANA_ProviderInfoTool::Add(diameter_grouped_t &grp, PANA_CfgProviderInfo &pInfo)
00037 {
00038 AAAAvpContainerManager cm;
00039 AAAAvpContainerEntryManager em;
00040 AAAAvpContainerEntry *e;
00041
00042
00043 if (pInfo.id_ > 0) {
00044 AAAAvpContainer *c_id = cm.acquire("Provider-Identifier");
00045 e = em.acquire(AAA_AVP_UINTEGER32_TYPE);
00046 diameter_unsigned32_t &pid = e->dataRef(Type2Type<diameter_unsigned32_t>());
00047 c_id->add(e);
00048 grp.add(c_id);
00049
00050
00051 pid = pInfo.id_;
00052 }
00053
00054
00055 AAAAvpContainer *c_name = cm.acquire("Provider-Name");
00056 e = em.acquire(AAA_AVP_UTF8_STRING_TYPE);
00057 diameter_utf8string_t &pname = e->dataRef(Type2Type<diameter_utf8string_t>());
00058 c_name->add(e);
00059 grp.add(c_name);
00060
00061
00062 pname.assign(pInfo.name_.data(), pInfo.name_.length());
00063 }
00064
00065 void PANA_ProviderInfoTool::Extract(diameter_grouped_t &grp, PANA_CfgProviderInfo &pInfo)
00066 {
00067 if (AAAAvpContainer *c_name = grp.search("Provider-Name")) {
00068 diameter_utf8string_t &name = (*c_name)[0]->dataRef(Type2Type<diameter_utf8string_t>());
00069 pInfo.name_.assign(name.data(), name.length());
00070 }
00071
00072 if (AAAAvpContainer *c_id = grp.search("Provider-Identifier")) {
00073 diameter_unsigned32_t &id = (*c_id)[0]->dataRef(Type2Type<diameter_unsigned32_t>());
00074 pInfo.id_ = id;
00075 }
00076 }
00077
00078
00079