本文整理汇总了C++中xmlnode::XMLSet类的典型用法代码示例。如果您正苦于以下问题:C++ XMLSet类的具体用法?C++ XMLSet怎么用?C++ XMLSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XMLSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkInterval
SensorManagerCfg::SensorManagerCfg(XMLElement* elem)
: CfgHelper<SensorManager, SensorManagerCfg>(elem, "sensorManager", false),
checkInterval(SM_DEFAULT_CHECK_INTERVAL),
sensorOutput(SM_DEFAULT_OUTPUT_FNAME),
append(SM_DEFAULT_APPEND)
{
if (!elem) return; // needed because of table inside ConfigManager
XMLNode::XMLSet<XMLElement*> set = _elem->getElementChildren();
for (XMLNode::XMLSet<XMLElement*>::iterator it = set.begin();
it != set.end();
it++) {
XMLElement* e = *it;
if (e->matches("checkinterval")) {
checkInterval = strtol(e->getFirstText().c_str(), NULL, 10);
if (checkInterval == 0) {
THROWEXCEPTION("invalid check interval specified: '%s'", e->getFirstText().c_str());
}
} else if (e->matches("outputfile")) {
sensorOutput = e->getFirstText().c_str();
if (sensorOutput.size() == 0) {
THROWEXCEPTION("invalid sensor output file specified: '%s'", e->getFirstText().c_str());
}
} else if (e->matches("append")) {
append = getInt("append")>0;
} else {
msg(MSG_FATAL, "Unknown sensor manager config statement: %s", e->getName().c_str());
}
}
}
示例2: readDos
BaseTCPDosDetect* AggregatorBaseCfg::readDos(XMLElement* elem)
{
BaseTCPDosDetect* temp = NULL;
int module;
int dosTemplateId;
int minimumRate;
int clusterTimeout;
std::map<uint32_t,uint32_t> subnets;
XMLNode::XMLSet<XMLElement*> set = elem->getElementChildren();
for (XMLNode::XMLSet<XMLElement*>::iterator it = set.begin();it!=set.end();it++)
{
XMLElement* e = *it;
if (e->matches("module")) {
module = getInt("module",-1,e);
} else if (e->matches("dosTemplateId")) {
dosTemplateId = getInt("dosTemplateId",-1,e);
} else if (e->matches("internal")) {
string ipstring = e->getFirstText();
uint32_t ip = 0;
uint32_t subnet = inet_addr("255.255.255.255");
int last_pos = ipstring.find("/");
if (last_pos)
{
string tempstr = ipstring.substr(0,last_pos);
ip = ntohl(inet_addr(tempstr.c_str()));
tempstr = ipstring.substr(last_pos+1,ipstring.length());
subnet >>= (32-atoi(tempstr.c_str()));
subnet <<= (32-atoi(tempstr.c_str()));
}
subnets[ip] = subnet;
} else if (e->matches("minimumRate")) {
示例3: port
IpfixDbWriterOracleCfg::IpfixDbWriterOracleCfg(XMLElement* elem)
: CfgHelper<IpfixDbWriterOracle, IpfixDbWriterOracleCfg>(elem, "ipfixDbWriterOracle"),
port(0), bufferRecords(30), observationDomainId(0)
{
msg(MSG_DEBUG, "Starting configuration for Oracle connection");
if (!elem) return;
XMLNode::XMLSet<XMLElement*> set = _elem->getElementChildren();
for (XMLNode::XMLSet<XMLElement*>::iterator it = set.begin(); it != set.end(); it++) {
XMLElement* e = *it;
if (e->matches("host")) {
hostname = e->getFirstText();
} else if (e->matches("port")) {
port = getInt("port");
} else if (e->matches("dbname")) {
dbname = e->getFirstText();
} else if (e->matches("username")) {
user = e->getFirstText();
} else if (e->matches("password")) {
password = e->getFirstText();
} else if (e->matches("bufferrecords")) {
bufferRecords = getInt("bufferrecords");
} else if (e->matches("columns")) {
readColumns(e);
} else if (e->matches("next")) { // ignore next
} else {
msg(MSG_FATAL, "Unknown IpfixDbWriterOracle config statement %s\n", e->getName().c_str());
continue;
}
}
if (hostname=="") THROWEXCEPTION("IpfixDbWriterOracleCfg: host not set in configuration!");
if (port==0) THROWEXCEPTION("IpfixDbWriterOracleCfg: port not set in configuration!");
if (dbname=="") THROWEXCEPTION("IpfixDbWriterOracleCfg: dbname not set in configuration!");
if (user=="") THROWEXCEPTION("IpfixDbWriterOracleCfg: username not set in configuration!");
if (password=="") THROWEXCEPTION("IpfixDbWriterOracleCfg: password not set in configuration!");
}
示例4: getInt
IpfixFileWriterCfg::IpfixFileWriterCfg(XMLElement* elem)
: CfgHelper<IpfixFileWriter, IpfixFileWriterCfg>(elem, "ipfixFileWriter"),
destinationPath("./"),
filenamePrefix("ipfix.dump"),
maximumFilesize(DEFAULTFILESIZE),
observationDomainId(0)
{
if (!elem) return; // needed because of table inside ConfigManager
XMLNode::XMLSet<XMLElement*> set = _elem->getElementChildren();
for (XMLNode::XMLSet<XMLElement*>::iterator it = set.begin();
it != set.end();
it++) {
XMLElement* e = *it;
if (e->matches("maximumFilesize")) {
maximumFilesize = getInt("maximumFilesize");
}else if (e->matches("destinationPath")){
destinationPath = e->getFirstText();
}else if (e->matches("filenamePrefix")){
filenamePrefix = e->getFirstText();
} else if (e->matches("observationDomainId")) {
observationDomainId = getInt("observationDomainId");
}
else {
msg(MSG_FATAL, "Unknown ipfixFileWriter config statement %s\n",
e->getName().c_str());
continue;
}
}
}
示例5: snapshotOffset
PacketIDMEFReporterCfg::PacketIDMEFReporterCfg(XMLElement* elem)
: CfgHelper<PacketIDMEFReporter, PacketIDMEFReporterCfg>(elem, "packetIDMEFReporter"),
snapshotOffset(0), snapshotLength(0)
{
if (!elem) return;
XMLNode::XMLSet<XMLElement*> set = _elem->getElementChildren();
for (XMLNode::XMLSet<XMLElement*>::iterator it = set.begin();
it != set.end();
it++) {
XMLElement* e = *it;
if (e->matches("snapshotoffset")) {
snapshotOffset = getInt("snapshotoffset");
} else if (e->matches("snapshotlength")) {
snapshotLength = getInt("snapshotlength");
} else if (e->matches("analyzerid")) {
analyzerId = e->getFirstText();
} else if (e->matches("idmeftemplate")) {
idmefTemplate = e->getFirstText();
} else if (e->matches("next")) { // ignore next
} else {
msg(MSG_FATAL, "Unknown PacketIDMEFReporter config statement %s\n", e->getName().c_str());
continue;
}
}
if (analyzerId=="") THROWEXCEPTION("PacketIDMEFReporterCfg: analyzerid not set in configuration!");
if (idmefTemplate=="") THROWEXCEPTION("PacketIDMEFReporterCfg: idmeftemplate not set in configuration!");
}
示例6: if
PCAPExporterCfg::PCAPExporterCfg(XMLElement* elem)
: CfgHelper<PCAPExporterModule, PCAPExporterCfg>(elem, "pcapExporter"), link_type(DLT_EN10MB)
{
if (!elem) return;
XMLNode::XMLSet<XMLElement*> set = elem->getElementChildren();
for (XMLNode::XMLSet<XMLElement*>::iterator it = set.begin();
it != set.end();
it++) {
XMLElement* e = *it;
if (e->matches("filename")) {
fileName = e->getFirstText();
} else if (e->matches("linkType")) {
int tmp = pcap_datalink_name_to_val(e->getFirstText().c_str());
if (tmp == -1) {
msg(MSG_ERROR, "Found illegal link type");
} else {
link_type = tmp;
}
} else if (e->matches("snaplen")) {
snaplen = getInt("snaplen", PCAP_MAX_CAPTURE_LENGTH, e);
}
}
}
示例7: port
IpfixDbReaderCfg::IpfixDbReaderCfg(XMLElement* elem)
: CfgHelper<IpfixDbReader, IpfixDbReaderCfg>(elem, "ipfixDbReader"),
port(0)
{
if (!elem) return;
XMLNode::XMLSet<XMLElement*> set = _elem->getElementChildren();
for (XMLNode::XMLSet<XMLElement*>::iterator it = set.begin();
it != set.end();
it++) {
XMLElement* e = *it;
if (e->matches("host")) {
hostname = e->getFirstText();
} else if (e->matches("port")) {
port = getInt("port");
} else if (e->matches("dbname")) {
dbname = e->getFirstText();
} else if (e->matches("username")) {
user = e->getFirstText();
} else if (e->matches("password")) {
password = e->getFirstText();
} else if (e->matches("next")) { // ignore next
} else {
msg(MSG_FATAL, "Unknown IpfixDbReader config statement %s\n", e->getName().c_str());
continue;
}
}
if (hostname=="") THROWEXCEPTION("IpfixDbReaderCfg: host not set in configuration!");
if (port==0) THROWEXCEPTION("IpfixDbReaderCfg: port not set in configuration!");
if (dbname=="") THROWEXCEPTION("IpfixDbReaderCfg: dbname not set in configuration!");
if (user=="") THROWEXCEPTION("IpfixDbReaderCfg: username not set in configuration!");
if (password=="") THROWEXCEPTION("IpfixDbReaderCfg: password not set in configuration!");
}
示例8: getInt
IpfixCollectorCfg::IpfixCollectorCfg(XMLElement* elem)
: CfgHelper<IpfixCollector, IpfixCollectorCfg>(elem, "ipfixCollector"),
listener(NULL),
ipfixCollector(NULL)
{
if (!elem)
return;
msg(MSG_INFO, "IpfixCollectorCfg: Start reading ipfixCollector section");
udpTemplateLifetime = getInt("udpTemplateLifetime", -1);
XMLNode::XMLSet<XMLElement*> set = elem->getElementChildren();
for (XMLNode::XMLSet<XMLElement*>::iterator it = set.begin();
it != set.end();
it++) {
XMLElement* e = *it;
if (e->matches("listener")) {
listener = new CollectorCfg(e);
} else if (e->matches("udpTemplateLifetime")) { // already done
} else if (e->matches("next")) { // ignore next
} else {
msg(MSG_FATAL, "Unkown observer config statement %s\n", e->getName().c_str());
continue;
}
}
if (listener == NULL)
THROWEXCEPTION("collectingProcess has to listen on one address!");
msg(MSG_INFO, "IpfixCollectorCfg: Successfully parsed collectingProcess section");
}
示例9: PacketCountFilterCfg
PacketFilterCfg::PacketFilterCfg(XMLElement* elem)
: CfgHelper<FilterModule, PacketFilterCfg>(elem, "filter")
{
if (!elem)
return;
XMLNode::XMLSet<XMLElement*> set = elem->getElementChildren();
for (XMLNode::XMLSet<XMLElement*>::iterator it = set.begin();
it != set.end();
it++) {
Cfg* c;
XMLElement* e = *it;
if (e->matches("countBased")) {
msg(MSG_INFO, "Filter: Creating count based sampler");
c = new PacketCountFilterCfg(e);
} else if (e->matches("stringBased")) {
msg(MSG_INFO, "Filter: Creating string based sampler");
c = new PacketStringFilterCfg(e);
} else if (e->matches("regexBased")) {
msg(MSG_INFO, "Filter: Creating regex based sampler");
c = new PacketRegexFilterCfg(e);
} else if (e->matches("timeBased")) {
msg(MSG_INFO, "Filter: Creating time based sampler");
c = new PacketTimeFilterCfg(e);
} else if (e->matches("next")) { // ignore next
continue;
} else {
msg(MSG_FATAL, "Unkown packet filter %s\n", e->getName().c_str());
continue;
}
subCfgs.push_back(c);
}
}
示例10: getInt
IpfixCollectorCfg::IpfixCollectorCfg(XMLElement* elem)
: CfgHelper<IpfixCollector, IpfixCollectorCfg>(elem, "ipfixCollector"),
listener(NULL),
ipfixCollector(NULL)
{
if (!elem)
return;
msg(MSG_INFO, "IpfixCollectorCfg: Start reading ipfixCollector section");
udpTemplateLifetime = getInt("udpTemplateLifetime", -1);
// Config for DTLS
certificateChainFile = getOptional("cert");
privateKeyFile = getOptional("key");
caFile = getOptional("CAfile");
caPath = getOptional("CApath");
// observationDomainId = getInt("observationDomainId", 0);
XMLNode::XMLSet<XMLElement*> set = elem->getElementChildren();
for (XMLNode::XMLSet<XMLElement*>::iterator it = set.begin();
it != set.end();
it++) {
XMLElement* e = *it;
if (e->matches("listener")) {
if (listener)
THROWEXCEPTION("listener already set. There can only be one <listener> Element per Collector.");
listener = new CollectorCfg(e);
if (listener->getMtu() != 0) {
delete listener;
THROWEXCEPTION("You can not set the MTU for a listener.");
}
} else if (e->matches("udpTemplateLifetime")) { // already done
} else if (e->matches("next")) { // ignore next
} else if (e->matches("cert") || e->matches("key") ||
e->matches("CAfile") || e->matches("CApath")) {
// already done!
} else {
msg(MSG_FATAL, "Unkown collector config statement %s", e->getName().c_str());
continue;
}
}
if (listener == NULL)
THROWEXCEPTION("collectingProcess has to listen on one address!");
if (listener->getProtocol() != UDP &&
listener->getProtocol() != SCTP &&
listener->getProtocol() != DTLS_OVER_UDP &&
listener->getProtocol() != DTLS_OVER_SCTP)
THROWEXCEPTION("collectingProcess can handle only UDP or SCTP!");
msg(MSG_INFO, "IpfixCollectorCfg: Successfully parsed collectingProcess section");
}
示例11: initInstance
void AnonymizerCfg::initInstance(CfgBase* c, AnonModule* module, XMLNode::XMLSet<XMLElement*> set)
{
for (XMLNode::XMLSet<XMLElement*>::iterator it = set.begin();
it != set.end();
it++) {
XMLElement* e = *it;
if (e->matches("anonField")) {
InfoElementCfg* cfg = NULL;
std::string method;
std::string method_parameter;
XMLNode::XMLSet<XMLElement*> set = e->getElementChildren();
for (XMLNode::XMLSet<XMLElement*>::iterator jt = set.begin();
jt != set.end();
++jt) {
XMLElement* e = *jt;
if (e->matches("anonIE")) {
if(cfg) {
THROWEXCEPTION("Only on anonIE tag per anonField tag allowed");
}
cfg = new InfoElementCfg(*jt);
} else if (e->matches("anonMethod")) {
method = c->get("anonMethod", e);
} else if (e->matches("anonParam")) {
method_parameter = c->get("anonParam", e);
} else {
msg(MSG_ERROR, "Unknown field in anonField");
continue;
}
}
if (!cfg) {
msg(MSG_FATAL, "Missing information element in anonField");
THROWEXCEPTION("Missing information element in anonField");
}
if (method.empty()) {
msg(MSG_FATAL, "Missing anonymization method in anonField");
THROWEXCEPTION("Missing anonymization method in anonField");
}
if (cfg->getIeLength()==0) THROWEXCEPTION("Information element specified in anonField, but length==0");
module->addAnonymization(cfg->getIeId(), cfg->getIeLength(), AnonMethod::stringToMethod(method), method_parameter);
const ipfix_identifier* id = ipfix_id_lookup(cfg->getIeId());
msg(MSG_INFO, "Added anonymization %s for field %i (%s) with length %i", method.c_str(), cfg->getIeId(), id->name, cfg->getIeLength());
delete cfg;
} else if (e->matches("next") || e->matches("copyMode")) {
// ignore next and copyMode (see createInstance)
} else {
msg(MSG_FATAL, "Unkown anonymization field %s\n", e->getName().c_str());
continue;
}
}
}
示例12: CfgBase
PacketReportingCfg::PacketReportingCfg(XMLElement* elem)
: CfgBase(elem), recordVLFields(0), recordLength(0), templateId(0), t(NULL)
{
assert(elem);
XMLNode::XMLSet<XMLElement*> set = elem->getElementChildren();
for (XMLNode::XMLSet<XMLElement*>::iterator it = set.begin();
it != set.end();
it++) {
if ((*it)->getName()=="templateId") {
templateId = getInt("templateId", 0, elem);
} else {
exportedFields.push_back(new InfoElementCfg(*it));
}
}
}
示例13: noConnections
IpfixPayloadWriterCfg::IpfixPayloadWriterCfg(XMLElement* elem)
: CfgHelper<IpfixPayloadWriter, IpfixPayloadWriterCfg>(elem, "ipfixPayloadWriter"),
noConnections(0),
ignoreEmptyPayload(false),
ignoreIncompleteTCP(false),
startIdx(0)
{
if (!elem) return;
bool noconnseen = false;
XMLNode::XMLSet<XMLElement*> set = _elem->getElementChildren();
for (XMLNode::XMLSet<XMLElement*>::iterator it = set.begin();
it != set.end();
it++) {
XMLElement* e = *it;
if (e->matches("destPath")) {
path = e->getFirstText();
} else if (e->matches("filenamePrefix")) {
filenamePrefix = e->getFirstText();
} else if (e->matches("connNumber")) {
noConnections = getInt("connNumber");
noconnseen = true;
} else if (e->matches("ignoreEmptyPayload")) {
ignoreEmptyPayload = getBool("ignoreEmptyPayload");
} else if (e->matches("ignoreIncompleteTCP")) {
ignoreIncompleteTCP = getInt("ignoreIncompleteTCP");
} else if (e->matches("ignoreIncompleteTCP")) {
ignoreIncompleteTCP = getInt("ignoreIncompleteTCP");
} else if (e->matches("startIndex")) {
startIdx = getInt64("startIndex");
} else if (e->matches("next")) { // ignore next
} else {
msg(MSG_FATAL, "Unknown IpfixPayloadWriter config statement %s\n", e->getName().c_str());
continue;
}
}
if (path=="") THROWEXCEPTION("IpfixPayloadWriterCfg: destPath not set in configuration!");
if (filenamePrefix=="") THROWEXCEPTION("IpfixPayloadWriterCfg: filenamePrefix not set in configuration!");
if (!noconnseen) THROWEXCEPTION("IpfixPayloadWriterCfg: connNumber not set in configuration!");
struct stat s;
if (stat(path.c_str(), &s) != 0)
THROWEXCEPTION("IpfixPayloadWriterCfg: failed to access destination path '%s', error: %s", path.c_str(), strerror(errno));
}
示例14: templateRefreshRate
PSAMPExporterCfg::PSAMPExporterCfg(XMLElement* elem)
: CfgHelper<PSAMPExporterModule, PSAMPExporterCfg>(elem, "psampExporter"),
templateRefreshTime(0), /* templateRefreshRate(0), */
maxPacketSize(0), exportDelay(0), reporting(NULL)
{
if (!elem) return;
observationDomainId = getInt("observationDomainId", 0);
// determine captureLen
// FIXME: undocumented parameter, this value should come from observer
int captureLen = getInt("captureLen", PCAP_DEFAULT_CAPTURE_LENGTH);
XMLNode::XMLSet<XMLElement*> set = elem->getElementChildren();
for (XMLNode::XMLSet<XMLElement*>::iterator it = set.begin();
it != set.end();
it++) {
XMLElement* e = *it;
if (e->matches("ipfixPacketRestrictions")) {
maxPacketSize = (uint16_t)getInt("maxPacketSize", 0, e);
exportDelay = getTimeInUnit("maxExportDelay", mSEC, 0, e);
} else if (e->matches("udpTemplateManagement")) {
// use 0 as default values for both if the config entry isn't found
templateRefreshTime = getTimeInUnit("templateRefreshTimeout", SEC, IS_DEFAULT_TEMPLATE_TIMEINTERVAL, e);
/* templateRefreshRate = getInt("templateRefreshRate", IS_DEFAULT_TEMPLATE_RECORDINTERVAL, e); */ /* TODO */
} else if (e->matches("collector")) {
collectors.push_back(new CollectorCfg(e));
} else if (e->matches("packetReporting")) {
reporting = new PacketReportingCfg(e);
} else if (e->matches("captureLen") || e->matches("observationDomainId")) {
// ignore it, already handled
} else {
THROWEXCEPTION("Illegal PSAMPExporter config entry \"%s\"found",
e->getName().c_str());
}
}
if (reporting == NULL)
THROWEXCEPTION("No packetReporting found in psampExporter config");
// rough estimation of the maximum record length including variable length fields
recordLength = reporting->getRecordLength() +
reporting->getRecordsVariableLen() * captureLen;
}
示例15: readColumns
void IpfixDbWriterOracleCfg::readColumns(XMLElement* elem) {
colNames.clear();
XMLNode::XMLSet<XMLElement*> set = elem->getElementChildren();
for (XMLNode::XMLSet<XMLElement*>::iterator it = set.begin();
it != set.end();
it++) {
XMLElement* e = *it;
if (e->matches("name")) {
colNames.push_back(e->getFirstText());
msg(MSG_DEBUG, "Row: %s", e->getFirstText().c_str());
} else {
msg(MSG_FATAL, "Unknown IpfixDbWriterOracle config statement %s\n", e->getName().c_str());
continue;
}
}
}