Commit 47b23f5d authored by Olav Kvittem's avatar Olav Kvittem
Browse files

initiell

parents
This a fix to libipfix for automatic log file rotation with date/time.
please find a diff towards the original and the modified source tree.
This diff is collapsed.
ChangeLog for libipfix
Version 1.0
+ update of IE definitions
- fixes
Version 0.8.1 (2007-02-28)
+ update to draft-ietf-ipfix-info-15.txt
+ update psamp ies to draft-ietf-psamp-info-05.txt
+ basic TLS support (experimental)
- nf9 export fixed
- sending tcp/sctp templates updated.
- fixes
Version 0.8 (2006-12-18)
+ update to draft-ietf-ipfix-info-14.txt
+ ipfix probe added
+ libmisc updated
- make install fixed (reported by Thomas Hirsch)
- resend templates via udp
- resend templates after tcp reconnect fixed
- use sctp stream zero to send templates
- uint8 coding fixed
- ipfix header sequence no. counts data records
- fixes
Version 0.7 (2006-09-06)
+ update to draft-ietf-ipfix-info-12.txt
+ add psamp IEs draft-ietf-psamp-info-04.txt
+ collector uses exporter ipaddr plus observ. domain id to differ input streams
+ db export: change column names to ieENO_ID
+ db export: prefix template table names with 'ipfix_data_'
+ db export: write octet arrays as binary data
+ describe database layout in howto document
- fixes
Version 0.6 (2006-04-22)
+ support float32/float64 IEs
- send ipfix messages via tcp fixed (reported by Luca Deri)
- fixes to compile on OpenBSD
- send option data fixed
+ howto document added
Version 0.5 (2005-12-19)
+ update to draft-ietf-ipfix-info-11.txt
+ FOKUS IEs updated
+ ipfix message logging revised
+ collector now can start and stop export
to file, database (mysql) or screen (=message logging)
+ new func to generate template identifier
+ example exporter supports protocol parameter
to export via tcp, udp or sctp
- fixes
Version 0.4 (2005-08-03)
+ update to draft-ietf-ipfix-info-09.txt
+ example collector sctp support
+ collector marks scope fields
- some fixes
Version 0.3 (2005-07-08)
+ update to draft-ietf-ipfix-info-07.txt
+ collector processes unknown IEs
- export of unknown IEs disabled
- lots of fixes
Version 0.2 (2005-04-22)
= first release
+ rudimentary sctp protocol support
- fixes
Version 0.1 (2004-12-22)
= libipfix imported from openimp package
+ support tcp and udp protocol
+ support ipv4 and ipv6
+ collector exports to file or database
libipfix - a library which provides an implementation of the IPFIX protocol
for flexible flow data support. IPFIX is the successor of NetFlow v9
(see http://www.ietf.org/dyn/wg/charter/ipfix-charter.html and
RFC5101 and RFC5102 for details)
Copyright (c) 2005-2010, Fraunhofer FOKUS
All rights reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 3 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 Lesser General Public License along with
this program; if not, see <http://www.gnu.org/licenses/>.
prerequisites:
- libmysqlclient (only needed to build a collector which
stores results data into a mysql database)
- libpcap (only needed to build the IPFIX probe)
To build libipfix, run "./configure" (a shell script). The configure
script will determine your system attributes and generate
appropriate makefiles from Makefile.in. Next run "make". If everything
goes well you can run "make install".
example:
./configure --enable-ipv6 --prefix=/usr/local
make
make install
To compile the example programs:
cd examples
make
#
#
# $Id: Makefile.in,v 1.2 2005/01/04 09:25:12 luz Exp $
#
# Makefile
SHELL = /bin/bash
top_srcdir = .
prefix = /usr/local
SUBDIRS = lib libmisc examples collector probe
all: compile
rmtarget clean distclean:
@ for DIR in $(SUBDIRS) ; \
do \
( \
cd ./$$DIR; $(MAKE) $@; \
); \
done
compile:
@ for DIR in $(SUBDIRS) ; \
do \
( \
cd ./$$DIR; $(MAKE); \
); \
done
install:
@ for DIR in $(SUBDIRS) ; \
do \
( \
cd ./$$DIR; $(MAKE) $@; \
); \
done
#
#
# $Id: Makefile.in,v 1.2 2005/01/04 09:25:12 luz Exp $
#
# Makefile
SHELL = @SHELL@
top_srcdir = @top_srcdir@
prefix = @prefix@
SUBDIRS = lib libmisc examples collector probe
all: compile
rmtarget clean distclean:
@ for DIR in $(SUBDIRS) ; \
do \
( \
cd ./$$DIR; $(MAKE) $@; \
); \
done
compile:
@ for DIR in $(SUBDIRS) ; \
do \
( \
cd ./$$DIR; $(MAKE); \
); \
done
install:
@ for DIR in $(SUBDIRS) ; \
do \
( \
cd ./$$DIR; $(MAKE) $@; \
); \
done
libipfix 1.0
This package contains source code for a library to export and
collect IPFIX measurement and accounting data.
The library is complemented with an IPFIX collector and
a basic IPFIX probe.
The library supports IPFIX (draft-ietf-ipfix-protocol-24.txt,
draft-ietf-ipfix-info-15.txt, draft-ietf-psamp-info-05.txt)
and Netflow9 (RFC 3954) using TCP, UDP and SCTP as transport protocol.
There are some small example programs containing code that
demonstrates how to use the library.
Find a howto under: http://ants.fokus.fraunhofer.de/libipfix/docs.php
You can download the current version under:
http://ants.fokus.fraunhofer.de/libipfix/downloads.php
Please send inquiries/comments/reports to mark@fokus.fraunhofer.de
#
#
# $Id: Makefile.in,v 1.4 2006/12/20 10:12:44 luz Exp $
#
# Makefile
SHELL = /bin/bash
srcdir = .
top_srcdir = ..
prefix = /usr/local
exec_prefix = ${prefix}
bindir = ${exec_prefix}/bin
sbindir = ${exec_prefix}/sbin
libexecdir = ${exec_prefix}/libexec
datadir = ${datarootdir}
datarootdir = ${prefix}/share
libdir = ${exec_prefix}/lib
mandir = ${datarootdir}/man
includedir = ${prefix}/include
oldincludedir = /usr/include
top_builddir = .
INSTALL = /usr/bin/install -c
INSTALL_PROGRAM = ${INSTALL}
INSTALL_DATA = ${INSTALL} -m 644
INSTALL_SCRIPT = ${INSTALL}
INSTALL_HEADER = $(INSTALL_DATA)
CC = gcc
EXEEXT =
OBJEXT = o
PACKAGE = libipfix
VERSION = 1.0
install_sh = @install_sh@
DEFS = -DHAVE_CONFIG_H
CPPFLAGS = -DDBSUPPORT
LDFLAGS =
LIBS = -lmysqlclient -L../lib -L../libmisc -lipfix -lmisc
CCOPT = -Wall -g
INCLS = -I. -I.. -I../lib -I../libmisc
CFLAGS = $(CCOPT) $(INCLS) $(DEFS)
TARGETS = ipfix_collector
OBJS = collector.o
CLEANFILES = $(OBJS) $(TARGETS)
all: $(TARGETS)
clean:
rm -f $(CLEANFILES)
distclean:
rm -f $(CLEANFILES) Makefile
install: $(TARGETS)
[ -d $(bindir) ] || \
(mkdir -p $(bindir); chmod 755 $(bindir))
$(INSTALL_PROGRAM) $(TARGETS) $(bindir)
ipfix_collector: collector.o Makefile ../lib/libipfix.a
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ collector.o $(LDFLAGS) $(LIBS)
collector.o: collector.c Makefile
$(CC) $(CFLAGS) $(CPPFLAGS) -c collector.c
#
#
# $Id: Makefile.in,v 1.4 2006/12/20 10:12:44 luz Exp $
#
# Makefile
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
datarootdir = @datarootdir@
libdir = @libdir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
top_builddir = .
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_HEADER = $(INSTALL_DATA)
CC = @CC@
EXEEXT = @EXEEXT@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE_NAME@
VERSION = @PACKAGE_VERSION@
install_sh = @install_sh@
DEFS = @DEFS@
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@ @MYSQLLIBS@ @SCTPLIBS@ @SSLLIBS@ -L../lib -L../libmisc -lipfix -lmisc
CCOPT = -Wall -g
INCLS = -I. -I.. -I../lib -I../libmisc
CFLAGS = $(CCOPT) $(INCLS) $(DEFS)
TARGETS = ipfix_collector
OBJS = collector.o
CLEANFILES = $(OBJS) $(TARGETS)
all: $(TARGETS)
clean:
rm -f $(CLEANFILES)
distclean:
rm -f $(CLEANFILES) Makefile
install: $(TARGETS)
[ -d $(bindir) ] || \
(mkdir -p $(bindir); chmod 755 $(bindir))
$(INSTALL_PROGRAM) $(TARGETS) $(bindir)
ipfix_collector: collector.o Makefile
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ collector.o $(LDFLAGS) $(LIBS)
collector.o: collector.c Makefile
$(CC) $(CFLAGS) $(CPPFLAGS) -c collector.c
/*
*/
/*
* collector.c - example ipfix collector
*
* Copyright Fraunhofer FOKUS
*
* $Date: 2007/02/28 10:33:47 $
*
* $Revision: 1.12 $
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <signal.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <time.h>
#include <netinet/in.h>
#include <libgen.h>
#include <stdarg.h>
#include <fcntl.h>
#include <netdb.h>
#ifdef HAVE_CONFIG_H
#include "../config.h"
#endif
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
#include "misc.h"
#include <ipfix.h>
#ifdef DBSUPPORT
#include "ipfix_db.h"
#endif
#include "ipfix_col.h"
#include "ipfix_def_fokus.h"
#include "ipfix_fields_fokus.h"
/*------ defines ---------------------------------------------------------*/
#define CAFILE "rootcert.pem"
#define CADIR NULL
#define KEYFILE "server.pem"
#define CERTFILE "server.pem"
/*------ stuctures -------------------------------------------------------*/
typedef struct ipfix_collector_opts
{
char progname[30];
int debug; /* some debug output */
char *logfile;
char *datadir;
int rotation_time; /* seconds */
int dbexport; /* flag */
char *dbuser; /* db username */
char *dbpw; /* db password */
char *dbname; /* db name */
char *dbhost; /* hostname */
int udp; /* support udp clients */
int tcp; /* support tcp packets */
int sctp; /* support sctp clients */
int ssl; /* ipfix over TLS/SSL */
char *cafile;
char *cadir;
char *keyfile; /* private key */
char *certfile; /* certificate */
int port; /* port number */
int maxcon; /* backlog parameter for listen(2) */
int family; /* AF_UNSPEC, _INET, _INET6 */
} ipfix_col_opts_t;
/*------ globals ---------------------------------------------------------*/
ipfix_col_opts_t par;
int verbose_level = 0;
int *tcp_s=NULL, ntcp_s=0; /* socket */
int *udp_s=NULL, nudp_s=0;
int *sctp_s=NULL, nsctp_s=0;
ipfix_col_t *scol=NULL;
/*------ prototypes ------------------------------------------------------*/
/*------ static funcs ----------------------------------------------------*/
static void usage( char *taskname)
{
const char helptxt[] =
"[options]\n\n"
"options:\n"
" -h this help\n"
" -4 accept connections via AF_INET socket\n"
" -6 accept connections via AF_INET6 socket\n"
" -o <datadir> store files of collected data in this dir\n"
" -i seconds rotate file every seconds(600)\n"
" -p <portno> listen on this port (default=4739)\n"
" -s support SCTP clients\n"
" -t support TCP clients\n"
" -u support UDP clients\n"
" -v increase verbose level\n"
#ifdef DBSUPPORT
#ifdef HAVE_GETOPT_LONG
"db options:\n"
" --db export into database\n"
" --dbhost <hostname> db host\n"
" --dbname <database> db name\n"
" --dbuser <user> db user\n"
" --dbpw <password> db password\n"
#else
" -d export into database\n"
#endif
#ifdef SSLSUPPORT
"ssl options:\n"
" --ssl expect tls/ssl clients\n"
" --key <file> private key file to use\n"
" --cert <file> certificate file to use\n"
" --cafile <file> file of CAs\n"
" --cadir <dir> directory of CAs\n"
#endif
#endif
"\n";
fprintf( stderr, "\nipfix collector (%s %s)\n",
"$Revision: 1.12 $", __DATE__ );
fprintf( stderr,"\nusage: %s %sexample: %s -stu -vv -o . \n\n",
taskname, helptxt, taskname );
}/*usage*/
void exit_func ( int retval )
{
int i;
if ( par.tcp && tcp_s ) {
for( i=0; i<ntcp_s; i++ ) {
ipfix_col_close( tcp_s[i] );
}
free( tcp_s );
}
if ( par.udp && udp_s ) {
for( i=0; i<nudp_s; i++ ) {
ipfix_col_close( udp_s[i] );
}
free( udp_s );
}
if ( par.sctp && sctp_s ) {
for( i=0; i<nsctp_s; i++ ) {
ipfix_col_close( sctp_s[i] );
}
free( sctp_s );
}
if ( par.ssl && scol ) {
ipfix_col_close_ssl( scol );
}
if ( par.datadir ) ipfix_col_stop_fileexport();
#ifdef DBSUPPORT
if ( par.dbexport ) ipfix_col_stop_mysqlexport();
#endif
(void) ipfix_col_stop_msglog();
ipfix_col_cleanup();
ipfix_cleanup();
mlog_close();
exit( retval );
}
void sig_func( int signo )
{
if ( verbose_level )
fprintf( stderr, "\n[%s] got signo %d, bye.\n\n", par.progname, signo );
exit_func( 1 );
}
int do_collect()
{
int i, retval = -1;
ipfix_ssl_opts_t opts;
if ( par.ssl ) {
opts.cafile = par.cafile;
opts.cadir = par.cadir;
opts.keyfile = par.keyfile;
opts.certfile= par.certfile;
}
/** activate file export
*/
if ( par.datadir )
(void) ipfix_col_init_fileexport( par.datadir, par.rotation_time );
#ifdef DBSUPPORT
if ( par.dbexport ) {
if ( ipfix_col_init_mysqlexport( par.dbhost, par.dbuser,
par.dbpw, par.dbname ) <0 ) {
mlogf( 0, "[%s] cannot connect to database\n", par.progname );
return -1;
}
}
#endif
/** open ipfix collector port(s)
*/
if ( par.tcp ) {
if ( par.ssl ) {
if ( ipfix_col_listen_ssl( &scol, IPFIX_PROTO_TCP,
par.port, par.family, par.maxcon,
&opts ) <0 ) {
fprintf( stderr, "ipfix_listen_ssl(tcp) failed: %s\n",
strerror(errno) );
return -1;
}
}
else if ( ipfix_col_listen( &ntcp_s, &tcp_s, IPFIX_PROTO_TCP,
par.port, par.family, par.maxcon ) <0 ) {
fprintf( stderr, "ipfix_listen(tcp) failed: %s\n",
strerror(errno) );
return -1;
}
}
if ( par.udp ) {
if ( par.ssl ) {
if ( ipfix_col_listen_ssl( &scol, IPFIX_PROTO_UDP,
par.port, par.family, 0, &opts ) <0 ) {
fprintf( stderr, "ipfix_listen_ssl(udp) failed: %s\n",
strerror(errno) );
return -1;
}
}
else if ( ipfix_col_listen( &nudp_s, &udp_s, IPFIX_PROTO_UDP,
par.port, par.family, 0 ) <0 ) {
fprintf( stderr, "ipfix_listen(udp) failed: %s\n",
strerror(errno) );