+ 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, "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"))
+ {
+ m_p->m_connect_max = mp::xml::get_int(ptr, 0);
+ }
+ 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)
+{
+ m_p->m_ports = ports;
+
+ m_p->az = new yf::FrontendNet::ZAssocServer *[m_p->m_ports.size()];
+
+ // Create yf::FrontendNet::ZAssocServer for each port
+ size_t i;
+ for (i = 0; i<m_p->m_ports.size(); i++)
+ {
+ // create a PDU assoc object (one per yf::FrontendNet::ZAssocServer)
+ yazpp_1::PDU_Assoc *as = new yazpp_1::PDU_Assoc(&m_p->mySocketManager);
+
+ if (m_p->m_ports[i].cert_fname.length())
+ as->set_cert_fname(m_p->m_ports[i].cert_fname.c_str());
+ // create ZAssoc with PDU Assoc
+ m_p->az[i] = new yf::FrontendNet::ZAssocServer(
+ as, m_p->m_ports[i].route, m_p.get());
+ if (m_p->az[i]->server(m_p->m_ports[i].port.c_str()))
+ {
+ throw yf::FilterException("Unable to bind to address "
+ + std::string(m_p->m_ports[i].port));
+ }
+ COMSTACK cs = as->get_comstack();
+
+ if (cs && m_p->m_ports[i].max_recv_bytes)
+ cs_set_max_recv_bytes(cs, m_p->m_ports[i].max_recv_bytes);
+
+ }
+}
+
+void yf::FrontendNet::set_listen_duration(int d)
+{
+ m_p->m_listen_duration = d;