source: npl/internetserver/ntop/no_zc.patch @ 7c410f9

Last change on this file since 7c410f9 was cc2b9e2, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

added ntopng and dependencies

  • Property mode set to 100644
File size: 6.8 KB
RevLine 
[cc2b9e2]1diff -r -u ntopng-dev/include/ntop_includes.h ntopng-dev.new/include/ntop_includes.h
2--- ntopng-dev/include/ntop_includes.h  2017-04-24 14:19:03.000000000 +0000
3+++ ntopng-dev.new/include/ntop_includes.h      2017-04-25 10:48:47.000000000 +0000
4@@ -106,7 +106,6 @@
5 #include "lualib.h"
6 #ifdef HAVE_PF_RING
7 #include "pfring.h"
8-#include "pfring_zc.h"
9 #endif
10 #ifdef HAVE_NETFILTER
11 #include <linux/types.h>
12@@ -234,7 +233,6 @@
13 #endif
14 #include "ParserInterface.h"
15 #include "CollectorInterface.h"
16-#include "ZCCollectorInterface.h"
17 #include "DummyInterface.h"
18 #include "ExportInterface.h"
19 #include "Geolocation.h"
20diff -r -u ntopng-dev/src/ZCCollectorInterface.cpp ntopng-dev.new/src/ZCCollectorInterface.cpp
21--- ntopng-dev/src/ZCCollectorInterface.cpp     2017-04-24 14:19:03.000000000 +0000
22+++ ntopng-dev.new/src/ZCCollectorInterface.cpp 2017-04-25 10:45:24.000000000 +0000
23@@ -1,176 +0,0 @@
24-/*
25- *
26- * (C) 2016-17 - ntop.org
27- *
28- *
29- * This program is free software; you can redistribute it and/or modify
30- * it under the terms of the GNU General Public License as published by
31- * the Free Software Foundation; either version 3 of the License, or
32- * (at your option) any later version.
33- *
34- * This program is distributed in the hope that it will be useful,
35- * but WITHOUT ANY WARRANTY; without even the implied warranty of
36- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37- * GNU General Public License for more details.
38- *
39- * You should have received a copy of the GNU General Public License
40- * along with this program; if not, write to the Free Software Foundation,
41- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
42- *
43- */
44-
45-#include "ntop_includes.h"
46-
47-#if defined(HAVE_PF_RING) && (!defined(__mips)) && (!defined(__arm__)) && (!defined(__i686__))
48-
49-/* **************************************************** */
50-
51-ZCCollectorInterface::ZCCollectorInterface(const char *name) : ParserInterface(name) {
52-  char ifname[32];
53-  char *at;
54-
55-  cluster_id = queue_id = 0;
56-
57-  snprintf(ifname, sizeof(ifname), "%s", &name[7]);
58-
59-  at = strchr(ifname, '@');
60-
61-  if(at != NULL) {
62-    queue_id = atoi(&at[1]);
63-    at[0] = '\0';
64-  }
65-
66-  cluster_id = atoi(ifname);
67-
68-  zq = pfring_zc_ipc_attach_queue(cluster_id, queue_id, rx_only);
69-
70-  if(zq == NULL)
71-    throw("pfring_zc_ipc_attach_queue error");
72-
73-  zp = pfring_zc_ipc_attach_buffer_pool(cluster_id, queue_id);
74-
75-  if(zp == NULL)
76-    throw("pfring_zc_ipc_attach_buffer_pool error");
77-
78-  buffer = pfring_zc_get_packet_handle_from_pool(zp);
79-
80-  if(buffer == NULL)
81-    throw("pfring_zc_get_packet_handle_from_pool error");
82-
83-  memset(&last_pfring_zc_stat, 0, sizeof(last_pfring_zc_stat));
84-}
85-
86-/* **************************************************** */
87-
88-ZCCollectorInterface::~ZCCollectorInterface() {
89-  pfring_zc_sync_queue(zq, rx_only);
90-  pfring_zc_release_packet_handle_to_pool(zp, buffer);
91-  pfring_zc_ipc_detach_queue(zq);
92-  pfring_zc_ipc_detach_buffer_pool(zp);
93-}
94-
95-/* **************************************************** */
96-
97-void ZCCollectorInterface::collect_flows() {
98-  int rc;
99-
100-  ntop->getTrace()->traceEvent(TRACE_NORMAL, "Collecting flows from ZC queue %u@%u", cluster_id, queue_id);
101-
102-  while(isRunning()) {
103-    while(idle()) {
104-      purgeIdle(time(NULL));
105-      sleep(1);
106-      if(ntop->getGlobals()->isShutdown()) return;
107-    }
108-
109-    rc = pfring_zc_recv_pkt(zq, &buffer, 0 /* wait_for_packet */);
110-
111-    if(rc > 0) {
112-      u_char *json = pfring_zc_pkt_buff_data(buffer, zq);
113-      const char *master = "{ \"if.name\"";
114-     
115-      ntop->getTrace()->traceEvent(TRACE_INFO, "%s", json);
116-      // fprintf(stdout, "+"); fflush(stdout);
117-
118-      if(strncmp((char*)json, master, strlen(master)) == 0) {
119-       parseEvent((char*)json, buffer->len, 0, (void*)this);
120-      } else
121-       parseFlow((char*)json, buffer->len, 0, (void*)this);
122-      // fprintf(stdout, "."); fflush(stdout);
123-    } else if(rc == 0) {
124-      usleep(1);
125-      purgeIdle(time(NULL));
126-      // fprintf(stdout, "*"); fflush(stdout);
127-    } else {
128-      /* rc < 0 */
129-      break;
130-    }
131-  }
132-
133-  ntop->getTrace()->traceEvent(TRACE_NORMAL, "ZC Flow collection is over.");
134-
135-  pfring_zc_sync_queue(zq, rx_only);
136-}
137-
138-/* **************************************************** */
139-
140-static void *packetPollLoop(void *ptr) {
141-  ZCCollectorInterface *iface = (ZCCollectorInterface *) ptr;
142-
143-  /* Wait until the initialization completes */
144-  while(!iface->isRunning()) sleep(1);
145-
146-  iface->collect_flows();
147-  return(NULL);
148-}
149-
150-/* **************************************************** */
151-
152-void ZCCollectorInterface::startPacketPolling() {
153-  pthread_create(&pollLoop, NULL, packetPollLoop, (void *) this);
154-  pollLoopCreated = true;
155-  NetworkInterface::startPacketPolling();
156-}
157-
158-/* **************************************************** */
159-
160-void ZCCollectorInterface::shutdown() {
161-  if(running) {
162-    void *res;
163-
164-    NetworkInterface::shutdown();
165-    pfring_zc_queue_breakloop(zq);
166-    pthread_join(pollLoop, &res);
167-  }
168-}
169-
170-/* **************************************************** */
171-
172-bool ZCCollectorInterface::set_packet_filter(char *filter) {
173-  ntop->getTrace()->traceEvent(TRACE_ERROR,
174-                              "No filter can be set on a collector interface. Ignored %s", filter);
175-  return(false);
176-}
177-
178-/* **************************************************** */
179-
180-u_int32_t ZCCollectorInterface::getNumDroppedPackets() {
181-  pfring_zc_stat stats;
182-
183-  if(pfring_zc_stats(zq, &stats) >= 0) {
184-#if 0
185-    ntop->getTrace()->traceEvent(TRACE_NORMAL, "[%s][Sent: %llu]"
186-                                "[Rcvd: %llu][Drops: %llu][QueueLen: %d]",
187-                                ifname, stats.sent, stats.recv, stats.drop,
188-                                stats.sent-stats.recv);
189-#endif
190-    return(stats.drop);
191-  }
192-
193-  return 0;
194-}
195-
196-/* **************************************************** */
197-
198-#endif
199-
200diff -r -u ntopng-dev/src/main.cpp ntopng-dev.new/src/main.cpp
201--- ntopng-dev/src/main.cpp     2017-04-24 14:19:03.000000000 +0000
202+++ ntopng-dev.new/src/main.cpp 2017-04-25 10:45:24.000000000 +0000
203@@ -161,10 +161,6 @@
204          endpoint = ifName;
205 
206        iface = new CollectorInterface(endpoint);
207-#if defined(HAVE_PF_RING) && (!defined(__mips)) && (!defined(__arm__)) && (!defined(__i686__))
208-      } else if(strstr(ifName, "zcflow:")) {
209-       iface = new ZCCollectorInterface(ifName);
210-#endif
211       } else {
212        iface = NULL;
213 
214diff -r -u ntopng-dev/third-party/json-c/config.h.in ntopng-dev.new/third-party/json-c/config.h.in
215--- ntopng-dev/third-party/json-c/config.h.in   2017-04-24 14:19:03.000000000 +0000
216+++ ntopng-dev.new/third-party/json-c/config.h.in       2017-04-25 10:46:33.000000000 +0000
217@@ -104,8 +104,7 @@
218 /* Public define for json_inttypes.h */
219 #undef JSON_C_HAVE_INTTYPES_H
220 
221-/* Define to the sub-directory in which libtool stores uninstalled libraries.
222-   */
223+/* Define to the sub-directory where libtool stores uninstalled libraries. */
224 #undef LT_OBJDIR
225 
226 /* Name of package */
Note: See TracBrowser for help on using the repository browser.