[-]
[+]
|
Changed |
pmacct.changes
|
|
[-]
[+]
|
Changed |
pmacct.spec
^
|
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/AUTHORS
^
|
@@ -1,5 +1,5 @@
-pmacct (Promiscuous mode IP Accounting package) v0.14.1
-pmacct is Copyright (C) 2003-2012 by Paolo Lucente
+pmacct (Promiscuous mode IP Accounting package) v0.14.2
+pmacct is Copyright (C) 2003-2013 by Paolo Lucente
Founder:
@@ -24,16 +24,26 @@
Martin Anderberg
Sven Anderson
Joerg Behrens
+ Vincent Bernat
Robert Blechinger
Arnaud De-Bermingham
Marcello Di Leonardo
+ Pierre Francois
Rich Gade
Aaron Glenn
Gianluca Guida
+ Elisa Jasinska
Wim Kerkhoff
Peter Nixon
Karl O. Pinc
Vasiliy Ponomarev
Martin Pot
A.O. Prokofiev
+ Edwin Punt
Anik Rahman
+ Rene Stoutjesdijk
+ Thomas Telkamp
+ Stig Thormodsrud
+ Luca Tosolini
+ Brent Van Dussen
+ Chris Wilson
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/CONFIG-KEYS
^
|
@@ -38,7 +38,8 @@
sum_mac, sum_host, sum_net, sum_as, sum_port, flows, tag, tag2, class,
tcpflags, in_iface, out_iface, std_comm, ext_comm, as_path, peer_src_ip,
peer_dst_ip, peer_src_as, peer_dst_as, local_pref, med, src_as_path,
- src_std_comm, src_ext_comm, src_local_pref, src_med, mpls_vpn_rd]
+ src_std_comm, src_ext_comm, src_local_pref, src_med, mpls_vpn_rd,
+ sampling_rate, src_host_country, dst_host_country]
FOREWORDS: individual IP packets are uniquely identified by their header fields values (a
rather large set of primitives!). Same applies to uni-directional IP flows, as
they have at least enough information to discriminate where packets are coming
@@ -64,6 +65,9 @@
shipped with pmacct. Always check out documentation related to the RDBMS in
use (ie. 'sql/README.mysql') which will point you to extra primitive-related
documentation, if required.
+ * sampling_rate: if counters renormalization is enabled this field will report
+ a value of 1; otherwise it will report the rate pmacct would have applied if
+ renormalize counters was enabled.
KEY: aggregate_filter [NO_GLOBAL]
DESC: Per-plugin filtering applied against the original packet or flow. Aggregation
@@ -108,12 +112,14 @@
increased.
KEY: plugins (-P)
-VALUES: [ memory | print | mysql | pgsql | sqlite3 | nfprobe | sfprobe | tee ]
+VALUES: [ memory | print | mysql | pgsql | sqlite3 | mongodb | nfprobe | sfprobe | tee ]
DESC: plugins to be enabled. SQL plugins are available only if configured and compiled.
'memory' enables the use of a memory table as backend; then, a client tool, 'pmacct',
can fetch its content; mysql, pgsql and sqlite3 enable the use of respectively MySQL,
PostgreSQL and SQLite 3.x (or BerkeleyDB 5.x with the SQLite API compiled-in) tables
- to store data. 'print' prints aggregates to flat-files or stdout in CSV or formatted.
+ to store data. 'mongodb' enables use of the noSQL document-oriented database MongoDB
+ (requires installation of MongoDB API C driver which is shipped separatedly from the
+ main package). 'print' prints aggregates to flat-files or stdout in CSV or formatted.
'nfprobe' acts as a NetFlow/IPFIX agent and exports collected data via NetFlow v1/v5/
v9 and IPFIX datagrams to a remote collector. 'sfprobe' acts as a sFlow agent and
exports collected data via sFlow v5 datagrams to a remote collector. Both 'nfprobe'
@@ -272,11 +278,11 @@
directive refers to the full path to the database file (default: 'pmacct', SQLite 3.x
default: '/tmp/pmacct.db').
-KEY: [ sql_table | print_output_file ]
-DESC: In SQL plugins this defines the SQL table to use (sql_table); in print plugin it defines
- the file to write to (print_output_file). Dynamic names are supported through the use of
- variables, which are computed at the moment when data is purged to the backend. The list
- of supported variables follows:
+KEY: [ sql_table | print_output_file | mongo_table ]
+DESC: In SQL and mongodb plugins this defines the table to use; in print plugin it defines the
+ file to write output to. Dynamic names are supported through the use of variables, which
+ are computed at the moment when data is purged to the backend. The list of supported
+ variables follows:
%d The day of the month as a decimal number (range 01 to 31).
@@ -286,7 +292,7 @@
%M The minute as a decimal number (range 00 to 59).
- %s The number of seconds since the Epoch, i.e., since 1970-01-01 00:00:00 UTC.
+ %s The number of seconds since the Epoch, i.e., since 1970-01-01 00:00:00 UTC.
%w The day of the week as a decimal, range 0 to 6, Sunday being 0.
@@ -296,6 +302,10 @@
%Y The year as a decimal number including the century.
+ $ref Configured value of refresh time.
+
+ $hst Configured value of sql_history in seconds.
+
SQL plugins notes:
Time-related variables require 'sql_history' to be specified in order to work correctly
(see 'sql_history' entry in this in this document for further information) and that the
@@ -324,6 +334,9 @@
Print plugin notes:
If a non-dynamic filename is selected, content is overwritten to the existing one.
+ MongoDB plugin notes:
+ Default table is test.acct
+
Common notes:
The maximum table name length is 64 characters. The maximum number of variables it may
contain is 8.
@@ -373,8 +386,8 @@
in a faster but more rigid structure. Since v6 unified mode is being discontinued leading
to efficiency and simplification. (default: 'typed').
-KEY: sql_host
-DESC: defines the SQL server IP/hostname (default: localhost).
+KEY: [ sql_host | mongo_host ]
+DESC: defines the backend server IP/hostname (default: localhost).
KEY: sql_user
DESC: defines the username to use when connecting to the SQL server (default: pmacct).
@@ -382,9 +395,17 @@
KEY: sql_passwd
DESC: defines the password to use when connecting to the SQL server (default: arealsmartpwd).
-KEY: [ sql_refresh_time | print_refresh_time ] (-r)
-DESC: time interval between consecutive executions of the SQL cache scanner. The scanner purges
- data from the cache into the RDBMS. The value is expressed in seconds.
+KEY: [ sql_refresh_time | print_refresh_time | mongo_refresh_time ] (-r)
+DESC: time interval, in seconds, between consecutive executions of the plugin cache scanner. The
+ scanner purges data into the plugin backend. Note: internally all these config directives
+ write to the same variable; when using multiple plugins it is recommended to bind refresh
+ time definitions to specific plugins, ie.:
+
+ plugins: mysql[x], mongodb[y]
+ sql_refresh_time[x]: 900
+ mongo_refresh_time[y]: 300
+
+ As doing otherwise can originate unexpected behaviours.
KEY: sql_startup_delay
DESC: defines the time, in seconds, the first SQL cache scan event has to be delayed. This delay
@@ -404,7 +425,7 @@
always remember to specify which default SQL table version you intend to stick to by using
the 'sql_table_version' directive. (default: false)
-KEY: sql_history
+KEY: [ sql_history | mongo_history ]
VALUES: #[m|h|d|w|M]
DESC: enables historical accounting by dividing accounted data into configurable time-bins. It
will use the 'stamp_inserted' (base time of the time-bin) and 'stamp_updated' (last time
@@ -416,7 +437,7 @@
is close to time slots in a RRD file. Examples of valid values are: '5m' - five minutes,
'1h' - one hour, '4h' - four hours, '1d' - one day, '1w' - one week, '1M' - one month).
-KEY: [ sql_history_roundoff | print_time_roundoff ]
+KEY: [ sql_history_roundoff | print_time_roundoff | mongo_time_roundoff ]
VALUES [m,h,d,w,M]
DESC: enables alignment of minutes (m), hours (h), days of month (d), weeks (w) and months (M)
in print (to print_refresh_time) and SQL plugins (to sql_history and sql_refresh_time).
@@ -470,8 +491,8 @@
lost at this stage) and an error message is printed out. Triggers (sql_trigger_exec) will
continue working in any case. (default: 10)
-KEY: [ sql_cache_entries | print_cache_entries ]
-DESC: SQL and print plugins sport a Plugin Memory Cache (PMC) meant to accumulate bytes/packets
+KEY: [ sql_cache_entries | print_cache_entries | mongo_cache_entries ]
+DESC: SQL and other plugins sport a Plugin Memory Cache (PMC) meant to accumulate bytes/packets
counters until next purging event (for further insights take a look to 'sql_refresh_time').
This directive sets the number of PMC buckets. Default value is suitable for most common
scenarios, however when facing large-scale networks, it's higly recommended to carefully
@@ -507,14 +528,15 @@
to check the size of this pmacct buffer against the size of the corresponding MySQL buffer
(max_allowed_packet). (default: none)
-KEY: [ sql_trigger_exec | print_trigger_exec ]
+KEY: [ sql_trigger_exec | print_trigger_exec | mongo_trigger_exec ]
DESC: defines the executable to be launched at fixed time intervals to post-process aggregates;
in SQL plugins, intervals are specified by the 'sql_trigger_time' directive; if no interval
is supplied 'sql_refresh_time' value is used instead: this will result in a trigger being
fired each purging event. A number of environment variables are set in order to allow the
trigger to take actions; take a look to docs/TRIGGER_VARS to check them out. In the print
- plugin a simpler implementation is made: triggers can be fired at each 'print_refresh_time'
- only and no environment variables are passed over to the executable.
+ and mongodb plugins a simpler implementation is made: triggers can be fired each time data
+ is written to the backend (ie. print_refresh_time) and no environment variables are passed
+ over to the executable.
KEY: sql_trigger_time
VALUES: #[m|h|d|w|M]
@@ -707,8 +729,10 @@
and uacctd is for backward compatibility: 'mask' and 'file' are turned on if a networks_mask and
a networks_file are respectively specified by configuration. If they both are defined, the outcome
will be the intersection of their definitions. 'fallback' behaves in a longest-match-wins fashion:
- in nfacctd and sfacctd lookup is done against sFlow/NetFlow protocol, IGP and BGP (sFlow/NetFlow <
- IGP <= BGP) whereas in pmacctd and uacctd lookup is done against IGP and BGP only (IGP <= BGP).
+ in nfacctd and sfacctd lookup is done against a networks list (if networks_file is defined) sFlow/
+ NetFlow protocol, IGP (if the IGP thread started) and BGP (if the BGP thread is started) with the
+ following logics: networks_file < sFlow/NetFlow < IGP <= BGP; in pmacctd and uacctd lookup is done
+ against ia networks list, IGP and BGP only (networks_file < IGP <= BGP).
(default: nfacctd: 'netflow'; sfacctd: 'sflow'; pmacctd and uacctd: 'mask', 'file')
KEY: [ nfacctd_mcast_groups | sfacctd_mcast_groups ] [GLOBAL, NO_PMACCTD]
@@ -806,12 +830,14 @@
(default: false)
KEY: [ pmacctd_frag_buffer_size | uacctd_frag_buffer_size ] [GLOBAL, NO_NFACCTD]
-DESC: defines the maximum size of the fragment buffer. The value is expeced in bytes (default: 4 Mb).
+DESC: defines the maximum size of the fragment buffer. In case IPv6 is enabled two buffers of equal
+ size will be allocated. The value is expected in bytes (default: 4 Mb).
KEY: [ pmacctd_flow_buffer_size | uacctd_flow_buffer_size ] [GLOBAL, NO_NFACCTD]
DESC: defines the maximum size of the flow buffer. This is an upper limit to avoid unlimited growth
- of the memory structure. This value has to scale accordingly to the link traffic rate. It is
- expected in bytes (default: 16 Mb).
+ of the memory structure. This value has to scale accordingly to the link traffic rate. In case
+ IPv6 is enabled two buffers of equal size will be allocated. It is expected in bytes (default:
+ 16 Mb).
KEY: [ pmacctd_flow_buffer_buckets | uacctd_flow_buffer_buckets ] [GLOBAL, NO_NFACCTD]
DESC: defines the number of buckets of the flow buffer - which is organized as a chained hash table.
@@ -820,8 +846,8 @@
a value of 65536 works just fine under full 100Mbit load (default: 256).
KEY: [ pmacctd_conntrack_buffer_size | uacctd_conntrack_buffer_size ] [GLOBAL, NO_NFACCTD]
-DESC: defines the maximum size of the connection tracking buffer. The value is expected in bytes
- (default: 8 Mb).
+DESC: defines the maximum size of the connection tracking buffer. In case IPv6 is enabled two buffers
+ of equal size will be allocated. The value is expected in bytes (default: 8 Mb).
KEY: [ pmacctd_flow_lifetime | uacctd_flow_lifetime ] [GLOBAL, NO_NFACCTD]
DESC: defines how long a flow could remain inactive (ie. no packets belonging to such flow are received)
@@ -1206,11 +1232,15 @@
When the daemon is configured to set a neighborship with a Cisco router running IOS, this
value should match the value of the "clns mtu" IOS directive. (default: 1476)
-KEY isis_daemon_msglog
+KEY: isis_daemon_msglog
VALUES: [true|false]
DESC: enables IS-IS messages logging: as this can get easily verbose, it is intended for debug
and troubleshooting purposes only. (default: false)
+KEY: [ geoip_ipv4 | geoip_ipv6 ]
+DESC: If pmacct is compiled with --enable-geoip, this defines full pathname to the Maxmind GeoIP
+ IPv4/IPv6 database file to use.
+
KEY: uacctd_group
DESC: Sets the Linux Netlink ULOG multicast group to be joined. (default: 1)
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/ChangeLog
^
|
@@ -1,5 +1,56 @@
-pmacct (Promiscuous mode IP Accounting package) v0.14.1
-pmacct is Copyright (C) 2003-2012 by Paolo Lucente
+pmacct (Promiscuous mode IP Accounting package) v0.14.2
+pmacct is Copyright (C) 2003-2013 by Paolo Lucente
+
+0.14.2 -- 14-01-2013
+ + pmacct opens to MongoDB, a leading noSQL document-oriented database
+ via a new 'mongodb' plugin. Feature parity is maintained with all
+ existing plugins. The QUICKSTART doc includes a brief section on how
+ to getting started with it. Using MongoDB >= 2.2.0 is recommended;
+ MongoDB C driver is required.
+ + GeoIP lookups support has been introduced: geoip_ipv4 and geoip_ipv6
+ config directives now allow to load Maxmind IPv4/IPv6 GeoIP database
+ files; two new traffic aggregation primitives are added to support the
+ feature: src_host_country and dst_host_country. Feature implemented
+ against all deamons and all plugins and supports both IPv4 and IPv6.
+ Thanks to Vincent Bernat for his patches and precious support.
+ + networks_file: user-supplied files to define IP networks and their
+ associations to ASNs (optional) has been hooked up to the 'fallback'
+ (longest match wins) setting of [pm|u|sf|nf]acctd_net, [pm|u]acctd_as
+ and [sf|nf]acctd_as_new. Thanks to John Hess for his support.
+ + A new sampling_rate traffic aggregation primitive has been introduced:
+ to report on the sampling rate to be applied to renormalize counters
+ (ie. useful to support troubleshooting of untrusted node exports and
+ hybrid scenarios where a partial sampling_map is supplied). If renorm
+ of counters is enabled (ie. [n|s]facctd_renormalize set to true) then
+ sampling_rate will show as 1 (ie. already renormalized).
+ + sql_table, print_output_file, mongo_table: dynamic table names are
+ now enriched by a $ref variable, populated with the configured value
+ for refresh time, and a $hst variable, populated with the configured
+ value for sql_history (in secs).
+ + Solved the limit of 64 traffic aggregation primitives: the original
+ 64 bits bitmap is now split in a 16 bits index + 48 bits registry
+ with multiple entries (currently 2). cfg_set_aggregate() and, in
+ future, cfg_get_aggregate() functions are meant to safely manipulate
+ the new bitmap structure and detect mistakes in primitives definition.
+ ! fix, print plugin: removed print_output_file limitation to 64 chars.
+ Now maximum filename length is imposed by underlying OS.
+ ! fix, print plugin: primitives are selectively enabled for printing
+ based on 'aggregate' directive.
+ ! fix, print plugin: pointer to latest file been generated is updated
+ at very last in the workflow.
+ ! fix, ip_flow.c: incorrect initialization for IPv6 flow buffer. Thanks
+ to Mike Jager for reporting the issue and providing a patch.
+ ! fix, pre_tag_map: improved matching of pre_tag_map primitives against
+ IPFIX fields. Thanks to Nikita V Shirokov for reporting the issue.
+ ! fix, nfprobe plugin: improved handling of unsuccessful send() calls
+ in order to prevent file descriptors depletion and log failure cause.
+ Patch is courtesy by Mike Jager.
+ ! fix, nfacctd: gracefully handling the case of NetFlow v9/IPFIX flowset
+ length of zero; unproper handling of the condition was causing nfacctd
+ to infinite loop over the packet; patch is courtesy by Mike Jager.
+ ! fix, Setsocksize(): setsockopt() replaces Setsocksize() in certain
+ cases and Setsocksize() fix to len parameter. Patch is courtesy by
+ Vincent Bernat
0.14.1 -- 03-08-2012
+ nfacctd: introduced support for IPFIX variable-length IEs (RFC5101),
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/FAQS
^
|
@@ -1,5 +1,5 @@
pmacct (Promiscuous mode IP Accounting package)
-pmacct is Copyright (C) 2003-2012 by Paolo Lucente
+pmacct is Copyright (C) 2003-2013 by Paolo Lucente
Q1: What is pmacct project homepage ?
A: It is http://www.pmacct.net/ . There isn't any official mirror site.
@@ -22,12 +22,13 @@
Q4: What are pmacct main features?
-A: pmacct can collect, replicate and export network data. Collect in memory tables, OSS
- RDBMS (MySQL, PostgreSQL, SQLite 3.x, BerkeleyDB 5.x via SQLite API) and files (csv,
- formatted output). Export speaking sFlow v5, NetFlow v1/v5/v9 and IPFIX. pmacct is
- able to perform data aggregation, offering a rich set of primitives to choose from;
- it can also filter, sample, renormalize, tag and classify at L7. pmacct integrates a
- BGP daemon join routing visibility and network traffic information.
+A: pmacct can collect, replicate and export network data. Collect in memory tables,
+ RDBMS (MySQL, PostgreSQL, SQLite 3.x), noSQL databases (key-value: BerkeleyDB 5.x
+ via SQLite API; document-oriented: MongoDB) and files (csv, formatted output).
+ Export speaking sFlow v5, NetFlow v1/v5/v9 and IPFIX. pmacct is able to perform
+ data aggregation, offering a rich set of primitives to choose from; it can also
+ filter, sample, renormalize, tag and classify at L7. pmacct integrates a BGP daemon
+ join routing visibility and network traffic information.
Q5: Does any of the pmacct daemons logs to flat files?
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/QUICKSTART
^
|
@@ -1,10 +1,11 @@
pmacct (Promiscuous mode IP Accounting package)
-pmacct is Copyright (C) 2003-2012 by Paolo Lucente
+pmacct is Copyright (C) 2003-2013 by Paolo Lucente
+
TABLE OF CONTENTS:
I. Plugins included with pmacct distribution
II. Configuring pmacct for compilation
-III. Brief SQL (MySQL, PostgreSQL, SQLite 3.x) setup examples
+III. Brief SQL (MySQL, PostgreSQL, SQLite 3.x) and noSQL (MongoDB) setup examples
IV. Running the libpcap-based daemon (pmacctd)
V. Running the NetFlow and sFlow daemons (nfacctd/sfacctd)
VI. Running the ULOG-based daemon (uacctd)
@@ -17,6 +18,7 @@
XIII. Quickstart guide to setup a NetFlow/sFlow replicator
XIV. Quickstart guide to setup the IS-IS daemon
XV. Running the print plugin to write to flat-files
+XVI. Quickstart guide to setup GeoIP lookups
I. Plugins included with pmacct distribution
@@ -31,6 +33,8 @@
'sqlite3': a working SQLite 3.x or BerkeleyDB 5.x (compiled in with the SQLite API)
installation can be used for data storage
'print': data are printed at regular intervals to flat-files or standard output
+'mongodb': a working MongoDB installation can be used for data storage. Installation
+ of the MongoDB API C driver is also required.
II. Configuring pmacct for compilation
@@ -42,16 +46,17 @@
shell> ./configure --help
-Examples on how to enable the support for (1) MySQL, (2) PostgreSQL, (3) SQLite and
-any (4) mixed compilation:
+Examples on how to enable the support for (1) MySQL, (2) PostgreSQL, (3) SQLite,
+(4) MongoDB and any (5) mixed compilation:
(1) shell> ./configure --enable-mysql
(2) shell> ./configure --enable-pgsql
(3) shell> ./configure --enable-sqlite3
-(4) shell> ./configure --enable-mysql --enable-pgsql
+(4) shell> ./configure --enable-mongodb
+(5) shell> ./configure --enable-mysql --enable-pgsql
-III. Brief SQL setup examples
+III. Brief SQL and noSQL setup examples
Scripts for setting up databases (MySQL, PostgreSQL and SQLite) are into the 'sql/'
tree. For further guidance read the relevant README files in such directory. One of
the crucial concepts to deal with, when using default IP or BGP SQL tables, is table
@@ -148,7 +153,26 @@
sql_history_roundoff: m
sql_dont_try_update: true
-Note that sql_refresh_time is always expressed in seconds.
+Note that sql_refresh_time is always expressed in seconds. An alternative approach
+for cases where sql_refresh_time must be kept shorter than sql_history (for example
+because a) of long sql_history periods, ie. hours or days, and/or because b) near
+real-time data feed is a requirement) is to set up a synthetic auto-increment 'id'
+field: it successfully prevents duplicates but comes at the expenses of GROUP BY
+queries when retrieving data.
+
+IIIg. MongoDB examples
+MongoDB if a document-oriented noSQL database. Defining feature of document-oriented
+databases is that they are schemaless hence this section will only need to focus on a
+simple configuration with historical accounting support:
+
+...
+plugins: mongodb
+aggregate: ...
+mongo_history: 5m
+mongo_time_roundoff: m
+mongo_refresh_time: 300
+mongo_table: test.acct
+...
IV. Running the libpcap-based daemon (pmacctd)
@@ -853,14 +877,14 @@
) TYPE=MyISAM AUTO_INCREMENT=1;
XIIf. BGP daemon implementation concluding notes
-The implementation supports both 4-bytes ASN and IPv6 (MP-BGP); IPv6 peers are not
-supported yet though. When storing data via SQL, BGP primitives can be freely mix-
-and-matched with other primitives (ie. L2/L3/L4) when customizing the SQL table
-(sql_optimize_clauses: true). Environments making use of BGP Multi-Path are not
-currently supported; if you are using this and would like to see it implemented,
-please get in touch. TCP MD5 signature for BGP messages is not yet supported but
-on the radar. For a review of all the configurable knobs and features see the
-CONFIG-KEYS document.
+The implementation supports 4-bytes ASN as well as IPv4, IPv6 and VPNv4 (MP-BGP)
+address families; both IPv4 and IPv6 BGP sessions are supported. When storing
+data via SQL, BGP primitives can be freely mix-and-matched with other primitives
+(ie. L2/L3/L4) when customizing the SQL table (sql_optimize_clauses: true).
+Environments making use of BGP Multi-Path are not currently supported; if you
+are using this and would like to see it implemented, please get in touch. TCP
+MD5 signature for BGP messages is also supported. For a review of all knobs and
+features see the CONFIG-KEYS document.
XIII. Quickstart guide to setup a NetFlow/sFlow replicator
@@ -983,3 +1007,28 @@
-rw------- 1 paolo paolo 2772 Nov 21 00:30 blabla-20111121-0015.txt
-rw------- 1 paolo paolo 1916 Nov 21 00:45 blabla-20111121-0030.txt
-rw------- 1 paolo paolo 2940 Nov 21 01:00 blabla-20111121-0045.txt
+
+
+XVI. Quickstart guide to setup GeoIP lookups
+From pmacct 0.14.2 is possible to perform GeoIP country lookups against a
+Maxmind library database - and as a result of that two new traffic aggregation
+primitives have been added to the set: src_host_country and dst_host_country.
+Pre-requisite for the feature to work are: a) a working installed Maxmind GeoIP
+library and headers and b) a Maxmind GeoIP country database (freely available).
+Two steps to quickly start with GeoIP lookups in pmacct:
+
+* to compile the pmacct package with support for GeoIP lookups, the code must
+ be configured for compilation as follows: ./configure --enable-geoip [ ... ]
+ The switches --with-geoip-libs and --with-geoip-includes can be of help if
+ the library is installed in some non-standard location.
+
+* include as part of the pmacct configuration the following fragment:
+
+ ...
+ geoip_ipv4_file: /path/to/GeoIP/GeoIP.dat
+ aggregate: src_host_country, dst_host_country, ...
+ ...
+
+Concluding note: more fine-grained GeoIP lookup primitives (ie. cities, states,
+counties, metro areas, zip codes, etc.) are not yet supported: should you be
+interested into any of these, please get in touch.
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/TOOLS
^
|
@@ -3,22 +3,23 @@
pmacctd libpcap-based accounting daemon; it captures packets from an
interface it is bound to. Statistics can be printed to stdout,
stored in memory tables or a PostgreSQL/MySQL/SQLite/Berkeley
- DB(*) database, exported via NetFlow, IPFIX or sFlow protocols.
+ DB(*)/MongoDB database, exported via NetFlow, IPFIX or sFlow
+ protocols.
nfacctd NetFlow accounting daemon; it listens for NetFlow packets
v1/v5/v7/v8/v9 and IPFIX on one or more interfaces (IPv4 and
IPv6); statistics can be printed to stdout, stored in memory
- tables or a PostgreSQL/MySQL/SQLite/BerkeleyDB(*) database,
- replicated to other collectors.
+ tables or a PostgreSQL/MySQL/SQLite/BerkeleyDB(*)/MongoDB
+ database, replicated to other collectors.
sfacctd sFlow accounting daemon; it listens for sFlow packets v2,
v4 and v5 on one or more interfaces (both IPv4 and IPv6);
statistics can be printed to stdout, stored in memory tables
- or a PostgreSQL/MySQL/SQLite/BerkeleyDB(*) database, replicated
- to other collectors.
+ or a PostgreSQL/MySQL/SQLite/BerkeleyDB(*)/MongoDB database,
+ replicated to other collectors.
uacctd Linux Netlink ULOG accounting daemon; it captures packets by
leveraging a ULOG multicast group - and works only on Linux;
Statistics can be printed to stdout, stored in memory tables
- or a PostgreSQL/MySQL/SQLite/BerkeleyDB(*) database, exported
- via NetFlow, IPFIX or sFlow protocols.
+ or a PostgreSQL/MySQL/SQLite/BerkeleyDB(*)/MongoDB database,
+ exported via NetFlow, IPFIX or sFlow protocols.
pmacct commandline pmacct client; used to retrieve data from a
memory plugin; it can execute both partial and full data
retrieval. Output is either formatted or 'counters-only',
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/configure
^
|
@@ -39,12 +39,24 @@
ac_help="$ac_help
--with-pgsql-includes=DIR Search for PostgreSQL includes in the specified directory"
ac_help="$ac_help
+ --enable-mongodb Enable MongoDB support"
+ac_help="$ac_help
+ --with-mongodb-libs=DIR Search for MongoDB libs in the specified directory"
+ac_help="$ac_help
+ --with-mongodb-includes=DIR Search for MongoDB includes in the specified directory"
+ac_help="$ac_help
--enable-sqlite3 Enable SQLite3 support"
ac_help="$ac_help
--with-sqlite3-libs=DIR Search for SQLite3 libs in the specified directory"
ac_help="$ac_help
--with-sqlite3-includes=DIR Search for SQLite3 includes in the specified directory"
ac_help="$ac_help
+ --enable-geoip Enable GeoIP support"
+ac_help="$ac_help
+ --with-geoip-libs=DIR Search for Maxmind GeoIP libs in the specified directory"
+ac_help="$ac_help
+ --with-geoip-includes=DIR Search for Maxmind GeoIP includes in the specified directory"
+ac_help="$ac_help
--disable-so Disable shared objects"
ac_help="$ac_help
--enable-64bit Enable 64bit counters"
@@ -594,7 +606,7 @@
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:598: checking for a BSD compatible install" >&5
+echo "configure:610: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -647,7 +659,7 @@
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6
-echo "configure:651: checking whether build environment is sane" >&5
+echo "configure:663: checking whether build environment is sane" >&5
# Just in case
sleep 1
echo timestamp > conftestfile
@@ -704,7 +716,7 @@
test "$program_transform_name" = "" && program_transform_name="s,x,x,"
echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:708: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:720: checking whether ${MAKE-make} sets \${MAKE}" >&5
set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -733,7 +745,7 @@
PACKAGE=pmacctd
-VERSION=0.14.1
+VERSION=0.14.2
if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
{ echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; }
@@ -750,7 +762,7 @@
missing_dir=`cd $ac_aux_dir && pwd`
echo $ac_n "checking for working aclocal-${am__api_version}""... $ac_c" 1>&6
-echo "configure:754: checking for working aclocal-${am__api_version}" >&5
+echo "configure:766: checking for working aclocal-${am__api_version}" >&5
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
@@ -763,7 +775,7 @@
fi
echo $ac_n "checking for working autoconf""... $ac_c" 1>&6
-echo "configure:767: checking for working autoconf" >&5
+echo "configure:779: checking for working autoconf" >&5
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
@@ -776,7 +788,7 @@
fi
echo $ac_n "checking for working automake-${am__api_version}""... $ac_c" 1>&6
-echo "configure:780: checking for working automake-${am__api_version}" >&5
+echo "configure:792: checking for working automake-${am__api_version}" >&5
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
@@ -789,7 +801,7 @@
fi
echo $ac_n "checking for working autoheader""... $ac_c" 1>&6
-echo "configure:793: checking for working autoheader" >&5
+echo "configure:805: checking for working autoheader" >&5
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
@@ -802,7 +814,7 @@
fi
echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6
-echo "configure:806: checking for working makeinfo" >&5
+echo "configure:818: checking for working makeinfo" >&5
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
@@ -820,7 +832,7 @@
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:824: checking for $ac_word" >&5
+echo "configure:836: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -850,7 +862,7 @@
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:854: checking for $ac_word" >&5
+echo "configure:866: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -901,7 +913,7 @@
# Extract the first word of "cl", so it can be a program name with args.
set dummy cl; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:905: checking for $ac_word" >&5
+echo "configure:917: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -933,7 +945,7 @@
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:937: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:949: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
@@ -944,12 +956,12 @@
cat > conftest.$ac_ext << EOF
-#line 948 "configure"
+#line 960 "configure"
#include "confdefs.h"
main(){return(0);}
EOF
-if { (eval echo configure:953: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:965: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
ac_cv_prog_cc_works=yes
# If we can't run a trivial program, we are probably using a cross compiler.
if (./conftest; exit) 2>/dev/null; then
@@ -975,12 +987,12 @@
{ echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:979: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:991: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
cross_compiling=$ac_cv_prog_cc_cross
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:984: checking whether we are using GNU C" >&5
+echo "configure:996: checking whether we are using GNU C" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -989,7 +1001,7 @@
yes;
#endif
EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:993: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1005: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
@@ -1008,7 +1020,7 @@
ac_save_CFLAGS="$CFLAGS"
CFLAGS=
echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:1012: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:1024: checking whether ${CC-cc} accepts -g" >&5
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1044,17 +1056,17 @@
host_os1=`uname -rs`
echo $ac_n "checking OS""... $ac_c" 1>&6
-echo "configure:1048: checking OS" >&5
+echo "configure:1060: checking OS" >&5
echo "$ac_t""$host_os" 1>&6
echo $ac_n "checking hardware""... $ac_c" 1>&6
-echo "configure:1052: checking hardware" >&5
+echo "configure:1064: checking hardware" >&5
echo "$ac_t""$host_cpu" 1>&6
# Extract the first word of "ranlib", so it can be a program name with args.
set dummy ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1058: checking for $ac_word" >&5
+echo "configure:1070: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1103,7 +1115,7 @@
fi
echo $ac_n "checking whether to enable debugging compiler options""... $ac_c" 1>&6
-echo "configure:1107: checking whether to enable debugging compiler options" >&5
+echo "configure:1119: checking whether to enable debugging compiler options" >&5
# Check whether --enable-debug or --disable-debug was given.
if test "${enable_debug+set}" = set; then
enableval="$enable_debug"
@@ -1121,7 +1133,7 @@
echo $ac_n "checking whether to relax compiler optimizations""... $ac_c" 1>&6
-echo "configure:1125: checking whether to relax compiler optimizations" >&5
+echo "configure:1137: checking whether to relax compiler optimizations" >&5
# Check whether --enable-relax or --disable-relax was given.
if test "${enable_relax+set}" = set; then
enableval="$enable_relax"
@@ -1183,7 +1195,7 @@
# Extract the first word of "gmake", so it can be a program name with args.
set dummy gmake; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1187: checking for $ac_word" >&5
+echo "configure:1199: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_MAKE'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1213,7 +1225,7 @@
# Extract the first word of "make", so it can be a program name with args.
set dummy make; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:1217: checking for $ac_word" >&5
+echo "configure:1229: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_MAKE'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1242,7 +1254,7 @@
fi
echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
-echo "configure:1246: checking whether ${MAKE-make} sets \${MAKE}" >&5
+echo "configure:1258: checking whether ${MAKE-make} sets \${MAKE}" >&5
set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1270,16 +1282,16 @@
echo $ac_n "checking for __progname""... $ac_c" 1>&6
-echo "configure:1274: checking for __progname" >&5
+echo "configure:1286: checking for __progname" >&5
cat > conftest.$ac_ext <<EOF
-#line 1276 "configure"
+#line 1288 "configure"
#include "confdefs.h"
extern char *__progname;
int main() {
__progname = "test";
; return 0; }
EOF
-if { (eval echo configure:1283: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1295: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
#define PROGNAME 1
@@ -1295,7 +1307,7 @@
echo $ac_n "checking for extra flags needed to export symbols""... $ac_c" 1>&6
-echo "configure:1299: checking for extra flags needed to export symbols" >&5
+echo "configure:1311: checking for extra flags needed to export symbols" >&5
if test "x$ac_cv_prog_gcc" = xyes ; then
case $host_os in
aix4*|aix5*)
@@ -1305,14 +1317,14 @@
save_ldflags="${LDFLAGS}"
LDFLAGS="-Wl,--export-dynamic ${save_ldflags}"
cat > conftest.$ac_ext <<EOF
-#line 1309 "configure"
+#line 1321 "configure"
#include "confdefs.h"
int main() {
; return 0; }
EOF
-if { (eval echo configure:1316: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1328: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
echo "$ac_t""--export-dynamic" 1>&6
else
@@ -1321,14 +1333,14 @@
rm -rf conftest*
LDFLAGS="-Wl,-Bexport ${save_ldflags}"
cat > conftest.$ac_ext <<EOF
-#line 1325 "configure"
+#line 1337 "configure"
#include "confdefs.h"
int main() {
; return 0; }
EOF
-if { (eval echo configure:1332: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1344: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
echo "$ac_t""-Bexport" 1>&6
else
@@ -1350,9 +1362,9 @@
fi
echo $ac_n "checking for static inline""... $ac_c" 1>&6
-echo "configure:1354: checking for static inline" >&5
+echo "configure:1366: checking for static inline" >&5
cat > conftest.$ac_ext <<EOF
-#line 1356 "configure"
+#line 1368 "configure"
#include "confdefs.h"
#include <stdio.h>
@@ -1366,7 +1378,7 @@
; return 0; }
EOF
-if { (eval echo configure:1370: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1382: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
echo "$ac_t""yes" 1>&6
else
@@ -1383,12 +1395,12 @@
ac_cv_endianess="unknown"
if test x"$ac_cv_endianess" = x"unknown"; then
echo $ac_n "checking endianess""... $ac_c" 1>&6
-echo "configure:1387: checking endianess" >&5
+echo "configure:1399: checking endianess" >&5
if test "$cross_compiling" = yes; then
ac_cv_endianess="little"
else
cat > conftest.$ac_ext <<EOF
-#line 1392 "configure"
+#line 1404 "configure"
#include "confdefs.h"
main () {
@@ -1401,7 +1413,7 @@
exit (u.c[sizeof (long) - 1] == 1);
}
EOF
-if { (eval echo configure:1405: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1417: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_endianess="little"
else
@@ -1434,14 +1446,14 @@
alpha*|arm*|hp*|mips*|sh*|sparc*|ia64|nv1)
ac_cv_unaligned="fail"
echo $ac_n "checking unaligned accesses""... $ac_c" 1>&6
-echo "configure:1438: checking unaligned accesses" >&5
+echo "configure:1450: checking unaligned accesses" >&5
echo "$ac_t""$ac_cv_unaligned" 1>&6
;;
esac
if test x"$ac_cv_unaligned" = x"unknown"; then
echo $ac_n "checking unaligned accesses""... $ac_c" 1>&6
-echo "configure:1445: checking unaligned accesses" >&5
+echo "configure:1457: checking unaligned accesses" >&5
cat > conftest.c << EOF
#include <sys/types.h>
#include <sys/wait.h>
@@ -1488,7 +1500,7 @@
fi
echo $ac_n "checking whether to disable L2 features""... $ac_c" 1>&6
-echo "configure:1492: checking whether to disable L2 features" >&5
+echo "configure:1504: checking whether to disable L2 features" >&5
# Check whether --enable-l2 or --disable-l2 was given.
if test "${enable_l2+set}" = set; then
enableval="$enable_l2"
@@ -1513,7 +1525,7 @@
echo $ac_n "checking whether to enable IPv6 code""... $ac_c" 1>&6
-echo "configure:1517: checking whether to enable IPv6 code" >&5
+echo "configure:1529: checking whether to enable IPv6 code" >&5
# Check whether --enable-ipv6 or --disable-ipv6 was given.
if test "${enable_ipv6+set}" = set; then
enableval="$enable_ipv6"
@@ -1522,12 +1534,12 @@
for ac_func in inet_pton
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1526: checking for $ac_func" >&5
+echo "configure:1538: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1531 "configure"
+#line 1543 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1550,7 +1562,7 @@
; return 0; }
EOF
-if { (eval echo configure:1554: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1566: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1581,12 +1593,12 @@
for ac_func in inet_ntop
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1585: checking for $ac_func" >&5
+echo "configure:1597: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1590 "configure"
+#line 1602 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1609,7 +1621,7 @@
; return 0; }
EOF
-if { (eval echo configure:1613: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1625: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1659,7 +1671,7 @@
if test $ipv6support = "yes"; then
echo $ac_n "checking whether to enable IPv4-mapped IPv6 sockets ""... $ac_c" 1>&6
-echo "configure:1663: checking whether to enable IPv4-mapped IPv6 sockets " >&5
+echo "configure:1675: checking whether to enable IPv4-mapped IPv6 sockets " >&5
# Check whether --enable-v4-mapped or --disable-v4-mapped was given.
if test "${enable_v4_mapped+set}" = set; then
enableval="$enable_v4_mapped"
@@ -1711,7 +1723,7 @@
if test x"$PCAPINCLS" != x""; then
echo $ac_n "checking your own pcap includes""... $ac_c" 1>&6
-echo "configure:1715: checking your own pcap includes" >&5
+echo "configure:1727: checking your own pcap includes" >&5
if test -r $PCAPINCLS/pcap.h; then
echo "$ac_t""ok" 1>&6
cat >> confdefs.h <<\EOF
@@ -1726,7 +1738,7 @@
if test x"$PCAPINCLUDESFOUND" = x""; then
echo $ac_n "checking default locations for pcap.h""... $ac_c" 1>&6
-echo "configure:1730: checking default locations for pcap.h" >&5
+echo "configure:1742: checking default locations for pcap.h" >&5
if test -r /usr/include/pcap.h; then
echo "$ac_t""found in /usr/include" 1>&6
PCAPINCLUDESFOUND=1
@@ -1783,12 +1795,12 @@
if test x"$PCAPLIB" != x""; then
echo $ac_n "checking your own pcap libraries""... $ac_c" 1>&6
-echo "configure:1787: checking your own pcap libraries" >&5
+echo "configure:1799: checking your own pcap libraries" >&5
if test -r $PCAPLIB/libpcap.a -o -r $PCAPLIB/libpcap.so; then
echo "$ac_t""ok" 1>&6
PCAP_LIB_FOUND=1
echo $ac_n "checking for PF_RING library""... $ac_c" 1>&6
-echo "configure:1792: checking for PF_RING library" >&5
+echo "configure:1804: checking for PF_RING library" >&5
if test -r $PCAPLIB/libpfring.a -o -r $PCAPLIB/libpfring.so; then
LIBS="${LIBS} -lpcap -lpfring"
echo "$ac_t""yes" 1>&6
@@ -1804,13 +1816,13 @@
if test x"$PCAPLIBFOUND" = x""; then
echo $ac_n "checking default locations for libpcap""... $ac_c" 1>&6
-echo "configure:1808: checking default locations for libpcap" >&5
+echo "configure:1820: checking default locations for libpcap" >&5
if test -r /usr/local/lib/libpcap.a -o -r /usr/local/lib/libpcap.so; then
LIBS="${LIBS} -L/usr/local/lib"
echo "$ac_t""found in /usr/local/lib" 1>&6
PCAPLIBFOUND=1
echo $ac_n "checking for PF_RING library""... $ac_c" 1>&6
-echo "configure:1814: checking for PF_RING library" >&5
+echo "configure:1826: checking for PF_RING library" >&5
if test -r /usr/local/lib/libpfring.a -o -r /usr/local/lib/libpfring.so; then
LIBS="${LIBS} -lpcap -lpfring"
echo "$ac_t""yes" 1>&6
@@ -1826,7 +1838,7 @@
if test x"$PFRING_LIB_FOUND" = x""; then
echo $ac_n "checking for pcap_dispatch in -lpcap""... $ac_c" 1>&6
-echo "configure:1830: checking for pcap_dispatch in -lpcap" >&5
+echo "configure:1842: checking for pcap_dispatch in -lpcap" >&5
ac_lib_var=`echo pcap'_'pcap_dispatch | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1834,7 +1846,7 @@
ac_save_LIBS="$LIBS"
LIBS="-lpcap $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1838 "configure"
+#line 1850 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1845,7 +1857,7 @@
pcap_dispatch()
; return 0; }
EOF
-if { (eval echo configure:1849: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1861: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1877,7 +1889,7 @@
echo $ac_n "checking for pcap_setnonblock in -lpcap""... $ac_c" 1>&6
-echo "configure:1881: checking for pcap_setnonblock in -lpcap" >&5
+echo "configure:1893: checking for pcap_setnonblock in -lpcap" >&5
ac_lib_var=`echo pcap'_'pcap_setnonblock | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1885,7 +1897,7 @@
ac_save_LIBS="$LIBS"
LIBS="-lpcap $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1889 "configure"
+#line 1901 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -1896,7 +1908,7 @@
pcap_setnonblock()
; return 0; }
EOF
-if { (eval echo configure:1900: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1912: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -1922,7 +1934,7 @@
fi
echo $ac_n "checking packet capture type""... $ac_c" 1>&6
-echo "configure:1926: checking packet capture type" >&5
+echo "configure:1938: checking packet capture type" >&5
if test -r /dev/bpf0 ; then
V_PCAP=bpf
elif test -r /usr/include/net/pfilt.h ; then
@@ -1962,9 +1974,9 @@
echo $ac_n "checking whether to enable MySQL support""... $ac_c" 1>&6
-echo "configure:1966: checking whether to enable MySQL support" >&5
+echo "configure:1978: checking whether to enable MySQL support" >&5
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1968: checking how to run the C preprocessor" >&5
+echo "configure:1980: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@@ -1979,13 +1991,13 @@
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
-#line 1983 "configure"
+#line 1995 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1989: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2001: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -1996,13 +2008,13 @@
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
-#line 2000 "configure"
+#line 2012 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2006: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2018: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -2013,13 +2025,13 @@
rm -rf conftest*
CPP="${CC-cc} -nologo -E"
cat > conftest.$ac_ext <<EOF
-#line 2017 "configure"
+#line 2029 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2023: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2035: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -2070,7 +2082,7 @@
if test x"$MYSQLLIB" != x""; then
echo $ac_n "checking your own MySQL client library""... $ac_c" 1>&6
-echo "configure:2074: checking your own MySQL client library" >&5
+echo "configure:2086: checking your own MySQL client library" >&5
if test -r $MYSQLLIB/libmysqlclient.a -o -r $MYSQLLIB/libmysqlclient.so; then
echo "$ac_t""ok" 1>&6
else
@@ -2081,7 +2093,7 @@
if test x"$MYSQLLIBFOUND" = x""; then
echo $ac_n "checking default locations for libmysqlclient""... $ac_c" 1>&6
-echo "configure:2085: checking default locations for libmysqlclient" >&5
+echo "configure:2097: checking default locations for libmysqlclient" >&5
if test -r /usr/lib/mysql/libmysqlclient.a -o -r /usr/lib/mysql/libmysqlclient.so; then
LIBS="${LIBS} -L/usr/lib/mysql"
echo "$ac_t""found in /usr/lib/mysql" 1>&6
@@ -2101,7 +2113,7 @@
if test x"$MYSQLLIBFOUND" = x""; then
echo $ac_n "checking for mysql_real_connect in -lmysqlclient""... $ac_c" 1>&6
-echo "configure:2105: checking for mysql_real_connect in -lmysqlclient" >&5
+echo "configure:2117: checking for mysql_real_connect in -lmysqlclient" >&5
ac_lib_var=`echo mysqlclient'_'mysql_real_connect | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -2109,7 +2121,7 @@
ac_save_LIBS="$LIBS"
LIBS="-lmysqlclient $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2113 "configure"
+#line 2125 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -2120,7 +2132,7 @@
mysql_real_connect()
; return 0; }
EOF
-if { (eval echo configure:2124: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2136: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -2178,7 +2190,7 @@
if test x"$MYSQLINCLUDES" != x""; then
echo $ac_n "checking your own MySQL headers""... $ac_c" 1>&6
-echo "configure:2182: checking your own MySQL headers" >&5
+echo "configure:2194: checking your own MySQL headers" >&5
if test -r $MYSQLINCLUDES/mysql/mysql.h; then
echo "$ac_t""ok" 1>&6
elif test -r $MYSQLINCLUDES/mysql.h; then
@@ -2195,7 +2207,7 @@
if test x"$MYSQLINCLUDESFOUND" = x""; then
echo $ac_n "checking default locations for mysql.h""... $ac_c" 1>&6
-echo "configure:2199: checking default locations for mysql.h" >&5
+echo "configure:2211: checking default locations for mysql.h" >&5
if test -r /usr/include/mysql/mysql.h; then
echo "$ac_t""found in /usr/include/mysql" 1>&6
MYSQLINCLUDESFOUND=1;
@@ -2220,17 +2232,17 @@
if test x"$MYSQLINCLUDESFOUND" = x""; then
ac_safe=`echo "mysql/mysql.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for mysql/mysql.h""... $ac_c" 1>&6
-echo "configure:2224: checking for mysql/mysql.h" >&5
+echo "configure:2236: checking for mysql/mysql.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2229 "configure"
+#line 2241 "configure"
#include "confdefs.h"
#include <mysql/mysql.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2234: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2246: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -2271,7 +2283,7 @@
echo $ac_n "checking whether to enable PostgreSQL support""... $ac_c" 1>&6
-echo "configure:2275: checking whether to enable PostgreSQL support" >&5
+echo "configure:2287: checking whether to enable PostgreSQL support" >&5
# Check whether --enable-pgsql or --disable-pgsql was given.
if test "${enable_pgsql+set}" = set; then
enableval="$enable_pgsql"
@@ -2299,7 +2311,7 @@
if test x"$PGSQLLIB" != x""; then
echo $ac_n "checking your own PostgreSQL client library""... $ac_c" 1>&6
-echo "configure:2303: checking your own PostgreSQL client library" >&5
+echo "configure:2315: checking your own PostgreSQL client library" >&5
if test -r $PGSQLLIB/libpq.a -o -r $PGSQLLIB/libpq.so; then
echo "$ac_t""ok" 1>&6
else
@@ -2310,7 +2322,7 @@
if test x"$PGSQLLIBFOUND" = x""; then
echo $ac_n "checking default locations for libpq""... $ac_c" 1>&6
-echo "configure:2314: checking default locations for libpq" >&5
+echo "configure:2326: checking default locations for libpq" >&5
if test -r /usr/lib/libpq.a -o -r /usr/lib/libpq.so; then
echo "$ac_t""found in /usr/lib" 1>&6
PGSQLLIBFOUND=1
@@ -2329,7 +2341,7 @@
if test x"$PGSQLLIBFOUND" = x""; then
echo $ac_n "checking for PQconnectdb in -lpq""... $ac_c" 1>&6
-echo "configure:2333: checking for PQconnectdb in -lpq" >&5
+echo "configure:2345: checking for PQconnectdb in -lpq" >&5
ac_lib_var=`echo pq'_'PQconnectdb | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -2337,7 +2349,7 @@
ac_save_LIBS="$LIBS"
LIBS="-lpq $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2341 "configure"
+#line 2353 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -2348,7 +2360,7 @@
PQconnectdb()
; return 0; }
EOF
-if { (eval echo configure:2352: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2364: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -2401,7 +2413,7 @@
if test x"$PGSQLINCLUDES" != x""; then
echo $ac_n "checking your own PostgreSQL headers""... $ac_c" 1>&6
-echo "configure:2405: checking your own PostgreSQL headers" >&5
+echo "configure:2417: checking your own PostgreSQL headers" >&5
if test -r $PGSQLINCLUDES/libpq-fe.h; then
echo "$ac_t""ok" 1>&6
else
@@ -2412,7 +2424,7 @@
if test x"$PGSQLINCLUDESFOUND" = x""; then
echo $ac_n "checking default locations for libpq-fe.h""... $ac_c" 1>&6
-echo "configure:2416: checking default locations for libpq-fe.h" >&5
+echo "configure:2428: checking default locations for libpq-fe.h" >&5
if test -r /usr/include/libpq-fe.h; then
echo "$ac_t""found in /usr/include" 1>&6
PGSQLINCLUDESFOUND=1;
@@ -2433,17 +2445,17 @@
if test x"$PGSQLINCLUDESFOUND" = x""; then
ac_safe=`echo "libpq-fe.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for libpq-fe.h""... $ac_c" 1>&6
-echo "configure:2437: checking for libpq-fe.h" >&5
+echo "configure:2449: checking for libpq-fe.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2442 "configure"
+#line 2454 "configure"
#include "confdefs.h"
#include <libpq-fe.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2447: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2459: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -2483,8 +2495,211 @@
fi
+echo $ac_n "checking whether to enable MongoDB support""... $ac_c" 1>&6
+echo "configure:2500: checking whether to enable MongoDB support" >&5
+# Check whether --enable-mongodb or --disable-mongodb was given.
+if test "${enable_mongodb+set}" = set; then
+ enableval="$enable_mongodb"
+ case "$enableval" in
+ yes)
+ echo "$ac_t""yes" 1>&6
+
+ # Check whether --with-mongodb-libs or --without-mongodb-libs was given.
+if test "${with_mongodb_libs+set}" = set; then
+ withval="$with_mongodb_libs"
+
+
+ absdir=`cd $withval 2>/dev/null && pwd`
+ if test x$absdir != x ; then
+ withval=$absdir
+ fi
+
+ LIBS="${LIBS} -L$withval"
+ MONGODBLIB=$withval
+ MONGODBLIBFOUND=1
+
+fi
+
+
+ if test x"$MONGODBLIB" != x""; then
+ echo $ac_n "checking your own MongoDB library""... $ac_c" 1>&6
+echo "configure:2527: checking your own MongoDB library" >&5
+ if test -r $MONGODBLIB/libmongoc.a -o -r $MONGODBLIB/libmongoc.so; then
+ echo "$ac_t""ok" 1>&6
+ else
+ echo "$ac_t""no" 1>&6
+ { echo "configure: error: ERROR: missing MongoDB library in $MONGODBLIB" 1>&2; exit 1; }
+ fi
+ fi
+
+ if test x"$MONGODBLIBFOUND" = x""; then
+ echo $ac_n "checking default locations for libmongoc""... $ac_c" 1>&6
+echo "configure:2538: checking default locations for libmongoc" >&5
+ if test -r /usr/lib/libmongoc.a -o -r /usr/lib/libmongoc.so; then
+ echo "$ac_t""found in /usr/lib" 1>&6
+ MONGODBLIBFOUND=1
+ elif test -r /usr/local/lib/libmongoc.a -o -r /usr/local/lib/libmongoc.so; then
+ LIBS="${LIBS} -L/usr/local/lib"
+ echo "$ac_t""found in /usr/local/lib" 1>&6
+ MONGODBLIBFOUND=1
+ else
+ echo "$ac_t""not found" 1>&6
+ fi
+ fi
+
+ if test x"$MONGODBLIBFOUND" = x""; then
+ echo $ac_n "checking for mongo_connect in -lmongoc""... $ac_c" 1>&6
+echo "configure:2553: checking for mongo_connect in -lmongoc" >&5
+ac_lib_var=`echo mongoc'_'mongo_connect | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lmongoc $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 2561 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char mongo_connect();
+
+int main() {
+mongo_connect()
+; return 0; }
+EOF
+if { (eval echo configure:2572: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_lib=HAVE_LIB`echo mongoc | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_lib 1
+EOF
+
+ LIBS="-lmongoc $LIBS"
+
+else
+ echo "$ac_t""no" 1>&6
+{ echo "configure: error:
+ ERROR: missing MongoDB library. Refer to: http://api.mongodb.org/c/
+ " 1>&2; exit 1; }
+fi
+
+ else
+ LIBS="${LIBS} -lmongoc"
+ fi
+
+ # Check whether --with-mongodb-includes or --without-mongodb-includes was given.
+if test "${with_mongodb_includes+set}" = set; then
+ withval="$with_mongodb_includes"
+
+
+ absdir=`cd $withval 2>/dev/null && pwd`
+ if test x$absdir != x ; then
+ withval=$absdir
+ fi
+
+ INCLUDES="${INCLUDES} -I$withval"
+ MONGODBINCLUDES=$withval
+ MONGODBINCLUDESFOUND=1
+
+fi
+
+
+ if test x"$MONGODBINCLUDES" != x""; then
+ echo $ac_n "checking your own MongoDB headers""... $ac_c" 1>&6
+echo "configure:2625: checking your own MongoDB headers" >&5
+ if test -r $MONGODBINCLUDES/mongo.h; then
+ echo "$ac_t""ok" 1>&6
+ else
+ echo "$ac_t""no" 1>&6
+ { echo "configure: error: ERROR: missing MongoDB headers in $MONGODBINCLUDES" 1>&2; exit 1; }
+ fi
+ fi
+
+ if test x"$MONGODBINCLUDESFOUND" = x""; then
+ echo $ac_n "checking default locations for mongo.h""... $ac_c" 1>&6
+echo "configure:2636: checking default locations for mongo.h" >&5
+ if test -r /usr/include/mongo.h; then
+ echo "$ac_t""found in /usr/include" 1>&6
+ MONGODBINCLUDESFOUND=1;
+ elif test -r /usr/local/include/mongo.h; then
+ INCLUDES="${INCLUDES} -I/usr/local/include"
+ echo "$ac_t""found in /usr/local/include" 1>&6
+ MONGODBINCLUDESFOUND=1;
+ fi
+ if test x"$MONGODBINCLUDESFOUND" = x""; then
+ echo "$ac_t""not found" 1>&6
+ fi
+ fi
+
+ if test x"$MONGODBINCLUDESFOUND" = x""; then
+ ac_safe=`echo "mongo.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for mongo.h""... $ac_c" 1>&6
+echo "configure:2653: checking for mongo.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2658 "configure"
+#include "confdefs.h"
+#include <mongo.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:2663: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ :
+else
+ echo "$ac_t""no" 1>&6
+{ echo "configure: error: ERROR: missing MongoDB headers" 1>&2; exit 1; }
+fi
+
+ fi
+
+ cat >> confdefs.h <<\EOF
+#define WITH_MONGODB 1
+EOF
+
+ PLUGINS="${PLUGINS} mongodb_plugin.c"
+ ;;
+ no)
+ echo "$ac_t""no" 1>&6
+ ;;
+ esac
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
echo $ac_n "checking whether to enable SQLite3 support""... $ac_c" 1>&6
-echo "configure:2488: checking whether to enable SQLite3 support" >&5
+echo "configure:2703: checking whether to enable SQLite3 support" >&5
# Check whether --enable-sqlite3 or --disable-sqlite3 was given.
if test "${enable_sqlite3+set}" = set; then
enableval="$enable_sqlite3"
@@ -2512,7 +2727,7 @@
if test x"$SQLITE3LIB" != x""; then
echo $ac_n "checking your own SQLite3 client library""... $ac_c" 1>&6
-echo "configure:2516: checking your own SQLite3 client library" >&5
+echo "configure:2731: checking your own SQLite3 client library" >&5
if test -r $SQLITE3LIB/libsqlite3.a -o -r $SQLITE3LIB/libsqlite3.so; then
echo "$ac_t""ok" 1>&6
else
@@ -2523,7 +2738,7 @@
if test x"$SQLITE3LIBFOUND" = x""; then
echo $ac_n "checking default locations for libsqlite3""... $ac_c" 1>&6
-echo "configure:2527: checking default locations for libsqlite3" >&5
+echo "configure:2742: checking default locations for libsqlite3" >&5
if test -r /usr/lib/libsqlite3.a -o -r /usr/lib/libsqlite3.so; then
# LIBS="${LIBS} -L/usr/lib/sqlite3"
echo "$ac_t""found in /usr/lib" 1>&6
@@ -2543,7 +2758,7 @@
if test x"$SQLITE3LIBFOUND" = x""; then
echo $ac_n "checking for sqlite3_open in -lsqlite3""... $ac_c" 1>&6
-echo "configure:2547: checking for sqlite3_open in -lsqlite3" >&5
+echo "configure:2762: checking for sqlite3_open in -lsqlite3" >&5
ac_lib_var=`echo sqlite3'_'sqlite3_open | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -2551,7 +2766,7 @@
ac_save_LIBS="$LIBS"
LIBS="-lsqlite3 $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2555 "configure"
+#line 2770 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -2562,7 +2777,7 @@
sqlite3_open()
; return 0; }
EOF
-if { (eval echo configure:2566: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2781: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -2615,7 +2830,7 @@
if test x"$SQLITE3INCLUDES" != x""; then
echo $ac_n "checking your own SQLite3 headers""... $ac_c" 1>&6
-echo "configure:2619: checking your own SQLite3 headers" >&5
+echo "configure:2834: checking your own SQLite3 headers" >&5
if test -r $SQLITE3INCLUDES/sqlite3.h; then
echo "$ac_t""ok" 1>&6
else
@@ -2626,7 +2841,7 @@
if test x"$SQLITE3INCLUDESFOUND" = x""; then
echo $ac_n "checking default locations for sqlite3.h""... $ac_c" 1>&6
-echo "configure:2630: checking default locations for sqlite3.h" >&5
+echo "configure:2845: checking default locations for sqlite3.h" >&5
if test -r /usr/include/sqlite3.h; then
echo "$ac_t""found in /usr/include" 1>&6
SQLITE3INCLUDESFOUND=1;
@@ -2647,17 +2862,17 @@
if test x"$SQLITE3INCLUDESFOUND" = x""; then
ac_safe=`echo "sqlite3.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for sqlite3.h""... $ac_c" 1>&6
-echo "configure:2651: checking for sqlite3.h" >&5
+echo "configure:2866: checking for sqlite3.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2656 "configure"
+#line 2871 "configure"
#include "confdefs.h"
#include <sqlite3.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2661: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2876: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -2696,20 +2911,222 @@
fi
+echo $ac_n "checking whether to enable GeoIP support""... $ac_c" 1>&6
+echo "configure:2916: checking whether to enable GeoIP support" >&5
+# Check whether --enable-geoip or --disable-geoip was given.
+if test "${enable_geoip+set}" = set; then
+ enableval="$enable_geoip"
+ case "$enableval" in
+ yes)
+ echo "$ac_t""yes" 1>&6
+
+ # Check whether --with-geoip-libs or --without-geoip-libs was given.
+if test "${with_geoip_libs+set}" = set; then
+ withval="$with_geoip_libs"
+
+
+ absdir=`cd $withval 2>/dev/null && pwd`
+ if test x$absdir != x ; then
+ withval=$absdir
+ fi
+
+ LIBS="${LIBS} -L$withval"
+ MMGEOIPLIB=$withval
+ MMGEOIPLIBFOUND=1
+
+fi
+
+
+ if test x"$MMGEOIPLIB" != x""; then
+ echo $ac_n "checking your own Maxmind GeoIP library""... $ac_c" 1>&6
+echo "configure:2943: checking your own Maxmind GeoIP library" >&5
+ if test -r $MMGEOIPLIB/libGeoIP.a -o -r $MMGEOIPLIB/libGeoIP.so; then
+ echo "$ac_t""ok" 1>&6
+ else
+ echo "$ac_t""no" 1>&6
+ { echo "configure: error: ERROR: missing Maxmind GeoIP library in $MMGEOIPLIB" 1>&2; exit 1; }
+ fi
+ fi
+
+ if test x"$MMGEOIPLIBFOUND" = x""; then
+ echo $ac_n "checking default locations for libGeoIP""... $ac_c" 1>&6
+echo "configure:2954: checking default locations for libGeoIP" >&5
+ if test -r /usr/lib/libGeoIP.a -o -r /usr/lib/libGeoIP.so; then
+ echo "$ac_t""found in /usr/lib" 1>&6
+ MMGEOIPLIBFOUND=1
+ elif test -r /usr/local/lib/libGeoIP.a -o -r /usr/local/lib/libGeoIP.so; then
+ LIBS="${LIBS} -L/usr/local/lib"
+ echo "$ac_t""found in /usr/local/lib" 1>&6
+ MMGEOIPLIBFOUND=1
+ else
+ echo "$ac_t""not found" 1>&6
+ fi
+ fi
+
+ if test x"$MMGEOIPLIBFOUND" = x""; then
+ echo $ac_n "checking for GeoIP_open in -lGeoIP""... $ac_c" 1>&6
+echo "configure:2969: checking for GeoIP_open in -lGeoIP" >&5
+ac_lib_var=`echo GeoIP'_'GeoIP_open | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lGeoIP $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 2977 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char GeoIP_open();
+
+int main() {
+GeoIP_open()
+; return 0; }
+EOF
+if { (eval echo configure:2988: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_lib=HAVE_LIB`echo GeoIP | sed -e 's/[^a-zA-Z0-9_]/_/g' \
+ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_lib 1
+EOF
+
+ LIBS="-lGeoIP $LIBS"
+
+else
+ echo "$ac_t""no" 1>&6
+{ echo "configure: error:
+ ERROR: missing Maxmind GeoIP library. Refer to: http://www.maxmind.com/download/geoip/api/c/
+ " 1>&2; exit 1; }
+fi
+
+ else
+ LIBS="${LIBS} -lGeoIP"
+ fi
+
+ # Check whether --with-geoip-includes or --without-geoip-includes was given.
+if test "${with_geoip_includes+set}" = set; then
+ withval="$with_geoip_includes"
+
+
+ absdir=`cd $withval 2>/dev/null && pwd`
+ if test x$absdir != x ; then
+ withval=$absdir
+ fi
+
+ INCLUDES="${INCLUDES} -I$withval"
+ MMGEOIPINCLUDES=$withval
+ MMGEOIPINCLUDESFOUND=1
+
+fi
+
+
+ if test x"$MMGEOIPINCLUDES" != x""; then
+ echo $ac_n "checking your own Maxmind GeoIP headers""... $ac_c" 1>&6
+echo "configure:3041: checking your own Maxmind GeoIP headers" >&5
+ if test -r $MMGEOIPINCLUDES/GeoIP.h; then
+ echo "$ac_t""ok" 1>&6
+ else
+ echo "$ac_t""no" 1>&6
+ { echo "configure: error: ERROR: missing Maximind GeoIP headers in $MMGEOIPINCLUDES" 1>&2; exit 1; }
+ fi
+ fi
+
+ if test x"$MMGEOIPINCLUDESFOUND" = x""; then
+ echo $ac_n "checking default locations for GeoIP.h""... $ac_c" 1>&6
+echo "configure:3052: checking default locations for GeoIP.h" >&5
+ if test -r /usr/include/GeoIP.h; then
+ echo "$ac_t""found in /usr/include" 1>&6
+ MMGEOIPINCLUDESFOUND=1;
+ elif test -r /usr/local/include/GeoIP.h; then
+ INCLUDES="${INCLUDES} -I/usr/local/include"
+ echo "$ac_t""found in /usr/local/include" 1>&6
+ MMGEOIPINCLUDESFOUND=1;
+ fi
+ if test x"$MMGEOIPINCLUDESFOUND" = x""; then
+ echo "$ac_t""not found" 1>&6
+ fi
+ fi
+
+ if test x"$MMGEOIPINCLUDESFOUND" = x""; then
+ ac_safe=`echo "GeoIP.h" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for GeoIP.h""... $ac_c" 1>&6
+echo "configure:3069: checking for GeoIP.h" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 3074 "configure"
+#include "confdefs.h"
+#include <GeoIP.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:3079: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ :
+else
+ echo "$ac_t""no" 1>&6
+{ echo "configure: error: ERROR: missing Maxmind GeoIP headers" 1>&2; exit 1; }
+fi
+
+ fi
+
+ cat >> confdefs.h <<\EOF
+#define WITH_GEOIP 1
+EOF
+
+ ;;
+ no)
+ echo "$ac_t""no" 1>&6
+ ;;
+ esac
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
echo $ac_n "checking whether to disable shared objects""... $ac_c" 1>&6
-echo "configure:2701: checking whether to disable shared objects" >&5
+echo "configure:3118: checking whether to disable shared objects" >&5
# Check whether --enable-so or --disable-so was given.
if test "${enable_so+set}" = set; then
enableval="$enable_so"
if test x$enableval = x"yes" ; then
echo "$ac_t""no" 1>&6
echo $ac_n "checking for dlopen""... $ac_c" 1>&6
-echo "configure:2708: checking for dlopen" >&5
+echo "configure:3125: checking for dlopen" >&5
if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2713 "configure"
+#line 3130 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char dlopen(); below. */
@@ -2732,7 +3149,7 @@
; return 0; }
EOF
-if { (eval echo configure:2736: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3153: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_dlopen=yes"
else
@@ -2753,7 +3170,7 @@
if test x"$USING_DLOPEN" != x"yes"; then
echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:2757: checking for dlopen in -ldl" >&5
+echo "configure:3174: checking for dlopen in -ldl" >&5
ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -2761,7 +3178,7 @@
ac_save_LIBS="$LIBS"
LIBS="-ldl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2765 "configure"
+#line 3182 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -2772,7 +3189,7 @@
dlopen()
; return 0; }
EOF
-if { (eval echo configure:2776: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3193: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -2802,12 +3219,12 @@
else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for dlopen""... $ac_c" 1>&6
-echo "configure:2806: checking for dlopen" >&5
+echo "configure:3223: checking for dlopen" >&5
if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2811 "configure"
+#line 3228 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char dlopen(); below. */
@@ -2830,7 +3247,7 @@
; return 0; }
EOF
-if { (eval echo configure:2834: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3251: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_dlopen=yes"
else
@@ -2851,7 +3268,7 @@
if test x"$USING_DLOPEN" != x"yes"; then
echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
-echo "configure:2855: checking for dlopen in -ldl" >&5
+echo "configure:3272: checking for dlopen in -ldl" >&5
ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -2859,7 +3276,7 @@
ac_save_LIBS="$LIBS"
LIBS="-ldl $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2863 "configure"
+#line 3280 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@@ -2870,7 +3287,7 @@
dlopen()
; return 0; }
EOF
-if { (eval echo configure:2874: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3291: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -2910,12 +3327,12 @@
fi
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:2914: checking for ANSI C header files" >&5
+echo "configure:3331: checking for ANSI C header files" >&5
if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2919 "configure"
+#line 3336 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <stdarg.h>
@@ -2923,7 +3340,7 @@
#include <float.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2927: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3344: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -2940,7 +3357,7 @@
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 2944 "configure"
+#line 3361 "configure"
#include "confdefs.h"
#include <string.h>
EOF
@@ -2958,7 +3375,7 @@
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
-#line 2962 "configure"
+#line 3379 "configure"
#include "confdefs.h"
#include <stdlib.h>
EOF
@@ -2979,7 +3396,7 @@
:
else
cat > conftest.$ac_ext <<EOF
-#line 2983 "configure"
+#line 3400 "configure"
#include "confdefs.h"
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -2990,7 +3407,7 @@
exit (0); }
EOF
-if { (eval echo configure:2994: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3411: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
:
else
@@ -3014,12 +3431,12 @@
fi
echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
-echo "configure:3018: checking for sys/wait.h that is POSIX.1 compatible" >&5
+echo "configure:3435: checking for sys/wait.h that is POSIX.1 compatible" >&5
if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3023 "configure"
+#line 3440 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/wait.h>
@@ -3035,7 +3452,7 @@
s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
; return 0; }
EOF
-if { (eval echo configure:3039: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3456: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_header_sys_wait_h=yes
else
@@ -3059,17 +3476,17 @@
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3063: checking for $ac_hdr" >&5
+echo "configure:3480: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3068 "configure"
+#line 3485 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3073: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3490: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -3097,7 +3514,7 @@
echo $ac_n "checking for u_int64_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:3101: checking for u_int64_t in sys/types.h" >&5
+echo "configure:3518: checking for u_int64_t in sys/types.h" >&5
ac_lib_var=`echo u_int64_t'_'sys/types.h | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -3105,14 +3522,14 @@
eval "ac_cv_type_$ac_lib_var='not-found'"
ac_cv_check_typedef_header=`echo sys/types.h`
cat > conftest.$ac_ext <<EOF
-#line 3109 "configure"
+#line 3526 "configure"
#include "confdefs.h"
#include <$ac_cv_check_typedef_header>
int main() {
int x = sizeof(u_int64_t); x = x;
; return 0; }
EOF
-if { (eval echo configure:3116: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3533: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
eval "ac_cv_type_$ac_lib_var=yes"
else
@@ -3137,7 +3554,7 @@
fi
echo $ac_n "checking for u_int32_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:3141: checking for u_int32_t in sys/types.h" >&5
+echo "configure:3558: checking for u_int32_t in sys/types.h" >&5
ac_lib_var=`echo u_int32_t'_'sys/types.h | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -3145,14 +3562,14 @@
eval "ac_cv_type_$ac_lib_var='not-found'"
ac_cv_check_typedef_header=`echo sys/types.h`
cat > conftest.$ac_ext <<EOF
-#line 3149 "configure"
+#line 3566 "configure"
#include "confdefs.h"
#include <$ac_cv_check_typedef_header>
int main() {
int x = sizeof(u_int32_t); x = x;
; return 0; }
EOF
-if { (eval echo configure:3156: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3573: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
eval "ac_cv_type_$ac_lib_var=yes"
else
@@ -3177,7 +3594,7 @@
fi
echo $ac_n "checking for u_int16_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:3181: checking for u_int16_t in sys/types.h" >&5
+echo "configure:3598: checking for u_int16_t in sys/types.h" >&5
ac_lib_var=`echo u_int16_t'_'sys/types.h | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -3185,14 +3602,14 @@
eval "ac_cv_type_$ac_lib_var='not-found'"
ac_cv_check_typedef_header=`echo sys/types.h`
cat > conftest.$ac_ext <<EOF
-#line 3189 "configure"
+#line 3606 "configure"
#include "confdefs.h"
#include <$ac_cv_check_typedef_header>
int main() {
int x = sizeof(u_int16_t); x = x;
; return 0; }
EOF
-if { (eval echo configure:3196: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3613: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
eval "ac_cv_type_$ac_lib_var=yes"
else
@@ -3217,7 +3634,7 @@
fi
echo $ac_n "checking for u_int8_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:3221: checking for u_int8_t in sys/types.h" >&5
+echo "configure:3638: checking for u_int8_t in sys/types.h" >&5
ac_lib_var=`echo u_int8_t'_'sys/types.h | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -3225,14 +3642,14 @@
eval "ac_cv_type_$ac_lib_var='not-found'"
ac_cv_check_typedef_header=`echo sys/types.h`
cat > conftest.$ac_ext <<EOF
-#line 3229 "configure"
+#line 3646 "configure"
#include "confdefs.h"
#include <$ac_cv_check_typedef_header>
int main() {
int x = sizeof(u_int8_t); x = x;
; return 0; }
EOF
-if { (eval echo configure:3236: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3653: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
eval "ac_cv_type_$ac_lib_var=yes"
else
@@ -3257,7 +3674,7 @@
fi
echo $ac_n "checking for uint64_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:3261: checking for uint64_t in sys/types.h" >&5
+echo "configure:3678: checking for uint64_t in sys/types.h" >&5
ac_lib_var=`echo uint64_t'_'sys/types.h | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -3265,14 +3682,14 @@
eval "ac_cv_type_$ac_lib_var='not-found'"
ac_cv_check_typedef_header=`echo sys/types.h`
cat > conftest.$ac_ext <<EOF
-#line 3269 "configure"
+#line 3686 "configure"
#include "confdefs.h"
#include <$ac_cv_check_typedef_header>
int main() {
int x = sizeof(uint64_t); x = x;
; return 0; }
EOF
-if { (eval echo configure:3276: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3693: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
eval "ac_cv_type_$ac_lib_var=yes"
else
@@ -3297,7 +3714,7 @@
fi
echo $ac_n "checking for uint32_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:3301: checking for uint32_t in sys/types.h" >&5
+echo "configure:3718: checking for uint32_t in sys/types.h" >&5
ac_lib_var=`echo uint32_t'_'sys/types.h | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -3305,14 +3722,14 @@
eval "ac_cv_type_$ac_lib_var='not-found'"
ac_cv_check_typedef_header=`echo sys/types.h`
cat > conftest.$ac_ext <<EOF
-#line 3309 "configure"
+#line 3726 "configure"
#include "confdefs.h"
#include <$ac_cv_check_typedef_header>
int main() {
int x = sizeof(uint32_t); x = x;
; return 0; }
EOF
-if { (eval echo configure:3316: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3733: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
eval "ac_cv_type_$ac_lib_var=yes"
else
@@ -3337,7 +3754,7 @@
fi
echo $ac_n "checking for uint16_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:3341: checking for uint16_t in sys/types.h" >&5
+echo "configure:3758: checking for uint16_t in sys/types.h" >&5
ac_lib_var=`echo uint16_t'_'sys/types.h | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -3345,14 +3762,14 @@
eval "ac_cv_type_$ac_lib_var='not-found'"
ac_cv_check_typedef_header=`echo sys/types.h`
cat > conftest.$ac_ext <<EOF
-#line 3349 "configure"
+#line 3766 "configure"
#include "confdefs.h"
#include <$ac_cv_check_typedef_header>
int main() {
int x = sizeof(uint16_t); x = x;
; return 0; }
EOF
-if { (eval echo configure:3356: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3773: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
eval "ac_cv_type_$ac_lib_var=yes"
else
@@ -3377,7 +3794,7 @@
fi
echo $ac_n "checking for uint8_t in sys/types.h""... $ac_c" 1>&6
-echo "configure:3381: checking for uint8_t in sys/types.h" >&5
+echo "configure:3798: checking for uint8_t in sys/types.h" >&5
ac_lib_var=`echo uint8_t'_'sys/types.h | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -3385,14 +3802,14 @@
eval "ac_cv_type_$ac_lib_var='not-found'"
ac_cv_check_typedef_header=`echo sys/types.h`
cat > conftest.$ac_ext <<EOF
-#line 3389 "configure"
+#line 3806 "configure"
#include "confdefs.h"
#include <$ac_cv_check_typedef_header>
int main() {
int x = sizeof(uint8_t); x = x;
; return 0; }
EOF
-if { (eval echo configure:3396: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3813: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
eval "ac_cv_type_$ac_lib_var=yes"
else
@@ -3418,7 +3835,7 @@
echo $ac_n "checking whether to enable 64bit counters""... $ac_c" 1>&6
-echo "configure:3422: checking whether to enable 64bit counters" >&5
+echo "configure:3839: checking whether to enable 64bit counters" >&5
# Check whether --enable-64bit or --disable-64bit was given.
if test "${enable_64bit+set}" = set; then
enableval="$enable_64bit"
@@ -3439,7 +3856,7 @@
echo $ac_n "checking whether to enable multithreading in pmacctd""... $ac_c" 1>&6
-echo "configure:3443: checking whether to enable multithreading in pmacctd" >&5
+echo "configure:3860: checking whether to enable multithreading in pmacctd" >&5
# Check whether --enable-threads or --disable-threads was given.
if test "${enable_threads+set}" = set; then
enableval="$enable_threads"
@@ -3480,7 +3897,7 @@
echo $ac_n "checking whether to enable ULOG support""... $ac_c" 1>&6
-echo "configure:3484: checking whether to enable ULOG support" >&5
+echo "configure:3901: checking whether to enable ULOG support" >&5
# Check whether --enable-ulog or --disable-ulog was given.
if test "${enable_ulog+set}" = set; then
enableval="$enable_ulog"
@@ -3498,12 +3915,12 @@
echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:3502: checking return type of signal handlers" >&5
+echo "configure:3919: checking return type of signal handlers" >&5
if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3507 "configure"
+#line 3924 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <signal.h>
@@ -3520,7 +3937,7 @@
int i;
; return 0; }
EOF
-if { (eval echo configure:3524: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:3941: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_type_signal=void
else
@@ -3542,12 +3959,12 @@
for ac_func in strlcpy vsnprintf setproctitle
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3546: checking for $ac_func" >&5
+echo "configure:3963: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 3551 "configure"
+#line 3968 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -3570,7 +3987,7 @@
; return 0; }
EOF
-if { (eval echo configure:3574: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3991: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/configure.in
^
|
@@ -1,8 +1,8 @@
dnl Process this file with autoconf to produce a configure script.
dnl configuration file for pmacct
-AC_INIT([src/pmacctd.c], [0.14.1], [paolo@pmacct.net])
-AM_INIT_AUTOMAKE([pmacctd], [0.14.1])
+AC_INIT([src/pmacctd.c], [0.14.2], [paolo@pmacct.net])
+AM_INIT_AUTOMAKE([pmacctd], [0.14.2])
AC_PREFIX_DEFAULT([/usr/local])
dnl Checks for programs.
@@ -677,6 +677,105 @@
AC_MSG_RESULT(no))
dnl finish: pgsql handling
+dnl start: mongodb handling
+AC_MSG_CHECKING(whether to enable MongoDB support)
+AC_ARG_ENABLE(mongodb,
+ [ --enable-mongodb Enable MongoDB support],
+ [ case "$enableval" in
+ yes)
+ AC_MSG_RESULT(yes)
+dnl USING_SQL="yes"
+
+ AC_ARG_WITH(mongodb-libs,
+ [ --with-mongodb-libs=DIR Search for MongoDB libs in the specified directory],
+ [
+ AC_LINEARIZE_PATH($withval, withval=$absdir)
+ LIBS="${LIBS} -L$withval"
+ MONGODBLIB=$withval
+ MONGODBLIBFOUND=1
+ ])
+
+ if test x"$MONGODBLIB" != x""; then
+ AC_MSG_CHECKING(your own MongoDB library)
+ if test -r $MONGODBLIB/libmongoc.a -o -r $MONGODBLIB/libmongoc.so; then
+ AC_MSG_RESULT(ok)
+ else
+ AC_MSG_RESULT(no)
+ AC_MSG_ERROR(ERROR: missing MongoDB library in $MONGODBLIB)
+ fi
+ fi
+
+ if test x"$MONGODBLIBFOUND" = x""; then
+ AC_MSG_CHECKING([default locations for libmongoc])
+ if test -r /usr/lib/libmongoc.a -o -r /usr/lib/libmongoc.so; then
+ AC_MSG_RESULT([found in /usr/lib])
+ MONGODBLIBFOUND=1
+ elif test -r /usr/local/lib/libmongoc.a -o -r /usr/local/lib/libmongoc.so; then
+ LIBS="${LIBS} -L/usr/local/lib"
+ AC_MSG_RESULT([found in /usr/local/lib])
+ MONGODBLIBFOUND=1
+ else
+ AC_MSG_RESULT([not found])
+ fi
+ fi
+
+ if test x"$MONGODBLIBFOUND" = x""; then
+ AC_CHECK_LIB([mongoc], [mongo_connect], [], [AC_MSG_ERROR([
+ ERROR: missing MongoDB library. Refer to: http://api.mongodb.org/c/
+ ])])
+ else
+ LIBS="${LIBS} -lmongoc"
+ fi
+
+ AC_ARG_WITH(mongodb-includes,
+ [ --with-mongodb-includes=DIR Search for MongoDB includes in the specified directory],
+ [
+ AC_LINEARIZE_PATH($withval, withval=$absdir)
+ INCLUDES="${INCLUDES} -I$withval"
+ MONGODBINCLUDES=$withval
+ MONGODBINCLUDESFOUND=1
+ ])
+
+ if test x"$MONGODBINCLUDES" != x""; then
+ AC_MSG_CHECKING(your own MongoDB headers)
+ if test -r $MONGODBINCLUDES/mongo.h; then
+ AC_MSG_RESULT(ok)
+ else
+ AC_MSG_RESULT(no)
+ AC_MSG_ERROR(ERROR: missing MongoDB headers in $MONGODBINCLUDES)
+ fi
+ fi
+
+ if test x"$MONGODBINCLUDESFOUND" = x""; then
+ AC_MSG_CHECKING([default locations for mongo.h])
+ if test -r /usr/include/mongo.h; then
+ AC_MSG_RESULT([found in /usr/include])
+ MONGODBINCLUDESFOUND=1;
+ elif test -r /usr/local/include/mongo.h; then
+ INCLUDES="${INCLUDES} -I/usr/local/include"
+ AC_MSG_RESULT([found in /usr/local/include])
+ MONGODBINCLUDESFOUND=1;
+ fi
+ if test x"$MONGODBINCLUDESFOUND" = x""; then
+ AC_MSG_RESULT([not found])
+ fi
+ fi
+
+ if test x"$MONGODBINCLUDESFOUND" = x""; then
+ AC_CHECK_HEADER([mongo.h],,
+ [AC_MSG_ERROR(ERROR: missing MongoDB headers)])
+ fi
+
+ AC_DEFINE(WITH_MONGODB, 1)
+ PLUGINS="${PLUGINS} mongodb_plugin.c"
+ ;;
+ no)
+ AC_MSG_RESULT(no)
+ ;;
+ esac ],
+AC_MSG_RESULT(no))
+dnl finish: mongodb handling
+
AC_MSG_CHECKING(whether to enable SQLite3 support)
AC_ARG_ENABLE(sqlite3,
[ --enable-sqlite3 Enable SQLite3 support],
@@ -784,6 +883,103 @@
AC_MSG_RESULT(no))
dnl finish: sqlite3 handling
+dnl start: geoip handling
+AC_MSG_CHECKING(whether to enable GeoIP support)
+AC_ARG_ENABLE(geoip,
+ [ --enable-geoip Enable GeoIP support],
+ [ case "$enableval" in
+ yes)
+ AC_MSG_RESULT(yes)
+
+ AC_ARG_WITH(geoip-libs,
+ [ --with-geoip-libs=DIR Search for Maxmind GeoIP libs in the specified directory],
+ [
+ AC_LINEARIZE_PATH($withval, withval=$absdir)
+ LIBS="${LIBS} -L$withval"
+ MMGEOIPLIB=$withval
+ MMGEOIPLIBFOUND=1
+ ])
+
+ if test x"$MMGEOIPLIB" != x""; then
+ AC_MSG_CHECKING(your own Maxmind GeoIP library)
+ if test -r $MMGEOIPLIB/libGeoIP.a -o -r $MMGEOIPLIB/libGeoIP.so; then
+ AC_MSG_RESULT(ok)
+ else
+ AC_MSG_RESULT(no)
+ AC_MSG_ERROR(ERROR: missing Maxmind GeoIP library in $MMGEOIPLIB)
+ fi
+ fi
+
+ if test x"$MMGEOIPLIBFOUND" = x""; then
+ AC_MSG_CHECKING([default locations for libGeoIP])
+ if test -r /usr/lib/libGeoIP.a -o -r /usr/lib/libGeoIP.so; then
+ AC_MSG_RESULT([found in /usr/lib])
+ MMGEOIPLIBFOUND=1
+ elif test -r /usr/local/lib/libGeoIP.a -o -r /usr/local/lib/libGeoIP.so; then
+ LIBS="${LIBS} -L/usr/local/lib"
+ AC_MSG_RESULT([found in /usr/local/lib])
+ MMGEOIPLIBFOUND=1
+ else
+ AC_MSG_RESULT([not found])
+ fi
+ fi
+
+ if test x"$MMGEOIPLIBFOUND" = x""; then
+ AC_CHECK_LIB([GeoIP], [GeoIP_open], [], [AC_MSG_ERROR([
+ ERROR: missing Maxmind GeoIP library. Refer to: http://www.maxmind.com/download/geoip/api/c/
+ ])])
+ else
+ LIBS="${LIBS} -lGeoIP"
+ fi
+
+ AC_ARG_WITH(geoip-includes,
+ [ --with-geoip-includes=DIR Search for Maxmind GeoIP includes in the specified directory],
+ [
+ AC_LINEARIZE_PATH($withval, withval=$absdir)
+ INCLUDES="${INCLUDES} -I$withval"
+ MMGEOIPINCLUDES=$withval
+ MMGEOIPINCLUDESFOUND=1
+ ])
+
+ if test x"$MMGEOIPINCLUDES" != x""; then
+ AC_MSG_CHECKING(your own Maxmind GeoIP headers)
+ if test -r $MMGEOIPINCLUDES/GeoIP.h; then
+ AC_MSG_RESULT(ok)
+ else
+ AC_MSG_RESULT(no)
+ AC_MSG_ERROR(ERROR: missing Maximind GeoIP headers in $MMGEOIPINCLUDES)
+ fi
+ fi
+
+ if test x"$MMGEOIPINCLUDESFOUND" = x""; then
+ AC_MSG_CHECKING([default locations for GeoIP.h])
+ if test -r /usr/include/GeoIP.h; then
+ AC_MSG_RESULT([found in /usr/include])
+ MMGEOIPINCLUDESFOUND=1;
+ elif test -r /usr/local/include/GeoIP.h; then
+ INCLUDES="${INCLUDES} -I/usr/local/include"
+ AC_MSG_RESULT([found in /usr/local/include])
+ MMGEOIPINCLUDESFOUND=1;
+ fi
+ if test x"$MMGEOIPINCLUDESFOUND" = x""; then
+ AC_MSG_RESULT([not found])
+ fi
+ fi
+
+ if test x"$MMGEOIPINCLUDESFOUND" = x""; then
+ AC_CHECK_HEADER([GeoIP.h],,
+ [AC_MSG_ERROR(ERROR: missing Maxmind GeoIP headers)])
+ fi
+
+ AC_DEFINE(WITH_GEOIP, 1)
+ ;;
+ no)
+ AC_MSG_RESULT(no)
+ ;;
+ esac ],
+AC_MSG_RESULT(no))
+dnl finish: GeoIP handling
+
AC_MSG_CHECKING([whether to disable shared objects])
AC_ARG_ENABLE(so,
[ --disable-so Disable shared objects],
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/docs/SIGNALS
^
|
@@ -1,81 +1,32 @@
SIGNALS:
-Here follows a list of supported signals and their meaning; remember
-that pmacct core says goodbye when its last child dies or is terminated.
+Here follows a list of supported signals and their meaning; note: pmacct core
+process says goodbye when its last child dies or is terminated.
-pmacctd/nfacctd/sfacctd Core process:
+Core process:
SIGCHLD: used to handle gracefully his loved child processes;
-SIGHUP: reopens the logging infrastructure. Works with both syslog and logfiles
-SIGUSR1: returns various statistics via either console or syslog; the syslog level reserved
- for such purpose is NOTICE; the facility is selected through configuration (ie key
- 'syslog'). It works for all pmacctd/nfacctd/sfacctd;
-SIGUSR2: if 'refresh_maps' configuration directive is enabled it causes Core Process-based
- maps to be reloaded (ie. Pre-Tagging, BGP source peer ASN, NetFlow/sFlow agent to
- BGP peer, BGP MD5, etc.);
-SIGINT: ignored if the daemon is started in background; otherwise the signal is propagated
- to each running plugin (which is in turn gracefully terminated);
-SIGTERM: not handled (which means it follows the default behaviour for the OS) if the daemon
- is started in background; else it works like SIGINT;
+SIGHUP: reopens the logging infrastructure. Works with both syslog
+ and logfiles;
+SIGUSR1: returns various statistics via either console or syslog; the
+ syslog level used is NOTICE; the facility is selected through
+ configuration (ie. key 'syslog'). The feature works for all
+ daemons;
+SIGUSR2: if 'refresh_maps' config directive is enabled, it causes Core
+ Process-based maps to be reloaded (ie. Pre-Tagging, BGP source
+ peer ASN, NetFlow/sFlow agent to BGP peer, BGP MD5, etc.).
+SIGINT: ignored if the daemon is started in background; otherwise the
+ signal is propagated to each running plugin (which is in turn
+ gracefully terminated);
+SIGTERM: not handled (which means it follows the default behaviour for
+ the OS) if the daemon is started in background; otherwise it
+ orks like SIGINT;
SIGPIPE: ignored;
-MySQL plugin process:
+Plugin (SQL, noSQL, memory, print, tee, probes, etc.) processes:
SIGPIPE: ignored;
SIGCHLD: ignored;
SIGHUP: inherited by Core Process;
SIGUSR1: ignored;
-SIGUSR2: if 'refresh_maps' configuration directive is enabled it causes the Ports and Networks
- maps to be reloaded;
+SIGUSR2: if 'refresh_maps' configuration directive is enabled it causes
+ Ports and Networks maps to be reloaded;
SIGINT: causes the process to exit gracefully;
-
-PGSQL plugin process:
-SIGPIPE: ignored;
-SIGCHLD: ignored;
-SIGHUP: inherited by Core Process;
-SIGUSR1: ignored;
-SIGUSR2: if 'refresh_maps' configuration directive is enabled it causes the Ports and Networks
- maps to be reloaded;
-SIGINT: causes the process to exit gracefully;
-
-In-memory table process:
-SIGPIPE: ignored;
-SIGCHLD: ignored;
-SIGHUP: inherited by Core Process;
-SIGUSR1: ignored;
-SIGUSR2: if 'refresh_maps' configuration directive is enabled it causes the Ports and Networks
- maps to be reloaded;
-SIGINT: causes the process to exit gracefully;
-
-Print process:
-SIGPIPE: ignored;
-SIGCHLD: ignored;
-SIGHUP: inherited by Core Process;
-SIGUSR1: ignored;
-SIGUSR2: if 'refresh_maps' configuration directive is enabled it causes the Ports and Networks
- maps to be reloaded;
-SIGINT: causes the process to exit gracefully;
-
-NetFlow probe process:
-SIGPIPE: ignored;
-SIGCHLD: ignored;
-SIGHUP: inherited by Core Process;
-SIGUSR1: ignored;
-SIGUSR2: if 'refresh_maps' configuration directive is enabled it causes the Ports and Networks
- maps to be reloaded;
-SIGINT: causes the process to exit gracefully;
-
-sFlow probe process:
-SIGPIPE: ignored;
-SIGCHLD: ignored;
-SIGHUP: inherited by Core Process;
-SIGUSR1: ignored;
-SIGUSR2: if 'refresh_maps' configuration directive is enabled it causes the Ports and Networks
- maps to be reloaded;
-SIGINT: causes the process to exit gracefully;
-
-Tee process:
-SIGPIPE: ignored;
-SIGCHLD: ignored;
-SIGHUP: inherited by Core Process;
-SIGUSR1: ignored;
-SIGUSR2: ignored;
-SIGINT: causes the process to exit gracefully;
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/docs/TRIGGER_VARS
^
|
@@ -1,73 +1,65 @@
INTRODUCTION
-Recently (0.7) an executable triggering mechanism has been added to
-both SQL plugins (sql_trigger_exec). Such executables may either be
-spawned each time a cache purging event occurs or at arbitrary time
-intervals (specified via sql_trigger_time).
-Because the triggering mechanism is hooked on top of 'lazy deadlines'
-it should absolutely not be preferred to run tasks strictly connected
-to timing issues (use crontab instead). The concept of lazy deadlines
-has been introduced a while ago to avoid the wide use of signals for
-time handling with the purpose of keep it light while preserving its
-correctness.
-Version 0.7.8 sees the introduction of a few status informations passed
-to the trigger in the form of environment variables. The list of supported
-variables follows:
+An executable triggering mechanism feature is part of all SQL plugins
+(sql_trigger_exec). Executables may either be spawned each time a cache
+purging event occurs or at arbitrary time intervals (that are specified
+via sql_trigger_time). Because the triggering mechanism is hooked on top
+of the 'lazy deadlines' plugin concept, it should not be preferred method
+to run tasks strictly connected to timing issues (use crontab instead).
+As a recap, the concept of lazy deadlines was introduced a while ago to
+avoid large use of UNIX signals for precise time handling. Information
+is being passed to the triggered executable in the form of environment
+variables. The list of supported variables follows:
VAR: $SQL_DB
-DESC: The DB name currently in use by the plugin.
+DESC: RDBMS database name.
VAR: $SQL_TABLE
-DESC: The SQL table name currently in use by the plugin.
+DESC: SQL table name.
VAR: $EFFECTIVE_SQL_TABLE
-DESC: The SQL table name currently in use by the plugin. It is
- defined only whether the 'sql_table' value contains any
- variable. Variable values are substitute here by their
- actual values.
+DESC: SQL table name. This is defined only if the 'sql_table' value
+ contains variables. Variables are replaced here by their actual
+ values.
VAR: $SQL_HOST
-DESC: Hostname (if any) to which the plugin is connecting to
- contact the SQL server.
+DESC: SQL server hostname (if any)
VAR: $SQL_USER
-DESC: Username currently in use while authenticating to the
- SQL server.
+DESC: Username when authenticating to the SQL server.
VAR: $SQL_REFRESH_TIME
-DESC: The time interval at which data is currently purged from
- the cache into the DB.
+DESC: Time interval at which data is currently purged from the cache
+ to the database.
VAR: $SAMPLING_RATE
-DESC: The ratio of packet to be sampled (1 out of N). It is
- defined only if packet sampling is actually enabled via
- 'sampling_rate' (see CONFIG-KEYS for further details
- about the key).
+DESC: Packet sampling ratio (1 out of N). It is defined only if packet
+ sampling is actually enabled via a 'sampling_rate' configuration
+ directive (see CONFIG-KEYS for further details about the key).
VAR: $SQL_RECOVERY_LOGFILE
-DESC: Full pathname to the logfile used when recovery mode is
- enabled. It is defined only if 'sql_recovery_logfile' (see
- CONFIG-KEYS for further details about the key) is actually
- defined.
+DESC: Full pathname to the logfile used when recovery mode is enabled.
+ This is defined only if a 'sql_recovery_logfile' configuration
+ directive is defined (see CONFIG-KEYS for further details about
+ the key). Note: sql_recovery_logfile is being deprecated.
VAR: $SQL_RECOVERY_BACKUP_HOST
-DESC: Hostname which is contacted as a backup SQL server. It is
- defined only if 'sql_recovery_backup_host' (see CONFIG-KEYS
- for further details about the key) is actually defined.
+DESC: SQL server hostname contacted if the primary server fails. This
+ is defined only if 'sql_recovery_backup_host' is activated (see
+ CONFIG-KEYS for further details about the key).
VAR: $TOTAL_ELEM_NUMBER
-DESC: Returns the total number of elements on the queue during the
- last cache-to-DB purging event. Elements may be subsequently
- filtered out and, then, are encapsulated in SQL queries. It
- is defined only if 'sql_trigger_time' is NOT defined (this
- causes the trigger to be launched each time the purging event
- occurs).
+DESC: Returns the total number of queued elements during the last
+ purging event. Elements may be subsequently filtered out. It
+ is defined only if 'sql_trigger_time' directive is NOT defined
+ (this causes the trigger to be launched each time the purging
+ event occurs).
VAR: $EFFECTIVE_ELEM_NUMBER
DESC: Returns the effective number of elements (that is, excluding
those filtered out) on the queue being encapsulated in SQL
- queries during the last cache-to-DB purging event. It is
- defined only if 'sql_trigger_time' is NOT defined (this causes
- the trigger to be launched each time the purging event occurs).
+ queries during the last purging event. It is defined only if
+ 'sql_trigger_time' is NOT defined (this causes the trigger to
+ be launched each time the purging event occurs).
VAR: $INSERT_QUERIES_NUMBER
DESC: Returns the number of elements being successfully incapsulated
@@ -84,34 +76,34 @@
occurs).
VAR: $ELAPSED_TIME
-DESC: Returns the number of seconds the last cache-to-DB purging
- event took to complete. It is defined only if 'sql_trigger_time'
- is NOT defined (this causes the trigger to be launched each
- time the purging event occurs).
+DESC: Returns the number of seconds the last purging event took to
+ complete. It is defined only if 'sql_trigger_time' directive is
+ NOT defined (this causes the trigger to be launched each time
+ the purging event occurs).
VAR: $SQL_HISTORY_BASETIME
DESC: Returns the basetime of the current timeslot, if 'sql_history'
- (see CONFIG-KEYS for further details about the key) is defined.
+ is defined (see CONFIG-KEYS for further details about the key).
It is the same value being inserted into 'stamp_inserted' field
- and is expressed as unixtime (seconds since Epoch). It is defined
- only if 'sql_trigger_time' is NOT defined (this causes the trigger
- to be launched each time the purging event occurs).
+ and is expressed as unixtime (seconds since Epoch). This is
+ defined only if 'sql_trigger_time' is NOT defined (this causes
+ the trigger to be launched each time the purging event occurs).
VAR: $SQL_HISTORY_TIMESLOT
-DESC: Returns the current timeslot width (in seconds), if 'sql_history'
- (see CONFIG-KEYS for further details about the key) is defined.
- Note that this value may change (it's recomputed) if monthly
- timeslot are in use. It is defined only if 'sql_trigger_time'
- is NOT defined (this causes the trigger to be launched each time
- the purging event occurs).
+DESC: Returns the timeslot size (in seconds), if 'sql_history' (see
+ CONFIG-KEYS for further details about the key) is defined. Note
+ that this value may change (it's recomputed) if monthly timeslot
+ are in use. This is defined only if 'sql_trigger_time' is NOT
+ defined (this causes the trigger to be launched each time the
+ purging event occurs).
VAR: $SQL_MAX_WRITERS
-DESC: Returns the maximum number of concurrent writer processes allowed
- (see CONFIG-KEYS for further details about 'sql_max_writers').
+DESC: Returns the maximum number of concurrent SQL writer processes
+ allowed (see CONFIG-KEYS for details about 'sql_max_writers').
VAR: $SQL_ACTIVE_WRITERS
-DESC: Returns the active number of concurrent writer processes in place
- (see CONFIG-KEYS for further details about 'sql_max_writers'). If
- used in conjunction with $SQL_MAX_WRITERS, it can prevent hitting
- the upper limit of writers by taking corrective actions or firing
- proper notifications.
+DESC: Returns the active number of concurrent writer processes in
+ place (see CONFIG-KEYS for details about 'sql_max_writers'). If
+ used in conjunction with $SQL_MAX_WRITERS, this can prevent
+ hitting the upper limit of writers by, say, taking corrective
+ actions or sending proper warning notifications.
|
[-]
[+]
|
Added |
pmacct-0.14.2.tar.bz2/sql/README.country
^
|
@@ -0,0 +1,18 @@
+This document doesn't replace documentation relevant to the database software you are
+using, ie. README.mysql, README.pgsql or README.sqlite3.
+
+The 'country_ip_src' and 'country_ip_dst' fields.
+Such fields are being introduced to natively support source/destination IP Geo lookup
+against a defined database or map. The guidelines below (typically in MySQL format)
+are to add such primitives to the SQL schema:
+
+* country_ip_src field:
+ - "country_ip_src CHAR(2) NOT NULL," to declare the field itself
+ - "PRIMARY KEY (..., country_ip_src, ...)" to put it in the primary key
+
+* country_ip_dst field:
+ - "country_ip_dst CHAR(2) NOT NULL," to declare the field itself
+ - "PRIMARY KEY (..., country_ip_dst, ...)" to put it in the primary key
+
+The primitives are not declared as part of any default table version; yet will not
+fail version checks which are enabled when 'sql_optimize_clauses' feature is disabled.
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/sql/README.mysql
^
|
@@ -83,6 +83,9 @@
* dst_mask => mask_dst (INT(1) UNSIGNED NOT NULL, see README.mask)
* cos => cos (INT(1) UNSIGNED NOT NULL, see README.cos)
* etype => etype (INT(2) UNSIGNED NOT NULL, see README.etype)
+ * src_host_country => country_ip_src (CHAR(2) NOT NULL, see README.country)
+ * dst_host_country => country_ip_dst (CHAR(2) NOT NULL, see README.country)
+ * sampling_rate => sampling_rate (INT(4) UNSIGNED NOT NULL, see README.sampling_rate)
* class => class_id (CHAR(16) NOT NULL)
* src_mac => mac_src (CHAR(17) NOT NULL)
* dst_mac => mac_dst (CHAR(17) NOT NULL)
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/sql/README.pgsql
^
|
@@ -91,6 +91,9 @@
* dst_mask => mask_dst (SMALLINT NOT NULL DEFAULT 0, see README.mask)
* cos => cos (SMALLINT NOT NULL DEFAULT 0, see README.cos)
* etype => etype (INT NOT NULL DEFAULT 0, see README.etype)
+ * src_host_country => country_ip_src (CHAR (2) NOT NULL DEFAULT '--', see README.country)
+ * dst_host_country => country_ip_dst (CHAR (2) NOT NULL DEFAULT '--', see README.country)
+ * sampling_rate => sampling_rate (BIGINT NOT NULL DEFAULT 0, see README.sampling_rate)
* class => class_id (CHAR(16) NOT NOT NULL DEFAULT ' ')
* src_mac => mac_src (macaddr NOT NULL DEFAULT '0:0:0:0:0:0')
* dst_mac => mac_dst (macaddr NOT NULL DEFAULT '0:0:0:0:0:0')
|
[-]
[+]
|
Added |
pmacct-0.14.2.tar.bz2/sql/README.sampling_rate
^
|
@@ -0,0 +1,14 @@
+This document doesn't replace documentation relevant to the database software you are
+using, ie. README.mysql, README.pgsql or README.sqlite3.
+
+The 'sampling_rate' field.
+Such field is being introduced to inform about the sampling rate that has either been
+applied (if renormalization was enabled) or should be applied to counters. Guidelines
+below (typically in MySQL format) are to add such primitives to the SQL schema:
+
+* iface_in field:
+ - "sampling_rate INT(4) UNSIGNED NOT NULL," to declare the field itself
+ - "PRIMARY KEY (..., sampling_rate, ...)" to put it in the primary key
+
+The primitive is not declared as part of any default table version; yet will not fail
+version checks which are enabled when 'sql_optimize_clauses' feature is disabled.
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/sql/README.sqlite3
^
|
@@ -84,6 +84,9 @@
* dst_mask => mask_dst (INT(2) NOT NULL DEFAULT 0, see README.mask)
* cos => cos (INT(2) NOT NULL DEFAULT 0, see README.cos)
* etype => etype (INT(2) NOT NULL DEFAULT 0, see README.etype)
+ * src_host_country => country_ip_src (CHAR(2) NOT NULL DEFAULT '--', see README.country)
+ * dst_host_country => country_ip_dst (CHAR(2) NOT NULL DEFAULT '--', see README.country)
+ * sampling_rate => sampling_rate (INT(8) NOT NULL DEFAULT 0, see README.sampling_rate)
* class => class_id (CHAR(16) NOT NOT NULL DEFAULT ' ')
* src_mac => mac_src (CHAR(17) NOT NULL DEFAULT '0:0:0:0:0:0')
* dst_mac => mac_dst (CHAR(17) NOT NULL DEFAULT '0:0:0:0:0:0')
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/bgp/bgp.c
^
|
@@ -133,8 +133,8 @@
if (rc < 0) Log(LOG_ERR, "WARN ( default/core/BGP ): setsockopt() failed for IP_TOS (errno: %d).\n", errno);
}
- rc = Setsocksize(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&yes, sizeof(yes));
- if (rc < 0) Log(LOG_ERR, "WARN ( default/core/BGP ): Setsocksize() failed for SO_REUSEADDR (errno: %d).\n", errno);
+ rc = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&yes, sizeof(yes));
+ if (rc < 0) Log(LOG_ERR, "WARN ( default/core/BGP ): setsockopt() failed for SO_REUSEADDR (errno: %d).\n", errno);
rc = bind(sock, (struct sockaddr *) &server, slen);
if (rc < 0) {
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/cfg.h
^
|
@@ -32,8 +32,10 @@
};
struct configuration {
- u_int64_t what_to_count;
+ u_int64_t what_to_count; /* first registry */
+ u_int64_t what_to_count_2; /* second registry */
u_int64_t nfprobe_what_to_count;
+ u_int64_t nfprobe_what_to_count_2;
char *name;
char *type;
int sock;
@@ -88,7 +90,6 @@
char *sql_locking_style;
int sql_use_copy;
char *sql_delimiter;
- int print_refresh_time;
int print_cache_entries;
int print_markers;
int print_output;
@@ -136,6 +137,14 @@
char *nfacctd_isis_iface;
int nfacctd_isis_mtu;
int nfacctd_isis_msglog;
+ char *geoip_ipv4_file;
+ char *geoip_ipv6_file;
+#if defined WITH_GEOIP
+ GeoIP *geoip_ipv4;
+#if defined ENABLE_IPV6
+ GeoIP *geoip_ipv6;
+#endif
+#endif
int promisc; /* pcap_open_live() promisc parameter */
char *clbuf; /* pcap filter */
char *pcap_savefile;
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/cfg_handlers.c
^
|
@@ -122,68 +122,76 @@
{
struct plugins_list_entry *list = plugins_list;
char *count_token;
- u_int64_t value = 0;
+ u_int64_t value[3];
u_int32_t changes = 0;
trim_all_spaces(value_ptr);
+ memset(&value, 0, sizeof(value));
while (count_token = extract_token(&value_ptr, ',')) {
- if (!strcmp(count_token, "src_host")) value |= COUNT_SRC_HOST;
- else if (!strcmp(count_token, "dst_host")) value |= COUNT_DST_HOST;
- else if (!strcmp(count_token, "src_net")) value |= COUNT_SRC_NET;
- else if (!strcmp(count_token, "dst_net")) value |= COUNT_DST_NET;
- else if (!strcmp(count_token, "sum")) value |= COUNT_SUM_HOST;
- else if (!strcmp(count_token, "src_port")) value |= COUNT_SRC_PORT;
- else if (!strcmp(count_token, "dst_port")) value |= COUNT_DST_PORT;
- else if (!strcmp(count_token, "proto")) value |= COUNT_IP_PROTO;
+ if (!strcmp(count_token, "src_host")) cfg_set_aggregate(filename, value, COUNT_INT_SRC_HOST, count_token);
+ else if (!strcmp(count_token, "dst_host")) cfg_set_aggregate(filename, value, COUNT_INT_DST_HOST, count_token);
+ else if (!strcmp(count_token, "src_net")) cfg_set_aggregate(filename, value, COUNT_INT_SRC_NET, count_token);
+ else if (!strcmp(count_token, "dst_net")) cfg_set_aggregate(filename, value, COUNT_INT_DST_NET, count_token);
+ else if (!strcmp(count_token, "sum")) cfg_set_aggregate(filename, value, COUNT_INT_SUM_HOST, count_token);
+ else if (!strcmp(count_token, "src_port")) cfg_set_aggregate(filename, value, COUNT_INT_SRC_PORT, count_token);
+ else if (!strcmp(count_token, "dst_port")) cfg_set_aggregate(filename, value, COUNT_INT_DST_PORT, count_token);
+ else if (!strcmp(count_token, "proto")) cfg_set_aggregate(filename, value, COUNT_INT_IP_PROTO, count_token);
#if defined (HAVE_L2)
- else if (!strcmp(count_token, "src_mac")) value |= COUNT_SRC_MAC;
- else if (!strcmp(count_token, "dst_mac")) value |= COUNT_DST_MAC;
- else if (!strcmp(count_token, "vlan")) value |= COUNT_VLAN;
- else if (!strcmp(count_token, "sum_mac")) value |= COUNT_SUM_MAC;
+ else if (!strcmp(count_token, "src_mac")) cfg_set_aggregate(filename, value, COUNT_INT_SRC_MAC, count_token);
+ else if (!strcmp(count_token, "dst_mac")) cfg_set_aggregate(filename, value, COUNT_INT_DST_MAC, count_token);
+ else if (!strcmp(count_token, "vlan")) cfg_set_aggregate(filename, value, COUNT_INT_VLAN, count_token);
+ else if (!strcmp(count_token, "sum_mac")) cfg_set_aggregate(filename, value, COUNT_INT_SUM_MAC, count_token);
#endif
- else if (!strcmp(count_token, "tos")) value |= COUNT_IP_TOS;
- else if (!strcmp(count_token, "none")) value |= COUNT_NONE;
- else if (!strcmp(count_token, "src_as")) value |= COUNT_SRC_AS;
- else if (!strcmp(count_token, "dst_as")) value |= COUNT_DST_AS;
- else if (!strcmp(count_token, "sum_host")) value |= COUNT_SUM_HOST;
- else if (!strcmp(count_token, "sum_net")) value |= COUNT_SUM_NET;
- else if (!strcmp(count_token, "sum_as")) value |= COUNT_SUM_AS;
- else if (!strcmp(count_token, "sum_port")) value |= COUNT_SUM_PORT;
- else if (!strcmp(count_token, "tag")) value |= COUNT_ID;
- else if (!strcmp(count_token, "tag2")) value |= COUNT_ID2;
- else if (!strcmp(count_token, "flows")) value |= COUNT_FLOWS;
- else if (!strcmp(count_token, "class")) value |= COUNT_CLASS;
- else if (!strcmp(count_token, "tcpflags")) value |= COUNT_TCPFLAGS;
- else if (!strcmp(count_token, "std_comm")) value |= COUNT_STD_COMM;
- else if (!strcmp(count_token, "ext_comm")) value |= COUNT_EXT_COMM;
- else if (!strcmp(count_token, "as_path")) value |= COUNT_AS_PATH;
- else if (!strcmp(count_token, "local_pref")) value |= COUNT_LOCAL_PREF;
- else if (!strcmp(count_token, "med")) value |= COUNT_MED;
- else if (!strcmp(count_token, "peer_src_as")) value |= COUNT_PEER_SRC_AS;
- else if (!strcmp(count_token, "peer_dst_as")) value |= COUNT_PEER_DST_AS;
- else if (!strcmp(count_token, "peer_src_ip")) value |= COUNT_PEER_SRC_IP;
- else if (!strcmp(count_token, "peer_dst_ip")) value |= COUNT_PEER_DST_IP;
- else if (!strcmp(count_token, "src_as_path")) value |= COUNT_SRC_AS_PATH;
- else if (!strcmp(count_token, "src_std_comm")) value |= COUNT_SRC_STD_COMM;
- else if (!strcmp(count_token, "src_ext_comm")) value |= COUNT_SRC_EXT_COMM;
- else if (!strcmp(count_token, "src_local_pref")) value |= COUNT_SRC_LOCAL_PREF;
- else if (!strcmp(count_token, "src_med")) value |= COUNT_SRC_MED;
- else if (!strcmp(count_token, "in_iface")) value |= COUNT_IN_IFACE;
- else if (!strcmp(count_token, "out_iface")) value |= COUNT_OUT_IFACE;
- else if (!strcmp(count_token, "src_mask")) value |= COUNT_SRC_NMASK;
- else if (!strcmp(count_token, "dst_mask")) value |= COUNT_DST_NMASK;
- else if (!strcmp(count_token, "cos")) value |= COUNT_COS;
- else if (!strcmp(count_token, "etype")) value |= COUNT_ETHERTYPE;
- else if (!strcmp(count_token, "mpls_vpn_rd")) value |= COUNT_MPLS_VPN_RD;
+ else if (!strcmp(count_token, "tos")) cfg_set_aggregate(filename, value, COUNT_INT_IP_TOS, count_token);
+ else if (!strcmp(count_token, "none")) cfg_set_aggregate(filename, value, COUNT_INT_NONE, count_token);
+ else if (!strcmp(count_token, "src_as")) cfg_set_aggregate(filename, value, COUNT_INT_SRC_AS, count_token);
+ else if (!strcmp(count_token, "dst_as")) cfg_set_aggregate(filename, value, COUNT_INT_DST_AS, count_token);
+ else if (!strcmp(count_token, "sum_host")) cfg_set_aggregate(filename, value, COUNT_INT_SUM_HOST, count_token);
+ else if (!strcmp(count_token, "sum_net")) cfg_set_aggregate(filename, value, COUNT_INT_SUM_NET, count_token);
+ else if (!strcmp(count_token, "sum_as")) cfg_set_aggregate(filename, value, COUNT_INT_SUM_AS, count_token);
+ else if (!strcmp(count_token, "sum_port")) cfg_set_aggregate(filename, value, COUNT_INT_SUM_PORT, count_token);
+ else if (!strcmp(count_token, "tag")) cfg_set_aggregate(filename, value, COUNT_INT_ID, count_token);
+ else if (!strcmp(count_token, "tag2")) cfg_set_aggregate(filename, value, COUNT_INT_ID2, count_token);
+ else if (!strcmp(count_token, "flows")) cfg_set_aggregate(filename, value, COUNT_INT_FLOWS, count_token);
+ else if (!strcmp(count_token, "class")) cfg_set_aggregate(filename, value, COUNT_INT_CLASS, count_token);
+ else if (!strcmp(count_token, "tcpflags")) cfg_set_aggregate(filename, value, COUNT_INT_TCPFLAGS, count_token);
+ else if (!strcmp(count_token, "std_comm")) cfg_set_aggregate(filename, value, COUNT_INT_STD_COMM, count_token);
+ else if (!strcmp(count_token, "ext_comm")) cfg_set_aggregate(filename, value, COUNT_INT_EXT_COMM, count_token);
+ else if (!strcmp(count_token, "as_path")) cfg_set_aggregate(filename, value, COUNT_INT_AS_PATH, count_token);
+ else if (!strcmp(count_token, "local_pref")) cfg_set_aggregate(filename, value, COUNT_INT_LOCAL_PREF, count_token);
+ else if (!strcmp(count_token, "med")) cfg_set_aggregate(filename, value, COUNT_INT_MED, count_token);
+ else if (!strcmp(count_token, "peer_src_as")) cfg_set_aggregate(filename, value, COUNT_INT_PEER_SRC_AS, count_token);
+ else if (!strcmp(count_token, "peer_dst_as")) cfg_set_aggregate(filename, value, COUNT_INT_PEER_DST_AS, count_token);
+ else if (!strcmp(count_token, "peer_src_ip")) cfg_set_aggregate(filename, value, COUNT_INT_PEER_SRC_IP, count_token);
+ else if (!strcmp(count_token, "peer_dst_ip")) cfg_set_aggregate(filename, value, COUNT_INT_PEER_DST_IP, count_token);
+ else if (!strcmp(count_token, "src_as_path")) cfg_set_aggregate(filename, value, COUNT_INT_SRC_AS_PATH, count_token);
+ else if (!strcmp(count_token, "src_std_comm")) cfg_set_aggregate(filename, value, COUNT_INT_SRC_STD_COMM, count_token);
+ else if (!strcmp(count_token, "src_ext_comm")) cfg_set_aggregate(filename, value, COUNT_INT_SRC_EXT_COMM, count_token);
+ else if (!strcmp(count_token, "src_local_pref")) cfg_set_aggregate(filename, value, COUNT_INT_SRC_LOCAL_PREF, count_token);
+ else if (!strcmp(count_token, "src_med")) cfg_set_aggregate(filename, value, COUNT_INT_SRC_MED, count_token);
+ else if (!strcmp(count_token, "in_iface")) cfg_set_aggregate(filename, value, COUNT_INT_IN_IFACE, count_token);
+ else if (!strcmp(count_token, "out_iface")) cfg_set_aggregate(filename, value, COUNT_INT_OUT_IFACE, count_token);
+ else if (!strcmp(count_token, "src_mask")) cfg_set_aggregate(filename, value, COUNT_INT_SRC_NMASK, count_token);
+ else if (!strcmp(count_token, "dst_mask")) cfg_set_aggregate(filename, value, COUNT_INT_DST_NMASK, count_token);
+ else if (!strcmp(count_token, "cos")) cfg_set_aggregate(filename, value, COUNT_INT_COS, count_token);
+ else if (!strcmp(count_token, "etype")) cfg_set_aggregate(filename, value, COUNT_INT_ETHERTYPE, count_token);
+ else if (!strcmp(count_token, "mpls_vpn_rd")) cfg_set_aggregate(filename, value, COUNT_INT_MPLS_VPN_RD, count_token);
+ else if (!strcmp(count_token, "sampling_rate")) cfg_set_aggregate(filename, value, COUNT_INT_SAMPLING_RATE, count_token);
+ else if (!strcmp(count_token, "src_host_country")) cfg_set_aggregate(filename, value, COUNT_INT_SRC_HOST_COUNTRY, count_token);
+ else if (!strcmp(count_token, "dst_host_country")) cfg_set_aggregate(filename, value, COUNT_INT_DST_HOST_COUNTRY, count_token);
else Log(LOG_WARNING, "WARN ( %s ): ignoring unknown aggregation method: %s.\n", filename, count_token);
}
- if (!name) for (; list; list = list->next, changes++) list->cfg.what_to_count = value;
+ if (!name) for (; list; list = list->next, changes++) {
+ list->cfg.what_to_count = value[1];
+ list->cfg.what_to_count_2 = value[2];
+ }
else {
for (; list; list = list->next) {
if (!strcmp(name, list->name)) {
- list->cfg.what_to_count = value;
+ list->cfg.what_to_count = value[1];
+ list->cfg.what_to_count_2 = value[2];
changes++;
break;
}
@@ -654,7 +662,7 @@
}
if (strlen(value_ptr) > 64) {
- Log(LOG_ERR, "ERROR ( %s ): sql_table, exceeded the maximum SQL table name length (64).\n", filename);
+ Log(LOG_ERR, "ERROR ( %s ): sql_table, exceeded the maximum SQL table name length (255).\n", filename);
exit(1);
}
@@ -672,6 +680,71 @@
return changes;
}
+int cfg_key_print_output_file(char *filename, char *name, char *value_ptr)
+{
+ struct plugins_list_entry *list = plugins_list;
+ int changes = 0;
+
+ /* validations: we allow only a) certain variable names, b) a maximum of 8 variables */
+ {
+ int num = 0;
+ char *c, *ptr = value_ptr;
+
+ while (c = strchr(ptr, '%')) {
+ c++;
+ ptr = c;
+ switch (*c) {
+ case 'd':
+ num++;
+ break;
+ case 'H':
+ num++;
+ break;
+ case 'm':
+ num++;
+ break;
+ case 'M':
+ num++;
+ break;
+ case 'w':
+ num++;
+ break;
+ case 'W':
+ num++;
+ break;
+ case 'Y':
+ num++;
+ break;
+ case 's':
+ num++;
+ break;
+ default:
+ Log(LOG_ERR, "ERROR ( %s ): sql_table, %%%c not supported.\n", filename, *c);
+ exit(1);
+ break;
+ }
+ }
+
+ if (num > 8) {
+ Log(LOG_ERR, "ERROR ( %s ): sql_table, exceeded the maximum allowed variables (8) into the table name.\n", filename);
+ exit(1);
+ }
+ }
+
+ if (!name) for (; list; list = list->next, changes++) list->cfg.sql_table = value_ptr;
+ else {
+ for (; list; list = list->next) {
+ if (!strcmp(name, list->name)) {
+ list->cfg.sql_table = value_ptr;
+ changes++;
+ break;
+ }
+ }
+ }
+
+ return changes;
+}
+
int cfg_key_sql_table_schema(char *filename, char *name, char *value_ptr)
{
struct plugins_list_entry *list = plugins_list;
@@ -1464,31 +1537,6 @@
return changes;
}
-int cfg_key_print_refresh_time(char *filename, char *name, char *value_ptr)
-{
- struct plugins_list_entry *list = plugins_list;
- int value, changes = 0;
-
- value = atoi(value_ptr);
- if (value <= 0) {
- Log(LOG_ERR, "WARN ( %s ): 'print_refresh_time' has to be > 0.\n", filename);
- return ERR;
- }
-
- if (!name) for (; list; list = list->next, changes++) list->cfg.print_refresh_time = value;
- else {
- for (; list; list = list->next) {
- if (!strcmp(name, list->name)) {
- list->cfg.print_refresh_time = value;
- changes++;
- break;
- }
- }
- }
-
- return changes;
-}
-
int cfg_key_print_cache_entries(char *filename, char *name, char *value_ptr)
{
struct plugins_list_entry *list = plugins_list;
@@ -3053,3 +3101,39 @@
return changes;
}
+
+#if defined WITH_GEOIP
+int cfg_key_geoip_ipv4_file(char *filename, char *name, char *value_ptr)
+{
+ struct plugins_list_entry *list = plugins_list;
+ int changes = 0;
+
+ for (; list; list = list->next, changes++) list->cfg.geoip_ipv4_file = value_ptr;
+
+ return changes;
+}
+
+#if defined ENABLE_IPV6
+int cfg_key_geoip_ipv6_file(char *filename, char *name, char *value_ptr)
+{
+ struct plugins_list_entry *list = plugins_list;
+ int changes = 0;
+
+ for (; list; list = list->next, changes++) list->cfg.geoip_ipv6_file = value_ptr;
+
+ return changes;
+}
+#endif
+#endif
+
+void cfg_set_aggregate(char *filename, u_int64_t registry[], u_int64_t input, char *token)
+{
+ u_int64_t index = (input >> COUNT_REGISTRY_BITS) & COUNT_INDEX_MASK;
+ u_int64_t value = (input & COUNT_REGISTRY_MASK);
+
+ if (registry[index] & value) {
+ Log(LOG_ERR, "ERROR ( %s ): '%s' repeated in 'aggregate' or invalid 0x%x bit code.\n", filename, token, input);
+ exit(1);
+ }
+ else registry[index] |= value;
+}
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/cfg_handlers.h
^
|
@@ -87,10 +87,10 @@
EXT int cfg_key_networks_cache_entries(char *, char *, char *);
EXT int cfg_key_ports_file(char *, char *, char *);
EXT int cfg_key_refresh_maps(char *, char *, char *);
-EXT int cfg_key_print_refresh_time(char *, char *, char *);
EXT int cfg_key_print_cache_entries(char *, char *, char *);
EXT int cfg_key_print_markers(char *, char *, char *);
EXT int cfg_key_print_output(char *, char *, char *);
+EXT int cfg_key_print_output_file(char *, char *, char *);
EXT int cfg_key_nfacctd_port(char *, char *, char *);
EXT int cfg_key_nfacctd_ip(char *, char *, char *);
EXT int cfg_key_nfacctd_allow_file(char *, char *, char *);
@@ -170,6 +170,8 @@
EXT int cfg_key_nfacctd_isis_iface(char *, char *, char *);
EXT int cfg_key_nfacctd_isis_mtu(char *, char *, char *);
EXT int cfg_key_nfacctd_isis_msglog(char *, char *, char *);
+EXT int cfg_key_geoip_ipv4_file(char *, char *, char *);
+EXT int cfg_key_geoip_ipv6_file(char *, char *, char *);
EXT int cfg_key_uacctd_group(char *, char *, char *);
EXT int cfg_key_uacctd_nl_size(char *, char *, char *);
EXT int cfg_key_tunnel_0(char *, char *, char *);
@@ -177,4 +179,5 @@
EXT int cfg_key_xlate_dst(char *, char *, char *);
EXT void parse_time(char *, char *, int *, int *);
+EXT void cfg_set_aggregate(char *, u_int64_t [], u_int64_t, char *);
#undef EXT
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/imt_plugin.c
^
|
@@ -1,6 +1,6 @@
/*
pmacct (Promiscuous mode IP Accounting package)
- pmacct is Copyright (C) 2003-2012 by Paolo Lucente
+ pmacct is Copyright (C) 2003-2013 by Paolo Lucente
*/
/*
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/imt_plugin.h
^
|
@@ -1,6 +1,6 @@
/*
pmacct (Promiscuous mode IP Accounting package)
- pmacct is Copyright (C) 2003-2010 by Paolo Lucente
+ pmacct is Copyright (C) 2003-2012 by Paolo Lucente
*/
/*
@@ -58,6 +58,7 @@
struct query_header {
int type; /* type of query */
u_int64_t what_to_count; /* aggregation */
+ u_int64_t what_to_count_2; /* aggregation */
unsigned int num; /* number of queries */
unsigned int ip_sz; /* IP addresses size (in bytes) */
unsigned int cnt_sz; /* counters size (in bytes) */
@@ -66,6 +67,7 @@
struct query_entry {
u_int64_t what_to_count; /* aggregation */
+ u_int64_t what_to_count_2; /* aggregation */
struct pkt_primitives data; /* actual data */
struct pkt_bgp_primitives pbgp; /* extended BGP data */
};
@@ -112,7 +114,7 @@
EXT void reset_counters(struct acc *);
EXT int build_query_server(char *);
EXT void process_query_data(int, unsigned char *, int, int);
-EXT void mask_elem(struct pkt_primitives *, struct pkt_bgp_primitives *, struct acc *, u_int64_t);
+EXT void mask_elem(struct pkt_primitives *, struct pkt_bgp_primitives *, struct acc *, u_int64_t, u_int64_t);
EXT void enQueue_elem(int, struct reply_buffer *, void *, int, int);
EXT void Accumulate_Counters(struct pkt_data *, struct acc *);
#undef EXT
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/ip_flow.c
^
|
@@ -395,7 +395,7 @@
{
int size;
- if (config.frag_bufsz) flt6_total_nodes = config.frag_bufsz / sizeof(struct ip_flow6);
+ if (config.flow_bufsz) flt6_total_nodes = config.flow_bufsz / sizeof(struct ip_flow6);
else flt6_total_nodes = DEFAULT_FLOW_BUFFER_SIZE / sizeof(struct ip_flow6);
if (!config.flow_hashsz) config.flow_hashsz = FLOW_TABLE_HASHSZ;
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/log_templates.h
^
|
@@ -1,6 +1,6 @@
/*
pmacct (Promiscuous mode IP Accounting package)
- pmacct is Copyright (C) 2003-2008 by Paolo Lucente
+ pmacct is Copyright (C) 2003-2012 by Paolo Lucente
*/
/*
@@ -29,7 +29,8 @@
};
struct template_entry {
- u_int32_t tag;
+ u_int64_t tag;
+ /* u_int64_t tag_2; XXX: not supported */
u_int8_t size;
u_int8_t type; /* unused */
};
|
[-]
[+]
|
Added |
pmacct-0.14.2.tar.bz2/src/mongodb_plugin.c
^
|
@@ -0,0 +1,561 @@
+/*
+ pmacct (Promiscuous mode IP Accounting package)
+ pmacct is Copyright (C) 2003-2013 by Paolo Lucente
+*/
+
+/*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#define __MONGODB_PLUGIN_C
+
+/* includes */
+#include "pmacct.h"
+#include "pmacct-data.h"
+#include "plugin_hooks.h"
+#include "print_plugin.h"
+#include "mongodb_plugin.h"
+#include "net_aggr.h"
+#include "ports_aggr.h"
+#include "ip_flow.h"
+#include "classifier.h"
+#include "crc32.c"
+
+/* Functions */
+void mongodb_plugin(int pipe_fd, struct configuration *cfgptr, void *ptr)
+{
+ struct pkt_data *data;
+ struct ports_table pt;
+ unsigned char *pipebuf;
+ struct pollfd pfd;
+ time_t t, now;
+ int timeout, ret, num;
+ struct ring *rg = &((struct channels_list_entry *)ptr)->rg;
+ struct ch_status *status = ((struct channels_list_entry *)ptr)->status;
+ u_int32_t bufsz = ((struct channels_list_entry *)ptr)->bufsize;
+
+ unsigned char *rgptr;
+ int pollagain = TRUE;
+ u_int32_t seq = 1, rg_err_count = 0;
+
+ struct pkt_bgp_primitives *pbgp;
+ char *dataptr;
+
+ memcpy(&config, cfgptr, sizeof(struct configuration));
+ recollect_pipe_memory(ptr);
+ pm_setproctitle("%s [%s]", "MongoDB Plugin", config.name);
+ if (config.pidfile) write_pid_file_plugin(config.pidfile, config.type, config.name);
+ if (config.logfile) {
+ fclose(config.logfile_fd);
+ config.logfile_fd = open_logfile(config.logfile);
+ }
+
+ reload_map = FALSE;
+
+ basetime_init = NULL;
+ basetime_eval = NULL;
+ basetime_cmp = NULL;
+ memset(&basetime, 0, sizeof(basetime));
+ memset(&ibasetime, 0, sizeof(ibasetime));
+ memset(&sbasetime, 0, sizeof(sbasetime));
+ memset(×lot, 0, sizeof(timeslot));
+
+ /* signal handling */
+ signal(SIGINT, MongoDB_exit_now);
+ signal(SIGUSR1, SIG_IGN);
+ signal(SIGUSR2, reload_maps);
+ signal(SIGPIPE, SIG_IGN);
+#if !defined FBSD4
+ signal(SIGCHLD, SIG_IGN);
+#else
+ signal(SIGCHLD, ignore_falling_child);
+#endif
+
+ if (!config.sql_refresh_time)
+ config.sql_refresh_time = DEFAULT_PRINT_REFRESH_TIME;
+
+ timeout = config.sql_refresh_time*1000;
+
+ /* XXX: reusing cache functions from print plugin -- should get common'ed? */
+ if (config.what_to_count & (COUNT_SUM_HOST|COUNT_SUM_NET))
+ insert_func = P_sum_host_insert;
+ else if (config.what_to_count & COUNT_SUM_PORT) insert_func = P_sum_port_insert;
+ else if (config.what_to_count & COUNT_SUM_AS) insert_func = P_sum_as_insert;
+#if defined (HAVE_L2)
+ else if (config.what_to_count & COUNT_SUM_MAC) insert_func = P_sum_mac_insert;
+#endif
+ else insert_func = P_cache_insert;
+
+ /* Dirty but allows to save some IFs, centralizes
+ checks and makes later comparison statements lean */
+ if (!(config.what_to_count & (COUNT_STD_COMM|COUNT_EXT_COMM|COUNT_LOCAL_PREF|COUNT_MED|COUNT_AS_PATH|
+ COUNT_PEER_SRC_AS|COUNT_PEER_DST_AS|COUNT_PEER_SRC_IP|COUNT_PEER_DST_IP|
+ COUNT_SRC_STD_COMM|COUNT_SRC_EXT_COMM|COUNT_SRC_AS_PATH|COUNT_SRC_MED|
+ COUNT_SRC_LOCAL_PREF|COUNT_MPLS_VPN_RD)))
+ PbgpSz = 0;
+
+ memset(&nt, 0, sizeof(nt));
+ memset(&nc, 0, sizeof(nc));
+ memset(&pt, 0, sizeof(pt));
+
+ load_networks(config.networks_file, &nt, &nc);
+ set_net_funcs(&nt);
+
+ if (config.ports_file) load_ports(config.ports_file, &pt);
+
+ pp_size = sizeof(struct pkt_primitives);
+ pb_size = sizeof(struct pkt_bgp_primitives);
+ dbc_size = sizeof(struct chained_cache);
+ if (!config.print_cache_entries) config.print_cache_entries = PRINT_CACHE_ENTRIES;
+ memset(&sa, 0, sizeof(struct scratch_area));
+ sa.num = config.print_cache_entries*AVERAGE_CHAIN_LEN;
+ sa.size = sa.num*dbc_size;
+
+ pipebuf = (unsigned char *) Malloc(config.buffer_size);
+ cache = (struct chained_cache *) Malloc(config.print_cache_entries*dbc_size);
+ queries_queue = (struct chained_cache **) Malloc((sa.num+config.print_cache_entries)*sizeof(struct chained_cache *));
+ sa.base = (unsigned char *) Malloc(sa.size);
+ sa.ptr = sa.base;
+ sa.next = NULL;
+
+ pfd.fd = pipe_fd;
+ pfd.events = POLLIN;
+ setnonblocking(pipe_fd);
+
+ now = time(NULL);
+
+ /* print_refresh time init: deadline */
+ refresh_deadline = now;
+ t = roundoff_time(refresh_deadline, config.sql_history_roundoff);
+ while ((t+config.sql_refresh_time) < refresh_deadline) t += config.sql_refresh_time;
+ refresh_deadline = t;
+ refresh_deadline += config.sql_refresh_time; /* it's a deadline not a basetime */
+
+ if (config.sql_history) {
+ basetime_init = P_init_historical_acct;
+ basetime_eval = P_eval_historical_acct;
+ basetime_cmp = P_cmp_historical_acct;
+
+ (*basetime_init)(now);
+ }
+
+ /* setting number of entries in _protocols structure */
+ while (_protocols[protocols_number].number != -1) protocols_number++;
+
+ memset(pipebuf, 0, config.buffer_size);
+ memset(cache, 0, config.print_cache_entries*sizeof(struct chained_cache));
+ memset(queries_queue, 0, (sa.num+config.print_cache_entries)*sizeof(struct chained_cache *));
+ memset(sa.base, 0, sa.size);
+ memset(&flushtime, 0, sizeof(flushtime));
+
+ mongo_init(&db_conn);
+ mongo_set_op_timeout(&db_conn, 1000);
+
+ /* plugin main loop */
+ for(;;) {
+ poll_again:
+ status->wakeup = TRUE;
+ ret = poll(&pfd, 1, timeout);
+ if (ret < 0) goto poll_again;
+
+ now = time(NULL);
+
+ if (config.sql_history) {
+ memset(&sbasetime, 0, sizeof(sbasetime));
+ while (now > (basetime.tv_sec + timeslot)) {
+ sbasetime.tv_sec = basetime.tv_sec;
+ basetime.tv_sec += timeslot;
+ if (config.sql_history == COUNT_MONTHLY)
+ timeslot = calc_monthly_timeslot(basetime.tv_sec, config.sql_history_howmany, ADD);
+ }
+ }
+
+ switch (ret) {
+ case 0: /* timeout */
+ if (qq_ptr) {
+ switch (fork()) {
+ case 0: /* Child */
+ MongoDB_cache_purge(queries_queue, qq_ptr);
+ exit(0);
+ default: /* Parent */
+ MongoDB_cache_flush(queries_queue, qq_ptr);
+ gettimeofday(&flushtime, NULL);
+ refresh_deadline += config.sql_refresh_time;
+ qq_ptr = FALSE;
+ if (reload_map) {
+ load_networks(config.networks_file, &nt, &nc);
+ load_ports(config.ports_file, &pt);
+ reload_map = FALSE;
+ }
+ break;
+ }
+ }
+ break;
+ default: /* we received data */
+ read_data:
+ if (!pollagain) {
+ seq++;
+ seq %= MAX_SEQNUM;
+ if (seq == 0) rg_err_count = FALSE;
+ }
+ else {
+ if ((ret = read(pipe_fd, &rgptr, sizeof(rgptr))) == 0)
+ exit_plugin(1); /* we exit silently; something happened at the write end */
+ }
+
+ if (((struct ch_buf_hdr *)rg->ptr)->seq != seq) {
+ if (!pollagain) {
+ pollagain = TRUE;
+ goto poll_again;
+ }
+ else {
+ rg_err_count++;
+ if (config.debug || (rg_err_count > MAX_RG_COUNT_ERR)) {
+ Log(LOG_ERR, "ERROR ( %s/%s ): We are missing data.\n", config.name, config.type);
+ Log(LOG_ERR, "If you see this message once in a while, discard it. Otherwise some solutions follow:\n");
+ Log(LOG_ERR, "- increase shared memory size, 'plugin_pipe_size'; now: '%u'.\n", config.pipe_size);
+ Log(LOG_ERR, "- increase buffer size, 'plugin_buffer_size'; now: '%u'.\n", config.buffer_size);
+ Log(LOG_ERR, "- increase system maximum socket size.\n\n");
+ }
+ seq = ((struct ch_buf_hdr *)rg->ptr)->seq;
+ }
+ }
+
+ pollagain = FALSE;
+ memcpy(pipebuf, rg->ptr, bufsz);
+ if ((rg->ptr+bufsz) >= rg->end) rg->ptr = rg->base;
+ else rg->ptr += bufsz;
+
+ /* lazy refresh time handling */
+ if (now > refresh_deadline) {
+ if (qq_ptr) {
+ switch (fork()) {
+ case 0: /* Child */
+ MongoDB_cache_purge(queries_queue, qq_ptr);
+ exit(0);
+ default: /* Parent */
+ MongoDB_cache_flush(queries_queue, qq_ptr);
+ gettimeofday(&flushtime, NULL);
+ refresh_deadline += config.sql_refresh_time;
+ qq_ptr = FALSE;
+ if (reload_map) {
+ load_networks(config.networks_file, &nt, &nc);
+ load_ports(config.ports_file, &pt);
+ reload_map = FALSE;
+ }
+ break;
+ }
+ }
+ }
+
+ data = (struct pkt_data *) (pipebuf+sizeof(struct ch_buf_hdr));
+
+ while (((struct ch_buf_hdr *)pipebuf)->num) {
+ for (num = 0; net_funcs[num]; num++)
+ (*net_funcs[num])(&nt, &nc, &data->primitives);
+
+ if (config.ports_file) {
+ if (!pt.table[data->primitives.src_port]) data->primitives.src_port = 0;
+ if (!pt.table[data->primitives.dst_port]) data->primitives.dst_port = 0;
+ }
+
+ if (PbgpSz) pbgp = (struct pkt_bgp_primitives *) ((u_char *)data+PdataSz);
+ else pbgp = NULL;
+
+ (*insert_func)(data, pbgp);
+
+ ((struct ch_buf_hdr *)pipebuf)->num--;
+ if (((struct ch_buf_hdr *)pipebuf)->num) {
+ dataptr = (unsigned char *) data;
+ dataptr += PdataSz + PbgpSz;
+ data = (struct pkt_data *) dataptr;
+ }
+ }
+ goto read_data;
+ }
+ }
+}
+
+void MongoDB_cache_flush(struct chained_cache *queue[], int index)
+{
+ int j;
+
+ for (j = 0; j < index; j++) {
+ queue[j]->valid = FALSE;
+ queue[j]->next = NULL;
+ }
+
+ /* rewinding scratch area stuff */
+ sa.ptr = sa.base;
+}
+
+void MongoDB_cache_purge(struct chained_cache *queue[], int index)
+{
+ struct pkt_primitives *data = NULL;
+ struct pkt_bgp_primitives *pbgp = NULL;
+ struct pkt_bgp_primitives empty_pbgp;
+ char src_mac[18], dst_mac[18], src_host[INET6_ADDRSTRLEN], dst_host[INET6_ADDRSTRLEN], ip_address[INET6_ADDRSTRLEN];
+ char rd_str[SRVBUFLEN], misc_str[SRVBUFLEN];
+ char *as_path, *bgp_comm, empty_aspath[] = "^$", default_table[] = "test.acct";
+ int i, j, db_status;
+
+ const bson **bson_batch;
+ bson *bson_elem;
+
+ if (config.sql_host)
+ db_status = mongo_connect(&db_conn, config.sql_host, 27017 /* default port */);
+ else
+ db_status = mongo_connect(&db_conn, "127.0.0.1", 27017 /* default port */);
+
+ if (db_status != MONGO_OK) {
+ switch (db_conn.err) {
+ case MONGO_CONN_SUCCESS:
+ Log(LOG_DEBUG, "DEBUG ( %s/%s ): Connection succeeded (MONGO_CONN_SUCCESS) to MongoDB\n", config.name, config.type);
+ break;
+ case MONGO_CONN_NO_SOCKET:
+ Log(LOG_ERR, "ERROR ( %s/%s ): Connection failed to MongoDB: no socket\n", config.name, config.type);
+ return;
+ case MONGO_CONN_NOT_MASTER:
+ Log(LOG_ERR, "ERROR ( %s/%s ): Connection failed to MongoDB: not master\n", config.name, config.type);
+ return;
+ case MONGO_CONN_FAIL:
+ default:
+ Log(LOG_ERR, "ERROR ( %s/%s ): Connection failed to MongoDB\n", config.name, config.type);
+ return;
+ }
+ }
+ else Log(LOG_DEBUG, "DEBUG ( %s/%s ): Connection succeeded (MONGO_OK) to MongoDB\n", config.name, config.type);
+
+ memset(&empty_pbgp, 0, sizeof(struct pkt_bgp_primitives));
+
+ if (!config.sql_table) config.sql_table = default_table;
+ if (strchr(config.sql_table, '%') || strchr(config.sql_table, '$')) dyn_table = TRUE;
+ else dyn_table = FALSE;
+
+ bson_batch = (bson **) malloc(sizeof(bson *) * index);
+
+ for (j = 0; j < index; j++) {
+ bson_elem = (bson *) malloc(sizeof(bson));
+ bson_init(bson_elem);
+ bson_append_new_oid(bson_elem, "_id" );
+
+ data = &queue[j]->primitives;
+ if (queue[j]->pbgp) pbgp = queue[j]->pbgp;
+ else pbgp = &empty_pbgp;
+
+ if (!queue[j]->bytes_counter && !queue[j]->packet_counter && !queue[j]->flow_counter)
+ continue;
+
+ if (config.what_to_count & COUNT_ID) bson_append_long(bson_elem, "tag", data->id);
+ if (config.what_to_count & COUNT_ID2) bson_append_long(bson_elem, "tag2", data->id2);
+ if (config.what_to_count & COUNT_CLASS) bson_append_string(bson_elem, "class", ((data->class && class[(data->class)-1].id) ? class[(data->class)-1].protocol : "unknown" ));
+#if defined (HAVE_L2)
+ if (config.what_to_count & COUNT_SRC_MAC) {
+ etheraddr_string(data->eth_shost, src_mac);
+ bson_append_string(bson_elem, "mac_src", src_mac);
+ }
+ if (config.what_to_count & COUNT_DST_MAC) {
+ etheraddr_string(data->eth_dhost, dst_mac);
+ bson_append_string(bson_elem, "mac_dst", dst_mac);
+ }
+
+ if (config.what_to_count & COUNT_VLAN) {
+ sprintf(misc_str, "%u", data->vlan_id);
+ bson_append_string(bson_elem, "vlan_id", misc_str);
+ }
+ if (config.what_to_count & COUNT_COS) {
+ sprintf(misc_str, "%u", data->cos);
+ bson_append_string(bson_elem, "cos", misc_str);
+ }
+ if (config.what_to_count & COUNT_ETHERTYPE) {
+ sprintf(misc_str, "%x", data->etype);
+ bson_append_string(bson_elem, "etype", misc_str);
+ }
+#endif
+ if (config.what_to_count & COUNT_SRC_AS) bson_append_int(bson_elem, "as_src", data->src_as);
+ if (config.what_to_count & COUNT_DST_AS) bson_append_int(bson_elem, "as_dst", data->dst_as);
+
+ if (config.what_to_count & COUNT_STD_COMM) {
+ bgp_comm = pbgp->std_comms;
+ while (bgp_comm) {
+ bgp_comm = strchr(pbgp->std_comms, ' ');
+ if (bgp_comm) *bgp_comm = '_';
+ }
+
+ if (strlen(pbgp->std_comms))
+ bson_append_string(bson_elem, "comms", pbgp->std_comms);
+ else
+ bson_append_null(bson_elem, "comms");
+ }
+
+ if (config.what_to_count & COUNT_AS_PATH) {
+ as_path = pbgp->as_path;
+ while (as_path) {
+ as_path = strchr(pbgp->as_path, ' ');
+ if (as_path) *as_path = '_';
+ }
+ if (strlen(pbgp->as_path))
+ bson_append_string(bson_elem, "as_path", pbgp->as_path);
+ else
+ bson_append_string(bson_elem, "as_path", empty_aspath);
+ }
+
+ if (config.what_to_count & COUNT_LOCAL_PREF) bson_append_int(bson_elem, "local_pref", pbgp->local_pref);
+ if (config.what_to_count & COUNT_MED) bson_append_int(bson_elem, "med", pbgp->med);
+ if (config.what_to_count & COUNT_PEER_SRC_AS) bson_append_int(bson_elem, "peer_as_src", pbgp->peer_src_as);
+ if (config.what_to_count & COUNT_PEER_DST_AS) bson_append_int(bson_elem, "peer_as_dst", pbgp->peer_dst_as);
+
+ if (config.what_to_count & COUNT_PEER_SRC_IP) {
+ addr_to_str(ip_address, &pbgp->peer_src_ip);
+ bson_append_string(bson_elem, "peer_ip_src", ip_address);
+ }
+ if (config.what_to_count & COUNT_PEER_DST_IP) {
+ addr_to_str(ip_address, &pbgp->peer_dst_ip);
+ bson_append_string(bson_elem, "peer_ip_dst", ip_address);
+ }
+
+ if (config.what_to_count & COUNT_IN_IFACE) bson_append_int(bson_elem, "iface_in", data->ifindex_in);
+ if (config.what_to_count & COUNT_OUT_IFACE) bson_append_int(bson_elem, "iface_out", data->ifindex_out);
+
+ if (config.what_to_count & COUNT_MPLS_VPN_RD) {
+ bgp_rd2str(rd_str, &pbgp->mpls_vpn_rd);
+ bson_append_string(bson_elem, "mpls_vpn_rd", rd_str);
+ }
+
+ if (config.what_to_count & COUNT_SRC_HOST) {
+ addr_to_str(src_host, &data->src_ip);
+ bson_append_string(bson_elem, "ip_src", src_host);
+ }
+ if (config.what_to_count & COUNT_DST_HOST) {
+ addr_to_str(dst_host, &data->dst_ip);
+ bson_append_string(bson_elem, "ip_dst", dst_host);
+ }
+
+ if (config.what_to_count & COUNT_SRC_NMASK) {
+ sprintf(misc_str, "%u", data->src_nmask);
+ bson_append_string(bson_elem, "mask_src", misc_str);
+ }
+ if (config.what_to_count & COUNT_DST_NMASK) {
+ sprintf(misc_str, "%u", data->dst_nmask);
+ bson_append_string(bson_elem, "mask_dst", misc_str);
+ }
+ if (config.what_to_count & COUNT_SRC_PORT) {
+ sprintf(misc_str, "%u", data->src_port);
+ bson_append_string(bson_elem, "port_src", misc_str);
+ }
+ if (config.what_to_count & COUNT_DST_PORT) {
+ sprintf(misc_str, "%u", data->dst_port);
+ bson_append_string(bson_elem, "port_dst", misc_str);
+ }
+#if defined (WITH_GEOIP)
+ if (config.what_to_count_2 & COUNT_SRC_HOST_COUNTRY) {
+ if (data->src_host_country > 0)
+ bson_append_string(bson_elem, "country_ip_src", GeoIP_code_by_id(data->src_ip_country));
+ else
+ bson_append_null(bson_elem, "country_ip_src");
+ }
+ if (config.what_to_count & COUNT_DST_HOST_COUNTRY) {
+ if (data->dst_host_country > 0)
+ bson_append_string(bson_elem, "country_ip_dst", GeoIP_code_by_id(data->dst_ip_country));
+ else
+ bson_append_null(bson_elem, "country_ip_dst");
+ }
+#endif
+ if (config.what_to_count & COUNT_TCPFLAGS) {
+ sprintf(misc_str, "%u", queue[j]->tcp_flags);
+ bson_append_string(bson_elem, "tcp_flags", misc_str);
+ }
+
+ if (config.what_to_count & COUNT_IP_PROTO) {
+ if (!config.num_protos) bson_append_string(bson_elem, "ip_proto", _protocols[data->proto].name);
+ else {
+ sprintf(misc_str, "%u", _protocols[data->proto].number);
+ bson_append_string(bson_elem, "ip_proto", misc_str);
+ }
+ }
+
+ if (config.what_to_count & COUNT_IP_TOS) {
+ sprintf(misc_str, "%u", data->tos);
+ bson_append_string(bson_elem, "tos", misc_str);
+ }
+
+ if (config.what_to_count_2 & COUNT_SAMPLING_RATE) bson_append_int(bson_elem, "sampling_rate", data->sampling_rate);
+
+ if (config.sql_history) {
+ bson_append_date(bson_elem, "stamp_inserted", (bson_date_t) 1000*queue[j]->basetime.tv_sec);
+ bson_append_date(bson_elem, "stamp_updated", (bson_date_t) 1000*time(NULL));
+ }
+
+#if defined HAVE_64BIT_COUNTERS
+ bson_append_long(bson_elem, "packets", queue[j]->packet_counter);
+ bson_append_long(bson_elem, "flows", queue[j]->flow_counter);
+ bson_append_long(bson_elem, "bytes", queue[j]->bytes_counter);
+#else
+ bson_append_int(bson_elem, "packets", queue[j]->packet_counter);
+ bson_append_int(bson_elem, "flows", queue[j]->flow_counter);
+ bson_append_int(bson_elem, "bytes", queue[j]->bytes_counter);
+#endif
+
+ bson_finish(bson_elem);
+ bson_batch[j] = bson_elem;
+
+ if (config.debug) bson_print(bson_elem);
+ }
+
+ if (dyn_table) {
+ char tmpbuf[LONGLONGSRVBUFLEN];
+ time_t stamp = sbasetime.tv_sec ? sbasetime.tv_sec : basetime.tv_sec;
+
+ handle_dynname_internal_strings_same(tmpbuf, LONGSRVBUFLEN, config.sql_table);
+
+ strftime_same(config.sql_table, LONGSRVBUFLEN, tmpbuf, &stamp);
+ mongo_insert_batch(&db_conn, tmpbuf, bson_batch, j, NULL, MONGO_CONTINUE_ON_ERROR /* XXX: test */);
+ }
+ else mongo_insert_batch(&db_conn, config.sql_table, bson_batch, j, NULL, MONGO_CONTINUE_ON_ERROR /* XXX: test */);
+
+ for (i = 0; i < j; i++) {
+ bson_elem = (bson *) bson_batch[i];
+ bson_destroy(bson_elem);
+ free(bson_elem);
+ }
+
+ if (config.sql_trigger_exec) MongoDB_trigger_exec(config.sql_trigger_exec);
+}
+
+void MongoDB_exit_now(int signum)
+{
+ MongoDB_cache_purge(queries_queue, qq_ptr);
+
+ wait(NULL);
+ exit_plugin(0);
+}
+
+int MongoDB_trigger_exec(char *filename)
+{
+ char *args[1];
+ int pid;
+
+ memset(args, 0, sizeof(args));
+
+ switch (pid = vfork()) {
+ case -1:
+ return -1;
+ case 0:
+ execv(filename, args);
+ exit(0);
+ }
+
+ return 0;
+}
|
[-]
[+]
|
Added |
pmacct-0.14.2.tar.bz2/src/mongodb_plugin.h
^
|
@@ -0,0 +1,57 @@
+/*
+ pmacct (Promiscuous mode IP Accounting package)
+ pmacct is Copyright (C) 2003-2012 by Paolo Lucente
+*/
+
+/*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+/* includes */
+#include <sys/poll.h>
+
+/* defines */
+#if (!defined MONGO_HAVE_STDINT)
+#define MONGO_HAVE_STDINT 1
+#endif
+#include <mongo.h>
+
+/* structures */
+
+/* prototypes */
+#if (!defined __MONGODB_PLUGIN_C)
+#define EXT extern
+#else
+#define EXT
+#endif
+EXT void mongodb_plugin(int, struct configuration *, void *);
+EXT void MongoDB_cache_flush(struct chained_cache *[], int);
+EXT void MongoDB_cache_purge(struct chained_cache *[], int);
+EXT void MongoDB_exit_now(int);
+EXT int MongoDB_trigger_exec(char *);
+
+/* global vars */
+EXT void (*insert_func)(struct pkt_data *, struct pkt_bgp_primitives *); /* pointer to INSERT function */
+EXT struct scratch_area sa;
+EXT struct chained_cache *cache;
+EXT struct chained_cache **queries_queue;
+EXT struct timeval flushtime;
+EXT int qq_ptr, pp_size, pb_size, dbc_size, quit;
+EXT time_t refresh_deadline;
+EXT mongo db_conn;
+
+EXT struct timeval sbasetime;
+EXT int dyn_table;
+#undef EXT
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/mysql_plugin.c
^
|
@@ -1,6 +1,6 @@
/*
pmacct (Promiscuous mode IP Accounting package)
- pmacct is Copyright (C) 2003-2012 by Paolo Lucente
+ pmacct is Copyright (C) 2003-2013 by Paolo Lucente
*/
/*
@@ -100,7 +100,7 @@
for(;;) {
poll_again:
status->wakeup = TRUE;
- sql_calc_refresh_timeout(refresh_deadline, idata.now, &timeout);
+ calc_refresh_timeout(refresh_deadline, idata.now, &timeout);
ret = poll(&pfd, 1, timeout);
if (ret < 0) goto poll_again;
@@ -439,6 +439,10 @@
char tmpbuf[LONGLONGSRVBUFLEN];
time_t stamp = idata->new_basetime ? idata->new_basetime : idata->basetime;
+ handle_dynname_internal_strings_same(tmpbuf, LONGSRVBUFLEN, insert_clause);
+ handle_dynname_internal_strings_same(tmpbuf, LONGSRVBUFLEN, update_clause);
+ handle_dynname_internal_strings_same(tmpbuf, LONGSRVBUFLEN, lock_clause);
+
strftime_same(insert_clause, LONGSRVBUFLEN, tmpbuf, &stamp);
strftime_same(update_clause, LONGSRVBUFLEN, tmpbuf, &stamp);
strftime_same(lock_clause, LONGSRVBUFLEN, tmpbuf, &stamp);
@@ -681,7 +685,7 @@
else if (config.sql_table_version == 2) config.sql_table = mysql_table_v2;
else config.sql_table = mysql_table;
}
- if (strchr(config.sql_table, '%')) idata->dyn_table = TRUE;
+ if (strchr(config.sql_table, '%') || strchr(config.sql_table, '$')) idata->dyn_table = TRUE;
glob_dyn_table = idata->dyn_table;
if (config.sql_backup_host || config.sql_recovery_logfile) idata->recover = TRUE;
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/net_aggr.c
^
|
@@ -1,6 +1,6 @@
/*
pmacct (Promiscuous mode IP Accounting package)
- pmacct is Copyright (C) 2003-2012 by Paolo Lucente
+ pmacct is Copyright (C) 2003-2013 by Paolo Lucente
*/
/*
@@ -435,11 +435,11 @@
if (j < 4 && index) nt->maskbits[j] = ~(0xffffffffU >> index);
if (config.what_to_count & (COUNT_SRC_NET|COUNT_SUM_NET)) {
- net_funcs[count] = mask_src_ipaddr;
+ net_funcs[count] = mask_static_src_ipaddr;
count++;
}
if (config.what_to_count & COUNT_DST_NET) {
- net_funcs[count] = mask_dst_ipaddr;
+ net_funcs[count] = mask_static_dst_ipaddr;
count++;
}
if (config.what_to_count & COUNT_SRC_NMASK) {
@@ -453,9 +453,9 @@
}
#if defined ENABLE_IPV6
- if ((!nt->num) && (!nt->num6)) return;
+ if ((!nt->num) && (!nt->num6)) goto exit_lane;
#else
- if (!nt->num) return;
+ if (!nt->num) goto exit_lane;
#endif
if (config.what_to_count & (COUNT_SRC_HOST|COUNT_SUM_HOST)) {
@@ -463,64 +463,145 @@
count++;
}
- if (config.what_to_count & COUNT_SRC_NMASK) {
+ if (config.nfacctd_net & NF_NET_NEW) {
net_funcs[count] = search_src_nmask;
count++;
}
- if ((config.nfacctd_net & NF_NET_NEW) && config.what_to_count & (COUNT_SRC_NET|COUNT_SUM_NET)) {
- net_funcs[count] = search_src_net;
- count++;
- }
-
- if (config.what_to_count & (COUNT_SRC_AS|COUNT_SUM_AS)) {
- if (((config.acct_type == ACCT_NF || config.acct_type == ACCT_SF) &&
- (config.nfacctd_as & NF_AS_KEEP || config.nfacctd_as & NF_AS_BGP))
- || (config.acct_type == ACCT_PM && config.nfacctd_as & NF_AS_BGP));
- else {
+ if (config.nfacctd_as & NF_AS_NEW) {
+ if (config.what_to_count & (COUNT_SRC_AS|COUNT_SUM_AS)) {
net_funcs[count] = search_src_as;
count++;
+ }
+ }
- if (!(config.what_to_count & (COUNT_SRC_HOST|COUNT_SUM_HOST|COUNT_SRC_NET|COUNT_SUM_NET))) {
- net_funcs[count] = drop_src_host;
- count++;
- }
+ if (!(config.what_to_count & (COUNT_SRC_HOST|COUNT_SUM_HOST|COUNT_SRC_NET|COUNT_SUM_NET))) {
+ net_funcs[count] = clear_src_host;
+ count++;
+ }
+ else {
+ if (config.what_to_count & (COUNT_SRC_NET|COUNT_SUM_NET)) {
+ net_funcs[count] = mask_src_ipaddr;
+ count++;
}
}
+ if (!(config.what_to_count & COUNT_SRC_NMASK)) {
+ net_funcs[count] = clear_src_nmask;
+ count++;
+ }
+
if (config.what_to_count & (COUNT_DST_HOST|COUNT_SUM_HOST)) {
net_funcs[count] = search_dst_host;
count++;
}
- if (config.what_to_count & COUNT_DST_NMASK) {
+ if (config.nfacctd_net & NF_NET_NEW) {
net_funcs[count] = search_dst_nmask;
count++;
}
- if ((config.nfacctd_net & NF_NET_NEW) && config.what_to_count & (COUNT_DST_NET|COUNT_SUM_NET)) {
- net_funcs[count] = search_dst_net;
+ if (config.nfacctd_as & NF_AS_NEW) {
+ if (config.what_to_count & (COUNT_DST_AS|COUNT_SUM_AS)) {
+ net_funcs[count] = search_dst_as;
+ count++;
+ }
+ }
+
+ if (!(config.what_to_count & (COUNT_DST_HOST|COUNT_SUM_HOST|COUNT_DST_NET|COUNT_SUM_NET))) {
+ net_funcs[count] = clear_dst_host;
+ count++;
+ }
+ else {
+ if (config.what_to_count & (COUNT_DST_NET|COUNT_SUM_NET)) {
+ net_funcs[count] = mask_dst_ipaddr;
+ count++;
+ }
+ }
+
+ if (!(config.what_to_count & COUNT_DST_NMASK)) {
+ net_funcs[count] = clear_dst_nmask;
count++;
}
- if (config.what_to_count & (COUNT_DST_AS|COUNT_SUM_AS)) {
- if (((config.acct_type == ACCT_NF || config.acct_type == ACCT_SF) &&
- (config.nfacctd_as & NF_AS_KEEP || config.nfacctd_as & NF_AS_BGP))
- || (config.acct_type == ACCT_PM && config.nfacctd_as & NF_AS_BGP));
- else {
- net_funcs[count] = search_dst_as;
+ assert(count < NET_FUNCS_N);
+
+ return;
+
+ /* no networks_file loaded: apply masks and clean-up */
+ exit_lane:
+
+ if (!(config.what_to_count & (COUNT_SRC_HOST|COUNT_SUM_HOST|COUNT_SRC_NET|COUNT_SUM_NET))) {
+ net_funcs[count] = clear_src_host;
+ count++;
+ }
+ else {
+ if (config.what_to_count & (COUNT_SRC_NET|COUNT_SUM_NET)) {
+ net_funcs[count] = mask_src_ipaddr;
count++;
+ }
+ }
- if (!(config.what_to_count & (COUNT_DST_HOST|COUNT_DST_NET))) {
- net_funcs[count] = drop_dst_host;
- count++;
- }
+ if (!(config.what_to_count & (COUNT_DST_HOST|COUNT_SUM_HOST|COUNT_DST_NET|COUNT_SUM_NET))) {
+ net_funcs[count] = clear_dst_host;
+ count++;
+ }
+ else {
+ if (config.what_to_count & COUNT_DST_NET) {
+ net_funcs[count] = mask_dst_ipaddr;
+ count++;
}
}
+
+ if (!(config.what_to_count & COUNT_SRC_NMASK)) {
+ net_funcs[count] = clear_src_nmask;
+ count++;
+ }
+
+ if (!(config.what_to_count & COUNT_DST_NMASK)) {
+ net_funcs[count] = clear_dst_nmask;
+ count++;
+ }
+
+ assert(count < NET_FUNCS_N);
+}
+
+void clear_src_nmask(struct networks_table *nt, struct networks_cache *nc, struct pkt_primitives *p)
+{
+ p->src_nmask = 0;
+}
+
+void clear_dst_nmask(struct networks_table *nt, struct networks_cache *nc, struct pkt_primitives *p)
+{
+ p->dst_nmask = 0;
}
void mask_src_ipaddr(struct networks_table *nt, struct networks_cache *nc, struct pkt_primitives *p)
{
+ u_int32_t maskbits[4], addrh[4];
+ u_int8_t j, mask;
+
+ memset(maskbits, 0,sizeof(maskbits));
+ mask = p->src_nmask;
+ for (j = 0; j < 4 && mask >= 32; j++, mask -= 32) maskbits[j] = 0xffffffffU;
+ if (j < 4 && mask) maskbits[j] = ~(0xffffffffU >> mask);
+
+ if (p->src_ip.family == AF_INET) {
+ addrh[0] = ntohl(p->src_ip.address.ipv4.s_addr);
+ addrh[0] &= maskbits[0];
+ p->src_ip.address.ipv4.s_addr = htonl(addrh[0]);
+ }
+#if defined ENABLE_IPV6
+ else if (p->src_ip.family == AF_INET6) {
+ memcpy(&addrh, (void *) pm_ntohl6(&p->src_ip.address.ipv6), IP6AddrSz);
+ for (j = 0; j < 4; j++) addrh[j] &= nt->maskbits[j];
+ memcpy(&p->src_ip.address.ipv6, (void *) pm_htonl6(addrh), IP6AddrSz);
+ }
+#endif
+}
+
+void mask_static_src_ipaddr(struct networks_table *nt, struct networks_cache *nc, struct pkt_primitives *p)
+{
u_int32_t addrh[4];
u_int8_t j;
@@ -540,6 +621,30 @@
void mask_dst_ipaddr(struct networks_table *nt, struct networks_cache *nc, struct pkt_primitives *p)
{
+ u_int32_t maskbits[4], addrh[4];
+ u_int8_t j, mask;
+
+ memset(maskbits, 0,sizeof(maskbits));
+ mask = p->dst_nmask;
+ for (j = 0; j < 4 && mask >= 32; j++, mask -= 32) maskbits[j] = 0xffffffffU;
+ if (j < 4 && mask) maskbits[j] = ~(0xffffffffU >> mask);
+
+ if (p->dst_ip.family == AF_INET) {
+ addrh[0] = ntohl(p->dst_ip.address.ipv4.s_addr);
+ addrh[0] &= maskbits[0];
+ p->dst_ip.address.ipv4.s_addr = htonl(addrh[0]);
+ }
+#if defined ENABLE_IPV6
+ else if (p->dst_ip.family == AF_INET6) {
+ memcpy(&addrh, (void *) pm_ntohl6(&p->dst_ip.address.ipv6), IP6AddrSz);
+ for (j = 0; j < 4; j++) addrh[j] &= nt->maskbits[j];
+ memcpy(&p->dst_ip.address.ipv6, (void *) pm_htonl6(addrh), IP6AddrSz);
+ }
+#endif
+}
+
+void mask_static_dst_ipaddr(struct networks_table *nt, struct networks_cache *nc, struct pkt_primitives *p)
+{
u_int32_t addrh[4];
u_int8_t j;
@@ -609,67 +714,33 @@
#endif
}
-void search_src_net(struct networks_table *nt, struct networks_cache *nc, struct pkt_primitives *p)
+void search_src_nmask(struct networks_table *nt, struct networks_cache *nc, struct pkt_primitives *p)
{
struct networks_table_entry *res;
#if defined ENABLE_IPV6
struct networks6_table_entry *res6;
#endif
+ u_int8_t mask = 0;
if (p->src_ip.family == AF_INET) {
res = binsearch(nt, nc, &p->src_ip);
- if (!res) p->src_ip.address.ipv4.s_addr = 0;
- else p->src_ip.address.ipv4.s_addr = htonl(res->net);
+ if (!res) mask = 0;
+ else mask = res->masknum;
}
#if defined ENABLE_IPV6
else if (p->src_ip.family == AF_INET6) {
res6 = binsearch6(nt, nc, &p->src_ip);
- if (!res6) memset(&p->src_ip.address.ipv6, 0, IP6AddrSz);
- else memcpy(&p->src_ip.address.ipv6, (void *)pm_htonl6(res6->net), IP6AddrSz);
- }
-#endif
-}
-
-void search_dst_net(struct networks_table *nt, struct networks_cache *nc, struct pkt_primitives *p)
-{
- struct networks_table_entry *res;
-#if defined ENABLE_IPV6
- struct networks6_table_entry *res6;
-#endif
-
- if (p->dst_ip.family == AF_INET) {
- res = binsearch(nt, nc, &p->dst_ip);
- if (!res) p->dst_ip.address.ipv4.s_addr = 0;
- else p->dst_ip.address.ipv4.s_addr = htonl(res->net);
+ if (!res6) mask = 0;
+ else mask = res6->masknum;
}
-#if defined ENABLE_IPV6
- else if (p->dst_ip.family == AF_INET6) {
- res6 = binsearch6(nt, nc, &p->dst_ip);
- if (!res6) memset(&p->dst_ip.address.ipv6, 0, IP6AddrSz);
- else memcpy(&p->dst_ip.address.ipv6, (void *)pm_htonl6(res6->net), IP6AddrSz);
- }
-#endif
-}
-
-void search_src_nmask(struct networks_table *nt, struct networks_cache *nc, struct pkt_primitives *p)
-{
- struct networks_table_entry *res;
-#if defined ENABLE_IPV6
- struct networks6_table_entry *res6;
#endif
- if (p->src_ip.family == AF_INET) {
- res = binsearch(nt, nc, &p->src_ip);
- if (!res) p->src_nmask = 0;
- else p->src_nmask = res->masknum;
+ if (!(config.nfacctd_net & NF_NET_FALLBACK)) {
+ p->src_nmask = mask;
}
-#if defined ENABLE_IPV6
- else if (p->src_ip.family == AF_INET6) {
- res6 = binsearch6(nt, nc, &p->src_ip);
- if (!res6) p->src_nmask = 0;
- else p->src_nmask = res6->masknum;
+ else {
+ if (mask > p->src_nmask) p->src_nmask = mask;
}
-#endif
}
void search_dst_nmask(struct networks_table *nt, struct networks_cache *nc, struct pkt_primitives *p)
@@ -678,19 +749,27 @@
#if defined ENABLE_IPV6
struct networks6_table_entry *res6;
#endif
+ u_int8_t mask = 0;
if (p->dst_ip.family == AF_INET) {
res = binsearch(nt, nc, &p->dst_ip);
- if (!res) p->dst_nmask = 0;
- else p->dst_nmask = res->masknum;
+ if (!res) mask = 0;
+ else mask = res->masknum;
}
#if defined ENABLE_IPV6
else if (p->dst_ip.family == AF_INET6) {
res6 = binsearch6(nt, nc, &p->dst_ip);
- if (!res6) p->dst_nmask = 0;
- else p->dst_nmask = res6->masknum;
+ if (!res6) mask = 0;
+ else mask = res6->masknum;
}
#endif
+
+ if (!(config.nfacctd_net & NF_NET_FALLBACK)) {
+ p->dst_nmask = mask;
+ }
+ else {
+ if (mask > p->dst_nmask) p->dst_nmask = mask;
+ }
}
void search_src_as(struct networks_table *nt, struct networks_cache *nc, struct pkt_primitives *p)
@@ -702,12 +781,26 @@
if (p->src_ip.family == AF_INET) {
res = binsearch(nt, nc, &p->src_ip);
- if (res) p->src_as = res->as;
+ if (res) {
+ if (!(config.nfacctd_as & NF_AS_FALLBACK)) {
+ p->src_as = res->as;
+ }
+ else {
+ if (res->masknum >= p->src_nmask) p->src_as = res->as;
+ }
+ }
}
#if defined ENABLE_IPV6
else if (p->src_ip.family == AF_INET6) {
res6 = binsearch6(nt, nc, &p->src_ip);
- if (res6) p->src_as = res6->as;
+ if (res6) {
+ if (!(config.nfacctd_as & NF_AS_FALLBACK)) {
+ p->src_as = res6->as;
+ }
+ else {
+ if (res6->masknum >= p->src_nmask) p->src_as = res6->as;
+ }
+ }
}
#endif
}
@@ -721,22 +814,36 @@
if (p->dst_ip.family == AF_INET) {
res = binsearch(nt, nc, &p->dst_ip);
- if (res) p->dst_as = res->as;
+ if (res) {
+ if (!(config.nfacctd_as & NF_AS_FALLBACK)) {
+ p->dst_as = res->as;
+ }
+ else {
+ if (res->masknum >= p->dst_nmask) p->dst_as = res->as;
+ }
+ }
}
#if defined ENABLE_IPV6
else if (p->dst_ip.family == AF_INET6) {
res6 = binsearch6(nt, nc, &p->dst_ip);
- if (res6) p->dst_as = res6->as;
+ if (res6) {
+ if (!(config.nfacctd_as & NF_AS_FALLBACK)) {
+ p->dst_as = res6->as;
+ }
+ else {
+ if (res6->masknum >= p->dst_nmask) p->dst_as = res6->as;
+ }
+ }
}
#endif
}
-void drop_src_host(struct networks_table *nt, struct networks_cache *nc, struct pkt_primitives *p)
+void clear_src_host(struct networks_table *nt, struct networks_cache *nc, struct pkt_primitives *p)
{
memset(&p->src_ip, 0, HostAddrSz);
}
-void drop_dst_host(struct networks_table *nt, struct networks_cache *nc, struct pkt_primitives *p)
+void clear_dst_host(struct networks_table *nt, struct networks_cache *nc, struct pkt_primitives *p)
{
memset(&p->dst_ip, 0, HostAddrSz);
}
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/net_aggr.h
^
|
@@ -1,6 +1,6 @@
/*
pmacct (Promiscuous mode IP Accounting package)
- pmacct is Copyright (C) 2003-2010 by Paolo Lucente
+ pmacct is Copyright (C) 2003-2013 by Paolo Lucente
*/
/*
@@ -24,6 +24,7 @@
#define NETWORKS6_CACHE_ENTRIES 32771
#define RETURN_NET 0
#define RETURN_AS 1
+#define NET_FUNCS_N 32
/* structures */
struct networks_cache_entry {
@@ -87,24 +88,26 @@
#else
#define EXT
#endif
-EXT net_func net_funcs[8];
+EXT net_func net_funcs[NET_FUNCS_N];
EXT void set_net_funcs();
EXT void mask_src_ipaddr(struct networks_table *, struct networks_cache *, struct pkt_primitives *);
EXT void mask_dst_ipaddr(struct networks_table *, struct networks_cache *, struct pkt_primitives *);
+EXT void mask_static_src_ipaddr(struct networks_table *, struct networks_cache *, struct pkt_primitives *);
+EXT void mask_static_dst_ipaddr(struct networks_table *, struct networks_cache *, struct pkt_primitives *);
EXT void copy_src_mask(struct networks_table *, struct networks_cache *, struct pkt_primitives *);
EXT void copy_dst_mask(struct networks_table *, struct networks_cache *, struct pkt_primitives *);
EXT void search_src_host(struct networks_table *, struct networks_cache *, struct pkt_primitives *);
EXT void search_dst_host(struct networks_table *, struct networks_cache *, struct pkt_primitives *);
-EXT void search_src_net(struct networks_table *, struct networks_cache *, struct pkt_primitives *);
-EXT void search_dst_net(struct networks_table *, struct networks_cache *, struct pkt_primitives *);
EXT void search_src_nmask(struct networks_table *, struct networks_cache *, struct pkt_primitives *);
EXT void search_dst_nmask(struct networks_table *, struct networks_cache *, struct pkt_primitives *);
EXT void search_src_as(struct networks_table *, struct networks_cache *, struct pkt_primitives *);
EXT void search_dst_as(struct networks_table *, struct networks_cache *, struct pkt_primitives *);
+EXT void clear_src_host(struct networks_table *, struct networks_cache *, struct pkt_primitives *);
+EXT void clear_dst_host(struct networks_table *, struct networks_cache *, struct pkt_primitives *);
+EXT void clear_src_nmask(struct networks_table *, struct networks_cache *, struct pkt_primitives *);
+EXT void clear_dst_nmask(struct networks_table *, struct networks_cache *, struct pkt_primitives *);
EXT as_t search_pretag_src_as(struct networks_table *, struct networks_cache *, struct packet_ptrs *);
EXT as_t search_pretag_dst_as(struct networks_table *, struct networks_cache *, struct packet_ptrs *);
-EXT void drop_src_host(struct networks_table *, struct networks_cache *, struct pkt_primitives *);
-EXT void drop_dst_host(struct networks_table *, struct networks_cache *, struct pkt_primitives *);
EXT void load_networks(char *, struct networks_table *, struct networks_cache *); /* wrapper */
EXT void load_networks4(char *, struct networks_table *, struct networks_cache *);
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/network.h
^
|
@@ -360,9 +360,14 @@
u_int8_t proto;
u_int32_t ifindex_in;
u_int32_t ifindex_out;
+#if defined (WITH_GEOIP)
+ pm_country_t src_ip_country;
+ pm_country_t dst_ip_country;
+#endif
pm_id_t id;
pm_id_t id2;
pm_class_t class;
+ u_int32_t sampling_rate;
};
struct pkt_data {
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/nfacctd.c
^
|
@@ -1,6 +1,6 @@
/*
pmacct (Promiscuous mode IP Accounting package)
- pmacct is Copyright (C) 2003-2012 by Paolo Lucente
+ pmacct is Copyright (C) 2003-2013 by Paolo Lucente
*/
/*
@@ -46,7 +46,7 @@
/* Functions */
void usage_daemon(char *prog_name)
{
- printf("%s\n", NFACCTD_USAGE_HEADER);
+ printf("%s (%s)\n", NFACCTD_USAGE_HEADER, PMACCT_BUILD);
printf("Usage: %s [ -D | -d ] [ -L IP address ] [ -l port ] [ -c primitive [ , ... ] ] [ -P plugin [ , ... ] ]\n", prog_name);
printf(" %s [ -f config_file ]\n", prog_name);
printf(" %s [ -h ]\n", prog_name);
@@ -55,11 +55,11 @@
printf(" -L \tBind to the specified IP address\n");
printf(" -l \tListen on the specified UDP port\n");
printf(" -f \tLoad configuration from the specified file\n");
- printf(" -c \t[ src_mac | dst_mac | vlan | src_host | dst_host | src_net | dst_net | src_port | dst_port |\n\t tos | proto | src_as | dst_as | sum_mac | sum_host | sum_net | sum_as | sum_port | tag |\n\t tag2 | flows | class | tcpflags | in_iface | out_iface | src_mask | dst_mask | cos | etype | none ] \n\tAggregation string (DEFAULT: src_host)\n");
+ printf(" -c \t[ src_mac | dst_mac | vlan | src_host | dst_host | src_net | dst_net | src_port | dst_port |\n\t tos | proto | src_as | dst_as | sum_mac | sum_host | sum_net | sum_as | sum_port | tag |\n\t tag2 | flows | class | tcpflags | in_iface | out_iface | src_mask | dst_mask | cos | etype |\n\t sampling_rate | src_host_country | dst_host_country | none ]\n\tAggregation string (DEFAULT: src_host)\n");
printf(" -D \tDaemonize\n");
printf(" -n \tPath to a file containing Network definitions\n");
printf(" -o \tPath to a file containing Port definitions\n");
- printf(" -P \t[ memory | print | mysql | pgsql | sqlite3 | tee ] \n\tActivate plugin\n");
+ printf(" -P \t[ memory | print | mysql | pgsql | sqlite3 | mongodb | tee ] \n\tActivate plugin\n");
printf(" -d \tEnable debug\n");
printf(" -S \t[ auth | mail | daemon | kern | user | local[0-7] ] \n\tLog to the specified syslog facility\n");
printf(" -F \tWrite Core Process PID into the specified file\n");
@@ -266,10 +266,6 @@
strlcpy(cfg_cmdline[rows], "sql_refresh_time: ", SRVBUFLEN);
strncat(cfg_cmdline[rows], optarg, CFG_LINE_LEN(cfg_cmdline[rows]));
rows++;
- cfg_cmdline[rows] = malloc(SRVBUFLEN);
- strlcpy(cfg_cmdline[rows], "print_refresh_time: ", SRVBUFLEN);
- strncat(cfg_cmdline[rows], optarg, CFG_LINE_LEN(cfg_cmdline[rows]));
- rows++;
break;
case 'v':
strlcpy(cfg_cmdline[rows], "sql_table_version: ", SRVBUFLEN);
@@ -378,17 +374,21 @@
else {
list->cfg.data_type = PIPE_TYPE_METADATA;
evaluate_sums(&list->cfg.what_to_count, list->name, list->type.string);
- if (!list->cfg.what_to_count) {
+ if (!list->cfg.what_to_count && !list->cfg.what_to_count_2) {
Log(LOG_WARNING, "WARN ( %s/%s ): defaulting to SRC HOST aggregation.\n", list->name, list->type.string);
list->cfg.what_to_count |= COUNT_SRC_HOST;
}
- if ((list->cfg.what_to_count & (COUNT_SRC_AS|COUNT_DST_AS|COUNT_SUM_AS)) && !list->cfg.networks_file && list->cfg.nfacctd_as & NF_AS_NEW) {
- Log(LOG_ERR, "ERROR ( %s/%s ): AS aggregation selected but NO 'networks_file' specified. Exiting...\n\n", list->name, list->type.string);
- exit(1);
- }
- if ((list->cfg.what_to_count & (COUNT_SRC_AS|COUNT_DST_AS|COUNT_SUM_AS)) && !list->cfg.nfacctd_bgp && list->cfg.nfacctd_as == NF_AS_BGP) {
- Log(LOG_ERR, "ERROR ( %s/%s ): AS aggregation selected but 'bgp_daemon' is not enabled. Exiting...\n\n", list->name, list->type.string);
- exit(1);
+ if (list->cfg.what_to_count & (COUNT_SRC_AS|COUNT_DST_AS|COUNT_SUM_AS)) {
+ if (!list->cfg.networks_file && list->cfg.nfacctd_as & NF_AS_NEW) {
+ Log(LOG_ERR, "ERROR ( %s/%s ): AS aggregation selected but NO 'networks_file' specified. Exiting...\n\n", list->name, list->type.string);
+ exit(1);
+ }
+ if (!list->cfg.nfacctd_bgp && list->cfg.nfacctd_as == NF_AS_BGP) {
+ Log(LOG_ERR, "ERROR ( %s/%s ): AS aggregation selected but 'bgp_daemon' is not enabled. Exiting...\n\n", list->name, list->type.string);
+ exit(1);
+ }
+ if (list->cfg.nfacctd_as & NF_AS_FALLBACK && list->cfg.networks_file)
+ list->cfg.nfacctd_as |= NF_AS_NEW;
}
if (list->cfg.what_to_count & (COUNT_SRC_NET|COUNT_DST_NET|COUNT_SUM_NET|COUNT_SRC_NMASK|COUNT_DST_NMASK|COUNT_PEER_DST_IP)) {
if (!list->cfg.nfacctd_net) {
@@ -404,6 +404,8 @@
Log(LOG_ERR, "ERROR ( %s/%s ): network aggregation selected but none of 'bgp_daemon', 'isis_daemon', 'networks_file', 'networks_mask' is specified. Exiting ...\n\n", list->name, list->type.string);
exit(1);
}
+ if (list->cfg.nfacctd_net & NF_NET_FALLBACK && list->cfg.networks_file)
+ list->cfg.nfacctd_net |= NF_NET_NEW;
}
}
@@ -413,6 +415,7 @@
list->cfg.what_to_count |= COUNT_COUNTERS;
}
}
+
list = list->next;
}
@@ -467,8 +470,8 @@
}
/* bind socket to port */
- rc = Setsocksize(config.sock, SOL_SOCKET, SO_REUSEADDR, (char *)&yes, sizeof(yes));
- if (rc < 0) Log(LOG_ERR, "WARN ( default/core ): Setsocksize() failed for SO_REUSEADDR.\n");
+ rc = setsockopt(config.sock, SOL_SOCKET, SO_REUSEADDR, (char *)&yes, sizeof(yes));
+ if (rc < 0) Log(LOG_ERR, "WARN ( default/core ): setsockopt() failed for SO_REUSEADDR.\n");
if (config.pipe_size) {
rc = Setsocksize(config.sock, SOL_SOCKET, SO_RCVBUF, &config.pipe_size, sizeof(config.pipe_size));
@@ -593,6 +596,12 @@
}
#endif
+#if defined WITH_GEOIP
+ if (config.geoip_ipv4_file || config.geoip_ipv6_file) {
+ req.bpf_filter = TRUE;
+ }
+#endif
+
rc = bind(config.sock, (struct sockaddr *) &server, slen);
if (rc < 0) {
Log(LOG_ERR, "ERROR ( default/core ): bind() to ip=%s port=%d/udp failed (errno: %d).\n", config.nfacctd_ip, config.nfacctd_port, errno);
@@ -1107,12 +1116,20 @@
process_flowset:
if (off+NfDataHdrV9Sz >= len) {
notify_malf_packet(LOG_INFO, "INFO: unable to read next Flowset; incomplete NetFlow v9/IPFIX packet",
- (struct sockaddr *) pptrsv->v4.f_agent);
+ (struct sockaddr *) pptrsv->v4.f_agent);
xflow_tot_bad_datagrams++;
return;
}
data_hdr = (struct data_hdr_v9 *)pkt;
+
+ if (data_hdr->flow_len == 0) {
+ notify_malf_packet(LOG_INFO, "INFO: unable to read next Flowset; NetFlow v9/IPFIX packet claiming flow_len 0!",
+ (struct sockaddr *) pptrsv->v4.f_agent);
+ xflow_tot_bad_datagrams++;
+ return;
+ }
+
fid = ntohs(data_hdr->flow_id);
if (fid == 0 || fid == 2) { /* template: 0 NetFlow v9, 2 IPFIX */
unsigned char *tpl_ptr = pkt;
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/nfprobe_plugin/netflow1.c
^
|
@@ -22,13 +22,13 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* $Id: netflow1.c,v 1.2 2009/11/29 13:45:52 paolo Exp $ */
+/* $Id: netflow1.c,v 1.3 2012/12/21 19:10:40 paolo Exp $ */
#include "common.h"
#include "treetype.h"
#include "nfprobe_plugin.h"
-RCSID("$Id: netflow1.c,v 1.2 2009/11/29 13:45:52 paolo Exp $");
+RCSID("$Id: netflow1.c,v 1.3 2012/12/21 19:10:40 paolo Exp $");
/*
* This is the Cisco Netflow(tm) version 1 packet format
@@ -87,8 +87,10 @@
errsz = sizeof(err);
getsockopt(nfsock, SOL_SOCKET, SO_ERROR,
&err, &errsz); /* Clear ICMP errors */
- if (send(nfsock, packet, (size_t)offset, 0) == -1)
- return (-1);
+ if (send(nfsock, packet, (size_t)offset, 0) == -1) {
+ Log(LOG_WARNING, "WARN ( %s/%s ): send() failed: %s\n", config.name, config.type, strerror(errno));
+ return (-1);
+ }
*flows_exported += j;
j = 0;
num_packets++;
@@ -163,8 +165,10 @@
errsz = sizeof(err);
getsockopt(nfsock, SOL_SOCKET, SO_ERROR,
&err, &errsz); /* Clear ICMP errors */
- if (send(nfsock, packet, (size_t)offset, 0) == -1)
- return (-1);
+ if (send(nfsock, packet, (size_t)offset, 0) == -1) {
+ Log(LOG_WARNING, "WARN ( %s/%s ): send() failed: %s\n", config.name, config.type, strerror(errno));
+ return (-1);
+ }
num_packets++;
}
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/nfprobe_plugin/netflow5.c
^
|
@@ -29,13 +29,13 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* $Id: netflow5.c,v 1.9 2012/04/10 14:53:22 paolo Exp $ */
+/* $Id: netflow5.c,v 1.10 2012/12/21 19:10:40 paolo Exp $ */
#include "common.h"
#include "treetype.h"
#include "nfprobe_plugin.h"
-RCSID("$Id: netflow5.c,v 1.9 2012/04/10 14:53:22 paolo Exp $");
+RCSID("$Id: netflow5.c,v 1.10 2012/12/21 19:10:40 paolo Exp $");
/*
* This is the Cisco Netflow(tm) version 5 packet format
@@ -93,8 +93,10 @@
errsz = sizeof(err);
getsockopt(nfsock, SOL_SOCKET, SO_ERROR,
&err, &errsz); /* Clear ICMP errors */
- if (send(nfsock, packet, (size_t)offset, 0) == -1)
- return (-1);
+ if (send(nfsock, packet, (size_t)offset, 0) == -1) {
+ Log(LOG_WARNING, "WARN ( %s/%s ): send() failed: %s\n", config.name, config.type, strerror(errno));
+ return (-1);
+ }
*flows_exported += j;
j = 0;
num_packets++;
@@ -203,8 +205,10 @@
errsz = sizeof(err);
getsockopt(nfsock, SOL_SOCKET, SO_ERROR,
&err, &errsz); /* Clear ICMP errors */
- if (send(nfsock, packet, (size_t)offset, 0) == -1)
- return (-1);
+ if (send(nfsock, packet, (size_t)offset, 0) == -1) {
+ Log(LOG_WARNING, "WARN ( %s/%s ): send() failed: %s\n", config.name, config.type, strerror(errno));
+ return (-1);
+ }
num_packets++;
}
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/nfprobe_plugin/netflow9.c
^
|
@@ -29,7 +29,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/* $Id: netflow9.c,v 1.23 2012/04/23 16:31:49 paolo Exp $ */
+/* $Id: netflow9.c,v 1.25 2012/12/21 19:10:40 paolo Exp $ */
#define __NFPROBE_NETFLOW9_C
@@ -412,7 +412,7 @@
* aggregation, then let's choose one. If we don't have one or
* more flow-distinguishing primitives, then let's add flow
* aggregation info to the template */
- if ( ! config.nfprobe_what_to_count ) {
+ if (!config.nfprobe_what_to_count && !config.nfprobe_what_to_count_2) {
config.nfprobe_what_to_count |= COUNT_SRC_HOST;
config.nfprobe_what_to_count |= COUNT_DST_HOST;
config.nfprobe_what_to_count |= COUNT_SRC_PORT;
@@ -1655,8 +1655,10 @@
errsz = sizeof(err);
/* Clear ICMP errors */
getsockopt(nfsock, SOL_SOCKET, SO_ERROR, &err, &errsz);
- if (send(nfsock, packet, (size_t)offset, 0) == -1)
- return (-1);
+ if (send(nfsock, packet, (size_t)offset, 0) == -1) {
+ Log(LOG_WARNING, "WARN ( %s/%s ): send() failed: %s\n", config.name, config.type, strerror(errno));
+ return (-1);
+ }
num_packets++;
nf9_pkts_until_template--;
}
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/nfprobe_plugin/nfprobe_plugin.c
^
|
@@ -1,6 +1,6 @@
/*
pmacct (Promiscuous mode IP Accounting package)
- pmacct is Copyright (C) 2003-2012 by Paolo Lucente
+ pmacct is Copyright (C) 2003-2013 by Paolo Lucente
*/
/*
@@ -1509,6 +1509,7 @@
/* Let's try to sleep a bit and re-open the NetFlow send socket */
if (dest.ss_family != 0) {
+ if (target.fd != -1) close(target.fd);
sleep(5);
target.fd = connsock(&dest, dest_len, hoplimit);
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/pgsql_plugin.c
^
|
@@ -1,6 +1,6 @@
/*
pmacct (Promiscuous mode IP Accounting package)
- pmacct is Copyright (C) 2003-2012 by Paolo Lucente
+ pmacct is Copyright (C) 2003-2013 by Paolo Lucente
*/
/*
@@ -97,7 +97,7 @@
for(;;) {
poll_again:
status->wakeup = TRUE;
- sql_calc_refresh_timeout(refresh_deadline, idata.now, &timeout);
+ calc_refresh_timeout(refresh_deadline, idata.now, &timeout);
ret = poll(&pfd, 1, timeout);
if (ret < 0) goto poll_again;
@@ -442,6 +442,11 @@
char tmpbuf[LONGLONGSRVBUFLEN];
time_t stamp = idata->new_basetime ? idata->new_basetime : idata->basetime;
+ handle_dynname_internal_strings_same(tmpbuf, LONGSRVBUFLEN, copy_clause);
+ handle_dynname_internal_strings_same(tmpbuf, LONGSRVBUFLEN, insert_clause);
+ handle_dynname_internal_strings_same(tmpbuf, LONGSRVBUFLEN, update_clause);
+ handle_dynname_internal_strings_same(tmpbuf, LONGSRVBUFLEN, lock_clause);
+
strftime_same(copy_clause, LONGSRVBUFLEN, tmpbuf, &stamp);
strftime_same(insert_clause, LONGSRVBUFLEN, tmpbuf, &stamp);
strftime_same(update_clause, LONGSRVBUFLEN, tmpbuf, &stamp);
@@ -885,7 +890,7 @@
else config.sql_table = pgsql_table_uni;
}
}
- if (strchr(config.sql_table, '%')) idata->dyn_table = TRUE;
+ if (strchr(config.sql_table, '%') || strchr(config.sql_table, '$')) idata->dyn_table = TRUE;
glob_dyn_table = idata->dyn_table;
if (config.sql_backup_host || config.sql_recovery_logfile) idata->recover = TRUE;
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/pkt_handlers.c
^
|
@@ -1,6 +1,6 @@
/*
pmacct (Promiscuous mode IP Accounting package)
- pmacct is Copyright (C) 2003-2012 by Paolo Lucente
+ pmacct is Copyright (C) 2003-2013 by Paolo Lucente
*/
/*
@@ -81,71 +81,63 @@
#endif
if (channels_list[index].aggregation & (COUNT_SRC_HOST|COUNT_SRC_NET|COUNT_SUM_HOST|COUNT_SUM_NET)) {
- if (channels_list[index].aggregation & (COUNT_SRC_NET|COUNT_SUM_NET)) {
- if (channels_list[index].plugin->cfg.nfacctd_net & NF_NET_BGP) {
- channels_list[index].phandler[primitives] = bgp_src_net_handler;
- primitives++;
- }
+ /* always copy the host */
+ if (config.acct_type == ACCT_PM) channels_list[index].phandler[primitives] = src_host_handler;
+ else if (config.acct_type == ACCT_NF) channels_list[index].phandler[primitives] = NF_src_host_handler;
+ else if (config.acct_type == ACCT_SF) channels_list[index].phandler[primitives] = SF_src_host_handler;
+ primitives++;
- if (channels_list[index].plugin->cfg.nfacctd_net & NF_NET_IGP) {
- channels_list[index].phandler[primitives] = igp_src_net_handler;
- primitives++;
- }
+ /* optionally copy mask */
+ if (channels_list[index].aggregation & (COUNT_SRC_NET|COUNT_SUM_NET)) {
+ if (!(channels_list[index].aggregation & COUNT_SRC_NMASK)) {
+ if (channels_list[index].plugin->cfg.nfacctd_net & NF_NET_BGP) {
+ channels_list[index].phandler[primitives] = bgp_src_nmask_handler;
+ primitives++;
+ }
- if (channels_list[index].plugin->cfg.nfacctd_net & NF_NET_KEEP) {
- if (config.acct_type == ACCT_NF) channels_list[index].phandler[primitives] = NF_src_host_handler;
- else if (config.acct_type == ACCT_SF) channels_list[index].phandler[primitives] = SF_src_host_handler;
- else primitives--; /* Just in case */
- primitives++;
- }
+ if (channels_list[index].plugin->cfg.nfacctd_net & NF_NET_IGP) {
+ channels_list[index].phandler[primitives] = igp_src_nmask_handler;
+ primitives++;
+ }
- if (channels_list[index].plugin->cfg.nfacctd_net & (NF_NET_COMPAT|NF_NET_NEW|NF_NET_STATIC)) {
- if (config.acct_type == ACCT_PM) channels_list[index].phandler[primitives] = src_host_handler;
- else if (config.acct_type == ACCT_NF) channels_list[index].phandler[primitives] = NF_src_host_handler;
- else if (config.acct_type == ACCT_SF) channels_list[index].phandler[primitives] = SF_src_host_handler;
- primitives++;
+ if (channels_list[index].plugin->cfg.nfacctd_net & NF_NET_KEEP) {
+ if (config.acct_type == ACCT_NF) channels_list[index].phandler[primitives] = NF_src_nmask_handler;
+ else if (config.acct_type == ACCT_SF) channels_list[index].phandler[primitives] = SF_src_nmask_handler;
+ else primitives--; /* Just in case */
+ primitives++;
+ }
}
}
- else {
- if (config.acct_type == ACCT_PM) channels_list[index].phandler[primitives] = src_host_handler;
- else if (config.acct_type == ACCT_NF) channels_list[index].phandler[primitives] = NF_src_host_handler;
- else if (config.acct_type == ACCT_SF) channels_list[index].phandler[primitives] = SF_src_host_handler;
- primitives++;
- }
}
if (channels_list[index].aggregation & (COUNT_DST_HOST|COUNT_DST_NET|COUNT_SUM_HOST|COUNT_SUM_NET)) {
- if (channels_list[index].aggregation & (COUNT_DST_NET|COUNT_SUM_NET)) {
- if (channels_list[index].plugin->cfg.nfacctd_net & NF_NET_BGP) {
- channels_list[index].phandler[primitives] = bgp_dst_net_handler;
- primitives++;
- }
+ /* always copy the host */
+ if (config.acct_type == ACCT_PM) channels_list[index].phandler[primitives] = dst_host_handler;
+ else if (config.acct_type == ACCT_NF) channels_list[index].phandler[primitives] = NF_dst_host_handler;
+ else if (config.acct_type == ACCT_SF) channels_list[index].phandler[primitives] = SF_dst_host_handler;
+ primitives++;
- if (channels_list[index].plugin->cfg.nfacctd_net & NF_NET_IGP) {
- channels_list[index].phandler[primitives] = igp_dst_net_handler;
- primitives++;
- }
+ /* optionally copy mask */
+ if (channels_list[index].aggregation & (COUNT_DST_NET|COUNT_SUM_NET)) {
+ if (!(channels_list[index].aggregation & COUNT_DST_NMASK)) {
+ if (channels_list[index].plugin->cfg.nfacctd_net & NF_NET_BGP) {
+ channels_list[index].phandler[primitives] = bgp_dst_nmask_handler;
+ primitives++;
+ }
- if (channels_list[index].plugin->cfg.nfacctd_net & NF_NET_KEEP) {
- if (config.acct_type == ACCT_NF) channels_list[index].phandler[primitives] = NF_dst_host_handler;
- else if (config.acct_type == ACCT_SF) channels_list[index].phandler[primitives] = SF_dst_host_handler;
- else primitives--; /* Just in case */
- primitives++;
- }
+ if (channels_list[index].plugin->cfg.nfacctd_net & NF_NET_IGP) {
+ channels_list[index].phandler[primitives] = igp_dst_nmask_handler;
+ primitives++;
+ }
- if (channels_list[index].plugin->cfg.nfacctd_net & (NF_NET_COMPAT|NF_NET_NEW|NF_NET_STATIC)) {
- if (config.acct_type == ACCT_PM) channels_list[index].phandler[primitives] = dst_host_handler;
- else if (config.acct_type == ACCT_NF) channels_list[index].phandler[primitives] = NF_dst_host_handler;
- else if (config.acct_type == ACCT_SF) channels_list[index].phandler[primitives] = SF_dst_host_handler;
- primitives++;
+ if (channels_list[index].plugin->cfg.nfacctd_net & NF_NET_KEEP) {
+ if (config.acct_type == ACCT_NF) channels_list[index].phandler[primitives] = NF_dst_nmask_handler;
+ else if (config.acct_type == ACCT_SF) channels_list[index].phandler[primitives] = SF_dst_nmask_handler;
+ else primitives--; /* Just in case */
+ primitives++;
+ }
}
}
- else {
- if (config.acct_type == ACCT_PM) channels_list[index].phandler[primitives] = dst_host_handler;
- else if (config.acct_type == ACCT_NF) channels_list[index].phandler[primitives] = NF_dst_host_handler;
- else if (config.acct_type == ACCT_SF) channels_list[index].phandler[primitives] = SF_dst_host_handler;
- primitives++;
- }
}
if (channels_list[index].aggregation & COUNT_SRC_NMASK) {
@@ -165,6 +157,15 @@
else primitives--; /* Just in case */
primitives++;
}
+
+ if (channels_list[index].plugin->cfg.nfacctd_net & (NF_NET_COMPAT|NF_NET_NEW)) {
+ if (!(channels_list[index].aggregation & (COUNT_SRC_HOST|COUNT_SRC_NET|COUNT_SUM_HOST|COUNT_SUM_NET))) {
+ if (config.acct_type == ACCT_PM) channels_list[index].phandler[primitives] = src_host_handler;
+ else if (config.acct_type == ACCT_NF) channels_list[index].phandler[primitives] = NF_src_host_handler;
+ else if (config.acct_type == ACCT_SF) channels_list[index].phandler[primitives] = SF_src_host_handler;
+ primitives++;
+ }
+ }
}
if (channels_list[index].aggregation & COUNT_DST_NMASK) {
@@ -184,44 +185,89 @@
else primitives--; /* Just in case */
primitives++;
}
+
+ if (channels_list[index].plugin->cfg.nfacctd_net & (NF_NET_COMPAT|NF_NET_NEW)) {
+ if (!(channels_list[index].aggregation & (COUNT_DST_HOST|COUNT_DST_NET|COUNT_SUM_HOST|COUNT_SUM_NET))) {
+ if (config.acct_type == ACCT_PM) channels_list[index].phandler[primitives] = dst_host_handler;
+ else if (config.acct_type == ACCT_NF) channels_list[index].phandler[primitives] = NF_dst_host_handler;
+ else if (config.acct_type == ACCT_SF) channels_list[index].phandler[primitives] = SF_dst_host_handler;
+ primitives++;
+ }
+ }
}
if (channels_list[index].aggregation & (COUNT_SRC_AS|COUNT_SUM_AS)) {
- if (config.acct_type == ACCT_PM) {
- if (config.nfacctd_as & NF_AS_KEEP) channels_list[index].phandler[primitives] = src_host_handler;
- else if (config.nfacctd_as & NF_AS_NEW) channels_list[index].phandler[primitives] = src_host_handler;
- else if (config.nfacctd_as & NF_AS_BGP) primitives--; /* This is handled elsewhere */
- }
- else if (config.acct_type == ACCT_NF) {
- if (config.nfacctd_as & NF_AS_KEEP) channels_list[index].phandler[primitives] = NF_src_as_handler;
- else if (config.nfacctd_as & NF_AS_NEW) channels_list[index].phandler[primitives] = NF_src_host_handler;
- else if (config.nfacctd_as & NF_AS_BGP) primitives--; /* This is handled elsewhere */
+ if (channels_list[index].plugin->cfg.nfacctd_as & NF_AS_KEEP) {
+ if (config.acct_type == ACCT_PM) channels_list[index].phandler[primitives] = src_host_handler;
+ else if (config.acct_type == ACCT_NF) channels_list[index].phandler[primitives] = NF_src_as_handler;
+ else if (config.acct_type == ACCT_SF) channels_list[index].phandler[primitives] = SF_src_as_handler;
+ primitives++;
}
- else if (config.acct_type == ACCT_SF) {
- if (config.nfacctd_as & NF_AS_KEEP) channels_list[index].phandler[primitives] = SF_src_as_handler;
- else if (config.nfacctd_as & NF_AS_NEW) channels_list[index].phandler[primitives] = SF_src_host_handler;
- else if (config.nfacctd_as & NF_AS_BGP) primitives--; /* This is handled elsewhere */
+
+ if (channels_list[index].plugin->cfg.nfacctd_as & NF_AS_NEW) {
+ if (!(channels_list[index].aggregation & (COUNT_SRC_HOST|COUNT_SRC_NET|COUNT_SUM_HOST|COUNT_SUM_NET))) {
+ if (config.acct_type == ACCT_PM) channels_list[index].phandler[primitives] = src_host_handler;
+ else if (config.acct_type == ACCT_NF) channels_list[index].phandler[primitives] = NF_src_host_handler;
+ else if (config.acct_type == ACCT_SF) channels_list[index].phandler[primitives] = SF_src_host_handler;
+ primitives++;
+ }
+
+ if (!(channels_list[index].aggregation & COUNT_SRC_NMASK)) {
+ if (channels_list[index].plugin->cfg.nfacctd_net & NF_NET_BGP) {
+ channels_list[index].phandler[primitives] = bgp_src_nmask_handler;
+ primitives++;
+ }
+
+ if (channels_list[index].plugin->cfg.nfacctd_net & NF_NET_IGP) {
+ channels_list[index].phandler[primitives] = igp_src_nmask_handler;
+ primitives++;
+ }
+
+ if (channels_list[index].plugin->cfg.nfacctd_net & NF_NET_KEEP) {
+ if (config.acct_type == ACCT_NF) channels_list[index].phandler[primitives] = NF_src_nmask_handler;
+ else if (config.acct_type == ACCT_SF) channels_list[index].phandler[primitives] = SF_src_nmask_handler;
+ else primitives--; /* Just in case */
+ primitives++;
+ }
+ }
}
- primitives++;
}
if (channels_list[index].aggregation & (COUNT_DST_AS|COUNT_SUM_AS)) {
- if (config.acct_type == ACCT_PM) {
- if (config.nfacctd_as & NF_AS_KEEP) channels_list[index].phandler[primitives] = dst_host_handler;
- else if (config.nfacctd_as & NF_AS_NEW) channels_list[index].phandler[primitives] = dst_host_handler;
- else if (config.nfacctd_as & NF_AS_BGP) primitives--; /* This is handled elsewhere */
- }
- else if (config.acct_type == ACCT_NF) {
- if (config.nfacctd_as & NF_AS_KEEP) channels_list[index].phandler[primitives] = NF_dst_as_handler;
- else if (config.nfacctd_as & NF_AS_NEW) channels_list[index].phandler[primitives] = NF_dst_host_handler;
- else if (config.nfacctd_as & NF_AS_BGP) primitives--; /* This is handled elsewhere */
+ if (channels_list[index].plugin->cfg.nfacctd_as & NF_AS_KEEP) {
+ if (config.acct_type == ACCT_PM) channels_list[index].phandler[primitives] = dst_host_handler;
+ else if (config.acct_type == ACCT_NF) channels_list[index].phandler[primitives] = NF_dst_as_handler;
+ else if (config.acct_type == ACCT_SF) channels_list[index].phandler[primitives] = SF_dst_as_handler;
+ primitives++;
}
- else if (config.acct_type == ACCT_SF) {
- if (config.nfacctd_as & NF_AS_KEEP) channels_list[index].phandler[primitives] = SF_dst_as_handler;
- else if (config.nfacctd_as & NF_AS_NEW) channels_list[index].phandler[primitives] = SF_dst_host_handler;
- else if (config.nfacctd_as & NF_AS_BGP) primitives--; /* This is handled elsewhere */
+
+ if (channels_list[index].plugin->cfg.nfacctd_as & NF_AS_NEW) {
+ if (!(channels_list[index].aggregation & (COUNT_DST_HOST|COUNT_DST_NET|COUNT_SUM_HOST|COUNT_SUM_NET))) {
+ if (config.acct_type == ACCT_PM) channels_list[index].phandler[primitives] = dst_host_handler;
+ else if (config.acct_type == ACCT_NF) channels_list[index].phandler[primitives] = NF_dst_host_handler;
+ else if (config.acct_type == ACCT_SF) channels_list[index].phandler[primitives] = SF_dst_host_handler;
+ primitives++;
+ }
+
+ if (!(channels_list[index].aggregation & COUNT_DST_NMASK)) {
+ if (channels_list[index].plugin->cfg.nfacctd_net & NF_NET_BGP) {
+ channels_list[index].phandler[primitives] = bgp_dst_nmask_handler;
+ primitives++;
+ }
+
+ if (channels_list[index].plugin->cfg.nfacctd_net & NF_NET_IGP) {
+ channels_list[index].phandler[primitives] = igp_dst_nmask_handler;
+ primitives++;
+ }
+
+ if (channels_list[index].plugin->cfg.nfacctd_net & NF_NET_KEEP) {
+ if (config.acct_type == ACCT_NF) channels_list[index].phandler[primitives] = NF_dst_nmask_handler;
+ else if (config.acct_type == ACCT_SF) channels_list[index].phandler[primitives] = SF_dst_nmask_handler;
+ else primitives--; /* Just in case */
+ primitives++;
+ }
+ }
}
- primitives++;
}
if (channels_list[index].aggregation & COUNT_PEER_SRC_IP) {
@@ -261,13 +307,13 @@
if (channels_list[index].aggregation & COUNT_PEER_SRC_AS) {
if (config.acct_type == ACCT_NF) {
- if (config.nfacctd_as & NF_AS_KEEP && config.nfacctd_bgp_peer_as_src_type & BGP_SRC_PRIMITIVES_KEEP) {
+ if (channels_list[index].plugin->cfg.nfacctd_as & NF_AS_KEEP && config.nfacctd_bgp_peer_as_src_type & BGP_SRC_PRIMITIVES_KEEP) {
channels_list[index].phandler[primitives] = NF_peer_src_as_handler;
primitives++;
}
}
else if (config.acct_type == ACCT_SF) {
- if (config.nfacctd_as & NF_AS_KEEP && config.nfacctd_bgp_peer_as_src_type & BGP_SRC_PRIMITIVES_KEEP) {
+ if (channels_list[index].plugin->cfg.nfacctd_as & NF_AS_KEEP && config.nfacctd_bgp_peer_as_src_type & BGP_SRC_PRIMITIVES_KEEP) {
channels_list[index].phandler[primitives] = SF_peer_src_as_handler;
primitives++;
}
@@ -276,13 +322,13 @@
if (channels_list[index].aggregation & COUNT_PEER_DST_AS) {
if (config.acct_type == ACCT_NF) {
- if (config.nfacctd_as & NF_AS_KEEP) {
+ if (channels_list[index].plugin->cfg.nfacctd_as & NF_AS_KEEP) {
channels_list[index].phandler[primitives] = NF_peer_dst_as_handler;
primitives++;
}
}
else if (config.acct_type == ACCT_SF) {
- if (config.nfacctd_as & NF_AS_KEEP) {
+ if (channels_list[index].plugin->cfg.nfacctd_as & NF_AS_KEEP) {
channels_list[index].phandler[primitives] = SF_peer_dst_as_handler;
primitives++;
}
@@ -291,7 +337,7 @@
if (channels_list[index].aggregation & COUNT_LOCAL_PREF) {
if (config.acct_type == ACCT_SF) {
- if (config.nfacctd_as & NF_AS_KEEP) {
+ if (channels_list[index].plugin->cfg.nfacctd_as & NF_AS_KEEP) {
channels_list[index].phandler[primitives] = SF_local_pref_handler;
primitives++;
}
@@ -300,7 +346,7 @@
if (channels_list[index].aggregation & COUNT_STD_COMM) {
if (config.acct_type == ACCT_SF) {
- if (config.nfacctd_as & NF_AS_KEEP) {
+ if (channels_list[index].plugin->cfg.nfacctd_as & NF_AS_KEEP) {
channels_list[index].phandler[primitives] = SF_std_comms_handler;
primitives++;
}
@@ -311,7 +357,7 @@
COUNT_AS_PATH|COUNT_PEER_DST_AS|COUNT_SRC_AS_PATH|COUNT_SRC_STD_COMM|
COUNT_SRC_EXT_COMM|COUNT_SRC_MED|COUNT_SRC_LOCAL_PREF|COUNT_SRC_AS|
COUNT_DST_AS|COUNT_PEER_SRC_AS|COUNT_MPLS_VPN_RD) &&
- config.nfacctd_as & NF_AS_BGP) {
+ channels_list[index].plugin->cfg.nfacctd_as & NF_AS_BGP) {
if (config.acct_type == ACCT_PM && config.nfacctd_bgp) {
if (channels_list[index].plugin->type.id == PLUGIN_ID_SFPROBE) {
channels_list[index].phandler[primitives] = sfprobe_bgp_ext_handler;
@@ -460,6 +506,25 @@
primitives++;
}
+ if (channels_list[index].aggregation_2 & COUNT_SAMPLING_RATE) {
+ if (config.acct_type == ACCT_PM) channels_list[index].phandler[primitives] = sampling_rate_handler;
+ else if (config.acct_type == ACCT_NF) channels_list[index].phandler[primitives] = NF_sampling_rate_handler;
+ else if (config.acct_type == ACCT_SF) channels_list[index].phandler[primitives] = SF_sampling_rate_handler;
+ primitives++;
+ }
+
+#if defined (WITH_GEOIP)
+ if (channels_list[index].aggregation_2 & COUNT_SRC_HOST_COUNTRY) {
+ channels_list[index].phandler[primitives] = src_host_country_handler;
+ primitives++;
+ }
+
+ if (channels_list[index].aggregation_2 & COUNT_DST_HOST_COUNTRY) {
+ channels_list[index].phandler[primitives] = dst_host_country_handler;
+ primitives++;
+ }
+#endif
+
if (channels_list[index].aggregation & COUNT_COUNTERS) {
if (config.acct_type == ACCT_PM) {
channels_list[index].phandler[primitives] = counters_handler;
@@ -633,54 +698,6 @@
}
#endif
-void bgp_src_net_handler(struct channels_list_entry *chptr, struct packet_ptrs *pptrs, char **data)
-{
- struct pkt_data *pdata = (struct pkt_data *) *data;
- struct bgp_node *ret = (struct bgp_node *) pptrs->bgp_src;
-
- /* check network-related primitives against fallback scenarios */
- if (!evaluate_lm_method(pptrs, FALSE, chptr->plugin->cfg.nfacctd_net, NF_NET_BGP)) return;
-
- if (pptrs->l3_proto == ETHERTYPE_IP) {
- if (ret) {
- memcpy(&pdata->primitives.src_ip.address.ipv4, &ret->p.u.prefix4, 4);
- pdata->primitives.src_ip.family = AF_INET;
- }
- }
-#if defined ENABLE_IPV6
- else if (pptrs->l3_proto == ETHERTYPE_IPV6) {
- if (ret) {
- memcpy(&pdata->primitives.src_ip.address.ipv6, &ret->p.u.prefix6, 16);
- pdata->primitives.src_ip.family = AF_INET6;
- }
- }
-#endif
-}
-
-void bgp_dst_net_handler(struct channels_list_entry *chptr, struct packet_ptrs *pptrs, char **data)
-{
- struct pkt_data *pdata = (struct pkt_data *) *data;
- struct bgp_node *ret = (struct bgp_node *) pptrs->bgp_dst;
-
- /* check network-related primitives against fallback scenarios */
- if (!evaluate_lm_method(pptrs, TRUE, chptr->plugin->cfg.nfacctd_net, NF_NET_BGP)) return;
-
- if (pptrs->l3_proto == ETHERTYPE_IP) {
- if (ret) {
- memcpy(&pdata->primitives.dst_ip.address.ipv4, &ret->p.u.prefix4, 4);
- pdata->primitives.dst_ip.family = AF_INET;
- }
- }
-#if defined ENABLE_IPV6
- else if (pptrs->l3_proto == ETHERTYPE_IPV6) {
- if (ret) {
- memcpy(&pdata->primitives.dst_ip.address.ipv6, &ret->p.u.prefix6, 16);
- pdata->primitives.dst_ip.family = AF_INET6;
- }
- }
-#endif
-}
-
void bgp_src_nmask_handler(struct channels_list_entry *chptr, struct packet_ptrs *pptrs, char **data)
{
struct pkt_data *pdata = (struct pkt_data *) *data;
@@ -738,54 +755,6 @@
}
}
-void igp_src_net_handler(struct channels_list_entry *chptr, struct packet_ptrs *pptrs, char **data)
-{
- struct pkt_data *pdata = (struct pkt_data *) *data;
- struct route_node *ret = (struct route_node *) pptrs->igp_src;
-
- /* check network-related primitives against fallback scenarios */
- if (!evaluate_lm_method(pptrs, FALSE, chptr->plugin->cfg.nfacctd_net, NF_NET_IGP)) return;
-
- if (pptrs->l3_proto == ETHERTYPE_IP) {
- if (ret) {
- memcpy(&pdata->primitives.src_ip.address.ipv4, &ret->p.u.prefix4, 4);
- pdata->primitives.src_ip.family = AF_INET;
- }
- }
-#if defined ENABLE_IPV6
- else if (pptrs->l3_proto == ETHERTYPE_IPV6) {
- if (ret) {
- memcpy(&pdata->primitives.src_ip.address.ipv6, &ret->p.u.prefix6, 16);
- pdata->primitives.src_ip.family = AF_INET6;
- }
- }
-#endif
-}
-
-void igp_dst_net_handler(struct channels_list_entry *chptr, struct packet_ptrs *pptrs, char **data)
-{
- struct pkt_data *pdata = (struct pkt_data *) *data;
- struct route_node *ret = (struct route_node *) pptrs->igp_dst;
-
- /* check network-related primitives against fallback scenarios */
- if (!evaluate_lm_method(pptrs, TRUE, chptr->plugin->cfg.nfacctd_net, NF_NET_IGP)) return;
-
- if (pptrs->l3_proto == ETHERTYPE_IP) {
- if (ret) {
- memcpy(&pdata->primitives.dst_ip.address.ipv4, &ret->p.u.prefix4, 4);
- pdata->primitives.dst_ip.family = AF_INET;
- }
- }
-#if defined ENABLE_IPV6
- else if (pptrs->l3_proto == ETHERTYPE_IPV6) {
- if (ret) {
- memcpy(&pdata->primitives.dst_ip.address.ipv6, &ret->p.u.prefix6, 16);
- pdata->primitives.dst_ip.family = AF_INET6;
- }
- }
-#endif
-}
-
void igp_src_nmask_handler(struct channels_list_entry *chptr, struct packet_ptrs *pptrs, char **data)
{
struct pkt_data *pdata = (struct pkt_data *) *data;
@@ -1074,6 +1043,18 @@
if (pptrs->ifindex_out > 0) pdata->primitives.ifindex_out = pptrs->ifindex_out;
}
+void sampling_rate_handler(struct channels_list_entry *chptr, struct packet_ptrs *pptrs, char **data)
+{
+ struct pkt_data *pdata = (struct pkt_data *) *data;
+
+ if (config.sfacctd_renormalize) {
+ pdata->primitives.sampling_rate = 1; /* already renormalized */
+ return;
+ }
+
+ pdata->primitives.sampling_rate = config.ext_sampling_rate ? config.ext_sampling_rate : 1;
+}
+
#if defined (HAVE_L2)
void NF_src_mac_handler(struct channels_list_entry *chptr, struct packet_ptrs *pptrs, char **data)
{
@@ -1167,9 +1148,6 @@
struct template_cache_entry *tpl = (struct template_cache_entry *) pptrs->f_tpl;
u_int8_t src_mask = 0;
- /* check network-related primitives against fallback scenarios */
- if (chptr->aggregation & (COUNT_SRC_NET|COUNT_SUM_NET) && !evaluate_lm_method(pptrs, FALSE, chptr->plugin->cfg.nfacctd_net, NF_NET_KEEP)) return;
-
switch(hdr->version) {
case 10:
case 9:
@@ -1178,18 +1156,13 @@
memcpy(&pdata->primitives.src_ip.address.ipv4, pptrs->f_data+tpl->tpl[NF9_ASA_XLATE_IPV4_SRC_ADDR].off, MIN(tpl->tpl[NF9_ASA_XLATE_IPV4_SRC_ADDR].len, 4));
src_mask = 32; /* no xlate mask field exists atm */
}
- else {
- memcpy(&pdata->primitives.src_ip.address.ipv4, pptrs->f_data+tpl->tpl[NF9_IPV4_SRC_ADDR].off, MIN(tpl->tpl[NF9_IPV4_SRC_ADDR].len, 4));
- memcpy(&src_mask, pptrs->f_data+tpl->tpl[NF9_SRC_MASK].off, tpl->tpl[NF9_SRC_MASK].len);
- }
+ else memcpy(&pdata->primitives.src_ip.address.ipv4, pptrs->f_data+tpl->tpl[NF9_IPV4_SRC_ADDR].off, MIN(tpl->tpl[NF9_IPV4_SRC_ADDR].len, 4));
pdata->primitives.src_ip.family = AF_INET;
break;
}
#if defined ENABLE_IPV6
if (pptrs->l3_proto == ETHERTYPE_IPV6) {
memcpy(&pdata->primitives.src_ip.address.ipv6, pptrs->f_data+tpl->tpl[NF9_IPV6_SRC_ADDR].off, MIN(tpl->tpl[NF9_IPV6_SRC_ADDR].len, 16));
- memcpy(&src_mask, pptrs->f_data+tpl->tpl[NF9_IPV6_SRC_MASK].off, tpl->tpl[NF9_IPV6_SRC_MASK].len);
-
pdata->primitives.src_ip.family = AF_INET6;
break;
}
@@ -1199,12 +1172,10 @@
switch(hdr->aggregation) {
case 3:
pdata->primitives.src_ip.address.ipv4.s_addr = ((struct struct_export_v8_3 *) pptrs->f_data)->src_prefix;
- src_mask = ((struct struct_export_v8_3 *) pptrs->f_data)->src_mask;
pdata->primitives.src_ip.family = AF_INET;
break;
case 5:
pdata->primitives.src_ip.address.ipv4.s_addr = ((struct struct_export_v8_5 *) pptrs->f_data)->src_prefix;
- src_mask = ((struct struct_export_v8_5 *) pptrs->f_data)->src_mask;
pdata->primitives.src_ip.family = AF_INET;
break;
case 7:
@@ -1217,17 +1188,14 @@
break;
case 11:
pdata->primitives.src_ip.address.ipv4.s_addr = ((struct struct_export_v8_11 *) pptrs->f_data)->src_prefix;
- src_mask = ((struct struct_export_v8_11 *) pptrs->f_data)->src_mask;
pdata->primitives.src_ip.family = AF_INET;
break;
case 13:
pdata->primitives.src_ip.address.ipv4.s_addr = ((struct struct_export_v8_13 *) pptrs->f_data)->src_prefix;
- src_mask = ((struct struct_export_v8_13 *) pptrs->f_data)->src_mask;
pdata->primitives.src_ip.family = AF_INET;
break;
case 14:
pdata->primitives.src_ip.address.ipv4.s_addr = ((struct struct_export_v8_14 *) pptrs->f_data)->src_prefix;
- src_mask = ((struct struct_export_v8_14 *) pptrs->f_data)->src_mask;
pdata->primitives.src_ip.family = AF_INET;
break;
default:
@@ -1238,32 +1206,9 @@
break;
default:
pdata->primitives.src_ip.address.ipv4.s_addr = ((struct struct_export_v5 *) pptrs->f_data)->srcaddr.s_addr;
- src_mask = ((struct struct_export_v5 *) pptrs->f_data)->src_mask;
pdata->primitives.src_ip.family = AF_INET;
break;
}
-
- if ((chptr->aggregation & (COUNT_SRC_NET|COUNT_SUM_NET)) && chptr->plugin->cfg.nfacctd_net & NF_NET_KEEP) {
- u_int32_t maskbits[4], addrh[4];
- u_int8_t j;
-
- memset(maskbits, 0,sizeof(maskbits));
- for (j = 0; j < 4 && src_mask >= 32; j++, src_mask -= 32) maskbits[j] = 0xffffffffU;
- if (j < 4 && src_mask) maskbits[j] = ~(0xffffffffU >> src_mask);
-
- if (pdata->primitives.src_ip.family == AF_INET) {
- addrh[0] = ntohl(pdata->primitives.src_ip.address.ipv4.s_addr);
- addrh[0] &= maskbits[0];
- pdata->primitives.src_ip.address.ipv4.s_addr = htonl(addrh[0]);
- }
-#if defined ENABLE_IPV6
- else if (pdata->primitives.src_ip.family == AF_INET6) {
- memcpy(&addrh, (void *) pm_ntohl6(&pdata->primitives.src_ip.address.ipv6), IP6AddrSz);
- for (j = 0; j < 4; j++) addrh[j] &= maskbits[j];
- memcpy(&pdata->primitives.src_ip.address.ipv6, (void *) pm_htonl6(addrh), IP6AddrSz);
- }
-#endif
- }
}
void NF_dst_host_handler(struct channels_list_entry *chptr, struct packet_ptrs *pptrs, char **data)
@@ -1273,9 +1218,6 @@
struct template_cache_entry *tpl = (struct template_cache_entry *) pptrs->f_tpl;
u_int8_t dst_mask = 0;
- /* check network-related primitives against fallback scenarios */
- if (chptr->aggregation & (COUNT_DST_NET|COUNT_SUM_NET) && !evaluate_lm_method(pptrs, TRUE, chptr->plugin->cfg.nfacctd_net, NF_NET_KEEP)) return;
-
switch(hdr->version) {
case 10:
case 9:
@@ -1284,10 +1226,7 @@
memcpy(&pdata->primitives.dst_ip.address.ipv4, pptrs->f_data+tpl->tpl[NF9_ASA_XLATE_IPV4_DST_ADDR].off, MIN(tpl->tpl[NF9_ASA_XLATE_IPV4_DST_ADDR].len, 4));
dst_mask = 32; /* no xlate mask field exists atm */
}
- else {
- memcpy(&pdata->primitives.dst_ip.address.ipv4, pptrs->f_data+tpl->tpl[NF9_IPV4_DST_ADDR].off, MIN(tpl->tpl[NF9_IPV4_DST_ADDR].len, 4));
- memcpy(&dst_mask, pptrs->f_data+tpl->tpl[NF9_DST_MASK].off, tpl->tpl[NF9_DST_MASK].len);
- }
+ else memcpy(&pdata->primitives.dst_ip.address.ipv4, pptrs->f_data+tpl->tpl[NF9_IPV4_DST_ADDR].off, MIN(tpl->tpl[NF9_IPV4_DST_ADDR].len, 4));
pdata->primitives.dst_ip.family = AF_INET;
break;
}
@@ -1305,12 +1244,10 @@
switch(hdr->aggregation) {
case 4:
pdata->primitives.dst_ip.address.ipv4.s_addr = ((struct struct_export_v8_4 *) pptrs->f_data)->dst_prefix;
- dst_mask = ((struct struct_export_v8_4 *) pptrs->f_data)->dst_mask;
pdata->primitives.dst_ip.family = AF_INET;
break;
case 5:
pdata->primitives.dst_ip.address.ipv4.s_addr = ((struct struct_export_v8_5 *) pptrs->f_data)->dst_prefix;
- dst_mask = ((struct struct_export_v8_5 *) pptrs->f_data)->dst_mask;
pdata->primitives.dst_ip.family = AF_INET;
break;
case 6:
@@ -1327,17 +1264,14 @@
break;
case 12:
pdata->primitives.dst_ip.address.ipv4.s_addr = ((struct struct_export_v8_12 *) pptrs->f_data)->dst_prefix;
- dst_mask = ((struct struct_export_v8_12 *) pptrs->f_data)->dst_mask;
pdata->primitives.dst_ip.family = AF_INET;
break;
case 13:
pdata->primitives.dst_ip.address.ipv4.s_addr = ((struct struct_export_v8_13 *) pptrs->f_data)->dst_prefix;
- dst_mask = ((struct struct_export_v8_13 *) pptrs->f_data)->dst_mask;
pdata->primitives.dst_ip.family = AF_INET;
break;
case 14:
pdata->primitives.dst_ip.address.ipv4.s_addr = ((struct struct_export_v8_14 *) pptrs->f_data)->dst_prefix;
- dst_mask = ((struct struct_export_v8_14 *) pptrs->f_data)->dst_mask;
pdata->primitives.dst_ip.family = AF_INET;
break;
default:
@@ -1348,32 +1282,9 @@
break;
default:
pdata->primitives.dst_ip.address.ipv4.s_addr = ((struct struct_export_v5 *) pptrs->f_data)->dstaddr.s_addr;
- dst_mask = ((struct struct_export_v5 *) pptrs->f_data)->dst_mask;
pdata->primitives.dst_ip.family = AF_INET;
break;
}
-
- if ((chptr->aggregation & (COUNT_DST_NET|COUNT_SUM_NET)) && chptr->plugin->cfg.nfacctd_net & NF_NET_KEEP) {
- u_int32_t maskbits[4], addrh[4];
- u_int8_t j;
-
- memset(maskbits, 0, sizeof(maskbits));
- for (j = 0; j < 4 && dst_mask >= 32; j++, dst_mask -= 32) maskbits[j] = 0xffffffffU;
- if (j < 4 && dst_mask) maskbits[j] = ~(0xffffffffU >> dst_mask);
-
- if (pdata->primitives.dst_ip.family == AF_INET) {
- addrh[0] = ntohl(pdata->primitives.dst_ip.address.ipv4.s_addr);
- addrh[0] &= maskbits[0];
- pdata->primitives.dst_ip.address.ipv4.s_addr = htonl(addrh[0]);
- }
-#if defined ENABLE_IPV6
- else if (pdata->primitives.dst_ip.family == AF_INET6) {
- memcpy(&addrh, (void *) pm_ntohl6(&pdata->primitives.dst_ip.address.ipv6), IP6AddrSz);
- for (j = 0; j < 4; j++) addrh[j] &= maskbits[j];
- memcpy(&pdata->primitives.dst_ip.address.ipv6, (void *) pm_htonl6(addrh), IP6AddrSz);
- }
-#endif
- }
}
void NF_src_nmask_handler(struct channels_list_entry *chptr, struct packet_ptrs *pptrs, char **data)
@@ -2477,6 +2388,96 @@
}
}
+void NF_sampling_rate_handler(struct channels_list_entry *chptr, struct packet_ptrs *pptrs, char **data)
+{
+ struct xflow_status_entry *xsentry = (struct xflow_status_entry *) pptrs->f_status;
+ struct xflow_status_entry *entry = (struct xflow_status_entry *) pptrs->f_status;
+ struct xflow_status_entry_sampling *sentry = NULL;
+ struct pkt_data *pdata = (struct pkt_data *) *data;
+ struct struct_header_v8 *hdr = (struct struct_header_v8 *) pptrs->f_header;
+ struct struct_header_v5 *hdr5 = (struct struct_header_v5 *) pptrs->f_header;
+ struct template_cache_entry *tpl = (struct template_cache_entry *) pptrs->f_tpl;
+ u_int16_t srate = 0, is_sampled = 0;
+ u_int16_t sampler_id = 0, t16 = 0;
+ u_int32_t sample_pool = 0, t32 = 0;
+ u_int8_t t8 = 0;
+
+ if (config.sfacctd_renormalize) {
+ pdata->primitives.sampling_rate = 1; /* already renormalized */
+ return;
+ }
+
+ pdata->primitives.sampling_rate = 0; /* 0 = unknown */
+
+ if (config.sampling_map) {
+ if (sampling_map_caching && xsentry && timeval_cmp(&xsentry->st.stamp, &reload_map_tstamp) > 0) {
+ pdata->primitives.sampling_rate = xsentry->st.id;
+ }
+ else {
+ NF_find_id((struct id_table *)pptrs->sampling_table, pptrs, (pm_id_t *) &pdata->primitives.sampling_rate, NULL);
+
+ if (xsentry) {
+ xsentry->st.id = pdata->primitives.sampling_rate;
+ gettimeofday(&xsentry->st.stamp, NULL);
+ }
+ }
+ }
+
+ if (pdata->primitives.sampling_rate == 0) { /* 0 = still unknown */
+ switch (hdr->version) {
+ case 10:
+ case 9:
+ if (tpl->tpl[NF9_FLOW_SAMPLER_ID].len) {
+ if (tpl->tpl[NF9_FLOW_SAMPLER_ID].len == 1) {
+ memcpy(&t8, pptrs->f_data+tpl->tpl[NF9_FLOW_SAMPLER_ID].off, 1);
+ sampler_id = t8;
+ }
+ else if (tpl->tpl[NF9_FLOW_SAMPLER_ID].len == 2) {
+ memcpy(&t16, pptrs->f_data+tpl->tpl[NF9_FLOW_SAMPLER_ID].off, 2);
+ sampler_id = ntohs(t16);
+ }
+ if (entry) sentry = search_smp_id_status_table(entry->sampling, sampler_id, TRUE);
+ if (sentry) pdata->primitives.sampling_rate = sentry->sample_pool;
+ }
+ /* SAMPLING_INTERVAL part of the NetFlow v9/IPFIX record seems to be reality, ie. FlowMon by Invea-Tech */
+ else if (tpl->tpl[NF9_SAMPLING_INTERVAL].len || tpl->tpl[NF9_FLOW_SAMPLER_INTERVAL].len) {
+ if (tpl->tpl[NF9_SAMPLING_INTERVAL].len == 2) {
+ memcpy(&t16, pptrs->f_data+tpl->tpl[NF9_SAMPLING_INTERVAL].off, 2);
+ sample_pool = ntohs(t16);
+ }
+ else if (tpl->tpl[NF9_SAMPLING_INTERVAL].len == 4) {
+ memcpy(&t32, pptrs->f_data+tpl->tpl[NF9_SAMPLING_INTERVAL].off, 4);
+ sample_pool = ntohl(t32);
+ }
+
+ if (tpl->tpl[NF9_FLOW_SAMPLER_INTERVAL].len == 2) {
+ memcpy(&t16, pptrs->f_data+tpl->tpl[NF9_FLOW_SAMPLER_INTERVAL].off, 2);
+ sample_pool = ntohs(t16);
+ }
+ else if (tpl->tpl[NF9_FLOW_SAMPLER_INTERVAL].len == 4) {
+ memcpy(&t32, pptrs->f_data+tpl->tpl[NF9_FLOW_SAMPLER_INTERVAL].off, 4);
+ sample_pool = ntohl(t32);
+ }
+
+ pdata->primitives.sampling_rate = sample_pool;
+ }
+ else {
+ if (entry) sentry = search_smp_id_status_table(entry->sampling, 0, FALSE);
+ if (sentry) pdata->primitives.sampling_rate = sentry->sample_pool;
+ }
+ break;
+ case 5:
+ hdr5 = (struct struct_header_v5 *) pptrs->f_header;
+ is_sampled = ( ntohs(hdr5->sampling) & 0xC000 );
+ srate = ( ntohs(hdr5->sampling) & 0x3FFF );
+ if (srate) pdata->primitives.sampling_rate = srate;
+ break;
+ default:
+ break;
+ }
+ }
+}
+
void NF_class_handler(struct channels_list_entry *chptr, struct packet_ptrs *pptrs, char **data)
{
struct pkt_data *pdata = (struct pkt_data *) *data;
@@ -2979,10 +2980,6 @@
struct pkt_data *pdata = (struct pkt_data *) *data;
SFSample *sample = (SFSample *) pptrs->f_data;
SFLAddress *addr = &sample->ipsrc;
- u_int8_t src_mask = sample->srcMask;
-
- /* check network-related primitives against fallback scenarios */
- if (chptr->aggregation & (COUNT_SRC_NET|COUNT_SUM_NET) && !evaluate_lm_method(pptrs, FALSE, chptr->plugin->cfg.nfacctd_net, NF_NET_KEEP)) return;
if (sample->gotIPV4) {
pdata->primitives.src_ip.address.ipv4.s_addr = sample->dcd_srcIP.s_addr;
@@ -2994,28 +2991,6 @@
pdata->primitives.src_ip.family = AF_INET6;
}
#endif
-
- if ((chptr->aggregation & (COUNT_SRC_NET|COUNT_SUM_NET)) && chptr->plugin->cfg.nfacctd_net & NF_NET_KEEP) {
- u_int32_t maskbits[4], addrh[4];
- u_int8_t j;
-
- memset(maskbits, 0, sizeof(maskbits));
- for (j = 0; j < 4 && src_mask >= 32; j++, src_mask -= 32) maskbits[j] = 0xffffffffU;
- if (j < 4 && src_mask) maskbits[j] = ~(0xffffffffU >> src_mask);
-
- if (pdata->primitives.src_ip.family == AF_INET) {
- addrh[0] = ntohl(pdata->primitives.src_ip.address.ipv4.s_addr);
- addrh[0] &= maskbits[0];
- pdata->primitives.src_ip.address.ipv4.s_addr = htonl(addrh[0]);
- }
-#if defined ENABLE_IPV6
- else if (pdata->primitives.src_ip.family == AF_INET6) {
- memcpy(&addrh, (void *) pm_ntohl6(&pdata->primitives.src_ip.address.ipv6), IP6AddrSz);
- for (j = 0; j < 4; j++) addrh[j] &= maskbits[j];
- memcpy(&pdata->primitives.src_ip.address.ipv6, (void *) pm_htonl6(addrh), IP6AddrSz);
- }
-#endif
- }
}
void SF_dst_host_handler(struct channels_list_entry *chptr, struct packet_ptrs *pptrs, char **data)
@@ -3023,10 +2998,6 @@
struct pkt_data *pdata = (struct pkt_data *) *data;
SFSample *sample = (SFSample *) pptrs->f_data;
SFLAddress *addr = &sample->ipdst;
- u_int8_t dst_mask = sample->dstMask;
-
- /* check network-related primitives against fallback scenarios */
- if (chptr->aggregation & (COUNT_DST_NET|COUNT_SUM_NET) && !evaluate_lm_method(pptrs, TRUE, chptr->plugin->cfg.nfacctd_net, NF_NET_KEEP)) return;
if (sample->gotIPV4) {
pdata->primitives.dst_ip.address.ipv4.s_addr = sample->dcd_dstIP.s_addr;
@@ -3038,28 +3009,6 @@
pdata->primitives.dst_ip.family = AF_INET6;
}
#endif
-
- if ((chptr->aggregation & (COUNT_DST_NET|COUNT_SUM_NET)) && chptr->plugin->cfg.nfacctd_net & NF_NET_KEEP) {
- u_int32_t maskbits[4], addrh[4];
- u_int8_t j;
-
- memset(maskbits, 0, sizeof(maskbits));
- for (j = 0; j < 4 && dst_mask >= 32; j++, dst_mask -= 32) maskbits[j] = 0xffffffffU;
- if (j < 4 && dst_mask) maskbits[j] = ~(0xffffffffU >> dst_mask);
-
- if (pdata->primitives.dst_ip.family == AF_INET) {
- addrh[0] = ntohl(pdata->primitives.dst_ip.address.ipv4.s_addr);
- addrh[0] &= maskbits[0];
- pdata->primitives.dst_ip.address.ipv4.s_addr = htonl(addrh[0]);
- }
-#if defined ENABLE_IPV6
- else if (pdata->primitives.dst_ip.family == AF_INET6) {
- memcpy(&addrh, (void *) pm_ntohl6(&pdata->primitives.dst_ip.address.ipv6), IP6AddrSz);
- for (j = 0; j < 4; j++) addrh[j] &= maskbits[j];
- memcpy(&pdata->primitives.dst_ip.address.ipv6, (void *) pm_htonl6(addrh), IP6AddrSz);
- }
-#endif
- }
}
void SF_src_nmask_handler(struct channels_list_entry *chptr, struct packet_ptrs *pptrs, char **data)
@@ -3373,6 +3322,38 @@
pdata->primitives.ifindex_out = sample->outputPort;
}
+void SF_sampling_rate_handler(struct channels_list_entry *chptr, struct packet_ptrs *pptrs, char **data)
+{
+ struct xflow_status_entry *xsentry = (struct xflow_status_entry *) pptrs->f_status;
+ struct pkt_data *pdata = (struct pkt_data *) *data;
+ SFSample *sample = (SFSample *) pptrs->f_data;
+
+ if (config.sfacctd_renormalize) {
+ pdata->primitives.sampling_rate = 1; /* already renormalized */
+ return;
+ }
+
+ pdata->primitives.sampling_rate = 0;
+
+ if (config.sampling_map) {
+ if (sampling_map_caching && xsentry && timeval_cmp(&xsentry->st.stamp, &reload_map_tstamp) > 0) {
+ pdata->primitives.sampling_rate = xsentry->st.id;
+ }
+ else {
+ SF_find_id((struct id_table *)pptrs->sampling_table, pptrs, (pm_id_t *) &pdata->primitives.sampling_rate, NULL);
+
+ if (xsentry) {
+ xsentry->st.id = pdata->primitives.sampling_rate;
+ gettimeofday(&xsentry->st.stamp, NULL);
+ }
+ }
+ }
+
+ if (pdata->primitives.sampling_rate == 0) {
+ pdata->primitives.sampling_rate = sample->meanSkipCount;
+ }
+}
+
void SF_class_handler(struct channels_list_entry *chptr, struct packet_ptrs *pptrs, char **data)
{
struct pkt_data *pdata = (struct pkt_data *) *data;
@@ -3438,6 +3419,53 @@
// XXX: fill this in
}
+#if defined WITH_GEOIP
+void geoip_init()
+{
+ if (config.geoip_ipv4_file && !config.geoip_ipv4)
+ config.geoip_ipv4 = GeoIP_open(config.geoip_ipv4_file, (GEOIP_MEMORY_CACHE|GEOIP_CHECK_CACHE));
+
+#if defined ENABLE_IPV6
+ if (config.geoip_ipv6_file && !config.geoip_ipv6)
+ config.geoip_ipv6 = GeoIP_open(config.geoip_ipv6_file, (GEOIP_MEMORY_CACHE|GEOIP_CHECK_CACHE));
+#endif
+}
+
+void src_host_country_handler(struct channels_list_entry *chptr, struct packet_ptrs *pptrs, char **data)
+{
+ struct pkt_data *pdata = (struct pkt_data *) *data;
+
+ geoip_init();
+ if (config.geoip_ipv4) {
+ if (pptrs->l3_proto == ETHERTYPE_IP)
+ pdata->primitives.src_ip_country = GeoIP_id_by_ipnum(config.geoip_ipv4, ntohl(((struct my_iphdr *) pptrs->iph_ptr)->ip_src.s_addr));
+ }
+#if defined ENABLE_IPV6
+ if (config.geoip_ipv6) {
+ if (pptrs->l3_proto == ETHERTYPE_IPV6)
+ pdata->primitives.src_ip_country = GeoIP_id_by_ipnum_v6(config.geoip_ipv6, ((struct ip6_hdr *)pptrs->iph_ptr)->ip6_src);
+ }
+#endif
+}
+
+void dst_host_country_handler(struct channels_list_entry *chptr, struct packet_ptrs *pptrs, char **data)
+{
+ struct pkt_data *pdata = (struct pkt_data *) *data;
+
+ geoip_init();
+ if (config.geoip_ipv4) {
+ if (pptrs->l3_proto == ETHERTYPE_IP)
+ pdata->primitives.dst_ip_country = GeoIP_id_by_ipnum(config.geoip_ipv4, ntohl(((struct my_iphdr *) pptrs->iph_ptr)->ip_dst.s_addr));
+ }
+#if defined ENABLE_IPV6
+ if (config.geoip_ipv6) {
+ if (pptrs->l3_proto == ETHERTYPE_IPV6)
+ pdata->primitives.dst_ip_country = GeoIP_id_by_ipnum_v6(config.geoip_ipv6, ((struct ip6_hdr *)pptrs->iph_ptr)->ip6_dst);
+ }
+#endif
+}
+#endif
+
/* srcdst: 0 == src, 1 == dst */
int evaluate_lm_method(struct packet_ptrs *pptrs, u_int8_t srcdst, u_int32_t bitmap, u_int32_t method)
{
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/pkt_handlers.h
^
|
@@ -1,6 +1,6 @@
/*
pmacct (Promiscuous mode IP Accounting package)
- pmacct is Copyright (C) 2003-2012 by Paolo Lucente
+ pmacct is Copyright (C) 2003-2013 by Paolo Lucente
*/
/*
@@ -56,6 +56,7 @@
EXT void class_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
EXT void in_iface_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
EXT void out_iface_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
+EXT void sampling_rate_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
EXT void sfprobe_payload_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
EXT void tee_payload_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
EXT void nfprobe_extras_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
@@ -87,6 +88,7 @@
EXT void NF_class_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
EXT void NF_in_iface_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
EXT void NF_out_iface_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
+EXT void NF_sampling_rate_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
EXT void NF_id_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
EXT void NF_id2_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
EXT void NF_counters_renormalize_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
@@ -98,14 +100,10 @@
EXT void bgp_peer_src_as_frommap_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
EXT void bgp_src_local_pref_frommap_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
EXT void bgp_src_med_frommap_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
-EXT void bgp_src_net_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
-EXT void bgp_dst_net_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
EXT void bgp_src_nmask_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
EXT void bgp_dst_nmask_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
EXT void bgp_peer_dst_ip_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
-EXT void igp_src_net_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
-EXT void igp_dst_net_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
EXT void igp_src_nmask_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
EXT void igp_dst_nmask_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
EXT void igp_peer_dst_ip_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
@@ -136,6 +134,7 @@
EXT void SF_class_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
EXT void SF_in_iface_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
EXT void SF_out_iface_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
+EXT void SF_sampling_rate_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
EXT void SF_sampling_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
EXT void SF_bgp_peer_src_as_fromext_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
EXT void SF_bgp_peer_src_as_fromstd_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
@@ -150,6 +149,12 @@
EXT void sampling_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
EXT void sfprobe_sampling_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
+#if defined (WITH_GEOIP)
+EXT void geoip_init();
+EXT void src_host_country_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
+EXT void dst_host_country_handler(struct channels_list_entry *, struct packet_ptrs *, char **);
+#endif
+
EXT int evaluate_lm_method(struct packet_ptrs *, u_int8_t, u_int32_t, u_int32_t);
EXT char *lookup_tpl_ext_db(void *, u_int32_t, u_int16_t);
#undef EXT
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/plugin_hooks.c
^
|
@@ -194,7 +194,7 @@
char *bptr;
int index;
- for (index = 0; channels_list[index].aggregation; index++) {
+ for (index = 0; channels_list[index].aggregation || channels_list[index].aggregation_2; index++) {
if (evaluate_filters(&channels_list[index].agg_filter, pptrs->packet_ptr, pptrs->pkthdr) &&
!evaluate_tags(&channels_list[index].tag_filter, pptrs->tag) &&
!evaluate_tags(&channels_list[index].tag2_filter, pptrs->tag2) &&
@@ -280,8 +280,9 @@
while (index < MAX_N_PLUGINS) {
chptr = &channels_list[index];
- if (!chptr->aggregation) { /* found room */
+ if (!chptr->aggregation && !chptr->aggregation_2) { /* found room */
chptr->aggregation = cfg->what_to_count;
+ chptr->aggregation_2 = cfg->what_to_count_2;
chptr->pipe = pipe;
chptr->agg_filter.table = cfg->bpfp_a_table;
chptr->agg_filter.num = (int *) &cfg->bpfp_a_num;
@@ -338,6 +339,7 @@
if (chptr->pipe == pipe) {
chptr->aggregation = FALSE;
+ chptr->aggregation_2 = FALSE;
/* we ensure that any plugin is depending on the one
being removed via the 'same_aggregate' flag */
@@ -346,7 +348,7 @@
for (index2++; index2 < MAX_N_PLUGINS; index2++) {
chptr = &channels_list[index2];
- if (!chptr->aggregation) break; /* we finished channels */
+ if (!chptr->aggregation && !chptr->aggregation_2) break; /* we finished channels */
if (chptr->same_aggregate) {
chptr->same_aggregate = FALSE;
break;
@@ -358,7 +360,7 @@
index2 = index;
for (index2++; index2 < MAX_N_PLUGINS; index2++) {
chptr = &channels_list[index2];
- if (chptr->aggregation) {
+ if (chptr->aggregation || chptr->aggregation_2) {
memcpy(&channels_list[index], chptr, sizeof(struct channels_list_entry));
memset(chptr, 0, sizeof(struct channels_list_entry));
index++;
@@ -380,11 +382,12 @@
int x = 0, y = 0;
while (x < MAX_N_PLUGINS) {
- if (!channels_list[x].aggregation) break;
+ if (!channels_list[x].aggregation && !channels_list[x].aggregation_2) break;
y = x+1;
while (y < MAX_N_PLUGINS) {
- if (!channels_list[y].aggregation) break;
- if (channels_list[x].aggregation == channels_list[y].aggregation) {
+ if (!channels_list[y].aggregation && !channels_list[y].aggregation_2) break;
+ if (channels_list[x].aggregation == channels_list[y].aggregation &&
+ channels_list[x].aggregation_2 == channels_list[y].aggregation_2) {
channels_list[y].same_aggregate = TRUE;
if (y == x+1) x++;
else {
@@ -524,7 +527,7 @@
{
int index;
- for (index = 0; channels_list[index].aggregation; index++) {
+ for (index = 0; channels_list[index].aggregation || channels_list[index].aggregation_2; index++) {
channels_list[index].hdr.seq++;
channels_list[index].hdr.seq %= MAX_SEQNUM;
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/plugin_hooks.h
^
|
@@ -1,6 +1,6 @@
/*
pmacct (Promiscuous mode IP Accounting package)
- pmacct is Copyright (C) 2003-2011 by Paolo Lucente
+ pmacct is Copyright (C) 2003-2012 by Paolo Lucente
*/
/*
@@ -64,6 +64,7 @@
struct channels_list_entry {
u_int64_t aggregation;
+ u_int64_t aggregation_2;
u_int32_t buf; /* buffer base */
u_int32_t bufptr; /* buffer current */
u_int32_t bufend; /* buffer end; max 4Gb */
@@ -142,6 +143,10 @@
EXT void sqlite3_plugin(int, struct configuration *, void *);
#endif
+#ifdef WITH_MONGODB
+EXT void mongodb_plugin(int, struct configuration *, void *);
+#endif
+
EXT void stats_plugin(int, struct configuration *, void *);
EXT char *extract_token(char **, int);
|
[-]
[+]
|
Added |
pmacct-0.14.2.tar.bz2/src/pmacct-build.h
^
|
@@ -0,0 +1 @@
+#define PMACCT_BUILD "20130114-00"
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/pmacct-data.h
^
|
@@ -29,6 +29,7 @@
#define PLUGIN_ID_PGSQL 6
#define PLUGIN_ID_SQLITE3 7
#define PLUGIN_ID_TEE 8
+#define PLUGIN_ID_MONGODB 9
#define PLUGIN_ID_UNKNOWN -1
/* vars */
@@ -271,14 +272,21 @@
{"sql_use_copy", cfg_key_sql_use_copy},
{"sql_num_protos", cfg_key_num_protos},
{"sql_num_hosts", cfg_key_num_hosts},
- {"print_refresh_time", cfg_key_print_refresh_time},
+ {"print_refresh_time", cfg_key_sql_refresh_time},
{"print_cache_entries", cfg_key_print_cache_entries},
{"print_markers", cfg_key_print_markers},
{"print_output", cfg_key_print_output},
{"print_num_protos", cfg_key_num_protos},
{"print_time_roundoff", cfg_key_sql_history_roundoff},
- {"print_output_file", cfg_key_sql_table},
+ {"print_output_file", cfg_key_print_output_file},
{"print_trigger_exec", cfg_key_sql_trigger_exec},
+ {"mongo_host", cfg_key_sql_host},
+ {"mongo_table", cfg_key_sql_table},
+ {"mongo_refresh_time", cfg_key_sql_refresh_time},
+ {"mongo_cache_entries", cfg_key_print_cache_entries},
+ {"mongo_history", cfg_key_sql_history},
+ {"mongo_time_roundoff", cfg_key_sql_history_roundoff},
+ {"mongo_trigger_exec", cfg_key_sql_trigger_exec},
{"nfacctd_port", cfg_key_nfacctd_port},
{"nfacctd_ip", cfg_key_nfacctd_ip},
{"nfacctd_allow_file", cfg_key_nfacctd_allow_file},
@@ -383,6 +391,12 @@
{"isis_daemon_iface", cfg_key_nfacctd_isis_iface},
{"isis_daemon_mtu", cfg_key_nfacctd_isis_mtu},
{"isis_daemon_msglog", cfg_key_nfacctd_isis_msglog},
+#if defined WITH_GEOIP
+ {"geoip_ipv4_file", cfg_key_geoip_ipv4_file},
+#if defined ENABLE_IPV6
+ {"geoip_ipv6_file", cfg_key_geoip_ipv6_file},
+#endif
+#endif
{"uacctd_group", cfg_key_uacctd_group},
{"uacctd_nl_size", cfg_key_uacctd_nl_size},
{"tunnel_0", cfg_key_tunnel_0},
@@ -406,6 +420,9 @@
#ifdef WITH_SQLITE3
{PLUGIN_ID_SQLITE3, "sqlite3", sqlite3_plugin},
#endif
+#ifdef WITH_MONGODB
+ {PLUGIN_ID_MONGODB, "mongodb", mongodb_plugin},
+#endif
{PLUGIN_ID_TEE, "tee", tee_plugin},
{PLUGIN_ID_UNKNOWN, "", NULL},
};
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/pmacct-defines.h
^
|
@@ -25,7 +25,7 @@
#define ARGS_PMACCTD "n:NdDhP:b:f:F:c:i:I:m:p:r:s:S:v:o:O:uwWL:R"
#define ARGS_UACCTD "n:NdDhP:b:f:F:c:m:p:r:s:S:v:o:O:uRg:L:"
#define ARGS_PMACCT "Ssc:Cetm:p:P:M:arN:n:lT:Ou"
-#define N_PRIMITIVES 48
+#define N_PRIMITIVES 50
#define N_FUNCS 10
#define MAX_N_PLUGINS 32
#define PROTO_LEN 12
@@ -60,13 +60,13 @@
#define LARGEBUFLEN (8192+MOREBUFSZ)
#define MANTAINER "Paolo Lucente <paolo@pmacct.net>"
-#define PMACCTD_USAGE_HEADER "Promiscuous Mode Accounting Daemon, pmacctd 0.14.1"
-#define UACCTD_USAGE_HEADER "Linux NetFilter ULOG Accounting Daemon, pmacctd 0.14.1"
-#define PMACCT_USAGE_HEADER "pmacct, pmacct client 0.14.1"
-#define PMMYPLAY_USAGE_HEADER "pmmyplay, pmacct MySQL logfile player 0.14.1"
-#define PMPGPLAY_USAGE_HEADER "pmpgplay, pmacct PGSQL logfile player 0.14.1"
-#define NFACCTD_USAGE_HEADER "NetFlow Accounting Daemon, nfacctd 0.14.1"
-#define SFACCTD_USAGE_HEADER "sFlow Accounting Daemon, sfacctd 0.14.1"
+#define PMACCTD_USAGE_HEADER "Promiscuous Mode Accounting Daemon, pmacctd 0.14.2"
+#define UACCTD_USAGE_HEADER "Linux NetFilter ULOG Accounting Daemon, pmacctd 0.14.2"
+#define PMACCT_USAGE_HEADER "pmacct, pmacct client 0.14.2"
+#define PMMYPLAY_USAGE_HEADER "pmmyplay, pmacct MySQL logfile player 0.14.2"
+#define PMPGPLAY_USAGE_HEADER "pmpgplay, pmacct PGSQL logfile player 0.14.2"
+#define NFACCTD_USAGE_HEADER "NetFlow Accounting Daemon, nfacctd 0.14.2"
+#define SFACCTD_USAGE_HEADER "sFlow Accounting Daemon, sfacctd 0.14.2"
#ifndef TRUE
#define TRUE 1
@@ -100,55 +100,122 @@
#define MAP_BGP_IFACE_TO_RD 104 /* bgp_iface_to_rd */
#define MAP_SAMPLING 105 /* sampling_map */
-/* 48 primitives currently defined */
-#define COUNT_SRC_HOST 0x0000000000000001ULL
-#define COUNT_DST_HOST 0x0000000000000002ULL
-#define COUNT_SUM_HOST 0x0000000000000004ULL
-#define COUNT_SRC_PORT 0x0000000000000008ULL
-#define COUNT_DST_PORT 0x0000000000000010ULL
-#define COUNT_IP_PROTO 0x0000000000000020ULL
-#define COUNT_SRC_MAC 0x0000000000000040ULL
-#define COUNT_DST_MAC 0x0000000000000080ULL
-#define COUNT_SRC_NET 0x0000000000000100ULL
-#define COUNT_DST_NET 0x0000000000000200ULL
-#define COUNT_ID 0x0000000000000400ULL
-#define COUNT_VLAN 0x0000000000000800ULL
-#define COUNT_IP_TOS 0x0000000000001000ULL
-#define COUNT_NONE 0x0000000000002000ULL
-#define COUNT_SRC_AS 0x0000000000004000ULL
-#define COUNT_DST_AS 0x0000000000008000ULL
-#define COUNT_SUM_NET 0x0000000000010000ULL
-#define COUNT_SUM_AS 0x0000000000020000ULL
-#define COUNT_SUM_PORT 0x0000000000040000ULL
-#define TIMESTAMP 0x0000000000080000ULL /* USE_TIMESTAMPS */
-#define COUNT_FLOWS 0x0000000000100000ULL
-#define COUNT_SUM_MAC 0x0000000000200000ULL
-#define COUNT_CLASS 0x0000000000400000ULL
-#define COUNT_COUNTERS 0x0000000000800000ULL
-#define COUNT_PAYLOAD 0x0000000001000000ULL
-#define COUNT_TCPFLAGS 0x0000000002000000ULL
-#define COUNT_STD_COMM 0x0000000004000000ULL
-#define COUNT_EXT_COMM 0x0000000008000000ULL
-#define COUNT_AS_PATH 0x0000000010000000ULL
-#define COUNT_LOCAL_PREF 0x0000000020000000ULL
-#define COUNT_MED 0x0000000040000000ULL
-#define COUNT_PEER_SRC_AS 0x0000000080000000ULL
-#define COUNT_PEER_DST_AS 0x0000000100000000ULL
-#define COUNT_PEER_SRC_IP 0x0000000200000000ULL
-#define COUNT_PEER_DST_IP 0x0000000400000000ULL
-#define COUNT_ID2 0x0000000800000000ULL
-#define COUNT_SRC_AS_PATH 0x0000001000000000ULL
-#define COUNT_SRC_STD_COMM 0x0000002000000000ULL
-#define COUNT_SRC_EXT_COMM 0x0000004000000000ULL
-#define COUNT_SRC_LOCAL_PREF 0x0000008000000000ULL
-#define COUNT_SRC_MED 0x0000010000000000ULL
-#define COUNT_MPLS_VPN_RD 0x0000020000000000ULL
-#define COUNT_IN_IFACE 0x0000040000000000ULL
-#define COUNT_OUT_IFACE 0x0000080000000000ULL
-#define COUNT_SRC_NMASK 0x0000100000000000ULL
-#define COUNT_DST_NMASK 0x0000200000000000ULL
-#define COUNT_COS 0x0000400000000000ULL
-#define COUNT_ETHERTYPE 0x0000800000000000ULL
+/* PRIMITIVES DEFINITION: START */
+/* 50 primitives currently defined */
+/* internal: first registry, ie. what_to_count, aggregation, etc. */
+#define COUNT_INT_SRC_HOST 0x0001000000000001ULL
+#define COUNT_INT_DST_HOST 0x0001000000000002ULL
+#define COUNT_INT_SUM_HOST 0x0001000000000004ULL
+#define COUNT_INT_SRC_PORT 0x0001000000000008ULL
+#define COUNT_INT_DST_PORT 0x0001000000000010ULL
+#define COUNT_INT_IP_PROTO 0x0001000000000020ULL
+#define COUNT_INT_SRC_MAC 0x0001000000000040ULL
+#define COUNT_INT_DST_MAC 0x0001000000000080ULL
+#define COUNT_INT_SRC_NET 0x0001000000000100ULL
+#define COUNT_INT_DST_NET 0x0001000000000200ULL
+#define COUNT_INT_ID 0x0001000000000400ULL
+#define COUNT_INT_VLAN 0x0001000000000800ULL
+#define COUNT_INT_IP_TOS 0x0001000000001000ULL
+#define COUNT_INT_NONE 0x0001000000002000ULL
+#define COUNT_INT_SRC_AS 0x0001000000004000ULL
+#define COUNT_INT_DST_AS 0x0001000000008000ULL
+#define COUNT_INT_SUM_NET 0x0001000000010000ULL
+#define COUNT_INT_SUM_AS 0x0001000000020000ULL
+#define COUNT_INT_SUM_PORT 0x0001000000040000ULL
+#define INT_TIMESTAMP 0x0001000000080000ULL /* USE_TIMESTAMPS */
+#define COUNT_INT_FLOWS 0x0001000000100000ULL
+#define COUNT_INT_SUM_MAC 0x0001000000200000ULL
+#define COUNT_INT_CLASS 0x0001000000400000ULL
+#define COUNT_INT_COUNTERS 0x0001000000800000ULL
+#define COUNT_INT_PAYLOAD 0x0001000001000000ULL
+#define COUNT_INT_TCPFLAGS 0x0001000002000000ULL
+#define COUNT_INT_STD_COMM 0x0001000004000000ULL
+#define COUNT_INT_EXT_COMM 0x0001000008000000ULL
+#define COUNT_INT_AS_PATH 0x0001000010000000ULL
+#define COUNT_INT_LOCAL_PREF 0x0001000020000000ULL
+#define COUNT_INT_MED 0x0001000040000000ULL
+#define COUNT_INT_PEER_SRC_AS 0x0001000080000000ULL
+#define COUNT_INT_PEER_DST_AS 0x0001000100000000ULL
+#define COUNT_INT_PEER_SRC_IP 0x0001000200000000ULL
+#define COUNT_INT_PEER_DST_IP 0x0001000400000000ULL
+#define COUNT_INT_ID2 0x0001000800000000ULL
+#define COUNT_INT_SRC_AS_PATH 0x0001001000000000ULL
+#define COUNT_INT_SRC_STD_COMM 0x0001002000000000ULL
+#define COUNT_INT_SRC_EXT_COMM 0x0001004000000000ULL
+#define COUNT_INT_SRC_LOCAL_PREF 0x0001008000000000ULL
+#define COUNT_INT_SRC_MED 0x0001010000000000ULL
+#define COUNT_INT_MPLS_VPN_RD 0x0001020000000000ULL
+#define COUNT_INT_IN_IFACE 0x0001040000000000ULL
+#define COUNT_INT_OUT_IFACE 0x0001080000000000ULL
+#define COUNT_INT_SRC_NMASK 0x0001100000000000ULL
+#define COUNT_INT_DST_NMASK 0x0001200000000000ULL
+#define COUNT_INT_COS 0x0001400000000000ULL
+#define COUNT_INT_ETHERTYPE 0x0001800000000000ULL
+
+/* internal: second registry, ie. what_to_count_2, aggregation_2, etc. */
+#define COUNT_INT_SAMPLING_RATE 0x0002000000000001ULL
+#define COUNT_INT_SRC_HOST_COUNTRY 0x0002000000000002ULL
+#define COUNT_INT_DST_HOST_COUNTRY 0x0002000000000004ULL
+
+#define COUNT_INDEX_MASK 0xFFFF
+#define COUNT_REGISTRY_MASK 0xFFFFFFFFFFFFULL
+#define COUNT_REGISTRY_BITS 48
+
+/* external: first registry, ie. what_to_count, aggregation, etc. */
+#define COUNT_SRC_HOST (COUNT_INT_SRC_HOST & COUNT_REGISTRY_MASK)
+#define COUNT_DST_HOST (COUNT_INT_DST_HOST & COUNT_REGISTRY_MASK)
+#define COUNT_SUM_HOST (COUNT_INT_SUM_HOST & COUNT_REGISTRY_MASK)
+#define COUNT_SRC_PORT (COUNT_INT_SRC_PORT & COUNT_REGISTRY_MASK)
+#define COUNT_DST_PORT (COUNT_INT_DST_PORT & COUNT_REGISTRY_MASK)
+#define COUNT_IP_PROTO (COUNT_INT_IP_PROTO & COUNT_REGISTRY_MASK)
+#define COUNT_SRC_MAC (COUNT_INT_SRC_MAC & COUNT_REGISTRY_MASK)
+#define COUNT_DST_MAC (COUNT_INT_DST_MAC & COUNT_REGISTRY_MASK)
+#define COUNT_SRC_NET (COUNT_INT_SRC_NET & COUNT_REGISTRY_MASK)
+#define COUNT_DST_NET (COUNT_INT_DST_NET & COUNT_REGISTRY_MASK)
+#define COUNT_ID (COUNT_INT_ID & COUNT_REGISTRY_MASK)
+#define COUNT_VLAN (COUNT_INT_VLAN & COUNT_REGISTRY_MASK)
+#define COUNT_IP_TOS (COUNT_INT_IP_TOS & COUNT_REGISTRY_MASK)
+#define COUNT_NONE (COUNT_INT_NONE & COUNT_REGISTRY_MASK)
+#define COUNT_SRC_AS (COUNT_INT_SRC_AS & COUNT_REGISTRY_MASK)
+#define COUNT_DST_AS (COUNT_INT_DST_AS & COUNT_REGISTRY_MASK)
+#define COUNT_SUM_NET (COUNT_INT_SUM_NET & COUNT_REGISTRY_MASK)
+#define COUNT_SUM_AS (COUNT_INT_SUM_AS & COUNT_REGISTRY_MASK)
+#define COUNT_SUM_PORT (COUNT_INT_SUM_PORT & COUNT_REGISTRY_MASK)
+#define TIMESTAMP (INT_TIMESTAMP & COUNT_REGISTRY_MASK)
+#define COUNT_FLOWS (COUNT_INT_FLOWS & COUNT_REGISTRY_MASK)
+#define COUNT_SUM_MAC (COUNT_INT_SUM_MAC & COUNT_REGISTRY_MASK)
+#define COUNT_CLASS (COUNT_INT_CLASS & COUNT_REGISTRY_MASK)
+#define COUNT_COUNTERS (COUNT_INT_COUNTERS & COUNT_REGISTRY_MASK)
+#define COUNT_PAYLOAD (COUNT_INT_PAYLOAD & COUNT_REGISTRY_MASK)
+#define COUNT_TCPFLAGS (COUNT_INT_TCPFLAGS & COUNT_REGISTRY_MASK)
+#define COUNT_STD_COMM (COUNT_INT_STD_COMM & COUNT_REGISTRY_MASK)
+#define COUNT_EXT_COMM (COUNT_INT_EXT_COMM & COUNT_REGISTRY_MASK)
+#define COUNT_AS_PATH (COUNT_INT_AS_PATH & COUNT_REGISTRY_MASK)
+#define COUNT_LOCAL_PREF (COUNT_INT_LOCAL_PREF & COUNT_REGISTRY_MASK)
+#define COUNT_MED (COUNT_INT_MED & COUNT_REGISTRY_MASK)
+#define COUNT_PEER_SRC_AS (COUNT_INT_PEER_SRC_AS & COUNT_REGISTRY_MASK)
+#define COUNT_PEER_DST_AS (COUNT_INT_PEER_DST_AS & COUNT_REGISTRY_MASK)
+#define COUNT_PEER_SRC_IP (COUNT_INT_PEER_SRC_IP & COUNT_REGISTRY_MASK)
+#define COUNT_PEER_DST_IP (COUNT_INT_PEER_DST_IP & COUNT_REGISTRY_MASK)
+#define COUNT_ID2 (COUNT_INT_ID2 & COUNT_REGISTRY_MASK)
+#define COUNT_SRC_AS_PATH (COUNT_INT_SRC_AS_PATH & COUNT_REGISTRY_MASK)
+#define COUNT_SRC_STD_COMM (COUNT_INT_SRC_STD_COMM & COUNT_REGISTRY_MASK)
+#define COUNT_SRC_EXT_COMM (COUNT_INT_SRC_EXT_COMM & COUNT_REGISTRY_MASK)
+#define COUNT_SRC_LOCAL_PREF (COUNT_INT_SRC_LOCAL_PREF & COUNT_REGISTRY_MASK)
+#define COUNT_SRC_MED (COUNT_INT_SRC_MED & COUNT_REGISTRY_MASK)
+#define COUNT_MPLS_VPN_RD (COUNT_INT_MPLS_VPN_RD & COUNT_REGISTRY_MASK)
+#define COUNT_IN_IFACE (COUNT_INT_IN_IFACE & COUNT_REGISTRY_MASK)
+#define COUNT_OUT_IFACE (COUNT_INT_OUT_IFACE & COUNT_REGISTRY_MASK)
+#define COUNT_SRC_NMASK (COUNT_INT_SRC_NMASK & COUNT_REGISTRY_MASK)
+#define COUNT_DST_NMASK (COUNT_INT_DST_NMASK & COUNT_REGISTRY_MASK)
+#define COUNT_COS (COUNT_INT_COS & COUNT_REGISTRY_MASK)
+#define COUNT_ETHERTYPE (COUNT_INT_ETHERTYPE & COUNT_REGISTRY_MASK)
+
+/* external: second registry, ie. what_to_count_2, aggregation_2, etc. */
+#define COUNT_SAMPLING_RATE (COUNT_INT_SAMPLING_RATE & COUNT_REGISTRY_MASK)
+#define COUNT_SRC_HOST_COUNTRY (COUNT_INT_SRC_HOST_COUNTRY & COUNT_REGISTRY_MASK)
+#define COUNT_DST_HOST_COUNTRY (COUNT_INT_DST_HOST_COUNTRY & COUNT_REGISTRY_MASK)
+/* PRIMITIVES DEFINITION: END */
/* BYTES and PACKETS are used into templates; we let their values to
overlap with some values we will not need into templates */
@@ -213,6 +280,7 @@
typedef u_int32_t pm_class_t;
typedef u_int64_t pm_id_t;
+typedef u_int32_t pm_country_t;
#if defined HAVE_64BIT_COUNTERS
typedef u_int64_t pm_counter_t;
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/pmacct.c
^
|
@@ -58,7 +58,7 @@
void usage_client(char *prog)
{
- printf("%s\n", PMACCT_USAGE_HEADER);
+ printf("%s (%s)\n", PMACCT_USAGE_HEADER, PMACCT_BUILD);
printf("Usage: %s [query]\n\n", prog);
printf("Queries:\n");
printf(" -s\tShow statistics\n");
@@ -67,7 +67,7 @@
printf(" -S\tSum counters instead of returning a single counter for each request (applies to -N)\n");
printf(" -M\t[matching data[';' ... ]] | ['file:'[filename]] \n\tMatch primitives; print formatted table (requires -c)\n");
printf(" -a\tDisplay all table fields (even those currently unused)\n");
- printf(" -c\t[ src_mac | dst_mac | vlan | cos | src_host | dst_host | src_net | dst_net | src_mask | dst_mask | \n\t src_port | dst_port | tos | proto | src_as | dst_as | sum_mac | sum_host | sum_net | sum_as | \n\t sum_port | in_iface | out_iface | tag | tag2 | flows | class | std_comm | ext_comm | as_path | \n\t peer_src_ip | peer_dst_ip | peer_src_as | peer_dst_as | src_as_path | src_std_comm | src_med | \n\t src_ext_comm | src_local_pref | mpls_vpn_rd | etype ] \n\tSelect primitives to match (required by -N and -M)\n");
+ printf(" -c\t[ src_mac | dst_mac | vlan | cos | src_host | dst_host | src_net | dst_net | src_mask | dst_mask | \n\t src_port | dst_port | tos | proto | src_as | dst_as | sum_mac | sum_host | sum_net | sum_as | \n\t sum_port | in_iface | out_iface | tag | tag2 | flows | class | std_comm | ext_comm | as_path | \n\t peer_src_ip | peer_dst_ip | peer_src_as | peer_dst_as | src_as_path | src_std_comm | src_med | \n\t src_ext_comm | src_local_pref | mpls_vpn_rd | etype | sampling_rate ] \n\tSelect primitives to match (required by -N and -M)\n");
printf(" -T\t[bytes|packets|flows] \n\tOutput top N statistics (applies to -M and -s)\n");
printf(" -e\tClear statistics\n");
printf(" -r\tReset counters (applies to -N and -M)\n");
@@ -120,7 +120,7 @@
exit(1);
}
-void write_stats_header_formatted(u_int64_t what_to_count, u_int8_t have_wtc)
+void write_stats_header_formatted(u_int64_t what_to_count, u_int64_t what_to_count_2, u_int8_t have_wtc)
{
if (!have_wtc) {
printf("TAG ");
@@ -169,6 +169,12 @@
printf("TCP_FLAGS ");
printf("PROTOCOL ");
printf("TOS ");
+#if defined (WITH_GEOIP)
+ printf("SH_COUNTRY ");
+ printf("DH_COUNTRY ");
+#endif
+ printf("SAMPLING_RATE ");
+
#if defined HAVE_64BIT_COUNTERS
printf("PACKETS ");
printf("FLOWS ");
@@ -230,6 +236,12 @@
if (what_to_count & COUNT_TCPFLAGS) printf("TCP_FLAGS ");
if (what_to_count & COUNT_IP_PROTO) printf("PROTOCOL ");
if (what_to_count & COUNT_IP_TOS) printf("TOS ");
+
+#ifdef WITH_GEOIP
+ if (what_to_count_2 & COUNT_SRC_HOST_COUNTRY) printf("SH_COUNTRY ");
+ if (what_to_count_2 & COUNT_DST_HOST_COUNTRY) printf("DH_COUNTRY ");
+#endif
+ if (what_to_count_2 & COUNT_SAMPLING_RATE) printf("SAMPLING_RATE ");
#if defined HAVE_64BIT_COUNTERS
printf("PACKETS ");
if (what_to_count & COUNT_FLOWS) printf("FLOWS ");
@@ -242,7 +254,7 @@
}
}
-void write_stats_header_csv(u_int64_t what_to_count, u_int8_t have_wtc)
+void write_stats_header_csv(u_int64_t what_to_count, u_int64_t what_to_count_2, u_int8_t have_wtc)
{
if (!have_wtc) {
printf("TAG,");
@@ -291,6 +303,11 @@
printf("TCP_FLAGS,");
printf("PROTOCOL,");
printf("TOS,");
+#if defined WITH_GEOIP
+ printf("SH_COUNTRY,");
+ printf("DH_COUNTRY,");
+#endif
+ printf("SAMPLING_RATE,");
#if defined HAVE_64BIT_COUNTERS
printf("PACKETS,");
printf("FLOWS,");
@@ -352,6 +369,13 @@
if (what_to_count & COUNT_TCPFLAGS) printf("TCP_FLAGS,");
if (what_to_count & COUNT_IP_PROTO) printf("PROTOCOL,");
if (what_to_count & COUNT_IP_TOS) printf("TOS,");
+
+#if defined WITH_GEOIP
+ if (what_to_count_2 & COUNT_SRC_HOST_COUNTRY) printf("SH_COUNTRY,");
+ if (what_to_count_2 & COUNT_DST_HOST_COUNTRY) printf("DH_COUNTRY,");
+#endif
+ if (what_to_count_2 & COUNT_SAMPLING_RATE) printf("SAMPLING_RATE,");
+
#if defined HAVE_64BIT_COUNTERS
printf("PACKETS,");
if (what_to_count & COUNT_FLOWS) printf("FLOWS,");
@@ -437,7 +461,7 @@
int want_status, want_mrtg, want_counter, want_match, want_all_fields;
int want_output, want_ipproto_num;
int which_counter, topN_counter, fetch_from_file, sum_counters, num_counters;
- u_int64_t what_to_count, have_wtc;
+ u_int64_t what_to_count, what_to_count_2, have_wtc;
u_int32_t tmpnum;
int PbgpSz = FALSE;
@@ -469,6 +493,7 @@
num_counters = FALSE;
fetch_from_file = FALSE;
what_to_count = FALSE;
+ what_to_count_2 = FALSE;
have_wtc = FALSE;
want_output = PRINT_OUTPUT_FORMATTED;
@@ -547,6 +572,20 @@
count_token_int[count_index] = COUNT_IP_TOS;
what_to_count |= COUNT_IP_TOS;
}
+#if defined WITH_GEOIP
+ else if (!strcmp(count_token[count_index], "src_host_country")) {
+ count_token_int[count_index] = COUNT_SRC_HOST_COUNTRY;
+ what_to_count_2 |= COUNT_SRC_HOST_COUNTRY;
+ }
+ else if (!strcmp(count_token[count_index], "dst_host_country")) {
+ count_token_int[count_index] = COUNT_DST_HOST_COUNTRY;
+ what_to_count_2 |= COUNT_DST_HOST_COUNTRY;
+ }
+#endif
+ else if (!strcmp(count_token[count_index], "sampling_rate")) {
+ count_token_int[count_index] = COUNT_SAMPLING_RATE;
+ what_to_count_2 |= COUNT_SAMPLING_RATE;
+ }
else if (!strcmp(count_token[count_index], "none")) {
count_token_int[count_index] = COUNT_NONE;
what_to_count |= COUNT_NONE;
@@ -752,7 +791,7 @@
exit(1);
}
- if ((want_counter || want_match) && !what_to_count) {
+ if ((want_counter || want_match) && (!what_to_count && !what_to_count_2)) {
printf("ERROR: -N or -M selected but -c has not been specified or is invalid.\n Exiting...\n\n");
usage_client(argv[0]);
exit(1);
@@ -788,7 +827,7 @@
}
/* Sanitizing the aggregation method */
- if (what_to_count) {
+ if (what_to_count || what_to_count_2) {
if (what_to_count & COUNT_STD_COMM && what_to_count & COUNT_EXT_COMM) {
printf("ERROR: The use of STANDARD and EXTENDED BGP communitities is mutual exclusive.\n");
exit(1);
@@ -888,12 +927,11 @@
/* 4th step: build queries */
for (q.num = 0; (q.num < strnum) && (q.num < MAX_QUERIES); q.num++) {
- u_int64_t entry_wtc = what_to_count;
-
match_string_ptr = strings[q.num];
match_string_index = 0;
memset(&request, 0, sizeof(struct query_entry));
request.what_to_count = what_to_count;
+ request.what_to_count_2 = what_to_count_2;
while ((*match_string_ptr != '\0') && (match_string_index < count_index)) {
match_string_token = pmc_extract_token(&match_string_ptr, ',');
@@ -992,6 +1030,17 @@
tmpnum = atoi(match_string_token);
request.data.tos = (u_int8_t) tmpnum;
}
+#if defined WITH_GEOIP
+ else if (!strcmp(count_token[match_string_index], "src_host_country")) {
+ request.data.src_ip_country = GeoIP_id_by_code(match_string_token);
+ }
+ else if (!strcmp(count_token[match_string_index], "dst_host_country")) {
+ request.data.dst_ip_country = GeoIP_id_by_code(match_string_token);
+ }
+#endif
+ else if (!strcmp(count_token[match_string_index], "sampling_rate")) {
+ request.data.sampling_rate = atoi(match_string_token);
+ }
else if (!strcmp(count_token[match_string_index], "proto")) {
int proto;
@@ -1234,6 +1283,7 @@
if (want_all_fields) have_wtc = FALSE;
else have_wtc = TRUE;
what_to_count = ((struct query_header *)largebuf)->what_to_count;
+ what_to_count_2 = ((struct query_header *)largebuf)->what_to_count_2;
if (check_data_sizes((struct query_header *)largebuf, acc_elem)) exit(1);
/* Before going on with the output, we need to retrieve the class strings
@@ -1270,9 +1320,9 @@
PbgpSz = TRUE;
if (want_output == PRINT_OUTPUT_FORMATTED)
- write_stats_header_formatted(what_to_count, have_wtc);
+ write_stats_header_formatted(what_to_count, what_to_count_2, have_wtc);
else if (want_output == PRINT_OUTPUT_CSV)
- write_stats_header_csv(what_to_count, have_wtc);
+ write_stats_header_csv(what_to_count, what_to_count_2, have_wtc);
elem = largebuf+sizeof(struct query_header);
unpacked -= sizeof(struct query_header);
@@ -1637,6 +1687,23 @@
else if (want_output == PRINT_OUTPUT_CSV) printf("%u,", acc_elem->primitives.tos);
}
+#if defined WITH_GEOIP
+ if (!have_wtc || (what_to_count_2 & COUNT_SRC_HOST_COUNTRY)) {
+ if (want_output == PRINT_OUTPUT_FORMATTED) printf("%-5s ", GeoIP_code_by_id(acc_elem->primitives.src_ip_country));
+ else if (want_output == PRINT_OUTPUT_CSV) printf("%u,", GeoIP_code_by_id(acc_elem->primitives.src_ip_country));
+ }
+
+ if (!have_wtc || (what_to_count_2 & COUNT_DST_HOST_COUNTRY)) {
+ if (want_output == PRINT_OUTPUT_FORMATTED) printf("%-5s ", GeoIP_code_by_id(acc_elem->primitives.dst_ip_country));
+ else if (want_output == PRINT_OUTPUT_CSV) printf("%u,", GeoIP_code_by_id(acc_elem->primitives.dst_ip_country));
+ }
+#endif
+
+ if (!have_wtc || (what_to_count_2 & COUNT_SAMPLING_RATE)) {
+ if (want_output == PRINT_OUTPUT_FORMATTED) printf("%-7u ", acc_elem->primitives.sampling_rate);
+ else if (want_output == PRINT_OUTPUT_CSV) printf("%u,", acc_elem->primitives.sampling_rate);
+ }
+
#if defined HAVE_64BIT_COUNTERS
if (want_output == PRINT_OUTPUT_FORMATTED) printf("%-20llu ", acc_elem->pkt_num);
else if (want_output == PRINT_OUTPUT_CSV) printf("%llu,", acc_elem->pkt_num);
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/pmacct.h
^
|
@@ -66,6 +66,12 @@
#endif
#endif
+#if defined (WITH_GEOIP)
+#include <GeoIP.h>
+#endif
+
+#include "pmacct-build.h"
+
#if !defined INET_ADDRSTRLEN
#define INET_ADDRSTRLEN 16
#endif
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/pmacctd.c
^
|
@@ -46,19 +46,19 @@
/* Functions */
void usage_daemon(char *prog_name)
{
- printf("%s\n", PMACCTD_USAGE_HEADER);
+ printf("%s (%s)\n", PMACCTD_USAGE_HEADER, PMACCT_BUILD);
printf("Usage: %s [ -D | -d ] [ -i interface ] [ -c primitive [ , ... ] ] [ -P plugin [ , ... ] ] [ filter ]\n", prog_name);
printf(" %s [ -f config_file ]\n", prog_name);
printf(" %s [ -h ]\n", prog_name);
printf("\nGeneral options:\n");
printf(" -h \tShow this page\n");
printf(" -f \tLoad configuration from the specified file\n");
- printf(" -c \t[ src_mac | dst_mac | vlan | src_host | dst_host | src_net | dst_net | src_port | dst_port |\n\t proto | tos | src_as | dst_as | sum_mac | sum_host | sum_net | sum_as | sum_port | tag |\n\t tag2 | flows | class | tcpflags | in_iface | out_iface | src_mask | dst_mask | cos | etype | none ] \n\tAggregation string (DEFAULT: src_host)\n");
+ printf(" -c \t[ src_mac | dst_mac | vlan | src_host | dst_host | src_net | dst_net | src_port | dst_port |\n\t proto | tos | src_as | dst_as | sum_mac | sum_host | sum_net | sum_as | sum_port | tag |\n\t tag2 | flows | class | tcpflags | in_iface | out_iface | src_mask | dst_mask | cos | etype |\n\t sampling_rate | src_host_country | dst_host_country | none ]\n\tAggregation string (DEFAULT: src_host)\n");
printf(" -D \tDaemonize\n");
printf(" -N \tDisable promiscuous mode\n");
printf(" -n \tPath to a file containing Network definitions\n");
printf(" -o \tPath to a file containing Port definitions\n");
- printf(" -P \t[ memory | print | mysql | pgsql | sqlite3 | nfprobe | sfprobe ] \n\tActivate plugin\n");
+ printf(" -P \t[ memory | print | mysql | pgsql | sqlite3 | mongodb | nfprobe | sfprobe ] \n\tActivate plugin\n");
printf(" -d \tEnable debug\n");
printf(" -i \tListen on the specified interface\n");
printf(" -I \tRead packets from the specified savefile\n");
@@ -233,10 +233,6 @@
strlcpy(cfg_cmdline[rows], "sql_refresh_time: ", SRVBUFLEN);
strncat(cfg_cmdline[rows], optarg, CFG_LINE_LEN(cfg_cmdline[rows]));
rows++;
- cfg_cmdline[rows] = malloc(SRVBUFLEN);
- strlcpy(cfg_cmdline[rows], "print_refresh_time: ", SRVBUFLEN);
- strncat(cfg_cmdline[rows], optarg, CFG_LINE_LEN(cfg_cmdline[rows]));
- rows++;
break;
case 'v':
strlcpy(cfg_cmdline[rows], "sql_table_version: ", SRVBUFLEN);
@@ -383,7 +379,9 @@
config.handle_fragments = TRUE;
list->cfg.nfprobe_what_to_count = list->cfg.what_to_count;
+ list->cfg.nfprobe_what_to_count_2 = list->cfg.what_to_count_2;
list->cfg.what_to_count = 0;
+ list->cfg.what_to_count_2 = 0;
#if defined (HAVE_L2)
if (list->cfg.nfprobe_version == 9 || list->cfg.nfprobe_version == 10) {
list->cfg.what_to_count |= COUNT_SRC_MAC;
@@ -437,6 +435,7 @@
if (psize < 128) psize = config.snaplen = 128; /* SFL_DEFAULT_HEADER_SIZE */
list->cfg.what_to_count = COUNT_PAYLOAD;
+ list->cfg.what_to_count_2 = 0;
if (list->cfg.classifiers_path) {
list->cfg.what_to_count |= COUNT_CLASS;
config.handle_fragments = TRUE;
@@ -483,13 +482,17 @@
config.handle_fragments = TRUE;
config.handle_flows = TRUE;
}
- if (!list->cfg.what_to_count) {
+ if (!list->cfg.what_to_count && !list->cfg.what_to_count_2) {
Log(LOG_WARNING, "WARN ( %s/%s ): defaulting to SRC HOST aggregation.\n", list->name, list->type.string);
list->cfg.what_to_count |= COUNT_SRC_HOST;
}
- if ((list->cfg.what_to_count & (COUNT_SRC_AS|COUNT_DST_AS|COUNT_SUM_AS)) && !list->cfg.networks_file && list->cfg.nfacctd_as != NF_AS_BGP) {
- Log(LOG_ERR, "ERROR ( %s/%s ): AS aggregation selected but NO 'networks_file' or 'pmacctd_as' are specified. Exiting...\n\n", list->name, list->type.string);
- exit(1);
+ if (list->cfg.what_to_count & (COUNT_SRC_AS|COUNT_DST_AS|COUNT_SUM_AS)) {
+ if (!list->cfg.networks_file && list->cfg.nfacctd_as != NF_AS_BGP) {
+ Log(LOG_ERR, "ERROR ( %s/%s ): AS aggregation selected but NO 'networks_file' or 'pmacctd_as' are specified. Exiting...\n\n", list->name, list->type.string);
+ exit(1);
+ }
+ if (list->cfg.nfacctd_as & NF_AS_FALLBACK && list->cfg.networks_file)
+ list->cfg.nfacctd_as |= NF_AS_NEW;
}
if (list->cfg.what_to_count & (COUNT_SRC_NET|COUNT_DST_NET|COUNT_SUM_NET|COUNT_SRC_NMASK|COUNT_DST_NMASK|COUNT_PEER_DST_IP)) {
if (!list->cfg.nfacctd_net) {
@@ -509,6 +512,8 @@
Log(LOG_ERR, "ERROR ( %s/%s ): network aggregation selected but none of 'bgp_daemon', 'isis_daemon', 'networks_file', 'networks_mask' is specified. Exiting ...\n\n", list->name, list->type.string);
exit(1);
}
+ if (list->cfg.nfacctd_net & NF_NET_FALLBACK && list->cfg.networks_file)
+ list->cfg.nfacctd_net |= NF_NET_NEW;
}
}
if (list->cfg.what_to_count & COUNT_CLASS && !list->cfg.classifiers_path) {
@@ -735,6 +740,12 @@
}
#endif
+#if defined WITH_GEOIP
+ if (config.geoip_ipv4_file || config.geoip_ipv6_file) {
+ req.bpf_filter = TRUE;
+ }
+#endif
+
/* Init tunnel handlers */
tunnel_registry_init();
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/pretag_handlers.c
^
|
@@ -915,6 +915,7 @@
u_int8_t neg = entry->input.neg;
switch(hdr->version) {
+ case 10:
case 9:
if (tpl->tpl[NF9_INPUT_SNMP].len == 2) {
if (!memcmp(&input16, pptrs->f_data+tpl->tpl[NF9_INPUT_SNMP].off, tpl->tpl[NF9_INPUT_SNMP].len))
@@ -976,6 +977,7 @@
u_int8_t neg = entry->output.neg;
switch(hdr->version) {
+ case 10:
case 9:
if (tpl->tpl[NF9_OUTPUT_SNMP].len == 2) {
if (!memcmp(&output16, pptrs->f_data+tpl->tpl[NF9_OUTPUT_SNMP].off, tpl->tpl[NF9_OUTPUT_SNMP].len))
@@ -1037,6 +1039,7 @@
struct template_cache_entry *tpl = (struct template_cache_entry *) pptrs->f_tpl;
switch(hdr->version) {
+ case 10:
case 9:
if (entry->nexthop.a.family == AF_INET) {
if (!memcmp(&entry->nexthop.a.address.ipv4, pptrs->f_data+tpl->tpl[NF9_IPV4_NEXT_HOP].off, tpl->tpl[NF9_IPV4_NEXT_HOP].len))
@@ -1070,6 +1073,7 @@
if (!evaluate_lm_method(pptrs, TRUE, config.nfacctd_net, NF_NET_KEEP)) return;
switch(hdr->version) {
+ case 10:
case 9:
if (entry->bgp_nexthop.a.family == AF_INET) {
if (!memcmp(&entry->bgp_nexthop.a.address.ipv4, pptrs->f_data+tpl->tpl[NF9_BGP_IPV4_NEXT_HOP].off, tpl->tpl[NF9_BGP_IPV4_NEXT_HOP].len))
@@ -1235,6 +1239,7 @@
if (entry->last_matched == PRETAG_SRC_AS) return FALSE;
switch(hdr->version) {
+ case 10:
case 9:
if (tpl->tpl[NF9_SRC_AS].len == 2) {
memcpy(&asn16, pptrs->f_data+tpl->tpl[NF9_SRC_AS].off, 2);
@@ -1314,6 +1319,7 @@
if (entry->last_matched == PRETAG_DST_AS) return FALSE;
switch(hdr->version) {
+ case 10:
case 9:
if (tpl->tpl[NF9_DST_AS].len == 2) {
memcpy(&asn16, pptrs->f_data+tpl->tpl[NF9_DST_AS].off, 2);
@@ -1541,6 +1547,7 @@
u_int16_t direction = 0;
switch (hdr->version) {
+ case 10:
case 9:
if (tpl->tpl[NF9_DIRECTION].len == 1) {
memcpy(&direction, pptrs->f_data+tpl->tpl[NF9_DIRECTION].off, 1);
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/print_plugin.c
^
|
@@ -1,6 +1,6 @@
/*
pmacct (Promiscuous mode IP Accounting package)
- pmacct is Copyright (C) 2003-2012 by Paolo Lucente
+ pmacct is Copyright (C) 2003-2013 by Paolo Lucente
*/
/*
@@ -63,6 +63,13 @@
reload_map = FALSE;
+ basetime_init = NULL;
+ basetime_eval = NULL;
+ basetime_cmp = NULL;
+ memset(&basetime, 0, sizeof(basetime));
+ memset(&ibasetime, 0, sizeof(ibasetime));
+ memset(×lot, 0, sizeof(timeslot));
+
/* signal handling */
signal(SIGINT, P_exit_now);
signal(SIGUSR1, SIG_IGN);
@@ -74,13 +81,13 @@
signal(SIGCHLD, ignore_falling_child);
#endif
- if (!config.print_refresh_time)
- config.print_refresh_time = DEFAULT_PRINT_REFRESH_TIME;
+ if (!config.sql_refresh_time)
+ config.sql_refresh_time = DEFAULT_PRINT_REFRESH_TIME;
if (!config.print_output)
config.print_output = PRINT_OUTPUT_FORMATTED;
- timeout = config.print_refresh_time*1000;
+ timeout = config.sql_refresh_time*1000;
if (config.what_to_count & (COUNT_SUM_HOST|COUNT_SUM_NET))
insert_func = P_sum_host_insert;
@@ -132,9 +139,9 @@
/* print_refresh time init: deadline */
refresh_deadline = now;
t = roundoff_time(refresh_deadline, config.sql_history_roundoff);
- while ((t+config.print_refresh_time) < refresh_deadline) t += config.print_refresh_time;
+ while ((t+config.sql_refresh_time) < refresh_deadline) t += config.sql_refresh_time;
refresh_deadline = t;
- refresh_deadline += config.print_refresh_time; /* it's a deadline not a basetime */
+ refresh_deadline += config.sql_refresh_time; /* it's a deadline not a basetime */
/* setting number of entries in _protocols structure */
while (_protocols[protocols_number].number != -1) protocols_number++;
@@ -154,6 +161,7 @@
for(;;) {
poll_again:
status->wakeup = TRUE;
+ calc_refresh_timeout(refresh_deadline, now, &timeout);
ret = poll(&pfd, 1, timeout);
if (ret < 0) goto poll_again;
@@ -161,23 +169,21 @@
switch (ret) {
case 0: /* timeout */
- if (qq_ptr) {
- switch (fork()) {
- case 0: /* Child */
- P_cache_purge(queries_queue, qq_ptr);
- exit(0);
- default: /* Parent */
- P_cache_flush(queries_queue, qq_ptr);
- gettimeofday(&flushtime, NULL);
- refresh_deadline += config.print_refresh_time;
- qq_ptr = FALSE;
- if (reload_map) {
- load_networks(config.networks_file, &nt, &nc);
- load_ports(config.ports_file, &pt);
- reload_map = FALSE;
- }
- break;
- }
+ switch (fork()) {
+ case 0: /* Child */
+ P_cache_purge(queries_queue, qq_ptr);
+ exit(0);
+ default: /* Parent */
+ P_cache_flush(queries_queue, qq_ptr);
+ gettimeofday(&flushtime, NULL);
+ refresh_deadline += config.sql_refresh_time;
+ qq_ptr = FALSE;
+ if (reload_map) {
+ load_networks(config.networks_file, &nt, &nc);
+ load_ports(config.ports_file, &pt);
+ reload_map = FALSE;
+ }
+ break;
}
break;
default: /* we received data */
@@ -225,7 +231,7 @@
default: /* Parent */
P_cache_flush(queries_queue, qq_ptr);
gettimeofday(&flushtime, NULL);
- refresh_deadline += config.print_refresh_time;
+ refresh_deadline += config.sql_refresh_time;
qq_ptr = FALSE;
if (reload_map) {
load_networks(config.networks_file, &nt, &nc);
@@ -281,16 +287,22 @@
{
unsigned int modulo = P_cache_modulo(data, pbgp);
struct chained_cache *cache_ptr = &cache[modulo];
- int res_data = TRUE, res_bgp = TRUE;
+ int res_data = TRUE, res_bgp = TRUE, res_time = TRUE;
start:
res_data = memcmp(&cache_ptr->primitives, data, sizeof(struct pkt_primitives));
+
+ if (basetime_cmp) {
+ res_time = (*basetime_cmp)(&cache_ptr->basetime, &ibasetime);
+ }
+ else res_time = FALSE;
+
if (PbgpSz) {
if (cache_ptr->pbgp) res_bgp = memcmp(cache_ptr->pbgp, pbgp, sizeof(struct pkt_bgp_primitives));
}
else res_bgp = FALSE;
- if (res_data || res_bgp) {
+ if (res_data || res_bgp || res_time) {
if (cache_ptr->valid == TRUE) {
if (cache_ptr->next) {
cache_ptr = cache_ptr->next;
@@ -308,7 +320,12 @@
unsigned int modulo = P_cache_modulo(&data->primitives, pbgp);
struct chained_cache *cache_ptr = &cache[modulo];
struct pkt_primitives *srcdst = &data->primitives;
- int res_data, res_bgp;
+ int res_data, res_bgp, res_time;
+
+ if (config.sql_history && (*basetime_eval)) {
+ memcpy(&ibasetime, &basetime, sizeof(ibasetime));
+ (*basetime_eval)(&data->time_start, &ibasetime, timeslot);
+ }
/* We are classifing packets. We have a non-zero bytes accumulator (ba)
and a non-zero class. Before accounting ba to this class, we have to
@@ -339,15 +356,21 @@
}
start:
- res_data = res_bgp = TRUE;
+ res_data = res_bgp = res_time = TRUE;
res_data = memcmp(&cache_ptr->primitives, srcdst, sizeof(struct pkt_primitives));
+
+ if (basetime_cmp) {
+ res_time = (*basetime_cmp)(&cache_ptr->basetime, &ibasetime);
+ }
+ else res_time = FALSE;
+
if (PbgpSz) {
if (cache_ptr->pbgp) res_bgp = memcmp(cache_ptr->pbgp, pbgp, sizeof(struct pkt_bgp_primitives));
}
else res_bgp = FALSE;
- if (res_data || res_bgp) {
+ if (res_data || res_bgp || res_time) {
/* aliasing of entries */
if (cache_ptr->valid == TRUE) {
if (cache_ptr->next) {
@@ -389,6 +412,8 @@
cache_ptr->flow_counter += data->cst.fa;
}
cache_ptr->valid = TRUE;
+ cache_ptr->basetime.tv_sec = ibasetime.tv_sec;
+ cache_ptr->basetime.tv_usec = ibasetime.tv_usec;
}
else {
if (cache_ptr->valid == TRUE) {
@@ -415,6 +440,8 @@
cache_ptr->flow_counter += data->cst.fa;
}
cache_ptr->valid = TRUE;
+ cache_ptr->basetime.tv_sec = ibasetime.tv_sec;
+ cache_ptr->basetime.tv_usec = ibasetime.tv_usec;
queries_queue[qq_ptr] = cache_ptr;
qq_ptr++;
}
@@ -451,14 +478,15 @@
struct pkt_bgp_primitives empty_pbgp;
char src_mac[18], dst_mac[18], src_host[INET6_ADDRSTRLEN], dst_host[INET6_ADDRSTRLEN], ip_address[INET6_ADDRSTRLEN];
char rd_str[SRVBUFLEN];
- char *as_path, *bgp_comm, empty_aspath[] = "^$";
+ char *as_path, *bgp_comm, empty_aspath[] = "^$", empty_ip4[] = "0.0.0.0", empty_ip6[] = "::";
+ char empty_macaddress[] = "00:00:00:00:00:00", empty_rd[] = "0:0";
FILE *f = NULL;
int j;
memset(&empty_pbgp, 0, sizeof(struct pkt_bgp_primitives));
if (config.sql_table) {
- f = open_print_output_file(config.sql_table, refresh_deadline-config.print_refresh_time);
+ f = open_print_output_file(config.sql_table, refresh_deadline-config.sql_refresh_time);
if (f) {
if (config.print_output == PRINT_OUTPUT_FORMATTED)
@@ -469,8 +497,8 @@
}
else f = stdout; /* write to standard output */
- if (f && config.print_markers) fprintf(f, "--START (%ld+%d)--\n", refresh_deadline-config.print_refresh_time,
- config.print_refresh_time);
+ if (f && config.print_markers) fprintf(f, "--START (%ld+%d)--\n", refresh_deadline-config.sql_refresh_time,
+ config.sql_refresh_time);
for (j = 0; j < index; j++) {
data = &queue[j]->primitives;
@@ -481,88 +509,148 @@
continue;
if (f && config.print_output == PRINT_OUTPUT_FORMATTED) {
- fprintf(f, "%-10llu ", data->id);
- fprintf(f, "%-10llu ", data->id2);
- fprintf(f, "%-16s ", ((data->class && class[(data->class)-1].id) ? class[(data->class)-1].protocol : "unknown" ));
+ if (config.what_to_count & COUNT_ID) fprintf(f, "%-10llu ", data->id);
+ if (config.what_to_count & COUNT_ID2) fprintf(f, "%-10llu ", data->id2);
+ if (config.what_to_count & COUNT_CLASS) fprintf(f, "%-16s ", ((data->class && class[(data->class)-1].id) ? class[(data->class)-1].protocol : "unknown" ));
#if defined (HAVE_L2)
- etheraddr_string(data->eth_shost, src_mac);
- fprintf(f, "%-17s ", src_mac);
- etheraddr_string(data->eth_dhost, dst_mac);
- fprintf(f, "%-17s ", dst_mac);
- fprintf(f, "%-5u ", data->vlan_id);
- fprintf(f, "%-2u ", data->cos);
- fprintf(f, "%-5x ", data->etype);
-#endif
- fprintf(f, "%-10u ", data->src_as);
- fprintf(f, "%-10u ", data->dst_as);
-
- bgp_comm = pbgp->std_comms;
- while (bgp_comm) {
- bgp_comm = strchr(pbgp->std_comms, ' ');
- if (bgp_comm) *bgp_comm = '_';
- }
-
- if (strlen(pbgp->std_comms))
- fprintf(f, "%-22s ", pbgp->std_comms);
- else
- fprintf(f, "%-22u ", 0);
-
- as_path = pbgp->as_path;
- while (as_path) {
- as_path = strchr(pbgp->as_path, ' ');
- if (as_path) *as_path = '_';
- }
- if (strlen(pbgp->as_path))
- fprintf(f, "%-22s ", pbgp->as_path);
- else
- fprintf(f, "%-22s ", empty_aspath);
-
- fprintf(f, "%-5u ", pbgp->local_pref);
- fprintf(f, "%-5u ", pbgp->med);
- fprintf(f, "%-10u ", pbgp->peer_src_as);
- fprintf(f, "%-10u ", pbgp->peer_dst_as);
+ if (config.what_to_count & COUNT_SRC_MAC) {
+ etheraddr_string(data->eth_shost, src_mac);
+ if (strlen(src_mac))
+ fprintf(f, "%-17s ", src_mac);
+ else
+ fprintf(f, "%-17s ", empty_macaddress);
+ }
+ if (config.what_to_count & COUNT_DST_MAC) {
+ etheraddr_string(data->eth_dhost, dst_mac);
+ if (strlen(dst_mac))
+ fprintf(f, "%-17s ", dst_mac);
+ else
+ fprintf(f, "%-17s ", empty_macaddress);
+ }
+ if (config.what_to_count & COUNT_VLAN) fprintf(f, "%-5u ", data->vlan_id);
+ if (config.what_to_count & COUNT_COS) fprintf(f, "%-2u ", data->cos);
+ if (config.what_to_count & COUNT_ETHERTYPE) fprintf(f, "%-5x ", data->etype);
+#endif
+ if (config.what_to_count & COUNT_SRC_AS) fprintf(f, "%-10u ", data->src_as);
+ if (config.what_to_count & COUNT_DST_AS) fprintf(f, "%-10u ", data->dst_as);
+
+ if (config.what_to_count & COUNT_STD_COMM) {
+ bgp_comm = pbgp->std_comms;
+ while (bgp_comm) {
+ bgp_comm = strchr(pbgp->std_comms, ' ');
+ if (bgp_comm) *bgp_comm = '_';
+ }
- addr_to_str(ip_address, &pbgp->peer_src_ip);
+ if (strlen(pbgp->std_comms))
+ fprintf(f, "%-22s ", pbgp->std_comms);
+ else
+ fprintf(f, "%-22u ", 0);
+ }
+
+ if (config.what_to_count & COUNT_AS_PATH) {
+ as_path = pbgp->as_path;
+ while (as_path) {
+ as_path = strchr(pbgp->as_path, ' ');
+ if (as_path) *as_path = '_';
+ }
+ if (strlen(pbgp->as_path))
+ fprintf(f, "%-22s ", pbgp->as_path);
+ else
+ fprintf(f, "%-22s ", empty_aspath);
+ }
+
+ if (config.what_to_count & COUNT_LOCAL_PREF) fprintf(f, "%-5u ", pbgp->local_pref);
+ if (config.what_to_count & COUNT_MED) fprintf(f, "%-5u ", pbgp->med);
+ if (config.what_to_count & COUNT_PEER_SRC_AS) fprintf(f, "%-10u ", pbgp->peer_src_as);
+ if (config.what_to_count & COUNT_PEER_DST_AS) fprintf(f, "%-10u ", pbgp->peer_dst_as);
+
+ if (config.what_to_count & COUNT_PEER_SRC_IP) {
+ addr_to_str(ip_address, &pbgp->peer_src_ip);
#if defined ENABLE_IPV6
- fprintf(f, "%-45s ", ip_address);
+ if (strlen(ip_address))
+ fprintf(f, "%-45s ", ip_address);
+ else
+ fprintf(f, "%-45s ", empty_ip6);
#else
- fprintf(f, "%-15s ", ip_address);
+ if (strlen(ip_address))
+ fprintf(f, "%-15s ", ip_address);
+ else
+ fprintf(f, "%-15s ", empty_ip4);
#endif
- addr_to_str(ip_address, &pbgp->peer_dst_ip);
+ }
+ if (config.what_to_count & COUNT_PEER_DST_IP) {
+ addr_to_str(ip_address, &pbgp->peer_dst_ip);
#if defined ENABLE_IPV6
- fprintf(f, "%-45s ", ip_address);
+ if (strlen(ip_address))
+ fprintf(f, "%-45s ", ip_address);
+ else
+ fprintf(f, "%-45s ", empty_ip6);
#else
- fprintf(f, "%-15s ", ip_address);
+ if (strlen(ip_address))
+ fprintf(f, "%-15s ", ip_address);
+ else
+ fprintf(f, "%-15s ", empty_ip4);
#endif
+ }
- fprintf(f, "%-10u ", data->ifindex_in);
- fprintf(f, "%-10u ", data->ifindex_out);
+ if (config.what_to_count & COUNT_IN_IFACE) fprintf(f, "%-10u ", data->ifindex_in);
+ if (config.what_to_count & COUNT_OUT_IFACE) fprintf(f, "%-10u ", data->ifindex_out);
- bgp_rd2str(rd_str, &pbgp->mpls_vpn_rd);
- fprintf(f, "%-18s ", rd_str);
+ if (config.what_to_count & COUNT_MPLS_VPN_RD) {
+ bgp_rd2str(rd_str, &pbgp->mpls_vpn_rd);
+ if (strlen(rd_str))
+ fprintf(f, "%-18s ", rd_str);
+ else
+ fprintf(f, "%-18s ", empty_rd);
+ }
- addr_to_str(src_host, &data->src_ip);
+ if (config.what_to_count & COUNT_SRC_HOST) {
+ addr_to_str(src_host, &data->src_ip);
#if defined ENABLE_IPV6
- fprintf(f, "%-45s ", src_host);
+ if (strlen(src_host))
+ fprintf(f, "%-45s ", src_host);
+ else
+ fprintf(f, "%-45s ", empty_ip6);
#else
- fprintf(f, "%-15s ", src_host);
+ if (strlen(src_host))
+ fprintf(f, "%-15s ", src_host);
+ else
+ fprintf(f, "%-15s ", empty_ip4);
#endif
- addr_to_str(dst_host, &data->dst_ip);
+ }
+ if (config.what_to_count & COUNT_DST_HOST) {
+ addr_to_str(dst_host, &data->dst_ip);
#if defined ENABLE_IPV6
- fprintf(f, "%-45s ", dst_host);
+ if (strlen(dst_host))
+ fprintf(f, "%-45s ", dst_host);
+ else
+ fprintf(f, "%-45s ", empty_ip6);
#else
- fprintf(f, "%-15s ", dst_host);
+ if (strlen(dst_host))
+ fprintf(f, "%-15s ", dst_host);
+ else
+ fprintf(f, "%-15s ", empty_ip4);
#endif
- fprintf(f, "%-3u ", data->src_nmask);
- fprintf(f, "%-3u ", data->dst_nmask);
- fprintf(f, "%-5u ", data->src_port);
- fprintf(f, "%-5u ", data->dst_port);
- fprintf(f, "%-3u ", queue[j]->tcp_flags);
+ }
+ if (config.what_to_count & COUNT_SRC_NMASK) fprintf(f, "%-3u ", data->src_nmask);
+ if (config.what_to_count & COUNT_DST_NMASK) fprintf(f, "%-3u ", data->dst_nmask);
+ if (config.what_to_count & COUNT_SRC_PORT) fprintf(f, "%-5u ", data->src_port);
+ if (config.what_to_count & COUNT_DST_PORT) fprintf(f, "%-5u ", data->dst_port);
+ if (config.what_to_count & COUNT_TCPFLAGS) fprintf(f, "%-3u ", queue[j]->tcp_flags);
+
+ if (config.what_to_count & COUNT_IP_PROTO) {
+ if (!config.num_protos) fprintf(f, "%-10s ", _protocols[data->proto].name);
+ else fprintf(f, "%-10d ", _protocols[data->proto].number);
+ }
+
+ if (config.what_to_count & COUNT_IP_TOS) fprintf(f, "%-3u ", data->tos);
- if (!config.num_protos) fprintf(f, "%-10s ", _protocols[data->proto].name);
- else fprintf(f, "%-10d ", _protocols[data->proto].number);
+#if defined WITH_GEOIP
+ if (config.what_to_count_2 & COUNT_SRC_HOST_COUNTRY) fprintf(f, "%-5s ", GeoIP_code_by_id(data->src_ip_country));
+ if (config.what_to_count_2 & COUNT_DST_HOST_COUNTRY) fprintf(f, "%-5s ", GeoIP_code_by_id(data->dst_ip_country));
+#endif
- fprintf(f, "%-3u ", data->tos);
+ if (config.what_to_count_2 & COUNT_SAMPLING_RATE) fprintf(f, "%-7u ", data->sampling_rate);
#if defined HAVE_64BIT_COUNTERS
fprintf(f, "%-20llu ", queue[j]->packet_counter);
fprintf(f, "%-20llu ", queue[j]->flow_counter);
@@ -574,70 +662,97 @@
#endif
}
else if (f && config.print_output == PRINT_OUTPUT_CSV) {
- fprintf(f, "%llu,", data->id);
- fprintf(f, "%llu,", data->id2);
- fprintf(f, "%s,", ((data->class && class[(data->class)-1].id) ? class[(data->class)-1].protocol : "unknown" ));
+ if (config.what_to_count & COUNT_ID) fprintf(f, "%llu,", data->id);
+ if (config.what_to_count & COUNT_ID2) fprintf(f, "%llu,", data->id2);
+ if (config.what_to_count & COUNT_CLASS) fprintf(f, "%s,", ((data->class && class[(data->class)-1].id) ? class[(data->class)-1].protocol : "unknown" ));
#if defined (HAVE_L2)
- etheraddr_string(data->eth_shost, src_mac);
- fprintf(f, "%s,", src_mac);
- etheraddr_string(data->eth_dhost, dst_mac);
- fprintf(f, "%s,", dst_mac);
- fprintf(f, "%u,", data->vlan_id);
- fprintf(f, "%u,", data->cos);
- fprintf(f, "%x,", data->etype);
-#endif
- fprintf(f, "%u,", data->src_as);
- fprintf(f, "%u,", data->dst_as);
-
- bgp_comm = pbgp->std_comms;
- while (bgp_comm) {
- bgp_comm = strchr(pbgp->std_comms, ' ');
- if (bgp_comm) *bgp_comm = '_';
- }
-
- if (strlen(pbgp->std_comms))
- fprintf(f, "%s,", pbgp->std_comms);
- else
- fprintf(f, "%u,", 0);
-
- as_path = pbgp->as_path;
- while (as_path) {
- as_path = strchr(pbgp->as_path, ' ');
- if (as_path) *as_path = '_';
- }
- fprintf(f, "%s,", pbgp->as_path);
-
- fprintf(f, "%u,", pbgp->local_pref);
- fprintf(f, "%u,", pbgp->med);
- fprintf(f, "%u,", pbgp->peer_src_as);
- fprintf(f, "%u,", pbgp->peer_dst_as);
-
- addr_to_str(ip_address, &pbgp->peer_src_ip);
- fprintf(f, "%s,", ip_address);
- addr_to_str(ip_address, &pbgp->peer_dst_ip);
- fprintf(f, "%s,", ip_address);
-
- fprintf(f, "%u,", data->ifindex_in);
- fprintf(f, "%u,", data->ifindex_out);
-
- bgp_rd2str(rd_str, &pbgp->mpls_vpn_rd);
- fprintf(f, "%s,", rd_str);
-
- addr_to_str(src_host, &data->src_ip);
- fprintf(f, "%s,", src_host);
- addr_to_str(dst_host, &data->dst_ip);
- fprintf(f, "%s,", dst_host);
-
- fprintf(f, "%u,", data->src_nmask);
- fprintf(f, "%u,", data->dst_nmask);
- fprintf(f, "%u,", data->src_port);
- fprintf(f, "%u,", data->dst_port);
- fprintf(f, "%u,", queue[j]->tcp_flags);
+ if (config.what_to_count & COUNT_SRC_MAC) {
+ etheraddr_string(data->eth_shost, src_mac);
+ fprintf(f, "%s,", src_mac);
+ }
+ if (config.what_to_count & COUNT_DST_MAC) {
+ etheraddr_string(data->eth_dhost, dst_mac);
+ fprintf(f, "%s,", dst_mac);
+ }
+ if (config.what_to_count & COUNT_VLAN) fprintf(f, "%u,", data->vlan_id);
+ if (config.what_to_count & COUNT_COS) fprintf(f, "%u,", data->cos);
+ if (config.what_to_count & COUNT_ETHERTYPE) fprintf(f, "%x,", data->etype);
+#endif
+ if (config.what_to_count & COUNT_SRC_AS) fprintf(f, "%u,", data->src_as);
+ if (config.what_to_count & COUNT_DST_AS) fprintf(f, "%u,", data->dst_as);
+
+ if (config.what_to_count & COUNT_STD_COMM) {
+ bgp_comm = pbgp->std_comms;
+ while (bgp_comm) {
+ bgp_comm = strchr(pbgp->std_comms, ' ');
+ if (bgp_comm) *bgp_comm = '_';
+ }
- if (!config.num_protos) fprintf(f, "%s,", _protocols[data->proto].name);
- else fprintf(f, "%d,", _protocols[data->proto].number);
+ if (strlen(pbgp->std_comms))
+ fprintf(f, "%s,", pbgp->std_comms);
+ else
+ fprintf(f, "%u,", 0);
+ }
- fprintf(f, "%u,", data->tos);
+ if (config.what_to_count & COUNT_AS_PATH) {
+ as_path = pbgp->as_path;
+ while (as_path) {
+ as_path = strchr(pbgp->as_path, ' ');
+ if (as_path) *as_path = '_';
+ }
+ fprintf(f, "%s,", pbgp->as_path);
+ }
+
+ if (config.what_to_count & COUNT_LOCAL_PREF) fprintf(f, "%u,", pbgp->local_pref);
+ if (config.what_to_count & COUNT_MED) fprintf(f, "%u,", pbgp->med);
+ if (config.what_to_count & COUNT_PEER_SRC_AS) fprintf(f, "%u,", pbgp->peer_src_as);
+ if (config.what_to_count & COUNT_PEER_DST_AS) fprintf(f, "%u,", pbgp->peer_dst_as);
+
+ if (config.what_to_count & COUNT_PEER_SRC_IP) {
+ addr_to_str(ip_address, &pbgp->peer_src_ip);
+ fprintf(f, "%s,", ip_address);
+ }
+ if (config.what_to_count & COUNT_PEER_DST_IP) {
+ addr_to_str(ip_address, &pbgp->peer_dst_ip);
+ fprintf(f, "%s,", ip_address);
+ }
+
+ if (config.what_to_count & COUNT_IN_IFACE) fprintf(f, "%u,", data->ifindex_in);
+ if (config.what_to_count & COUNT_OUT_IFACE) fprintf(f, "%u,", data->ifindex_out);
+
+ if (config.what_to_count & COUNT_MPLS_VPN_RD) {
+ bgp_rd2str(rd_str, &pbgp->mpls_vpn_rd);
+ fprintf(f, "%s,", rd_str);
+ }
+
+ if (config.what_to_count & COUNT_SRC_HOST) {
+ addr_to_str(src_host, &data->src_ip);
+ fprintf(f, "%s,", src_host);
+ }
+ if (config.what_to_count & COUNT_DST_HOST) {
+ addr_to_str(dst_host, &data->dst_ip);
+ fprintf(f, "%s,", dst_host);
+ }
+
+ if (config.what_to_count & COUNT_SRC_NMASK) fprintf(f, "%u,", data->src_nmask);
+ if (config.what_to_count & COUNT_DST_NMASK) fprintf(f, "%u,", data->dst_nmask);
+ if (config.what_to_count & COUNT_SRC_PORT) fprintf(f, "%u,", data->src_port);
+ if (config.what_to_count & COUNT_DST_PORT) fprintf(f, "%u,", data->dst_port);
+ if (config.what_to_count & COUNT_TCPFLAGS) fprintf(f, "%u,", queue[j]->tcp_flags);
+
+ if (config.what_to_count & COUNT_IP_PROTO) {
+ if (!config.num_protos) fprintf(f, "%s,", _protocols[data->proto].name);
+ else fprintf(f, "%d,", _protocols[data->proto].number);
+ }
+
+ if (config.what_to_count & COUNT_IP_TOS) fprintf(f, "%u,", data->tos);
+
+#if defined WITH_GEOIP
+ if (config.what_to_count_2 & COUNT_SRC_HOST_COUNTRY) fprintf(f, "%s,", GeoIP_code_by_id(data->src_ip_country));
+ if (config.what_to_count_2 & COUNT_DST_HOST_COUNTRY) fprintf(f, "%s,", GeoIP_code_by_id(data->dst_ip_country));
+#endif
+
+ if (config.what_to_count_2 & COUNT_SAMPLING_RATE) fprintf(f, "%u,", data->sampling_rate);
#if defined HAVE_64BIT_COUNTERS
fprintf(f, "%llu,", queue[j]->packet_counter);
fprintf(f, "%llu,", queue[j]->flow_counter);
@@ -652,50 +767,55 @@
if (f && config.print_markers) fprintf(f, "--END--\n");
- if (f && config.sql_table) fclose(f);
+ if (f && config.sql_table) close_print_output_file(f, config.sql_table, refresh_deadline-config.sql_refresh_time);
if (config.sql_trigger_exec) P_trigger_exec(config.sql_trigger_exec);
}
void P_write_stats_header_formatted(FILE *f)
{
- fprintf(f, "TAG ");
- fprintf(f, "TAG2 ");
- fprintf(f, "CLASS ");
+ if (config.what_to_count & COUNT_ID) fprintf(f, "TAG ");
+ if (config.what_to_count & COUNT_ID2) fprintf(f, "TAG2 ");
+ if (config.what_to_count & COUNT_CLASS) fprintf(f, "CLASS ");
#if defined HAVE_L2
- fprintf(f, "SRC_MAC ");
- fprintf(f, "DST_MAC ");
- fprintf(f, "VLAN ");
- fprintf(f, "COS ");
- fprintf(f, "ETYPE ");
-#endif
- fprintf(f, "SRC_AS ");
- fprintf(f, "DST_AS ");
- fprintf(f, "BGP_COMMS ");
- fprintf(f, "AS_PATH ");
- fprintf(f, "PREF ");
- fprintf(f, "MED ");
- fprintf(f, "PEER_SRC_AS ");
- fprintf(f, "PEER_DST_AS ");
- fprintf(f, "PEER_SRC_IP ");
- fprintf(f, "PEER_DST_IP ");
- fprintf(f, "IN_IFACE ");
- fprintf(f, "OUT_IFACE ");
- fprintf(f, "MPLS_VPN_RD ");
+ if (config.what_to_count & COUNT_SRC_MAC) fprintf(f, "SRC_MAC ");
+ if (config.what_to_count & COUNT_DST_MAC) fprintf(f, "DST_MAC ");
+ if (config.what_to_count & COUNT_VLAN) fprintf(f, "VLAN ");
+ if (config.what_to_count & COUNT_COS) fprintf(f, "COS ");
+ if (config.what_to_count & COUNT_ETHERTYPE) fprintf(f, "ETYPE ");
+#endif
+ if (config.what_to_count & COUNT_SRC_AS) fprintf(f, "SRC_AS ");
+ if (config.what_to_count & COUNT_DST_AS) fprintf(f, "DST_AS ");
+ if (config.what_to_count & COUNT_STD_COMM) fprintf(f, "BGP_COMMS ");
+ if (config.what_to_count & COUNT_AS_PATH) fprintf(f, "AS_PATH ");
+ if (config.what_to_count & COUNT_LOCAL_PREF) fprintf(f, "PREF ");
+ if (config.what_to_count & COUNT_MED) fprintf(f, "MED ");
+ if (config.what_to_count & COUNT_PEER_SRC_AS) fprintf(f, "PEER_SRC_AS ");
+ if (config.what_to_count & COUNT_PEER_DST_AS) fprintf(f, "PEER_DST_AS ");
+ if (config.what_to_count & COUNT_PEER_SRC_IP) fprintf(f, "PEER_SRC_IP ");
+ if (config.what_to_count & COUNT_PEER_DST_IP) fprintf(f, "PEER_DST_IP ");
+ if (config.what_to_count & COUNT_IN_IFACE) fprintf(f, "IN_IFACE ");
+ if (config.what_to_count & COUNT_OUT_IFACE) fprintf(f, "OUT_IFACE ");
+ if (config.what_to_count & COUNT_MPLS_VPN_RD) fprintf(f, "MPLS_VPN_RD ");
#if defined ENABLE_IPV6
- fprintf(f, "SRC_IP ");
- fprintf(f, "DST_IP ");
+ if (config.what_to_count & COUNT_SRC_HOST) fprintf(f, "SRC_IP ");
+ if (config.what_to_count & COUNT_DST_HOST) fprintf(f, "DST_IP ");
#else
- fprintf(f, "SRC_IP ");
- fprintf(f, "DST_IP ");
+ if (config.what_to_count & COUNT_SRC_HOST) fprintf(f, "SRC_IP ");
+ if (config.what_to_count & COUNT_DST_HOST) fprintf(f, "DST_IP ");
#endif
- fprintf(f, "SRC_MASK ");
- fprintf(f, "DST_MASK ");
- fprintf(f, "SRC_PORT ");
- fprintf(f, "DST_PORT ");
- fprintf(f, "TCP_FLAGS ");
- fprintf(f, "PROTOCOL ");
- fprintf(f, "TOS ");
+ if (config.what_to_count & COUNT_SRC_NMASK) fprintf(f, "SRC_MASK ");
+ if (config.what_to_count & COUNT_DST_NMASK) fprintf(f, "DST_MASK ");
+ if (config.what_to_count & COUNT_SRC_PORT) fprintf(f, "SRC_PORT ");
+ if (config.what_to_count & COUNT_DST_PORT) fprintf(f, "DST_PORT ");
+ if (config.what_to_count & COUNT_TCPFLAGS) fprintf(f, "TCP_FLAGS ");
+ if (config.what_to_count & COUNT_IP_PROTO) fprintf(f, "PROTOCOL ");
+ if (config.what_to_count & COUNT_IP_TOS) fprintf(f, "TOS ");
+#if defined WITH_GEOIP
+ if (config.what_to_count_2 & COUNT_SRC_HOST_COUNTRY) fprintf(f, "SH_COUNTRY ");
+ if (config.what_to_count_2 & COUNT_DST_HOST_COUNTRY) fprintf(f, "DH_COUNTRY ");
+#endif
+ if (config.what_to_count_2 & COUNT_SAMPLING_RATE) fprintf(f, "SAMPLING_RATE ");
#if defined HAVE_64BIT_COUNTERS
fprintf(f, "PACKETS ");
fprintf(f, "FLOWS ");
@@ -709,38 +829,43 @@
void P_write_stats_header_csv(FILE *f)
{
- fprintf(f, "TAG,");
- fprintf(f, "TAG2,");
- fprintf(f, "CLASS,");
+ if (config.what_to_count & COUNT_ID) fprintf(f, "TAG,");
+ if (config.what_to_count & COUNT_ID2) fprintf(f, "TAG2,");
+ if (config.what_to_count & COUNT_CLASS) fprintf(f, "CLASS,");
#if defined HAVE_L2
- fprintf(f, "SRC_MAC,");
- fprintf(f, "DST_MAC,");
- fprintf(f, "VLAN,");
- fprintf(f, "COS,");
- fprintf(f, "ETYPE,");
-#endif
- fprintf(f, "SRC_AS,");
- fprintf(f, "DST_AS,");
- fprintf(f, "BGP_COMMS,");
- fprintf(f, "AS_PATH,");
- fprintf(f, "PREF,");
- fprintf(f, "MED,");
- fprintf(f, "PEER_SRC_AS,");
- fprintf(f, "PEER_DST_AS,");
- fprintf(f, "PEER_SRC_IP,");
- fprintf(f, "PEER_DST_IP,");
- fprintf(f, "IN_IFACE,");
- fprintf(f, "OUT_IFACE,");
- fprintf(f, "MPLS_VPN_RD,");
- fprintf(f, "SRC_IP,");
- fprintf(f, "DST_IP,");
- fprintf(f, "SRC_MASK,");
- fprintf(f, "DST_MASK,");
- fprintf(f, "SRC_PORT,");
- fprintf(f, "DST_PORT,");
- fprintf(f, "TCP_FLAGS,");
- fprintf(f, "PROTOCOL,");
- fprintf(f, "TOS,");
+ if (config.what_to_count & COUNT_SRC_MAC) fprintf(f, "SRC_MAC,");
+ if (config.what_to_count & COUNT_DST_MAC) fprintf(f, "DST_MAC,");
+ if (config.what_to_count & COUNT_VLAN) fprintf(f, "VLAN,");
+ if (config.what_to_count & COUNT_COS) fprintf(f, "COS,");
+ if (config.what_to_count & COUNT_ETHERTYPE) fprintf(f, "ETYPE,");
+#endif
+ if (config.what_to_count & COUNT_SRC_AS) fprintf(f, "SRC_AS,");
+ if (config.what_to_count & COUNT_DST_AS) fprintf(f, "DST_AS,");
+ if (config.what_to_count & COUNT_STD_COMM) fprintf(f, "BGP_COMMS,");
+ if (config.what_to_count & COUNT_AS_PATH) fprintf(f, "AS_PATH,");
+ if (config.what_to_count & COUNT_LOCAL_PREF) fprintf(f, "PREF,");
+ if (config.what_to_count & COUNT_MED) fprintf(f, "MED,");
+ if (config.what_to_count & COUNT_PEER_SRC_AS) fprintf(f, "PEER_SRC_AS,");
+ if (config.what_to_count & COUNT_PEER_DST_AS) fprintf(f, "PEER_DST_AS,");
+ if (config.what_to_count & COUNT_PEER_SRC_IP) fprintf(f, "PEER_SRC_IP,");
+ if (config.what_to_count & COUNT_PEER_DST_IP) fprintf(f, "PEER_DST_IP,");
+ if (config.what_to_count & COUNT_IN_IFACE) fprintf(f, "IN_IFACE,");
+ if (config.what_to_count & COUNT_OUT_IFACE) fprintf(f, "OUT_IFACE,");
+ if (config.what_to_count & COUNT_MPLS_VPN_RD) fprintf(f, "MPLS_VPN_RD,");
+ if (config.what_to_count & COUNT_SRC_HOST) fprintf(f, "SRC_IP,");
+ if (config.what_to_count & COUNT_DST_HOST) fprintf(f, "DST_IP,");
+ if (config.what_to_count & COUNT_SRC_NMASK) fprintf(f, "SRC_MASK,");
+ if (config.what_to_count & COUNT_DST_NMASK) fprintf(f, "DST_MASK,");
+ if (config.what_to_count & COUNT_SRC_PORT) fprintf(f, "SRC_PORT,");
+ if (config.what_to_count & COUNT_DST_PORT) fprintf(f, "DST_PORT,");
+ if (config.what_to_count & COUNT_TCPFLAGS) fprintf(f, "TCP_FLAGS,");
+ if (config.what_to_count & COUNT_IP_PROTO) fprintf(f, "PROTOCOL,");
+ if (config.what_to_count & COUNT_IP_TOS) fprintf(f, "TOS,");
+#if defined WITH_GEOIP
+ if (config.what_to_count_2 & COUNT_SRC_HOST_COUNTRY) fprintf(f, "SH_COUNTRY,");
+ if (config.what_to_count_2 & COUNT_DST_HOST_COUNTRY) fprintf(f, "DH_COUNTRY,");
+#endif
+ if (config.what_to_count_2 & COUNT_SAMPLING_RATE) fprintf(f, "SAMPLING_RATE,");
fprintf(f, "PACKETS,");
fprintf(f, "FLOWS,");
fprintf(f, "BYTES\n");
@@ -834,3 +959,59 @@
return 0;
}
+
+void P_init_historical_acct(time_t now)
+{
+ time_t t = 0;
+
+ basetime.tv_sec = now;
+ basetime.tv_usec = 0;
+
+ if (config.sql_history == COUNT_MINUTELY) timeslot = config.sql_history_howmany*60;
+ else if (config.sql_history == COUNT_HOURLY) timeslot = config.sql_history_howmany*3600;
+ else if (config.sql_history == COUNT_DAILY) timeslot = config.sql_history_howmany*86400;
+ else if (config.sql_history == COUNT_WEEKLY) timeslot = config.sql_history_howmany*86400*7;
+ else if (config.sql_history == COUNT_MONTHLY) {
+ basetime.tv_sec = roundoff_time(basetime.tv_sec, "d"); /* resetting day of month */
+ timeslot = calc_monthly_timeslot(basetime.tv_sec, config.sql_history_howmany, ADD);
+ }
+
+ /* round off stuff */
+ t = roundoff_time(basetime.tv_sec, config.sql_history_roundoff);
+
+ while ((t+timeslot) < basetime.tv_sec) {
+ t += timeslot;
+ if (config.sql_history == COUNT_MONTHLY) timeslot = calc_monthly_timeslot(t, config.sql_history_howmany, ADD);
+ }
+
+ basetime.tv_sec = t;
+}
+
+void P_eval_historical_acct(struct timeval *stamp, struct timeval *basetime, time_t timeslot)
+{
+ if (stamp->tv_sec) {
+ while (basetime->tv_sec > stamp->tv_sec) {
+ if (config.sql_history != COUNT_MONTHLY) basetime->tv_sec -= timeslot;
+ else {
+ timeslot = calc_monthly_timeslot(basetime->tv_sec, config.sql_history_howmany, SUB);
+ basetime->tv_sec -= timeslot;
+ }
+ }
+ while ((basetime->tv_sec+timeslot) < stamp->tv_sec) {
+ if (config.sql_history != COUNT_MONTHLY) basetime->tv_sec += timeslot;
+ else {
+ basetime->tv_sec += timeslot;
+ timeslot = calc_monthly_timeslot(basetime->tv_sec, config.sql_history_howmany, ADD);
+ }
+ }
+ }
+}
+
+int P_cmp_historical_acct(struct timeval *entry_basetime, struct timeval *insert_basetime)
+{
+ int ret = TRUE;
+
+ ret = memcmp(entry_basetime, insert_basetime, sizeof(struct timeval));
+
+ return ret;
+}
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/print_plugin.h
^
|
@@ -1,6 +1,6 @@
/*
pmacct (Promiscuous mode IP Accounting package)
- pmacct is Copyright (C) 2003-2011 by Paolo Lucente
+ pmacct is Copyright (C) 2003-2012 by Paolo Lucente
*/
/*
@@ -44,6 +44,7 @@
u_int32_t tcp_flags;
struct pkt_bgp_primitives *pbgp;
int valid;
+ struct timeval basetime;
struct chained_cache *next;
};
@@ -79,4 +80,14 @@
EXT struct timeval flushtime;
EXT int qq_ptr, pp_size, pb_size, dbc_size, quit;
EXT time_t refresh_deadline;
+
+EXT void (*basetime_init)(time_t);
+EXT void (*basetime_eval)(struct timeval *, struct timeval *, time_t);
+EXT int (*basetime_cmp)(struct timeval *, struct timeval *);
+EXT struct timeval basetime, ibasetime;
+EXT time_t timeslot;
+
+EXT void P_init_historical_acct(time_t);
+EXT void P_eval_historical_acct(struct timeval *, struct timeval *, time_t);
+EXT int P_cmp_historical_acct(struct timeval *, struct timeval *);
#undef EXT
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/server.c
^
|
@@ -105,6 +105,7 @@
if (q->type & WANT_STATS) {
q->what_to_count = config.what_to_count;
+ q->what_to_count_2 = config.what_to_count_2;
for (idx = 0; idx < config.buckets; idx++) {
if (!following_chain) acc_elem = (struct acc *) elem;
if (acc_elem->bytes_counter && !acc_elem->reset_flag) {
@@ -158,10 +159,11 @@
unsigned int j;
q->what_to_count = config.what_to_count;
+ q->what_to_count_2 = config.what_to_count_2;
for (j = 0; j < uq->num; j++, bufptr += sizeof(struct query_entry)) {
memcpy(&request, bufptr, sizeof(struct query_entry));
Log(LOG_DEBUG, "DEBUG ( %s/%s ): Searching into accounting structure ...\n", config.name, config.type);
- if (request.what_to_count == config.what_to_count) {
+ if (request.what_to_count == config.what_to_count && request.what_to_count_2 == config.what_to_count_2) {
acc_elem = search_accounting_structure(&request.data, &request.pbgp);
if (acc_elem) {
if (acc_elem->bytes_counter && !acc_elem->reset_flag) {
@@ -206,7 +208,7 @@
for (idx = 0; idx < config.buckets; idx++) {
if (!following_chain) acc_elem = (struct acc *) elem;
if (acc_elem->bytes_counter && !acc_elem->reset_flag) {
- mask_elem(&tbuf, &bbuf, acc_elem, request.what_to_count);
+ mask_elem(&tbuf, &bbuf, acc_elem, request.what_to_count, request.what_to_count_2);
if (!memcmp(&tbuf, &request.data, sizeof(struct pkt_primitives)) &&
!memcmp(&bbuf, &request.pbgp, sizeof(struct pkt_bgp_primitives))) {
if (q->type & WANT_COUNTER) Accumulate_Counters(&abuf, acc_elem);
@@ -260,7 +262,7 @@
}
}
-void mask_elem(struct pkt_primitives *d1, struct pkt_bgp_primitives *d2, struct acc *src, u_int64_t w)
+void mask_elem(struct pkt_primitives *d1, struct pkt_bgp_primitives *d2, struct acc *src, u_int64_t w, u_int64_t w2)
{
struct pkt_primitives *s1 = &src->primitives;
struct pkt_bgp_primitives tmp_pbgp;
@@ -306,6 +308,12 @@
if (w & COUNT_ID2) d1->id2 = s1->id2;
if (w & COUNT_CLASS) d1->class = s1->class;
+#if defined WITH_GEOIP
+ if (w2 & COUNT_SRC_HOST_COUNTRY) d1->src_ip_country = s1->src_ip_country;
+ if (w2 & COUNT_DST_HOST_COUNTRY) d1->dst_ip_country = s1->dst_ip_country;
+#endif
+ if (w2 & COUNT_SAMPLING_RATE) d1->sampling_rate = s1->sampling_rate;
+
if (PbgpSz && s2) {
if (w & COUNT_STD_COMM) strlcpy(d2->std_comms, s2->std_comms, MAX_BGP_STD_COMMS);
if (w & COUNT_SRC_STD_COMM) strlcpy(d2->src_std_comms, s2->src_std_comms, MAX_BGP_STD_COMMS);
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/sfacctd.c
^
|
@@ -52,7 +52,7 @@
/* Functions */
void usage_daemon(char *prog_name)
{
- printf("%s\n", SFACCTD_USAGE_HEADER);
+ printf("%s (%s)\n", SFACCTD_USAGE_HEADER, PMACCT_BUILD);
printf("Usage: %s [ -D | -d ] [ -L IP address ] [ -l port ] [ -c primitive [ , ... ] ] [ -P plugin [ , ... ] ]\n", prog_name);
printf(" %s [ -f config_file ]\n", prog_name);
printf(" %s [ -h ]\n", prog_name);
@@ -61,11 +61,11 @@
printf(" -L \tBind to the specified IP address\n");
printf(" -l \tListen on the specified UDP port\n");
printf(" -f \tLoad configuration from the specified file\n");
- printf(" -c \t[ src_mac | dst_mac | vlan | src_host | dst_host | src_net | dst_net | src_port | dst_port |\n\t tos | proto | src_as | dst_as | sum_mac | sum_host | sum_net | sum_as | sum_port | tag |\n\t tag2 | flows | class | tcpflags | in_iface | out_iface | src_mask | dst_mask | cos | etype | none ] \n\tAggregation string (DEFAULT: src_host)\n");
+ printf(" -c \t[ src_mac | dst_mac | vlan | src_host | dst_host | src_net | dst_net | src_port | dst_port |\n\t tos | proto | src_as | dst_as | sum_mac | sum_host | sum_net | sum_as | sum_port | tag |\n\t tag2 | flows | class | tcpflags | in_iface | out_iface | src_mask | dst_mask | cos | etype |\n\t sampling_rate | src_host_country | dst_host_country | none ]\n\tAggregation string (DEFAULT: src_host)\n");
printf(" -D \tDaemonize\n");
printf(" -n \tPath to a file containing Network definitions\n");
printf(" -o \tPath to a file containing Port definitions\n");
- printf(" -P \t[ memory | print | mysql | pgsql | sqlite3 | tee ] \n\tActivate plugin\n");
+ printf(" -P \t[ memory | print | mysql | pgsql | sqlite3 | mongodb | tee ] \n\tActivate plugin\n");
printf(" -d \tEnable debug\n");
printf(" -S \t[ auth | mail | daemon | kern | user | local[0-7] ] \n\ttLog to the specified syslog facility\n");
printf(" -F \tWrite Core Process PID into the specified file\n");
@@ -273,10 +273,6 @@
strlcpy(cfg_cmdline[rows], "sql_refresh_time: ", SRVBUFLEN);
strncat(cfg_cmdline[rows], optarg, CFG_LINE_LEN(cfg_cmdline[rows]));
rows++;
- cfg_cmdline[rows] = malloc(SRVBUFLEN);
- strlcpy(cfg_cmdline[rows], "print_refresh_time: ", SRVBUFLEN);
- strncat(cfg_cmdline[rows], optarg, CFG_LINE_LEN(cfg_cmdline[rows]));
- rows++;
break;
case 'v':
strlcpy(cfg_cmdline[rows], "sql_table_version: ", SRVBUFLEN);
@@ -386,17 +382,21 @@
else {
list->cfg.data_type = PIPE_TYPE_METADATA;
evaluate_sums(&list->cfg.what_to_count, list->name, list->type.string);
- if (!list->cfg.what_to_count) {
+ if (!list->cfg.what_to_count && !list->cfg.what_to_count_2) {
Log(LOG_WARNING, "WARN ( %s/%s ): defaulting to SRC HOST aggregation.\n", list->name, list->type.string);
list->cfg.what_to_count |= COUNT_SRC_HOST;
}
- if ((list->cfg.what_to_count & (COUNT_SRC_AS|COUNT_DST_AS|COUNT_SUM_AS)) && !list->cfg.networks_file && list->cfg.nfacctd_as & NF_AS_NEW) {
- Log(LOG_ERR, "ERROR ( %s/%s ): AS aggregation was selected but NO 'networks_file' specified. Exiting...\n\n", list->name, list->type.string);
- exit(1);
- }
- if ((list->cfg.what_to_count & (COUNT_SRC_AS|COUNT_DST_AS|COUNT_SUM_AS)) && !list->cfg.nfacctd_bgp && list->cfg.nfacctd_as == NF_AS_BGP) {
- Log(LOG_ERR, "ERROR ( %s/%s ): AS aggregation selected but 'bgp_daemon' is not enabled. Exiting...\n\n", list->name, list->type.string);
- exit(1);
+ if (list->cfg.what_to_count & (COUNT_SRC_AS|COUNT_DST_AS|COUNT_SUM_AS)) {
+ if (!list->cfg.networks_file && list->cfg.nfacctd_as & NF_AS_NEW) {
+ Log(LOG_ERR, "ERROR ( %s/%s ): AS aggregation was selected but NO 'networks_file' specified. Exiting...\n\n", list->name, list->type.string);
+ exit(1);
+ }
+ if (!list->cfg.nfacctd_bgp && list->cfg.nfacctd_as == NF_AS_BGP) {
+ Log(LOG_ERR, "ERROR ( %s/%s ): AS aggregation selected but 'bgp_daemon' is not enabled. Exiting...\n\n", list->name, list->type.string);
+ exit(1);
+ }
+ if (list->cfg.nfacctd_as & NF_AS_FALLBACK && list->cfg.networks_file)
+ list->cfg.nfacctd_as |= NF_AS_NEW;
}
if (list->cfg.what_to_count & (COUNT_SRC_NET|COUNT_DST_NET|COUNT_SUM_NET|COUNT_SRC_NMASK|COUNT_DST_NMASK|COUNT_PEER_DST_IP)) {
if (!list->cfg.nfacctd_net) {
@@ -412,6 +412,8 @@
Log(LOG_ERR, "ERROR ( %s/%s ): network aggregation selected but none of 'bgp_daemon', 'isis_daemon', 'networks_file', 'networks_mask' is specified. Exiting ...\n\n", list->name, list->type.string);
exit(1);
}
+ if (list->cfg.nfacctd_net & NF_NET_FALLBACK && list->cfg.networks_file)
+ list->cfg.nfacctd_net |= NF_NET_NEW;
}
}
if (list->cfg.what_to_count & COUNT_CLASS && !list->cfg.classifiers_path) {
@@ -479,8 +481,8 @@
}
/* bind socket to port */
- rc = Setsocksize(config.sock, SOL_SOCKET, SO_REUSEADDR, (char *)&yes, sizeof(yes));
- if (rc < 0) Log(LOG_ERR, "WARN ( default/core ): Setsocksize() failed for SO_REUSEADDR.\n");
+ rc = setsockopt(config.sock, SOL_SOCKET, SO_REUSEADDR, (char *)&yes, sizeof(yes));
+ if (rc < 0) Log(LOG_ERR, "WARN ( default/core ): setsockopt() failed for SO_REUSEADDR.\n");
if (config.pipe_size) {
rc = Setsocksize(config.sock, SOL_SOCKET, SO_RCVBUF, &config.pipe_size, sizeof(config.pipe_size));
@@ -605,6 +607,12 @@
}
#endif
+#if defined WITH_GEOIP
+ if (config.geoip_ipv4_file || config.geoip_ipv6_file) {
+ req.bpf_filter = TRUE;
+ }
+#endif
+
rc = bind(config.sock, (struct sockaddr *) &server, slen);
if (rc < 0) {
Log(LOG_ERR, "ERROR ( default/core ): bind() to ip=%s port=%d/udp failed (errno: %d).\n", config.nfacctd_ip, config.nfacctd_port, errno);
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/sfprobe_plugin/sfprobe_plugin.c
^
|
@@ -1,6 +1,6 @@
/*
pmacct (Promiscuous mode IP Accounting package)
- pmacct is Copyright (C) 2003-2012 by Paolo Lucente
+ pmacct is Copyright (C) 2003-2013 by Paolo Lucente
*/
/*
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/sql_common.c
^
|
@@ -236,11 +236,6 @@
*rd += (config.sql_refresh_time+config.sql_startup_delay); /* it's a deadline not a basetime */
}
-void sql_calc_refresh_timeout(time_t deadline, time_t now, int *timeout)
-{
- *timeout = ((deadline-now)+1)*1000;
-}
-
void sql_init_pipe(struct pollfd *pollfd, int fd)
{
pollfd->fd = fd;
@@ -822,7 +817,7 @@
int sql_evaluate_primitives(int primitive)
{
- u_int64_t what_to_count = 0, fakes = 0;
+ u_int64_t what_to_count = 0, what_to_count_2 = 0, fakes = 0;
short int assume_custom_table = FALSE;
char *insert_clause_start_ptr = insert_clause + strlen(insert_clause);
char default_delim[] = ",", delim_buf[SRVBUFLEN];
@@ -839,6 +834,7 @@
if (config.sql_optimize_clauses) {
what_to_count = config.what_to_count;
+ what_to_count_2 = config.what_to_count_2;
assume_custom_table = TRUE;
}
else {
@@ -936,6 +932,11 @@
if (config.what_to_count & COUNT_OUT_IFACE) what_to_count |= COUNT_OUT_IFACE;
if (config.what_to_count & COUNT_SRC_NMASK) what_to_count |= COUNT_SRC_NMASK;
if (config.what_to_count & COUNT_DST_NMASK) what_to_count |= COUNT_DST_NMASK;
+#if defined WITH_GEOIP
+ if (config.what_to_count_2 & COUNT_SRC_HOST_COUNTRY) what_to_count_2 |= COUNT_SRC_HOST_COUNTRY;
+ if (config.what_to_count_2 & COUNT_DST_HOST_COUNTRY) what_to_count_2 |= COUNT_DST_HOST_COUNTRY;
+#endif
+ if (config.what_to_count_2 & COUNT_SAMPLING_RATE) what_to_count_2 |= COUNT_SAMPLING_RATE;
}
/* sorting out delimiter */
@@ -1691,6 +1692,50 @@
}
}
+#if defined WITH_GEOIP
+ if (what_to_count_2 & COUNT_SRC_HOST_COUNTRY) {
+ if (primitive) {
+ strncat(insert_clause, ", ", SPACELEFT(insert_clause));
+ strncat(values[primitive].string, delim_buf, SPACELEFT(values[primitive].string));
+ strncat(where[primitive].string, " AND ", SPACELEFT(where[primitive].string));
+ }
+ strncat(insert_clause, "country_ip_src", SPACELEFT(insert_clause));
+ strncat(values[primitive].string, "\'%s\'", SPACELEFT(values[primitive].string));
+ strncat(where[primitive].string, "country_ip_src=\'%s\'", SPACELEFT(where[primitive].string));
+ values[primitive].type = where[primitive].type = COUNT_SRC_HOST_COUNTRY;
+ values[primitive].handler = where[primitive].handler = count_src_host_country_handler;
+ primitive++;
+ }
+
+ if (what_to_count_2 & COUNT_DST_HOST_COUNTRY) {
+ if (primitive) {
+ strncat(insert_clause, ", ", SPACELEFT(insert_clause));
+ strncat(values[primitive].string, delim_buf, SPACELEFT(values[primitive].string));
+ strncat(where[primitive].string, " AND ", SPACELEFT(where[primitive].string));
+ }
+ strncat(insert_clause, "country_ip_dst", SPACELEFT(insert_clause));
+ strncat(values[primitive].string, "\'%s\'", SPACELEFT(values[primitive].string));
+ strncat(where[primitive].string, "country_ip_dst=\'%s\'", SPACELEFT(where[primitive].string));
+ values[primitive].type = where[primitive].type = COUNT_DST_HOST_COUNTRY;
+ values[primitive].handler = where[primitive].handler = count_dst_host_country_handler;
+ primitive++;
+ }
+#endif
+
+ if (what_to_count_2 & COUNT_SAMPLING_RATE) {
+ if (primitive) {
+ strncat(insert_clause, ", ", SPACELEFT(insert_clause));
+ strncat(values[primitive].string, delim_buf, SPACELEFT(values[primitive].string));
+ strncat(where[primitive].string, " AND ", SPACELEFT(where[primitive].string));
+ }
+ strncat(insert_clause, "sampling_rate", SPACELEFT(insert_clause));
+ strncat(values[primitive].string, "%u", SPACELEFT(values[primitive].string));
+ strncat(where[primitive].string, "sampling_rate=%u", SPACELEFT(where[primitive].string));
+ values[primitive].type = where[primitive].type = COUNT_SAMPLING_RATE;
+ values[primitive].handler = where[primitive].handler = count_sampling_rate_handler;
+ primitive++;
+ }
+
if (what_to_count & COUNT_ID) {
int count_it = FALSE;
@@ -2233,13 +2278,14 @@
void sql_create_table(struct DBdesc *db, time_t *basetime)
{
struct tm *nowtm;
- char buf[LARGEBUFLEN], tmpbuf[LARGEBUFLEN];
+ char buf[LARGEBUFLEN], tmpbuf[LARGEBUFLEN], tmpbuf2[LARGEBUFLEN];
int ret;
ret = read_SQLquery_from_file(config.sql_table_schema, tmpbuf, LARGEBUFLEN);
if (ret) {
+ handle_dynname_internal_strings(tmpbuf2, LARGEBUFLEN-10, tmpbuf);
nowtm = localtime(basetime);
- strftime(buf, LARGEBUFLEN, tmpbuf, nowtm);
+ strftime(buf, LARGEBUFLEN, tmpbuf2, nowtm);
(*sqlfunc_cbr.create_table)(db, buf);
}
}
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/sql_common.h
^
|
@@ -130,6 +130,7 @@
u_int16_t sql_optimize_clauses;
u_int16_t sql_history;
u_int64_t what_to_count;
+ u_int64_t what_to_count_2;
u_char pad[8];
};
@@ -227,6 +228,7 @@
EXT void count_out_iface_handler(const struct db_cache *, const struct insert_data *, int, char **, char **);
EXT void count_src_nmask_handler(const struct db_cache *, const struct insert_data *, int, char **, char **);
EXT void count_dst_nmask_handler(const struct db_cache *, const struct insert_data *, int, char **, char **);
+EXT void count_sampling_rate_handler(const struct db_cache *, const struct insert_data *, int, char **, char **);
EXT void MY_count_ip_proto_handler(const struct db_cache *, const struct insert_data *, int, char **, char **);
EXT void PG_count_ip_proto_handler(const struct db_cache *, const struct insert_data *, int, char **, char **);
EXT void count_timestamp_handler(const struct db_cache *, const struct insert_data *, int, char **, char **);
@@ -242,6 +244,11 @@
EXT void fake_as_path_handler(const struct db_cache *, const struct insert_data *, int, char **, char **);
EXT void fake_mpls_vpn_rd_handler(const struct db_cache *, const struct insert_data *, int, char **, char **);
+#if defined WITH_GEOIP
+EXT void count_src_host_country_handler(const struct db_cache *, const struct insert_data *, int, char **, char **);
+EXT void count_dst_host_country_handler(const struct db_cache *, const struct insert_data *, int, char **, char **);
+#endif
+
EXT void count_counters_setclause_handler(const struct db_cache *, const struct insert_data *, int, char **, char **);
EXT void count_flows_setclause_handler(const struct db_cache *, const struct insert_data *, int, char **, char **);
EXT void count_timestamp_setclause_handler(const struct db_cache *, const struct insert_data *, int, char **, char **);
@@ -264,7 +271,6 @@
EXT void sql_init_historical_acct(time_t, struct insert_data *);
EXT void sql_init_triggers(time_t, struct insert_data *);
EXT void sql_init_refresh_deadline(time_t *);
-EXT void sql_calc_refresh_timeout(time_t, time_t, int *);
EXT void sql_init_pipe(struct pollfd *, int);
EXT struct template_entry *sql_init_logfile_template(struct template_header *);
EXT void sql_link_backend_descriptors(struct BE_descs *, struct DBdesc *, struct DBdesc *);
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/sql_handlers.c
^
|
@@ -166,6 +166,32 @@
*ptr_values += strlen(*ptr_values);
}
+#if defined WITH_GEOIP
+void count_src_host_country_handler(const struct db_cache *cache_elem, const struct insert_data *idata, int num, char **ptr_values, char **ptr_where)
+{
+ snprintf(*ptr_where, SPACELEFT(where_clause), where[num].string, GeoIP_code_by_id(cache_elem->primitives.src_ip_country));
+ snprintf(*ptr_values, SPACELEFT(values_clause), values[num].string, GeoIP_code_by_id(cache_elem->primitives.src_ip_country));
+ *ptr_where += strlen(*ptr_where);
+ *ptr_values += strlen(*ptr_values);
+}
+
+void count_dst_host_country_handler(const struct db_cache *cache_elem, const struct insert_data *idata, int num, char **ptr_values, char **ptr_where)
+{
+ snprintf(*ptr_where, SPACELEFT(where_clause), where[num].string, GeoIP_code_by_id(cache_elem->primitives.dst_ip_country));
+ snprintf(*ptr_values, SPACELEFT(values_clause), values[num].string, GeoIP_code_by_id(cache_elem->primitives.dst_ip_country));
+ *ptr_where += strlen(*ptr_where);
+ *ptr_values += strlen(*ptr_values);
+}
+#endif
+
+void count_sampling_rate_handler(const struct db_cache *cache_elem, const struct insert_data *idata, int num, char **ptr_values, char **ptr_where)
+{
+ snprintf(*ptr_where, SPACELEFT(where_clause), where[num].string, cache_elem->primitives.sampling_rate);
+ snprintf(*ptr_values, SPACELEFT(values_clause), values[num].string, cache_elem->primitives.sampling_rate);
+ *ptr_where += strlen(*ptr_where);
+ *ptr_values += strlen(*ptr_values);
+}
+
void count_std_comm_handler(const struct db_cache *cache_elem, const struct insert_data *idata, int num, char **ptr_values, char **ptr_where)
{
snprintf(*ptr_where, SPACELEFT(where_clause), where[num].string, cache_elem->cbgp->std_comms);
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/sqlite3_plugin.c
^
|
@@ -1,6 +1,6 @@
/*
pmacct (Promiscuous mode IP Accounting package)
- pmacct is Copyright (C) 2003-2012 by Paolo Lucente
+ pmacct is Copyright (C) 2003-2013 by Paolo Lucente
*/
/*
@@ -96,7 +96,7 @@
for(;;) {
poll_again:
status->wakeup = TRUE;
- sql_calc_refresh_timeout(refresh_deadline, idata.now, &timeout);
+ calc_refresh_timeout(refresh_deadline, idata.now, &timeout);
ret = poll(&pfd, 1, timeout);
if (ret < 0) goto poll_again;
@@ -425,6 +425,10 @@
char tmpbuf[LONGLONGSRVBUFLEN];
time_t stamp = idata->new_basetime ? idata->new_basetime : idata->basetime;
+ handle_dynname_internal_strings_same(tmpbuf, LONGSRVBUFLEN, insert_clause);
+ handle_dynname_internal_strings_same(tmpbuf, LONGSRVBUFLEN, update_clause);
+ handle_dynname_internal_strings_same(tmpbuf, LONGSRVBUFLEN, lock_clause);
+
strftime_same(insert_clause, LONGSRVBUFLEN, tmpbuf, &stamp);
strftime_same(update_clause, LONGSRVBUFLEN, tmpbuf, &stamp);
strftime_same(lock_clause, LONGSRVBUFLEN, tmpbuf, &stamp);
@@ -654,7 +658,7 @@
else if (config.sql_table_version == 2) config.sql_table = sqlite3_table_v2;
else config.sql_table = sqlite3_table;
}
- if (strchr(config.sql_table, '%')) idata->dyn_table = TRUE;
+ if (strchr(config.sql_table, '%') || strchr(config.sql_table, '$')) idata->dyn_table = TRUE;
glob_dyn_table = idata->dyn_table;
if (config.sql_backup_host) idata->recover = TRUE;
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/tee_plugin/tee_plugin.c
^
|
@@ -76,8 +76,8 @@
dest_len = sizeof(dest);
Tee_parse_hostport(config.nfprobe_receiver, (struct sockaddr *)&dest, &dest_len);
- config.print_refresh_time = DEFAULT_TEE_REFRESH_TIME;
- timeout = config.print_refresh_time*1000;
+ config.sql_refresh_time = DEFAULT_TEE_REFRESH_TIME;
+ timeout = config.sql_refresh_time*1000;
pipebuf = (unsigned char *) Malloc(config.buffer_size);
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/uacctd.c
^
|
@@ -48,18 +48,18 @@
/* Functions */
void usage_daemon(char *prog_name)
{
- printf("%s\n", UACCTD_USAGE_HEADER);
+ printf("%s (%s)\n", UACCTD_USAGE_HEADER, PMACCT_BUILD);
printf("Usage: %s [ -D | -d ] [ -g ULOG group ] [ -c primitive [ , ... ] ] [ -P plugin [ , ... ] ]\n", prog_name);
printf(" %s [ -f config_file ]\n", prog_name);
printf(" %s [ -h ]\n", prog_name);
printf("\nGeneral options:\n");
printf(" -h \tShow this page\n");
printf(" -f \tLoad configuration from the specified file\n");
- printf(" -c \t[ src_mac | dst_mac | vlan | src_host | dst_host | src_net | dst_net | src_port | dst_port |\n\t proto | tos | src_as | dst_as | sum_mac | sum_host | sum_net | sum_as | sum_port | tag |\n\t tag2 | flows | class | tcpflags | in_iface | out_iface | src_mask | dst_mask | cos | etype | none ] \n\tAggregation string (DEFAULT: src_host)\n");
+ printf(" -c \t[ src_mac | dst_mac | vlan | src_host | dst_host | src_net | dst_net | src_port | dst_port |\n\t proto | tos | src_as | dst_as | sum_mac | sum_host | sum_net | sum_as | sum_port | tag |\n\t tag2 | flows | class | tcpflags | in_iface | out_iface | src_mask | dst_mask | cos | etype |\n\t sampling_rate | src_host_country | dst_host_country | none ]\n\tAggregation string (DEFAULT: src_host)\n");
printf(" -D \tDaemonize\n");
printf(" -n \tPath to a file containing Network definitions\n");
printf(" -o \tPath to a file containing Port definitions\n");
- printf(" -P \t[ memory | print | mysql | pgsql | sqlite3 | nfprobe | sfprobe ] \n\tActivate plugin\n");
+ printf(" -P \t[ memory | print | mysql | pgsql | sqlite3 | mongodb | nfprobe | sfprobe ] \n\tActivate plugin\n");
printf(" -d \tEnable debug\n");
printf(" -S \t[ auth | mail | daemon | kern | user | local[0-7] ] \n\tLog to the specified syslog facility\n");
printf(" -F \tWrite Core Process PID into the specified file\n");
@@ -243,10 +243,6 @@
strlcpy(cfg_cmdline[rows], "sql_refresh_time: ", SRVBUFLEN);
strncat(cfg_cmdline[rows], optarg, CFG_LINE_LEN(cfg_cmdline[rows]));
rows++;
- cfg_cmdline[rows] = malloc(SRVBUFLEN);
- strlcpy(cfg_cmdline[rows], "print_refresh_time: ", SRVBUFLEN);
- strncat(cfg_cmdline[rows], optarg, CFG_LINE_LEN(cfg_cmdline[rows]));
- rows++;
break;
case 'v':
strlcpy(cfg_cmdline[rows], "sql_table_version: ", SRVBUFLEN);
@@ -387,7 +383,9 @@
config.handle_fragments = TRUE;
list->cfg.nfprobe_what_to_count = list->cfg.what_to_count;
+ list->cfg.nfprobe_what_to_count_2 = list->cfg.what_to_count_2;
list->cfg.what_to_count = 0;
+ list->cfg.what_to_count_2 = 0;
#if defined (HAVE_L2)
if (list->cfg.nfprobe_version == 9 || list->cfg.nfprobe_version == 10) {
list->cfg.what_to_count |= COUNT_SRC_MAC;
@@ -441,6 +439,7 @@
if (psize < 128) psize = config.snaplen = 128; /* SFL_DEFAULT_HEADER_SIZE */
list->cfg.what_to_count = COUNT_PAYLOAD;
+ list->cfg.what_to_count_2 = 0;
if (list->cfg.classifiers_path) {
list->cfg.what_to_count |= COUNT_CLASS;
config.handle_fragments = TRUE;
@@ -487,13 +486,17 @@
config.handle_fragments = TRUE;
config.handle_flows = TRUE;
}
- if (!list->cfg.what_to_count) {
+ if (!list->cfg.what_to_count && !list->cfg.what_to_count_2) {
Log(LOG_WARNING, "WARN ( %s/%s ): defaulting to SRC HOST aggregation.\n", list->name, list->type.string);
list->cfg.what_to_count |= COUNT_SRC_HOST;
}
- if ((list->cfg.what_to_count & (COUNT_SRC_AS|COUNT_DST_AS|COUNT_SUM_AS)) && !list->cfg.networks_file && list->cfg.nfacctd_as != NF_AS_BGP) {
- Log(LOG_ERR, "ERROR ( %s/%s ): AS aggregation selected but NO 'networks_file' or 'uacctd_as' are specified. Exiting...\n\n", list->name, list->type.string);
- exit(1);
+ if (list->cfg.what_to_count & (COUNT_SRC_AS|COUNT_DST_AS|COUNT_SUM_AS)) {
+ if (!list->cfg.networks_file && list->cfg.nfacctd_as != NF_AS_BGP) {
+ Log(LOG_ERR, "ERROR ( %s/%s ): AS aggregation selected but NO 'networks_file' or 'uacctd_as' are specified. Exiting...\n\n", list->name, list->type.string);
+ exit(1);
+ }
+ if (list->cfg.nfacctd_as & NF_AS_FALLBACK && list->cfg.networks_file)
+ list->cfg.nfacctd_as |= NF_AS_NEW;
}
if (list->cfg.what_to_count & (COUNT_SRC_NET|COUNT_DST_NET|COUNT_SUM_NET|COUNT_SRC_NMASK|COUNT_DST_NMASK|COUNT_PEER_DST_IP)) {
if (!list->cfg.nfacctd_net) {
@@ -513,6 +516,8 @@
Log(LOG_ERR, "ERROR ( %s/%s ): network aggregation selected but none of 'bgp_daemon', 'isis_daemon', 'networks_file', 'networks_mask' is specified. Exiting ...\n\n", list->name, list->type.string);
exit(1);
}
+ if (list->cfg.nfacctd_net & NF_NET_FALLBACK && list->cfg.networks_file)
+ list->cfg.nfacctd_net |= NF_NET_NEW;
}
}
if (list->cfg.what_to_count & COUNT_CLASS && !list->cfg.classifiers_path) {
@@ -699,6 +704,12 @@
}
#endif
+#if defined WITH_GEOIP
+ if (config.geoip_ipv4_file || config.geoip_ipv6_file) {
+ req.bpf_filter = TRUE;
+ }
+#endif
+
/* plugins glue: creation (until 093) */
evaluate_packet_handlers();
pm_setproctitle("%s [%s]", "Core Process", "default");
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/util.c
^
|
@@ -379,24 +379,21 @@
return file;
}
-FILE *open_print_output_file(char *filename, time_t now)
+void close_print_output_file(FILE *f, char *filename, time_t now)
{
- char buf[LARGEBUFLEN], *fname_ptr, *fname_ptr_tmp;
+ char buf[LARGEBUFLEN], buf2[LARGEBUFLEN], *fname_ptr, *fname_ptr_tmp;
char latest_fname[LARGEBUFLEN], latest_pname[LARGEBUFLEN];
- FILE *file = NULL;
struct tm *tmnow;
- uid_t owner = -1;
- gid_t group = -1;
u_int16_t offset;
- if (config.files_uid) owner = config.files_uid;
- if (config.files_gid) group = config.files_gid;
+ fclose(f);
+ handle_dynname_internal_strings(buf, LARGEBUFLEN-10, filename);
tmnow = localtime(&now);
- strftime(buf, LARGEBUFLEN-10, filename, tmnow);
+ strftime(buf2, LARGEBUFLEN-10, buf, tmnow);
/* Check: filename is not making use of the reserved word 'latest' */
- for (fname_ptr_tmp = buf, fname_ptr = NULL; fname_ptr_tmp; fname_ptr_tmp = strchr(fname_ptr_tmp, '/')) {
+ for (fname_ptr_tmp = buf2, fname_ptr = NULL; fname_ptr_tmp; fname_ptr_tmp = strchr(fname_ptr_tmp, '/')) {
if (*fname_ptr_tmp == '/') fname_ptr_tmp++;
fname_ptr = fname_ptr_tmp;
}
@@ -404,40 +401,127 @@
strcpy(latest_fname, config.name);
strcat(latest_fname, "-latest");
if (!strcmp(fname_ptr, latest_fname)) {
- Log(LOG_WARNING, "WARN: Invalid print_ouput_file '%s': reserved word\n", buf);
- return NULL;
+ Log(LOG_WARNING, "WARN: Invalid print_ouput_file '%s': reserved word\n", buf2);
+ return;
}
- file = fopen(buf, "w");
+ /* Let's point 'latest' to the newly opened file */
+ if (f) {
+ memcpy(latest_pname, buf2, LARGEBUFLEN);
+ offset = strlen(buf2)-strlen(fname_ptr);
+ if (strlen(latest_fname) < LARGEBUFLEN-offset) {
+ strcpy(latest_pname+offset, latest_fname);
+ unlink(latest_pname);
+ symlink(fname_ptr, latest_pname);
+ }
+ else Log(LOG_WARNING, "WARN: Unable to link latest file for print_ouput_file '%s'\n", buf2);
+ }
+}
+
+FILE *open_print_output_file(char *filename, time_t now)
+{
+ char buf[LARGEBUFLEN], buf2[LARGEBUFLEN];
+ FILE *file = NULL;
+ struct tm *tmnow;
+ uid_t owner = -1;
+ gid_t group = -1;
+
+ if (config.files_uid) owner = config.files_uid;
+ if (config.files_gid) group = config.files_gid;
+
+ handle_dynname_internal_strings(buf, LARGEBUFLEN-10, filename);
+ tmnow = localtime(&now);
+ strftime(buf2, LARGEBUFLEN-10, buf, tmnow);
+
+ file = fopen(buf2, "w");
if (file) {
- if (chown(buf, owner, group) == -1)
- Log(LOG_WARNING, "WARN: Unable to chown() print_ouput_file '%s': %s\n", buf, strerror(errno));
+ if (chown(buf2, owner, group) == -1)
+ Log(LOG_WARNING, "WARN: Unable to chown() print_ouput_file '%s': %s\n", buf2, strerror(errno));
if (file_lock(fileno(file))) {
- Log(LOG_ALERT, "ALERT: Unable to obtain lock for print_ouput_file '%s'.\n", buf);
+ Log(LOG_ALERT, "ALERT: Unable to obtain lock for print_ouput_file '%s'.\n", buf2);
file = NULL;
}
-
- /* Let's point 'latest' to the newly opened file */
- if (file) {
- memcpy(latest_pname, buf, LARGEBUFLEN);
- offset = strlen(buf)-strlen(fname_ptr);
- if (strlen(latest_fname) < LARGEBUFLEN-offset) {
- strcpy(latest_pname+offset, latest_fname);
- unlink(latest_pname);
- symlink(fname_ptr, latest_pname);
- }
- else Log(LOG_WARNING, "WARN: Unable to link latest file for print_ouput_file '%s'\n", buf);
- }
}
else {
- Log(LOG_ERR, "ERROR: Unable to open print_ouput_file '%s'\n", buf);
+ Log(LOG_ERR, "ERROR: Unable to open print_ouput_file '%s'\n", buf2);
file = NULL;
}
return file;
}
+/*
+ Notes:
+ - we check for sufficient space: we do not (de)allocate anything
+ - as long as we have only a couple possible replacements, we test them all
+*/
+void handle_dynname_internal_strings(char *new, int newlen, char *old)
+{
+ int oldlen;
+ char ref_string[] = "$ref", hst_string[] = "$hst";
+ char *ptr_start, *ptr_end;
+
+ oldlen = strlen(old);
+ if (oldlen <= newlen) strcpy(new, old);
+
+ ptr_start = strstr(new, ref_string);
+ if (ptr_start) {
+ char buf[newlen];
+ int len;
+
+ len = strlen(ptr_start);
+ ptr_end = ptr_start;
+ ptr_end += 4;
+ len -= 4;
+
+ snprintf(buf, newlen, "%u", config.sql_refresh_time);
+ strncat(buf, ptr_end, len);
+
+ len = strlen(buf);
+ *ptr_start = '\0';
+ strncat(new, buf, len);
+ }
+
+ ptr_start = strstr(new, hst_string);
+ if (ptr_start) {
+ char buf[newlen];
+ int len, howmany;
+
+ len = strlen(ptr_start);
+ ptr_end = ptr_start;
+ ptr_end += 4;
+ len -= 4;
+
+ howmany = sql_history_to_secs(config.sql_history, config.sql_history_howmany);
+ snprintf(buf, newlen, "%u", howmany);
+ strncat(buf, ptr_end, len);
+
+ len = strlen(buf);
+ *ptr_start = '\0';
+ strncat(new, buf, len);
+ }
+}
+
+void handle_dynname_internal_strings_same(char *new, int newlen, char *old)
+{
+ handle_dynname_internal_strings(new, newlen, old);
+ strlcpy(old, new, newlen);
+}
+
+int sql_history_to_secs(int mu, int howmany)
+{
+ int ret = 0;
+
+ if (mu == COUNT_MINUTELY) ret = howmany*60;
+ else if (mu == COUNT_HOURLY) ret = howmany*3600;
+ else if (mu == COUNT_DAILY) ret = howmany*86400;
+ else if (mu == COUNT_WEEKLY) ret = howmany*86400*7;
+ else if (mu == COUNT_MONTHLY) ret = howmany*86400*30; /* XXX: this is an approx! */
+
+ return ret;
+}
+
void write_pid_file(char *filename)
{
FILE *file;
@@ -628,7 +712,7 @@
int Setsocksize(int s, int level, int optname, void *optval, int optlen)
{
- int ret, len, saved, value;
+ int ret, len = sizeof(int), saved, value;
memcpy(&value, optval, sizeof(int));
@@ -1252,3 +1336,8 @@
return ret;
}
+
+void calc_refresh_timeout(time_t deadline, time_t now, int *timeout)
+{
+ *timeout = ((deadline-now)+1)*1000;
+}
|
[-]
[+]
|
Changed |
pmacct-0.14.2.tar.bz2/src/util.h
^
|
@@ -75,6 +75,10 @@
EXT void set_default_preferences(struct configuration *);
EXT FILE *open_logfile(char *);
EXT FILE *open_print_output_file(char *, time_t);
+EXT void handle_dynname_internal_strings(char *, int, char *);
+EXT void handle_dynname_internal_strings_same(char *, int, char *);
+EXT int sql_history_to_secs(int, int);
+EXT void close_print_output_file(FILE *, char *, time_t);
EXT void evaluate_bgp_aspath_radius(char *, int, int);
EXT void copy_stdcomm_to_asn(char *, as_t *, int);
EXT void *Malloc(unsigned int);
@@ -83,6 +87,7 @@
EXT void load_bgp_md5_file(char *, struct bgp_md5_table *);
EXT void unload_bgp_md5_file(struct bgp_md5_table *);
EXT int BTA_find_id(struct id_table *, struct packet_ptrs *, pm_id_t *, pm_id_t *);
+EXT void calc_refresh_timeout(time_t, time_t, int *);
EXT unsigned int str_to_addr(const char *, struct host_addr *);
|