Commit 18335c4c authored by 's avatar

Added support for Napatech NT-series cards


git-svn-id: file:///home/svn/mapi/trunk@1446 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 16e4e3ba
......@@ -299,6 +299,30 @@ esac], [enp2611=false])
AM_CONDITIONAL(DRIVER_ENP2611, test x$enp2611 = xtrue)
AM_CONDITIONAL(BINARY_ENP2611FLIB, test x$enp2611 = xtrue)
# NAPATECH support
AC_MSG_CHECKING(if NAPATECH cards support is enabled)
AC_ARG_ENABLE(napatech,
AS_HELP_STRING([--enable-napatech], [Enable support for NAPATECH cards]),
[case "${enableval}" in
yes) napatech=true ;;
no) napatech=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-napatech) ;;
esac], [napatech=false])
AM_CONDITIONAL(DRIVER_NAPATECH, test x$napatech = xtrue)
# AM_CONDITIONAL(BINARY_DAGFLIB, test x$dag = xtrue)
# AM_CONDITIONAL(PRECLASSIFICATION, test x$dag = xtrue)
if test x$napatech = xtrue; then
# MAPI_CONF_DAG_ENTRY=$srcdir/config/mapi.conf.dag.entry
# MAPI_FUNC_LIBS="${MAPI_FUNC_LIBS}:dagflib.so"
# AC_DEFINE(PRECLASSIFICATION, 1, [hardware preliminary packet classification])
AC_DEFINE(WITH_NAPATECH, 1, [if NAPATECH cards are supported])
AC_MSG_RESULT(yes)
else
MAPI_CONF_NAPATECH_ENTRY=/dev/null
AC_MSG_RESULT(no)
fi
#AC_SUBST_FILE(MAPI_CONF_NAPATECH_ENTRY)
# optional MAPI function libraries
......@@ -554,6 +578,61 @@ AC_SUBST(DAGINC)
AC_SUBST(DAGLIB)
#
# libnapatech (only for --enable-napatech)
#
AC_MSG_CHECKING([for libnapatech])
AC_ARG_WITH(libnapatech,
AS_HELP_STRING([--with-libnapatech=DIR], [Manual libnapatech path configuration, in case the configuration script can't find it. Search for libnapatech in DIR/lib, and for the header file in DIR/include. Effective only if --enable-napatech has been previously specified]),
[ case "$withval" in
yes|no)
AC_MSG_RESULT(no)
;;
*)
if test x$napatech = xfalse; then
AC_MSG_ERROR(Please use --with-libnapatech only in conjunction with --enable-napatech. You don't need to configure libnapatech if you are not going to use a Napatech card.)
else
AC_MSG_RESULT($withval)
if test -f $withval/include/NTCommonInterface.h -a -f $withval/lib/libntcommoninterface.so; then
owd=`pwd`
if cd $withval; then withval=`pwd`; cd $owd; fi
NAPATECHINC="-I$withval/include"
NAPATECHLIB="-L$withval/lib -lntcommoninterface"
else
AC_MSG_ERROR(NTCommonInterface.h or libntcommoninterface.so not found in $withval/include and $withval/lib)
fi
fi
;;
esac ],
[ if test x$napatech = xtrue; then
if test -f ${prefix}/include/NTCommonInterface.h -a -f ${prefix}/lib/libntcommoninterface.so; then
NAPATECHINC="-I${prefix}/include"
NAPATECHLIB="-L${prefix}/lib -lntcommoninterface"
elif test -f /opt/napatech/include/NTCommonInterface.h -a -f /opt/napatech/lib/libntcommoninterface.so; then
NAPATECHINC="-I/opt/napatech/include"
NAPATECHLIB="-L/opt/napatech/lib -lntcommoninterface"
elif test -f /usr/local/include/NTCommonInterface.h -a -f /usr/local/lib/libntcommoninterface.so; then
NAPATECHINC="-I${prefix}/include"
NAPATECHLIB="-L${prefix}/lib -lntcommoninterface"
elif test -f /usr/include/napatech/NTCommonInterface.h; then
NAPATECHINC="-I/usr/include/napatech"
NAPATECHLIB="-lntcommoninterface"
elif test -f /usr/include/NTCommonInterface.h; then
NAPATECHLIB="NTCommonInterface.h"
else
AC_MSG_RESULT(no)
AC_MSG_ERROR([libnapatech not found])
fi
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi ]
)
AC_SUBST(NAPATECHINC)
AC_SUBST(NAPATECHLIB)
#
# libnids >= 1.21 (only for --enable-extraflib)
#
......@@ -853,6 +932,9 @@ fi
if test x$dag = xtrue; then
echo "option: support for DAG cards"
fi
if test x$napatech = xtrue; then
echo "option: support for Napatech cards"
fi
if test x$authentication = xtrue; then
echo "option: authentication on"
fi
......
AM_CPPFLAGS = -I$(srcdir)/.. -I$(srcdir)/../lib -I$(srcdir)/../common -I$(srcdir)/../bpfcompiler @PCAPINC@ @DAGINC@ -D_GNU_SOURCE -D_THREAD_SAFE
AM_CPPFLAGS = -I$(srcdir)/.. -I$(srcdir)/../lib -I$(srcdir)/../common -I$(srcdir)/../bpfcompiler @PCAPINC@ @DAGINC@ @NAPATECHINC@ -D_NT_OS_TYPE=_NT_OS_TYPE_LINUX -D_GNU_SOURCE -D_THREAD_SAFE
libdir = $(pkgdatadir)
if DRIVER_DAG
......@@ -9,7 +9,11 @@ if DRIVER_ENP2611
BUILD_enp2611drv = mapienp2611drv.la
endif
lib_LTLIBRARIES = mapinicdrv.la mapivindrv.la $(BUILD_dagdrv) $(BUILD_enp2611drv)
if DRIVER_NAPATECH
BUILD_napatechdrv = mapinapatechdrv.la
endif
lib_LTLIBRARIES = mapinicdrv.la mapivindrv.la $(BUILD_dagdrv) $(BUILD_enp2611drv) $(BUILD_napatechdrv)
# mapi device drivers are dynamically loadable modules (but not standalone
# libraries for users)
......@@ -59,4 +63,17 @@ mapienp2611drv_la_LIBADD = \
mapienp2611drv_la_SOURCES = mapienp2611drv.c mapidlib.c mapidlib.h mapidrv.h
endif
if DRIVER_NAPATECH
mapinapatechdrv_la_LDFLAGS = -module
mapinapatechdrv_la_LIBADD = \
../common/libflist.la \
../common/libmapiipc.la \
../common/libparseconf.la \
../common/libprintfstring.la \
../common/libmapilibhandler.la \
../common/libdebug.la \
../bpfcompiler/libbpfcompiler.la -lrt @NAPATECHLIB@
mapinapatechdrv_la_SOURCES = mapinapatechdrv.c mapidlib.c mapidlib.h mapidrv.h
endif
EXTRA_DIST = mapicombo6drv.c
......@@ -11,5 +11,6 @@
#define MAPI_DEVICE_NIC_BUF "1.3.1"
#define MAPI_DEVICE_VIN "1.4"
#define MAPI_DEVICE_ENP2611 "1.5"
#define MAPI_DEVICE_NAPATECH "1.6"
#endif
CC = gcc
CFLAGS = -g -O2 -W -Wall
LDFLAGS = -lmapi
CFLAGS = -g -O2 -W -Wall -I/home/ubik/opt/mapi/include
LDFLAGS = -lmapi -L/home/ubik/opt/mapi/lib
SOURCES=$(wildcard *.c)
TARGETS=$(SOURCES:.c=)
......
......@@ -25,7 +25,6 @@ int main(int argc, char *argv[])
fprintf(stderr,"Errorcode :%d description: %s \n" ,err_no, error);
return -1;
}
DOT;
if ((fid = mapi_apply_function(fd, "PKT_COUNTER")) == -1) {
fprintf(stderr, "Count not apply function PKT_COUNTER to flow %d\n", fd);
......@@ -33,166 +32,21 @@ DOT;
fprintf(stderr,"Errorcode :%d description: %s \n" ,err_no, error);
return -1;
}
DOT;
;
if (mapi_connect(fd) < 0) {
fprintf(stderr, "Could not connect to flow %d\n", fd);
mapi_read_error( &err_no, error);
fprintf(stderr,"Errorcode :%d description: %s \n" ,err_no, error);
return -1;
}
DOT;
usleep(200000); /* 0.2 sec */
DOT;
while (1) {
res = mapi_read_results(fd, fid);
printf("\npackets till now : %llu\n", *((unsigned long long*)res->res));
/*
* sanity checks
*/
if (*((unsigned long long*)res->res) > 100000000) {
fprintf(stderr, "\nWARNING: suspiciously high byte count (%llu)\n",
*((unsigned long long *)res->res));
}
if(mapi_close_flow(fd)<0){
fprintf(stderr,"Close flow failed\n");
mapi_read_error( &err_no, error);
fprintf(stderr,"Errorcode :%d description: %s \n" ,err_no, error);
return -1;
}
DOT;
/*
* Error checking
*/
if ((fd = mapi_create_flow(argv[1])) < 0) {
fprintf(stderr, "Could not create flow using '%s'\n", argv[1]);
mapi_read_error( &err_no, error);
fprintf(stderr,"Errorcode :%d description: %s \n" ,err_no, error);
return -1;
}
DOT;
if (mapi_connect(fd) < 0) {
fprintf(stderr, "Could not connect to flow %d\n", fd);
mapi_read_error( &err_no, error);
fprintf(stderr,"Errorcode :%d description: %s \n" ,err_no, error);
return -1;
}
DOT;
if( ( fid = mapi_apply_function(fd,"PKT_COUNTER", NULL , "ANOTHER1" , 453) ) == -1){
mapi_read_error( &err_no, error);
printf("Testing error case1: Errorcode :%d description: %s \n" ,err_no, error);
if(err_no != 7006){
fprintf(stderr, "\nWARNING: mapi_apply_function returned wrong errorcode\n");
flag = 1;
}
}
DOT;
if(mapi_close_flow(fd)<0){
fprintf(stderr,"Close flow failed\n");
mapi_read_error( &err_no, error);
fprintf(stderr,"Errorcode :%d description: %s \n" ,err_no, error);
return -1;
}
DOT;
fd =0;
if ((fd = mapi_create_offline_flow("./tracefile" , MFF_PCAP)) < 0) {
fprintf(stderr, "Could not create flow using '%s'\n", argv[1]);
mapi_read_error( &err_no, error);
fprintf(stderr,"Errorcode :%d description: %s \n" ,err_no, error);
return -1;
}
DOT;
if ((fid = mapi_apply_function(fd, "PKT_COUNTER")) == -1) {
fprintf(stderr, "Count not apply function PKT_COUNTER to flow %d\n", fd);
mapi_read_error( &err_no, error);
fprintf(stderr,"Errorcode :%d description: %s \n" ,err_no, error);
return -1;
}
DOT;
if (mapi_connect(fd) < 0) {
fprintf(stderr, "Could not connect to flow %d\n", fd);
mapi_read_error( &err_no, error);
fprintf(stderr,"Errorcode :%d description: %s \n" ,err_no, error);
return -1;
}
DOT;
usleep(200000); /* 0.2 sec */
DOT;
do
{
sleep(1);
mapi_get_flow_info(fd,&info);
} while(info.status!=FLOW_FINISHED);
res = mapi_read_results(fd, fid);
printf("\nPackets till now : %llu\n", *((unsigned long long*)res->res));
/*
* sanity checks
*/
if (*((unsigned long long*)res->res)!=893) {
fprintf(stderr, "\nWARNING: %llu packtes read instead of 893 \n",
*((unsigned long long *)res->res));
}
DOT;
if(mapi_close_flow(fd)<0){
fprintf(stderr,"Close flow failed\n");
mapi_read_error( &err_no, error);
fprintf(stderr,"Errorcode :%d description: %s \n" ,err_no, error);
return -1;
}
DOT;
sleep(1);
/*
* Error checking
*/
if ((fd = mapi_create_offline_flow("./tracefile", MFF_PCAP)) < 0) {
fprintf(stderr, "Could not create flow using '%s'\n", argv[1]);
mapi_read_error( &err_no, error);
fprintf(stderr,"Errorcode :%d description: %s \n" ,err_no, error);
return -1;
}
DOT;
if (mapi_connect(fd) < 0) {
fprintf(stderr, "Could not connect to flow %d\n", fd);
mapi_read_error( &err_no, error);
fprintf(stderr,"Errorcode :%d description: %s \n" ,err_no, error);
return -1;
}
DOT;
if( ( fid = mapi_apply_function(fd,"PKT_COUNTER", NULL , "ANOTHER1" , 453) ) == -1){
mapi_read_error( &err_no, error);
printf("Testing error case1: Errorcode :%d description: %s \n" ,err_no, error);
if(err_no != 7006){
fprintf(stderr, "\nWARNING: mapi_apply_function returned wrong errorcode\n");
flag = 1;
}
}
DOT;
if(mapi_close_flow(fd)<0){
fprintf(stderr,"Close flow failed\n");
mapi_read_error( &err_no, error);
fprintf(stderr,"Errorcode :%d description: %s \n" ,err_no, error);
return -1;
}
DOT;
if (!flag) {
printf("\nPacket Counter Error Checking OK\n");
return 0;
}
else{
fprintf(stderr,"\nPacket Counter Error Checking :FAILED:\n");
return -1;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment