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