zoom: build Z_Facet structures by hand.
[metaproxy-moved-to-github.git] / src / filter_frontend_net.cpp
1 /* This file is part of Metaproxy.
2    Copyright (C) 2005-2013 Index Data
3
4 Metaproxy is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17 */
18
19 #include "config.hpp"
20
21 #include <sstream>
22 #include <iomanip>
23 #include <metaproxy/util.hpp>
24 #include "pipe.hpp"
25 #include <metaproxy/filter.hpp>
26 #include <metaproxy/package.hpp>
27 #include "thread_pool_observer.hpp"
28 #include "filter_frontend_net.hpp"
29 #include <yazpp/z-assoc.h>
30 #include <yazpp/pdu-assoc.h>
31 #include <yazpp/socket-manager.h>
32 #include <yazpp/limit-connect.h>
33 #include <yaz/timing.h>
34 #include <yaz/log.h>
35 #include <yaz/daemon.h>
36 #include "gduutil.hpp"
37
38 #include <iostream>
39
40 namespace mp = metaproxy_1;
41 namespace yf = metaproxy_1::filter;
42
43 namespace metaproxy_1 {
44     namespace filter {
45         class FrontendNet::Port {
46             friend class Rep;
47             friend class FrontendNet;
48             std::string port;
49             std::string route;
50             std::string cert_fname;
51             int max_recv_bytes;
52         };
53         class FrontendNet::Rep {
54             friend class FrontendNet;
55
56             int m_no_threads;
57             std::vector<Port> m_ports;
58             int m_listen_duration;
59             int m_session_timeout;
60             int m_connect_max;
61             std::string m_msg_config;
62             std::string m_stat_req;
63             yazpp_1::SocketManager mySocketManager;
64             ZAssocServer **az;
65             int m_duration_freq[22];
66             double m_duration_lim[22];
67             double m_duration_max;
68             double m_duration_min;
69             double m_duration_total;
70             bool m_stop;
71         public:
72             Rep();
73             ~Rep();
74         };
75         class FrontendNet::My_Timer_Thread : public yazpp_1::ISocketObserver {
76         private:
77             yazpp_1::ISocketObservable *m_obs;
78             Pipe m_pipe;
79             bool m_timeout;
80         public:
81             My_Timer_Thread(yazpp_1::ISocketObservable *obs, int duration);
82             void socketNotify(int event);
83             bool timeout();
84         };
85         class FrontendNet::ZAssocChild : public yazpp_1::Z_Assoc {
86         public:
87             ~ZAssocChild();
88             ZAssocChild(yazpp_1::IPDU_Observable *the_PDU_Observable,
89                         mp::ThreadPoolSocketObserver *m_thread_pool_observer,
90                         const mp::Package *package,
91                         std::string route,
92                         Rep *rep);
93             int m_no_requests;
94             std::string m_route;
95         private:
96             yazpp_1::IPDU_Observer* sessionNotify(
97                 yazpp_1::IPDU_Observable *the_PDU_Observable,
98                 int fd);
99             void recv_GDU(Z_GDU *apdu, int len);
100             void report(Z_HTTP_Request *hreq);
101             void failNotify();
102             void timeoutNotify();
103             void connectNotify();
104         private:
105             mp::ThreadPoolSocketObserver *m_thread_pool_observer;
106             mp::Session m_session;
107             mp::Origin m_origin;
108             bool m_delete_flag;
109             const mp::Package *m_package;
110             Rep *m_p;
111         };
112         class FrontendNet::ThreadPoolPackage : public mp::IThreadPoolMsg {
113         public:
114             ThreadPoolPackage(mp::Package *package,
115                               yf::FrontendNet::ZAssocChild *ses,
116                               Rep *rep);
117             ~ThreadPoolPackage();
118             IThreadPoolMsg *handle();
119             void result(const char *t_info);
120             bool cleanup(void *info);
121         private:
122             yaz_timing_t timer;
123             ZAssocChild *m_assoc_child;
124             mp::Package *m_package;
125             Rep *m_p;
126         };
127         class FrontendNet::ZAssocServer : public yazpp_1::Z_Assoc {
128         public:
129             ~ZAssocServer();
130             ZAssocServer(yazpp_1::IPDU_Observable *PDU_Observable,
131                          std::string route,
132                          Rep *rep);
133             void set_package(const mp::Package *package);
134             void set_thread_pool(ThreadPoolSocketObserver *observer);
135         private:
136             yazpp_1::IPDU_Observer* sessionNotify(
137                 yazpp_1::IPDU_Observable *the_PDU_Observable,
138                 int fd);
139             void recv_GDU(Z_GDU *apdu, int len);
140
141             void failNotify();
142             void timeoutNotify();
143             void connectNotify();
144         private:
145             mp::ThreadPoolSocketObserver *m_thread_pool_observer;
146             const mp::Package *m_package;
147             yazpp_1::LimitConnect limit_connect;
148             std::string m_route;
149             Rep *m_p;
150         };
151     }
152 }
153
154 yf::FrontendNet::ThreadPoolPackage::ThreadPoolPackage(mp::Package *package,
155                                                       ZAssocChild *ses,
156                                                       Rep *rep) :
157     m_assoc_child(ses), m_package(package), m_p(rep)
158 {
159     timer = yaz_timing_create();
160 }
161
162 yf::FrontendNet::ThreadPoolPackage::~ThreadPoolPackage()
163 {
164     yaz_timing_destroy(&timer); // timer may be NULL
165     delete m_package;
166 }
167
168 bool yf::FrontendNet::ThreadPoolPackage::cleanup(void *info)
169 {
170     mp::Session *ses = (mp::Session *) info;
171
172     return *ses == m_package->session();
173 }
174
175 void yf::FrontendNet::ThreadPoolPackage::result(const char *t_info)
176 {
177     m_assoc_child->m_no_requests--;
178
179     yazpp_1::GDU *gdu = &m_package->response();
180
181     if (gdu->get())
182     {
183         int len;
184         m_assoc_child->send_GDU(gdu->get(), &len);
185
186         yaz_timing_stop(timer);
187         double duration = yaz_timing_get_real(timer);
188
189         size_t ent = 0;
190         while (m_p->m_duration_lim[ent] != 0.0 && duration > m_p->m_duration_lim[ent])
191             ent++;
192         m_p->m_duration_freq[ent]++;
193
194         m_p->m_duration_total += duration;
195
196         if (m_p->m_duration_max < duration)
197             m_p->m_duration_max = duration;
198
199         if (m_p->m_duration_min == 0.0 || m_p->m_duration_min > duration)
200             m_p->m_duration_min = duration;
201
202         if (m_p->m_msg_config.length())
203         {
204             Z_GDU *z_gdu = gdu->get();
205
206             std::ostringstream os;
207             os  << m_p->m_msg_config << " "
208                 << *m_package << " "
209                 << std::fixed << std::setprecision (6) << duration << " ";
210
211             if (z_gdu)
212                 os << *z_gdu;
213             else
214                 os << "-";
215
216             yaz_log(YLOG_LOG, "%s %s", os.str().c_str(), t_info);
217         }
218     }
219     else if (!m_package->session().is_closed())
220     {
221         // no response package and yet the session is still open..
222         // means that request is unhandled..
223         yazpp_1::GDU *gdu_req = &m_package->request();
224         Z_GDU *z_gdu = gdu_req->get();
225         if (z_gdu && z_gdu->which == Z_GDU_Z3950)
226         {
227             // For Z39.50, response with a Close and shutdown
228             mp::odr odr;
229             int len;
230             Z_APDU *apdu_response = odr.create_close(
231                 z_gdu->u.z3950, Z_Close_systemProblem,
232                 "unhandled Z39.50 request");
233
234             m_assoc_child->send_Z_PDU(apdu_response, &len);
235         }
236         else if (z_gdu && z_gdu->which == Z_GDU_HTTP_Request)
237         {
238             // For HTTP, respond with Server Error
239             int len;
240             mp::odr odr;
241             Z_GDU *zgdu_res
242                 = odr.create_HTTP_Response(m_package->session(),
243                                            z_gdu->u.HTTP_Request, 500);
244             m_assoc_child->send_GDU(zgdu_res, &len);
245         }
246         m_package->session().close();
247     }
248
249     if (m_assoc_child->m_no_requests == 0 && m_package->session().is_closed())
250     {
251         m_assoc_child->close();
252     }
253
254
255     delete this;
256 }
257
258 mp::IThreadPoolMsg *yf::FrontendNet::ThreadPoolPackage::handle()
259 {
260     m_package->move(m_assoc_child->m_route);
261     return this;
262 }
263
264 yf::FrontendNet::ZAssocChild::ZAssocChild(
265     yazpp_1::IPDU_Observable *PDU_Observable,
266     mp::ThreadPoolSocketObserver *my_thread_pool,
267     const mp::Package *package,
268     std::string route, Rep *rep)
269     :  Z_Assoc(PDU_Observable), m_p(rep)
270 {
271     m_thread_pool_observer = my_thread_pool;
272     m_no_requests = 0;
273     m_delete_flag = false;
274     m_package = package;
275     m_route = route;
276     const char *peername = PDU_Observable->getpeername();
277     if (!peername)
278         peername = "unknown";
279     m_origin.set_tcpip_address(std::string(peername), m_session.id());
280     timeout(m_p->m_session_timeout);
281 }
282
283 yazpp_1::IPDU_Observer *yf::FrontendNet::ZAssocChild::sessionNotify(
284     yazpp_1::IPDU_Observable *the_PDU_Observable, int fd)
285 {
286     return 0;
287 }
288
289 yf::FrontendNet::ZAssocChild::~ZAssocChild()
290 {
291 }
292
293 void yf::FrontendNet::ZAssocChild::report(Z_HTTP_Request *hreq)
294 {
295     mp::odr o;
296
297     Z_GDU *gdu_res = o.create_HTTP_Response(m_session, hreq, 200);
298
299     Z_HTTP_Response *hres = gdu_res->u.HTTP_Response;
300
301     mp::wrbuf w;
302     size_t i;
303     int number_total = 0;
304
305     for (i = 0; m_p->m_duration_lim[i] != 0.0; i++)
306         number_total += m_p->m_duration_freq[i];
307     number_total += m_p->m_duration_freq[i];
308
309     wrbuf_puts(w, "<?xml version=\"1.0\"?>\n");
310     wrbuf_puts(w, "<frontend_net>\n");
311     wrbuf_printf(w, "  <responses frequency=\"%d\">\n", number_total);
312     for (i = 0; m_p->m_duration_lim[i] != 0.0; i++)
313     {
314         if (m_p->m_duration_freq[i] > 0)
315             wrbuf_printf(
316                 w, "    <response duration_start=\"%f\" "
317                 "duration_end=\"%f\" frequency=\"%d\"/>\n",
318                 i > 0 ? m_p->m_duration_lim[i - 1] : 0.0,
319                 m_p->m_duration_lim[i], m_p->m_duration_freq[i]);
320     }
321
322     if (m_p->m_duration_freq[i] > 0)
323         wrbuf_printf(
324             w, "    <response duration_start=\"%f\" frequency=\"%d\"/>\n",
325             m_p->m_duration_lim[i - 1], m_p->m_duration_freq[i]);
326
327     if (m_p->m_duration_max != 0.0)
328         wrbuf_printf(
329             w, "    <response duration_max=\"%f\"/>\n",
330             m_p->m_duration_max);
331     if (m_p->m_duration_min != 0.0)
332         wrbuf_printf(
333             w, "    <response duration_min=\"%f\"/>\n",
334             m_p->m_duration_min);
335     if (m_p->m_duration_total != 0.0)
336         wrbuf_printf(
337             w, "    <response duration_average=\"%f\"/>\n",
338             m_p->m_duration_total / number_total);
339
340     wrbuf_puts(w, " </responses>\n");
341
342     int thread_busy;
343     int thread_total;
344     m_thread_pool_observer->get_thread_info(thread_busy, thread_total);
345
346     wrbuf_printf(w, " <thread_info busy=\"%d\" total=\"%d\"/>\n",
347                  thread_busy, thread_total);
348
349     wrbuf_puts(w, "</frontend_net>\n");
350
351     hres->content_len = w.len();
352     hres->content_buf = (char *) w.buf();
353
354     int len;
355     send_GDU(gdu_res, &len);
356 }
357
358 void yf::FrontendNet::ZAssocChild::recv_GDU(Z_GDU *z_pdu, int len)
359 {
360     m_no_requests++;
361
362     mp::Package *p = new mp::Package(m_session, m_origin);
363
364     if (z_pdu && z_pdu->which == Z_GDU_HTTP_Request)
365     {
366         Z_HTTP_Request *hreq = z_pdu->u.HTTP_Request;
367
368         const char *f = z_HTTP_header_lookup(hreq->headers, "X-Forwarded-For");
369         if (f)
370             p->origin().set_tcpip_address(std::string(f), m_session.id());
371
372         if (m_p->m_stat_req.length()
373             && !strcmp(hreq->path, m_p->m_stat_req.c_str()))
374         {
375             report(hreq);
376             return;
377         }
378     }
379
380     ThreadPoolPackage *tp = new ThreadPoolPackage(p, this, m_p);
381     p->copy_route(*m_package);
382     p->request() = yazpp_1::GDU(z_pdu);
383
384     if (m_p->m_msg_config.length())
385     {
386         if (z_pdu)
387         {
388             std::ostringstream os;
389             os  << m_p->m_msg_config << " "
390                 << *p << " "
391                 << "0.000000" << " "
392                 << *z_pdu;
393             yaz_log(YLOG_LOG, "%s", os.str().c_str());
394         }
395     }
396     m_thread_pool_observer->put(tp);
397 }
398
399 void yf::FrontendNet::ZAssocChild::failNotify()
400 {
401     // TODO: send Package to signal "close"
402     if (m_session.is_closed())
403     {
404         if (m_no_requests == 0)
405             delete this;
406         return;
407     }
408     m_no_requests++;
409
410     m_session.close();
411
412     mp::Package *p = new mp::Package(m_session, m_origin);
413
414     ThreadPoolPackage *tp = new ThreadPoolPackage(p, this, m_p);
415     p->copy_route(*m_package);
416     m_thread_pool_observer->cleanup(tp, &m_session);
417     m_thread_pool_observer->put(tp);
418 }
419
420 void yf::FrontendNet::ZAssocChild::timeoutNotify()
421 {
422     failNotify();
423 }
424
425 void yf::FrontendNet::ZAssocChild::connectNotify()
426 {
427
428 }
429
430 yf::FrontendNet::ZAssocServer::ZAssocServer(
431     yazpp_1::IPDU_Observable *PDU_Observable,
432     std::string route,
433     Rep *rep)
434     :
435     Z_Assoc(PDU_Observable), m_route(route), m_p(rep)
436 {
437     m_package = 0;
438 }
439
440
441 void yf::FrontendNet::ZAssocServer::set_package(const mp::Package *package)
442 {
443     m_package = package;
444 }
445
446 void yf::FrontendNet::ZAssocServer::set_thread_pool(
447     mp::ThreadPoolSocketObserver *observer)
448 {
449     m_thread_pool_observer = observer;
450 }
451
452 yazpp_1::IPDU_Observer *yf::FrontendNet::ZAssocServer::sessionNotify(
453     yazpp_1::IPDU_Observable *the_PDU_Observable, int fd)
454 {
455
456     const char *peername = the_PDU_Observable->getpeername();
457     if (peername)
458     {
459         limit_connect.add_connect(peername);
460         limit_connect.cleanup(false);
461         int con_sz = limit_connect.get_total(peername);
462         if (m_p->m_connect_max && con_sz > m_p->m_connect_max)
463             return 0;
464     }
465     ZAssocChild *my = new ZAssocChild(the_PDU_Observable,
466                                       m_thread_pool_observer,
467                                       m_package, m_route, m_p);
468     return my;
469 }
470
471 yf::FrontendNet::ZAssocServer::~ZAssocServer()
472 {
473 }
474
475 void yf::FrontendNet::ZAssocServer::recv_GDU(Z_GDU *apdu, int len)
476 {
477 }
478
479 void yf::FrontendNet::ZAssocServer::failNotify()
480 {
481 }
482
483 void yf::FrontendNet::ZAssocServer::timeoutNotify()
484 {
485 }
486
487 void yf::FrontendNet::ZAssocServer::connectNotify()
488 {
489 }
490
491 yf::FrontendNet::FrontendNet() : m_p(new Rep)
492 {
493 }
494
495 yf::FrontendNet::Rep::Rep()
496 {
497     m_no_threads = 5;
498     m_listen_duration = 0;
499     m_session_timeout = 300; // 5 minutes
500     m_connect_max = 0;
501     az = 0;
502     size_t i;
503     for (i = 0; i < 22; i++)
504         m_duration_freq[i] = 0;
505     m_duration_lim[0] = 0.000001;
506     m_duration_lim[1] = 0.00001;
507     m_duration_lim[2] = 0.0001;
508     m_duration_lim[3] = 0.001;
509     m_duration_lim[4] = 0.01;
510     m_duration_lim[5] = 0.1;
511     m_duration_lim[6] = 0.2;
512     m_duration_lim[7] = 0.3;
513     m_duration_lim[8] = 0.5;
514     m_duration_lim[9] = 1.0;
515     m_duration_lim[10] = 1.5;
516     m_duration_lim[11] = 2.0;
517     m_duration_lim[12] = 3.0;
518     m_duration_lim[13] = 4.0;
519     m_duration_lim[14] = 5.0;
520     m_duration_lim[15] = 6.0;
521     m_duration_lim[16] = 8.0;
522     m_duration_lim[17] = 10.0;
523     m_duration_lim[18] = 15.0;
524     m_duration_lim[19] = 20.0;
525     m_duration_lim[20] = 30.0;
526     m_duration_lim[21] = 0.0;
527     m_duration_max = 0.0;
528     m_duration_min = 0.0;
529     m_duration_total = 0.0;
530     m_stop = false;
531 }
532
533 yf::FrontendNet::Rep::~Rep()
534 {
535     if (az)
536     {
537         size_t i;
538         for (i = 0; i < m_ports.size(); i++)
539             delete az[i];
540         delete [] az;
541     }
542     az = 0;
543 }
544
545 yf::FrontendNet::~FrontendNet()
546 {
547 }
548
549 void yf::FrontendNet::stop() const
550 {
551     m_p->m_stop = true;
552 }
553
554 bool yf::FrontendNet::My_Timer_Thread::timeout()
555 {
556     return m_timeout;
557 }
558
559 yf::FrontendNet::My_Timer_Thread::My_Timer_Thread(
560     yazpp_1::ISocketObservable *obs,
561     int duration) :
562     m_obs(obs), m_pipe(9123), m_timeout(false)
563 {
564     obs->addObserver(m_pipe.read_fd(), this);
565     obs->maskObserver(this, yazpp_1::SOCKET_OBSERVE_READ);
566     obs->timeoutObserver(this, duration);
567 }
568
569 void yf::FrontendNet::My_Timer_Thread::socketNotify(int event)
570 {
571     m_timeout = true;
572     m_obs->deleteObserver(this);
573 }
574
575 void yf::FrontendNet::process(mp::Package &package) const
576 {
577     if (m_p->az == 0)
578         return;
579     size_t i;
580     My_Timer_Thread *tt = 0;
581
582     if (m_p->m_listen_duration)
583         tt = new My_Timer_Thread(&m_p->mySocketManager,
584                                  m_p->m_listen_duration);
585
586     ThreadPoolSocketObserver tp(&m_p->mySocketManager, m_p->m_no_threads);
587
588     for (i = 0; i<m_p->m_ports.size(); i++)
589     {
590         m_p->az[i]->set_package(&package);
591         m_p->az[i]->set_thread_pool(&tp);
592     }
593     while (m_p->mySocketManager.processEvent() > 0)
594     {
595         if (m_p->m_stop)
596         {
597             m_p->m_stop = false;
598             if (m_p->az)
599             {
600                 size_t i;
601                 for (i = 0; i < m_p->m_ports.size(); i++)
602                     m_p->az[i]->server("");
603                 yaz_daemon_stop();
604             }
605         }
606         int no = m_p->mySocketManager.getNumberOfObservers();
607         if (no <= 1)
608             break;
609         if (tt && tt->timeout())
610             break;
611     }
612     delete tt;
613 }
614
615 void yf::FrontendNet::configure(const xmlNode * ptr, bool test_only,
616                                 const char *path)
617 {
618     if (!ptr || !ptr->children)
619     {
620         throw yf::FilterException("No ports for Frontend");
621     }
622     std::vector<Port> ports;
623     for (ptr = ptr->children; ptr; ptr = ptr->next)
624     {
625         if (ptr->type != XML_ELEMENT_NODE)
626             continue;
627         if (!strcmp((const char *) ptr->name, "port"))
628         {
629             Port port;
630
631             const char *names[5] = {"route", "max_recv_bytes", "port",
632                                     "cert_fname", 0};
633             std::string values[4];
634
635             mp::xml::parse_attr(ptr, names, values);
636             port.route = values[0];
637             if (values[1].length() > 0)
638                 port.max_recv_bytes = atoi(values[1].c_str());
639             else
640                 port.max_recv_bytes = 0;
641             if (values[2].length() > 0)
642                 port.port = values[2];
643             else
644                 port.port = mp::xml::get_text(ptr);
645             port.cert_fname = values[3];
646             ports.push_back(port);
647         }
648         else if (!strcmp((const char *) ptr->name, "threads"))
649         {
650             std::string threads_str = mp::xml::get_text(ptr);
651             int threads = atoi(threads_str.c_str());
652             if (threads < 1)
653                 throw yf::FilterException("Bad value for threads: "
654                                                    + threads_str);
655             m_p->m_no_threads = threads;
656         }
657         else if (!strcmp((const char *) ptr->name, "timeout"))
658         {
659             std::string timeout_str = mp::xml::get_text(ptr);
660             int timeout = atoi(timeout_str.c_str());
661             if (timeout < 1)
662                 throw yf::FilterException("Bad value for timeout: "
663                                                    + timeout_str);
664             m_p->m_session_timeout = timeout;
665         }
666         else if (!strcmp((const char *) ptr->name, "connect-max"))
667         {
668             m_p->m_connect_max = mp::xml::get_int(ptr, 0);
669         }
670         else if (!strcmp((const char *) ptr->name, "message"))
671         {
672             m_p->m_msg_config = mp::xml::get_text(ptr);
673         }
674         else if (!strcmp((const char *) ptr->name, "stat-req"))
675         {
676             m_p->m_stat_req = mp::xml::get_text(ptr);
677         }
678         else
679         {
680             throw yf::FilterException("Bad element "
681                                       + std::string((const char *)
682                                                     ptr->name));
683         }
684     }
685     if (test_only)
686         return;
687     set_ports(ports);
688 }
689
690 void yf::FrontendNet::set_ports(std::vector<std::string> &ports)
691 {
692     std::vector<Port> nports;
693     size_t i;
694
695     for (i = 0; i < ports.size(); i++)
696     {
697         Port nport;
698
699         nport.port = ports[i];
700
701         nports.push_back(nport);
702     }
703     set_ports(nports);
704 }
705
706
707 void yf::FrontendNet::set_ports(std::vector<Port> &ports)
708 {
709     m_p->m_ports = ports;
710
711     m_p->az = new yf::FrontendNet::ZAssocServer *[m_p->m_ports.size()];
712
713     // Create yf::FrontendNet::ZAssocServer for each port
714     size_t i;
715     for (i = 0; i<m_p->m_ports.size(); i++)
716     {
717         // create a PDU assoc object (one per yf::FrontendNet::ZAssocServer)
718         yazpp_1::PDU_Assoc *as = new yazpp_1::PDU_Assoc(&m_p->mySocketManager);
719
720         if (m_p->m_ports[i].cert_fname.length())
721             as->set_cert_fname(m_p->m_ports[i].cert_fname.c_str());
722         // create ZAssoc with PDU Assoc
723         m_p->az[i] = new yf::FrontendNet::ZAssocServer(
724             as, m_p->m_ports[i].route, m_p.get());
725         if (m_p->az[i]->server(m_p->m_ports[i].port.c_str()))
726         {
727             throw yf::FilterException("Unable to bind to address "
728                                       + std::string(m_p->m_ports[i].port));
729         }
730         COMSTACK cs = as->get_comstack();
731
732         if (cs && m_p->m_ports[i].max_recv_bytes)
733             cs_set_max_recv_bytes(cs, m_p->m_ports[i].max_recv_bytes);
734
735     }
736 }
737
738 void yf::FrontendNet::set_listen_duration(int d)
739 {
740     m_p->m_listen_duration = d;
741 }
742
743 static yf::Base* filter_creator()
744 {
745     return new yf::FrontendNet;
746 }
747
748 extern "C" {
749     struct metaproxy_1_filter_struct metaproxy_1_filter_frontend_net = {
750         0,
751         "frontend_net",
752         filter_creator
753     };
754 }
755
756 /*
757  * Local variables:
758  * c-basic-offset: 4
759  * c-file-style: "Stroustrup"
760  * indent-tabs-mode: nil
761  * End:
762  * vim: shiftwidth=4 tabstop=8 expandtab
763  */
764