void _exit(const std::string & msg) {
- std::cout << std::endl << msg << std::endl;
- exit(-1);
+ std::cout << std::endl << msg << std::endl;
+ exit(-1);
}
int main(int argc, char** argv) {
- Logger::setLevel(Logger::Debug);
- Logger::initialize("stackManagement", new TraceWriter("file.trace", 2048000));
- stack::Engine & engine = stack::Engine::instantiate();
- std::string exec = argv[0];
- std::string param = argv[1] ? argv[1] : "";
-
- if (argc < 2) {
- std::string msg = anna::functions::asString("Usage: %s <list of xml dictionaries overloaded>,\n i.e. '%s avps.xml commands.xml'", exec.c_str(), exec.c_str());
- _exit(msg);
- }
-
- int index = 1;
- const char *xmlFile = argv[index];
- stack::Dictionary *dictionary;
-
- try {
- dictionary = engine.createDictionary(0 /* general unique stack id */);
- dictionary->allowUpdates();
-
- while (xmlFile) {
- dictionary->load(xmlFile);
- xmlFile = argv[++index];
- }
-
- engine.removeStack(0);
- // Trace:
- LOGINFORMATION(Logger::information(engine.asString(), ANNA_FILE_LOCATION));
- LOGDEBUG(Logger::debug(dictionary->asString(), ANNA_FILE_LOCATION));
- // Output:
- std::ofstream out("./result.xml", std::ifstream::out);
- std::string buffer = dictionary->asXMLString();
- out.write(buffer.c_str(), buffer.size());
- out.close();
- std::cout << "Written 'result.xml'" << std::endl;
- } catch (anna::RuntimeException &ex) {
- ex.trace();
- std::cout << ex.getText() << std::endl;
- }
-
- _exit("Open 'file.trace' in order to see the stacks loaded");
+ Logger::setLevel(Logger::Debug);
+ Logger::initialize("stackManagement", new TraceWriter("file.trace", 2048000));
+ stack::Engine & engine = stack::Engine::instantiate();
+ std::string exec = argv[0];
+ std::string param = argv[1] ? argv[1] : "";
+
+ if(argc < 2) {
+ std::string msg = anna::functions::asString("Usage: %s <list of xml dictionaries overloaded>,\n i.e. '%s avps.xml commands.xml'", exec.c_str(), exec.c_str());
+ _exit(msg);
+ }
+
+ int index = 1;
+ const char *xmlFile = argv[index];
+ stack::Dictionary *dictionary;
+
+ try {
+ dictionary = engine.createDictionary(0 /* general unique stack id */);
+ dictionary->allowUpdates();
+
+ while(xmlFile) {
+ dictionary->load(xmlFile);
+ xmlFile = argv[++index];
+ }
+
+ engine.removeStack(0);
+ // Trace:
+ LOGINFORMATION(Logger::information(engine.asString(), ANNA_FILE_LOCATION));
+ LOGDEBUG(Logger::debug(dictionary->asString(), ANNA_FILE_LOCATION));
+ // Output:
+ std::ofstream out("./result.xml", std::ifstream::out);
+ std::string buffer = dictionary->asXMLString();
+ out.write(buffer.c_str(), buffer.size());
+ out.close();
+ std::cout << "Written 'result.xml'" << std::endl;
+ } catch(anna::RuntimeException &ex) {
+ ex.trace();
+ std::cout << ex.getText() << std::endl;
+ }
+
+ _exit("Open 'file.trace' in order to see the stacks loaded");
}
void _exit(const std::string & msg) {
- std::cout << std::endl << msg << std::endl;
- exit(-1);
+ std::cout << std::endl << msg << std::endl;
+ exit(-1);
}
std::string exec_cmd(const char* cmd) {
FILE* pipe = popen(cmd, "r");
- if (!pipe) return "";
+
+ if(!pipe) return "";
+
char buffer[128];
std::string result = "";
+
while(!feof(pipe)) {
if(fgets(buffer, 128, pipe) != NULL)
result += buffer;
}
+
pclose(pipe);
return result;
}
std::string exec = argv[0];
std::string param = argv[1] ? argv[1] : "";
- if (argc < 2) {
+ if(argc < 2) {
std::string msg = "Usage: "; msg += exec; msg += " <xml directory>";
msg += "\n xml directory: contains the xml files needed, which are:";
msg += "\n";
msg += "\n";
msg += "\n For example: "; msg += exec; msg += " ";
std::string projectRoot = exec_cmd("git rev-parse --show-toplevel");
- if (projectRoot != "") {
+
+ if(projectRoot != "") {
//projectRoot.resize(projectRoot.size()-1);
- projectRoot.erase(projectRoot.size()-1);
+ projectRoot.erase(projectRoot.size() - 1);
msg += projectRoot;
msg += "/";
}
msg += "source/diameter/stack/setups";
-
_exit(msg);
}
dictionary->load(param + "/avps_tme.xml");
dictionary->load(param + "/commands_dccaOCS-CS_HuaweiNGIN_de-es.xml");
codecEngine->setDictionary(dictionary);
-
// Trace:
LOGINFORMATION(Logger::information(stackEngine.asString(), ANNA_FILE_LOCATION));
LOGDEBUG(Logger::debug(dictionary->asString(), ANNA_FILE_LOCATION));
LOGDEBUG(Logger::debug(codecEngine->asString(), ANNA_FILE_LOCATION));
-
- } catch (anna::RuntimeException &ex) {
+ } catch(anna::RuntimeException &ex) {
ex.trace();
std::cout << ex.getText() << std::endl;
}
// Build CCA
tmeMessage cca;
cca.setId("Credit-Control-Answer");
-
tmeAvp *sid = (tmeAvp*)cca.addAvp("Session-Id");
tmeAvp *ohst = (tmeAvp*)cca.addAvp("Origin-Host");
tmeAvp *orlm = (tmeAvp*)cca.addAvp("Origin-Realm");
-
- sid->getUTF8String()->setValue("grump.example.com:33041;23432;893;0AF3B81");
+ sid->getUTF8String()->setValue("grump.example.com:33041;23432;893;0AF3B81");
ohst->getDiameterIdentity()->setValue("c0-10-70-238-74-w5p1vepg1.vepc.ericsson.se");
orlm->getDiameterIdentity()->setValue("vepc.ericsson.se");
int inRange = 65535;
int outRange = inRange + 1;
//((tmeAvp*)cca.addAvp("CS-Result-Code"))->getUnsigned16()->setValue(inRange);
((tmeAvp*)cca.addAvp("CS-Result-Code"))->getUnsigned16()->setValue(outRange); // WILL BE 0 !!
-
-/*
- <command name="Credit-Control-Answer" code="272" type="Answer">
- <avprule id="Session-Id" type="Fixed"/>
- <avprule id="Result-Code" type="Mandatory"/>
- <avprule id="CS-Result-Code" type="Optional"/>
- <avprule id="CS-Dialogue-Handling" type="Optional"/>
- <avprule id="Origin-Host" type="Mandatory"/>
- <avprule id="Origin-Realm" type="Mandatory"/>
- <avprule id="Auth-Application-Id" type="Mandatory"/>
- <avprule id="CC-Request-Type" type="Mandatory"/>
- <avprule id="CC-Request-Number" type="Mandatory"/>
- <avprule id="Granted-Service-Unit" type="Optional"/>
- <avprule id="Cost-Information" type="Optional"/>
- <avprule id="Low-Balance-Indication" type="Optional"/>
- <avprule id="Remaining-Balance" type="Optional"/>
- <avprule id="Credit-Control-Failure-Handling" type="Optional"/>
- <avprule id="CC-Correlation-Id" type="Optional"/>
- <avprule id="Redirect-Host" type="Optional" qual="*"/>
- <avprule id="Redirect-Host-Usage" type="Optional"/>
- <avprule id="Redirect-Max-Cache-Time" type="Optional"/>
- <avprule id="Proxy-Info" type="Optional" qual="*"/>
- <avprule id="Route-Record" type="Optional" qual="*"/>
- <avprule id="Failed-AVP" type="Optional" qual="*"/>
- <avprule id="Service-Information" type="Optional"/>
- <avprule id="AVP" type="Optional" qual="*"/>
- </command>
-*/
- LOGDEBUG(Logger::debug(cca.asXMLString(), ANNA_FILE_LOCATION));
-
- _exit("Open 'file.trace' in order to see traces");
+ /*
+ <command name="Credit-Control-Answer" code="272" type="Answer">
+ <avprule id="Session-Id" type="Fixed"/>
+ <avprule id="Result-Code" type="Mandatory"/>
+ <avprule id="CS-Result-Code" type="Optional"/>
+ <avprule id="CS-Dialogue-Handling" type="Optional"/>
+ <avprule id="Origin-Host" type="Mandatory"/>
+ <avprule id="Origin-Realm" type="Mandatory"/>
+ <avprule id="Auth-Application-Id" type="Mandatory"/>
+ <avprule id="CC-Request-Type" type="Mandatory"/>
+ <avprule id="CC-Request-Number" type="Mandatory"/>
+ <avprule id="Granted-Service-Unit" type="Optional"/>
+ <avprule id="Cost-Information" type="Optional"/>
+ <avprule id="Low-Balance-Indication" type="Optional"/>
+ <avprule id="Remaining-Balance" type="Optional"/>
+ <avprule id="Credit-Control-Failure-Handling" type="Optional"/>
+ <avprule id="CC-Correlation-Id" type="Optional"/>
+ <avprule id="Redirect-Host" type="Optional" qual="*"/>
+ <avprule id="Redirect-Host-Usage" type="Optional"/>
+ <avprule id="Redirect-Max-Cache-Time" type="Optional"/>
+ <avprule id="Proxy-Info" type="Optional" qual="*"/>
+ <avprule id="Route-Record" type="Optional" qual="*"/>
+ <avprule id="Failed-AVP" type="Optional" qual="*"/>
+ <avprule id="Service-Information" type="Optional"/>
+ <avprule id="AVP" type="Optional" qual="*"/>
+ </command>
+ */
+ LOGDEBUG(Logger::debug(cca.asXMLString(), ANNA_FILE_LOCATION));
+ _exit("Open 'file.trace' in order to see traces");
}
//-------------------------------------- MultiRangeExpression::simplifyLiteral()
//------------------------------------------------------------------------------
const char * anna::MultiRangeExpression::simplifyLiteral(void) throw() {
-
- if (a_data.size() == 0) return NULL;
+ if(a_data.size() == 0) return NULL;
std::map < unsigned int, int/*dummy*/ >::const_iterator it;
std::map < unsigned int, int/*dummy*/ >::const_iterator it_min(a_data.begin());
std::map < unsigned int, int/*dummy*/ >::const_iterator it_max(a_data.end());
-
unsigned int min = UINT_MAX;
unsigned int max = 0;
unsigned int value;
unsigned int prevValue = a_data.begin()->first;
-
a_literal = "";
for(it = it_min; it != it_max; it++) {
value = (*it).first;
- if (value < min) min = value;
- if (value - prevValue > 1) {
+
+ if(value < min) min = value;
+
+ if(value - prevValue > 1) {
a_literal += anna::functions::asString(min);
a_literal += "-";
a_literal += anna::functions::asString(max);
a_literal += ",";
min = value;
}
- if (value > max) max = value;
+
+ if(value > max) max = value;
prevValue = value;
}
a_literal += anna::functions::asString(min);
- if (max != min) {
+
+ if(max != min) {
a_literal += "-";
a_literal += anna::functions::asString(max);
}