+ 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 struct _xmlAttr *attr;
+ for (attr = ptr->properties; attr; attr = attr->next)
+ {
+ if (!strcmp((const char *) attr->name, "route"))
+ port.route = mp::xml::get_text(attr);
+ }
+ port.port = mp::xml::get_text(ptr);
+ 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);
+
+ // 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));
+ }
+ }