+void yf::FrontendNet::configure(const xmlNode * ptr, bool test_only,
+ const char *path)
+{
+ if (!ptr || !ptr->children)
+ {
+ throw yf::FilterException("No ports for Frontend");
+ }
+ std::vector<Port> ports;
+ for (ptr = ptr->children; ptr; ptr = ptr->next)
+ {
+ if (ptr->type != XML_ELEMENT_NODE)
+ continue;
+ if (!strcmp((const char *) ptr->name, "port"))
+ {
+ Port port;
+
+ const char *names[5] = {"route", "max_recv_bytes", "port",
+ "cert_fname", 0};
+ std::string values[4];
+
+ mp::xml::parse_attr(ptr, names, values);
+ port.route = values[0];
+ if (values[1].length() > 0)
+ port.max_recv_bytes = atoi(values[1].c_str());
+ else
+ port.max_recv_bytes = 0;
+ if (values[2].length() > 0)
+ port.port = values[2];
+ else
+ port.port = mp::xml::get_text(ptr);
+ port.cert_fname = values[3];
+ ports.push_back(port);
+ }
+ else if (!strcmp((const char *) ptr->name, "threads"))
+ {
+ std::string threads_str = mp::xml::get_text(ptr);
+ int threads = atoi(threads_str.c_str());
+ if (threads < 1)
+ throw yf::FilterException("Bad value for threads: "
+ + threads_str);
+ m_p->m_no_threads = threads;
+ }
+ else if (!strcmp((const char *) ptr->name, "max-threads"))
+ {
+ std::string threads_str = mp::xml::get_text(ptr);
+ int threads = atoi(threads_str.c_str());
+ if (threads < 1)
+ throw yf::FilterException("Bad value for max-threads: "
+ + threads_str);
+ m_p->m_max_threads = threads;
+ }
+ else if (!strcmp((const char *) ptr->name, "stack-size"))
+ {
+ std::string sz_str = mp::xml::get_text(ptr);
+ int sz = atoi(sz_str.c_str());
+ if (sz < 0)
+ throw yf::FilterException("Bad value for stack-size: "
+ + sz_str);
+ m_p->m_stack_size = sz * 1024;
+ }
+ else if (!strcmp((const char *) ptr->name, "timeout"))
+ {
+ std::string timeout_str = mp::xml::get_text(ptr);
+ int timeout = atoi(timeout_str.c_str());
+ if (timeout < 1)
+ throw yf::FilterException("Bad value for timeout: "
+ + timeout_str);
+ m_p->m_session_timeout = timeout;
+ }
+ else if (!strcmp((const char *) ptr->name, "connect-max"))
+ {
+ const char *names[3] = {"ip", "verbose", 0};
+ std::string values[2];
+
+ mp::xml::parse_attr(ptr, names, values);
+ IP_Pattern m;
+ m.value = mp::xml::get_int(ptr, 0);
+ m.pattern = values[0];
+ m.verbose = values[1].length() ? atoi(values[1].c_str()) : 1;
+ m_p->connect_max.push_back(m);
+ }
+ else if (!strcmp((const char *) ptr->name, "http-req-max"))
+ {
+ const char *names[3] = {"ip", "verbose", 0};
+ std::string values[2];
+
+ mp::xml::parse_attr(ptr, names, values);
+ IP_Pattern m;
+ m.value = mp::xml::get_int(ptr, 0);
+ m.pattern = values[0];
+ m.verbose = values[1].length() ? atoi(values[1].c_str()) : 1;
+ m_p->http_req_max.push_back(m);
+ }
+ else if (!strcmp((const char *) ptr->name, "message"))
+ {
+ m_p->m_msg_config = mp::xml::get_text(ptr);
+ }
+ else if (!strcmp((const char *) ptr->name, "stat-req"))
+ {
+ m_p->m_stat_req = mp::xml::get_text(ptr);
+ }
+ else
+ {
+ throw yf::FilterException("Bad element "
+ + std::string((const char *)
+ ptr->name));
+ }
+ }
+ if (test_only)
+ return;
+ set_ports(ports);
+}
+
+void yf::FrontendNet::set_ports(std::vector<std::string> &ports)
+{
+ std::vector<Port> nports;
+ size_t i;
+
+ for (i = 0; i < ports.size(); i++)
+ {
+ Port nport;
+
+ nport.port = ports[i];
+
+ nports.push_back(nport);
+ }
+ set_ports(nports);
+}
+
+
+void yf::FrontendNet::set_ports(std::vector<Port> &ports)