diff options
author | Bart De Schuymer <bdschuym@pandora.be> | 2005-04-19 19:58:15 +0000 |
---|---|---|
committer | Bart De Schuymer <bdschuym@pandora.be> | 2005-04-19 19:58:15 +0000 |
commit | e773028f9636ecc388d68dee13fbe3057513f905 (patch) | |
tree | 33611c611668241382100ca7bca4e5f1e14b30ed /userspace/libebtc/test | |
parent | dc2061ed4d7e3c8b32708bfa3b4ededd9317fb87 (diff) |
add userspace library (Jens Götze)
Diffstat (limited to 'userspace/libebtc/test')
-rw-r--r-- | userspace/libebtc/test/Makefile.am | 51 | ||||
-rw-r--r-- | userspace/libebtc/test/Makefile.in | 493 | ||||
-rw-r--r-- | userspace/libebtc/test/ebtc_test1.c | 616 | ||||
-rw-r--r-- | userspace/libebtc/test/ebtc_test2.c | 342 | ||||
-rw-r--r-- | userspace/libebtc/test/util.c | 137 |
5 files changed, 1639 insertions, 0 deletions
diff --git a/userspace/libebtc/test/Makefile.am b/userspace/libebtc/test/Makefile.am new file mode 100644 index 0000000..201ff5e --- /dev/null +++ b/userspace/libebtc/test/Makefile.am @@ -0,0 +1,51 @@ +# +# ==[ Makefile ]================================================================ +# +# Project +# +# Library for ethernet bridge tables. +# +# +# Description +# +# Process this file with automake to create Makefile.in +# +# +# Copyright +# +# Copyright 2005 by Jens Götze +# All rights reserved. +# +# 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. +# +# +# ============================================================================== +# + + +MAINTAINERCLEANFILES = Makefile.in + +AM_CFLAGS = @CFLAGS@ -I../include +AM_LDFLAGS = @LDFLAGS@ + +EXTRA_DIST = + +noinst_PROGRAMS = ebtc_test1 ebtc_test2 + +ebtc_test1_SOURCES = ../src/ebtc.c ebtc_test1.c util.c +ebtc_test2_SOURCES = ../src/ebtc.c ebtc_test2.c util.c + + diff --git a/userspace/libebtc/test/Makefile.in b/userspace/libebtc/test/Makefile.in new file mode 100644 index 0000000..dc12956 --- /dev/null +++ b/userspace/libebtc/test/Makefile.in @@ -0,0 +1,493 @@ +# Makefile.in generated by automake 1.9.3 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# +# ==[ Makefile ]================================================================ +# +# Project +# +# Library for ethernet bridge tables. +# +# +# Description +# +# Process this file with automake to create Makefile.in +# +# +# Copyright +# +# Copyright 2005 by Jens Götze +# All rights reserved. +# +# 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. +# +# +# ============================================================================== +# + +SOURCES = $(ebtc_test1_SOURCES) $(ebtc_test2_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +noinst_PROGRAMS = ebtc_test1$(EXEEXT) ebtc_test2$(EXEEXT) +subdir = test +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/include/config.h +CONFIG_CLEAN_FILES = +PROGRAMS = $(noinst_PROGRAMS) +am_ebtc_test1_OBJECTS = ebtc.$(OBJEXT) ebtc_test1.$(OBJEXT) \ + util.$(OBJEXT) +ebtc_test1_OBJECTS = $(am_ebtc_test1_OBJECTS) +ebtc_test1_LDADD = $(LDADD) +am_ebtc_test2_OBJECTS = ebtc.$(OBJEXT) ebtc_test2.$(OBJEXT) \ + util.$(OBJEXT) +ebtc_test2_OBJECTS = $(am_ebtc_test2_OBJECTS) +ebtc_test2_LDADD = $(LDADD) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(ebtc_test1_SOURCES) $(ebtc_test2_SOURCES) +DIST_SOURCES = $(ebtc_test1_SOURCES) $(ebtc_test2_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +EBTC_LT_AGE = @EBTC_LT_AGE@ +EBTC_LT_CURRENT = @EBTC_LT_CURRENT@ +EBTC_LT_REVISION = @EBTC_LT_REVISION@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ +MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ +MAKEINFO = @MAKEINFO@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +ac_ct_RANLIB = @ac_ct_RANLIB@ +ac_ct_STRIP = @ac_ct_STRIP@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +MAINTAINERCLEANFILES = Makefile.in +AM_CFLAGS = @CFLAGS@ -I../include +AM_LDFLAGS = @LDFLAGS@ +EXTRA_DIST = +ebtc_test1_SOURCES = ../src/ebtc.c ebtc_test1.c util.c +ebtc_test2_SOURCES = ../src/ebtc.c ebtc_test2.c util.c +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu test/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +ebtc_test1$(EXEEXT): $(ebtc_test1_OBJECTS) $(ebtc_test1_DEPENDENCIES) + @rm -f ebtc_test1$(EXEEXT) + $(LINK) $(ebtc_test1_LDFLAGS) $(ebtc_test1_OBJECTS) $(ebtc_test1_LDADD) $(LIBS) +ebtc_test2$(EXEEXT): $(ebtc_test2_OBJECTS) $(ebtc_test2_DEPENDENCIES) + @rm -f ebtc_test2$(EXEEXT) + $(LINK) $(ebtc_test2_LDFLAGS) $(ebtc_test2_OBJECTS) $(ebtc_test2_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ebtc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ebtc_test1.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ebtc_test2.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/util.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +ebtc.o: ../src/ebtc.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ebtc.o -MD -MP -MF "$(DEPDIR)/ebtc.Tpo" -c -o ebtc.o `test -f '../src/ebtc.c' || echo '$(srcdir)/'`../src/ebtc.c; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/ebtc.Tpo" "$(DEPDIR)/ebtc.Po"; else rm -f "$(DEPDIR)/ebtc.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/ebtc.c' object='ebtc.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ebtc.o `test -f '../src/ebtc.c' || echo '$(srcdir)/'`../src/ebtc.c + +ebtc.obj: ../src/ebtc.c +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ebtc.obj -MD -MP -MF "$(DEPDIR)/ebtc.Tpo" -c -o ebtc.obj `if test -f '../src/ebtc.c'; then $(CYGPATH_W) '../src/ebtc.c'; else $(CYGPATH_W) '$(srcdir)/../src/ebtc.c'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/ebtc.Tpo" "$(DEPDIR)/ebtc.Po"; else rm -f "$(DEPDIR)/ebtc.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='../src/ebtc.c' object='ebtc.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ebtc.obj `if test -f '../src/ebtc.c'; then $(CYGPATH_W) '../src/ebtc.c'; else $(CYGPATH_W) '$(srcdir)/../src/ebtc.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstPROGRAMS ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/userspace/libebtc/test/ebtc_test1.c b/userspace/libebtc/test/ebtc_test1.c new file mode 100644 index 0000000..5137adb --- /dev/null +++ b/userspace/libebtc/test/ebtc_test1.c @@ -0,0 +1,616 @@ +/* + * ==[ FILENAME: ebtc_test.c ]================================================== + * + * Project + * + * Library for ethernet bridge tables. + * + * + * Description + * + * Test for this library. + * + * + * Copyright + * + * Copyright 2005 by Jens Götze + * All rights reserved. + * + * 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. + * + * + * ============================================================================= + */ + + +#include <stdio.h> +#include <stdlib.h> +#include <util.h> +#include <libebtc.h> + + +int insert_entry (const char *chain, ebtc_handle_t *handle) +{ + +/* ---- VAR ---- */ + + unsigned int size = 0; + + struct ebt_entry *entry; + + struct ebt_standard_target + *std_target; + + struct ebt_entry_target *target; + + + +/* ---- CODE ---- */ + + /* Allocate memory */ + + size += EBTC_ALIGN(sizeof(struct ebt_entry)); + size += EBTC_ALIGN(sizeof(struct ebt_standard_target)); + + entry = (struct ebt_entry *)malloc(size); + + if (!entry) { + + eprintf("Can't allocate memory\n"); + + return -1; + + } + + memset(entry, 0, size); + + size = EBTC_ALIGN(sizeof(*entry)); + std_target = (struct ebt_standard_target *)((char *)entry + size); + + /* Prepare entry */ + + entry->bitmask = EBT_ENTRY_OR_ENTRIES | EBT_NOPROTO; + + entry->watchers_offset = EBTC_ALIGN(sizeof(*entry)); + entry->target_offset = entry->watchers_offset; + entry->next_offset = entry->target_offset + EBTC_ALIGN(sizeof(*std_target)); + + /* Prepare target */ + + target = &std_target->target; + target->target_size = EBTC_ALIGN(sizeof(*std_target)); + target->target_size -= EBTC_ALIGN(sizeof(*target)); + + snprintf(target->u.name, EBT_FUNCTION_MAXNAMELEN, "standard"); + + std_target->verdict = EBT_CONTINUE; + + /* Append */ + + if (ebtc_insert_entry(chain, entry, 0, handle)) { + + eprintf("Can't insert entry\n"); + + free(entry); + + return -1; + + } + + free(entry); + + return 0; + +} + + +int replace_entry (const char *chain, ebtc_handle_t *handle) +{ + +/* ---- VAR ---- */ + + unsigned int size = 0; + + struct ebt_entry *entry; + + struct ebt_standard_target + *std_target; + + struct ebt_entry_target *target; + + + +/* ---- CODE ---- */ + + /* Allocate memory */ + + size += EBTC_ALIGN(sizeof(struct ebt_entry)); + size += EBTC_ALIGN(sizeof(struct ebt_standard_target)); + + entry = (struct ebt_entry *)malloc(size); + + if (!entry) { + + eprintf("Can't allocate memory\n"); + + return -1; + + } + + memset(entry, 0, size); + + size = EBTC_ALIGN(sizeof(*entry)); + std_target = (struct ebt_standard_target *)((char *)entry + size); + + /* Prepare entry */ + + entry->bitmask = EBT_ENTRY_OR_ENTRIES | EBT_NOPROTO; + + entry->watchers_offset = EBTC_ALIGN(sizeof(*entry)); + entry->target_offset = entry->watchers_offset; + entry->next_offset = entry->target_offset + EBTC_ALIGN(sizeof(*std_target)); + + /* Prepare target */ + + target = &std_target->target; + target->target_size = EBTC_ALIGN(sizeof(*std_target)); + target->target_size -= EBTC_ALIGN(sizeof(*target)); + + snprintf(target->u.name, EBT_FUNCTION_MAXNAMELEN, "standard"); + + std_target->verdict = EBT_ACCEPT; + + /* Append */ + + if (ebtc_replace_entry(chain, entry, 1, handle)) { + + eprintf("Can't replace entry\n"); + + free(entry); + + return -1; + + } + + free(entry); + + return 0; + +} + + +int append_entry (const char *chain, ebtc_handle_t *handle, char *chainname) +{ + +/* ---- VAR ---- */ + + unsigned int size = 0; + + struct ebt_entry *entry; + + struct ebt_standard_target + *std_target; + + struct ebt_entry_target *target; + + + +/* ---- CODE ---- */ + + /* Allocate memory */ + + size += EBTC_ALIGN(sizeof(struct ebt_entry)); + size += EBTC_ALIGN(sizeof(struct ebt_standard_target)); + + entry = (struct ebt_entry *)malloc(size); + + if (!entry) { + + eprintf("Can't allocate memory\n"); + + return -1; + + } + + memset(entry, 0, size); + + size = EBTC_ALIGN(sizeof(*entry)); + std_target = (struct ebt_standard_target *)((char *)entry + size); + + /* Prepare entry */ + + entry->bitmask = EBT_ENTRY_OR_ENTRIES | EBT_NOPROTO; + + entry->watchers_offset = EBTC_ALIGN(sizeof(*entry)); + entry->target_offset = entry->watchers_offset; + entry->next_offset = entry->target_offset + EBTC_ALIGN(sizeof(*std_target)); + + /* Prepare target */ + + if (ebtc_target_jumptochain(std_target, chainname, handle)) { + + eprintf("Can't jump to chain\n"); + + return -1; + + } + + /* Append */ + + if (ebtc_append_entry(chain, entry, handle)) { + + eprintf("Can't append entry\n"); + + free(entry); + + return -1; + + } + + free(entry); + + return 0; + +} + + +int main () +{ + +/* ---- VAR ---- */ + + int i; + + const char *chain; + + const char *policy; + + ebtc_handle_t handle; + + const struct ebt_entry *rule; + + struct ebt_counter counter_new; + + const struct ebt_counter + *counter; + + + +/* ---- CODE ---- */ + + /* Open ebtables handle */ + + handle = ebtc_init("filter", EBTC_INIT_WITHFLUSH); + + if (!handle) { + + eprintf("Can't open ebtables (%s)\n", ebtc_strerror(NULL)); + + return 1; + + } + + if (ebtc_commit(&handle)) { + + eprintf("Can't commit ebtables changes\n"); + + return 1; + + } + + /* Open ebtables handle */ + + handle = ebtc_init("filter", EBTC_INIT_WITHFLUSH); + + if (!handle) { + + eprintf("Can't open ebtables (%s)\n", ebtc_strerror(NULL)); + + return 1; + + } + + /* Entry functions */ + + if (append_entry("FORWARD", &handle, "CONTINUE")) { + + eprintf("Can't append entry\n"); + + ebtc_free(&handle); + + return 1; + + } + + if (append_entry("FORWARD", &handle, "CONTINUE")) { + + eprintf("Can't append entry\n"); + + ebtc_free(&handle); + + return 1; + + } + + if (insert_entry("FORWARD", &handle)) { + + eprintf("Can't insert entry\n"); + + ebtc_free(&handle); + + return 1; + + } + + if (replace_entry("FORWARD", &handle)) { + + eprintf("Can't replace entry\n"); + + ebtc_free(&handle); + + return 1; + + } + + /* Set policies */ + + policy = ebtc_get_policy("FORWARD", &handle); + + if (!policy) { + + eprintf("Can't get policy of chain\n"); + + ebtc_free(&handle); + + return 1; + + } + + printf("Chain policy before change: %s\n", policy); + + if (ebtc_set_policy("FORWARD", "DROP", &handle)) { + + eprintf("Can't set policy\n"); + + ebtc_free(&handle); + + return 1; + + } + + policy = ebtc_get_policy("FORWARD", &handle); + + if (!policy) { + + eprintf("Can't get policy of chain\n"); + + ebtc_free(&handle); + + return 1; + + } + + printf("Chain policy after change: %s\n", policy); + printf("\n"); + + /* Create chain */ + + if (ebtc_create_chain("test_prerename", &handle)) { + + eprintf("Can't create chain\n"); + + ebtc_free(&handle); + + return 1; + + } + + if (ebtc_rename_chain("test_prerename", "test", &handle)) { + + eprintf("Can't rename chain\n"); + + ebtc_free(&handle); + + return 1; + + } + + /* Delete chain */ + + printf("Chains before delete:\n"); + + chain = ebtc_first_chain(&handle); + + while (chain) { + + printf(" Chain: '%s'\n", chain); + + chain = ebtc_next_chain(&handle); + + } + + if (ebtc_delete_chain("test", &handle)) { + + eprintf("Can't delete chain\n"); + + ebtc_free(&handle); + + return 1; + + } + + printf("Chains after delete:\n"); + + chain = ebtc_first_chain(&handle); + + while (chain) { + + printf(" Chain: '%s'\n", chain); + + chain = ebtc_next_chain(&handle); + + } + + printf("\n"); + + /* Delete entry test */ + + if (append_entry("INPUT", &handle, "RETURN")) { + + eprintf("Can't append entry\n"); + + ebtc_free(&handle); + + return 1; + + } + + counter_new.bcnt = 1; + counter_new.pcnt = 2; + + if (ebtc_set_counter("INPUT", 0, &counter_new, &handle)) { + + eprintf("Can't set counter\n"); + + ebtc_free(&handle); + + return -1; + + } + + if (insert_entry("INPUT", &handle)) { + + eprintf("Can't insert entry\n"); + + ebtc_free(&handle); + + return 1; + + } + + printf("Rule list in chain INPUT before delete\n"); + + i = 0; + rule = ebtc_first_rule("INPUT", &handle); + + while (rule) { + + counter = ebtc_read_counter("INPUT", i++, &handle); + + printf(" Entry jump to '%s' (bcnt = %lld; pcnt = %lld)\n", + ebtc_get_target(rule, &handle), counter->bcnt, counter->pcnt); + + rule = ebtc_next_rule("INPUT", &handle); + + } + + if (ebtc_delete_entry("INPUT", 0, &handle)) { + + eprintf("Can't delete entry\n"); + + ebtc_free(&handle); + + return 1; + + } + + if (ebtc_zero_counter("INPUT", 0, &handle)) { + + eprintf("Can't zero counter\n"); + + ebtc_free(&handle); + + return 1; + + } + + printf("Rule list in chain INPUT after delete\n"); + + i = 0; + rule = ebtc_first_rule("INPUT", &handle); + + while (rule) { + + counter = ebtc_read_counter("INPUT", i++, &handle); + + printf(" Entry jump to '%s' (bcnt = %lld; pcnt = %lld)\n", + ebtc_get_target(rule, &handle), counter->bcnt, counter->pcnt); + + rule = ebtc_next_rule("INPUT", &handle); + + } + + printf("\n"); + + /* Counter test */ + + if (append_entry("OUTPUT", &handle, "DROP")) { + + eprintf("Can't append entry\n"); + + ebtc_free(&handle); + + return 1; + + } + + if (ebtc_zero_entries("OUTPUT", &handle)) { + + eprintf("Can't zero counter of chain\n"); + + return 1; + + } + + /* Jump to chain */ + + if (ebtc_create_chain("test2", &handle)) { + + eprintf("Can't create chain\n"); + + ebtc_free(&handle); + + return 1; + + } + + if (append_entry("OUTPUT", &handle, "test2")) { + + eprintf("Can't append entry\n"); + + ebtc_free(&handle); + + return 1; + + } + + /* Submit changes to kernel */ + + if (ebtc_commit(&handle)) { + + eprintf("Can't commit ebtables changes (%s)\n", ebtc_strerror(NULL)); + + return 1; + + } + + printf("Test successful finished.\n\n"); + + return 0; + +} + + diff --git a/userspace/libebtc/test/ebtc_test2.c b/userspace/libebtc/test/ebtc_test2.c new file mode 100644 index 0000000..98ac461 --- /dev/null +++ b/userspace/libebtc/test/ebtc_test2.c @@ -0,0 +1,342 @@ +/* + * ==[ FILENAME: ebtc_test2.c ]================================================= + * + * Project + * + * Library for ethernet bridge tables. + * + * + * Description + * + * Test for this library. + * + * + * Copyright + * + * Copyright 2005 by Jens Götze + * All rights reserved. + * + * 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. + * + * + * ============================================================================= + */ + + +#include <stdio.h> +#include <stdlib.h> +#include <util.h> +#include <libebtc.h> + + +int append_entry (const char *chain, ebtc_handle_t *handle) +{ + +/* ---- VAR ---- */ + + unsigned int size = 0; + + struct ebt_entry *entry; + + struct ebt_standard_target + *std_target; + + struct ebt_entry_target *target; + + + +/* ---- CODE ---- */ + + /* Allocate memory */ + + size += EBTC_ALIGN(sizeof(struct ebt_entry)); + size += EBTC_ALIGN(sizeof(struct ebt_standard_target)); + + entry = (struct ebt_entry *)malloc(size); + + if (!entry) { + + eprintf("Can't allocate memory\n"); + + return -1; + + } + + memset(entry, 0, size); + + size = EBTC_ALIGN(sizeof(*entry)); + std_target = (struct ebt_standard_target *)((char *)entry + size); + + /* Prepare entry */ + + entry->bitmask = EBT_ENTRY_OR_ENTRIES | EBT_NOPROTO; + + entry->watchers_offset = EBTC_ALIGN(sizeof(*entry)); + entry->target_offset = entry->watchers_offset; + entry->next_offset = entry->target_offset + EBTC_ALIGN(sizeof(*std_target)); + + /* Prepare target */ + + target = &std_target->target; + target->target_size = EBTC_ALIGN(sizeof(*std_target)); + target->target_size -= EBTC_ALIGN(sizeof(*target)); + + snprintf(target->u.name, EBT_FUNCTION_MAXNAMELEN, "standard"); + + std_target->verdict = EBT_CONTINUE; + + /* Append */ + + if (ebtc_append_entry(chain, entry, handle)) { + + eprintf("Can't append entry\n"); + + free(entry); + + return -1; + + } + + free(entry); + + return 0; + +} + + +void printlist (ebtc_handle_t *handle) +{ + +/* ---- VAR ---- */ + + const struct ebt_entry *rule; + + int i = 0; + + const struct ebt_counter + *counter; + + + +/* ---- CODE ---- */ + + rule = ebtc_first_rule("INPUT", handle); + + while (rule) { + + counter = ebtc_read_counter("INPUT", i++, handle); + + printf(" Entry jump to '%s' (bcnt = %lld; pcnt = %lld)\n", + ebtc_get_target(rule, handle), counter->bcnt, counter->pcnt); + + rule = ebtc_next_rule("INPUT", handle); + + } + +} + + +int test_run () +{ + +/* ---- VAR ---- */ + + int i; + + const char *chain; + + const char *policy; + + ebtc_handle_t handle; + + + +/* ---- CODE ---- */ + + /* Open ebtables handle */ + + handle = ebtc_init("filter", EBTC_INIT); + + if (!handle) { + + eprintf("Can't open ebtables (%s)\n", ebtc_strerror(NULL)); + + return 1; + + } + + /* Delete and append entry */ + + printf("Rule list in chain INPUT before delete\n"); + printlist(&handle); + printf("\n"); + + printf("Delete second entry\n"); + + if (ebtc_delete_entry("INPUT", 1, &handle)) { + + eprintf("Can't delete entry\n"); + + return 1; + + } + + printf("\n"); + + printf("Rule list in chain INPUT after delete\n"); + printlist(&handle); + printf("\n"); + + printf("Append entry\n"); + + if (append_entry("INPUT", &handle)) { + + eprintf("Can't append entry\n"); + + return 1; + + } + + printf("\n"); + + /* Wait for packets */ + + printf("Wait 5 seconds for network traffic...\n"); + sleep(5); + printf("\n"); + + /* Submit changes to kernel */ + + if (ebtc_commit(&handle)) { + + eprintf("Can't commit ebtables changes\n"); + + return 1; + + } + + /* Open ebtables handle */ + + handle = ebtc_init("filter", EBTC_INIT); + + if (!handle) { + + eprintf("Can't open ebtables (%s)\n", ebtc_strerror(NULL)); + + return 1; + + } + + /* List current entries */ + + printf("Rule list in chain INPUT after commit\n"); + printlist(&handle); + printf("\n"); + + /* Submit changes to kernel */ + + ebtc_free(&handle); + + return 0; + +} + + +int test_init () +{ + +/* ---- VAR ---- */ + + int i; + + const char *chain; + + const char *policy; + + ebtc_handle_t handle; + + + +/* ---- CODE ---- */ + + handle = ebtc_init("filter", EBTC_INIT_WITHFLUSH); + + if (!handle) { + + eprintf("Can't open ebtables (%s)\n", ebtc_strerror(NULL)); + + return 1; + + } + + printf("Append entry\n"); + + if (append_entry("INPUT", &handle)) { + + eprintf("Can't append entry\n"); + + return 1; + + } + + printf("Append entry\n"); + + if (append_entry("INPUT", &handle)) { + + eprintf("Can't append entry\n"); + + return 1; + + } + + printf("\n"); + + if (ebtc_commit(&handle)) { + + eprintf("Can't commit ebtables changes\n"); + + return 1; + + } + + return 0; + +} + + +int main (int argc, char **argv) +{ + +/* ---- CODE ---- */ + + if (argc != 2) { + + printf("Usage: progname <init|run>\n\n"); + + return 1; + + } + + if (!strcmp(argv[1], "init")) + return test_init(); + else if (!strcmp(argv[1], "run")) + return test_run(); + + return 0; + +} + + diff --git a/userspace/libebtc/test/util.c b/userspace/libebtc/test/util.c new file mode 100644 index 0000000..cb18eb5 --- /dev/null +++ b/userspace/libebtc/test/util.c @@ -0,0 +1,137 @@ +/* + * ==[ FILENAME: util.c ]======================================================= + * + * Project + * + * Library for ethernet bridge tables. + * + * + * Description + * + * Utilities + * + * + * Copyright + * + * Copyright 2005 by Jens Götze + * All rights reserved. + * + * 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. + * + * + * ============================================================================= + */ + + +#include <stdio.h> +#include <stdarg.h> + + +int __eprintf (char *filename, int line, char *format, ...) +{ + +/* ---- VAR ---- */ + + va_list ap; + + + +/* ---- CODE ---- */ + + /* Open argument list */ + + va_start(ap, format); + + /* Print message on screen */ + + fprintf(stderr, "[ERROR] [%s:%d] ", filename, line); + vfprintf(stderr, format, ap); + fflush(stderr); + + /* Close argument list */ + + va_end(ap); + + return 0; + +} + + +void printhex (FILE *output, const char *buf, size_t size) +{ + +/* ---- VAR ---- */ + + int i; + + char *ptr; + + char c; + + size_t tmp; + + + +/* ---- CODE ---- */ + + while (size) { + + if (size > 1) { + + fprintf(output, "%08X-%08X ", (unsigned int)buf, + (unsigned int)buf + (size > 15 ? 15 : size - 1)); + + } else + fprintf(output, "%08X %8.8s ", (unsigned int)buf, ""); + + ptr = (char *)buf; + tmp = size; + + for (i = 8; i && tmp; i--, tmp--) + fprintf(output, " %02X", (unsigned char)*ptr++); + + for (; i; i--) + fprintf(output, " "); + + fprintf(output, " "); + + if (tmp) { + + for (i = 8; i && tmp; i--, tmp--) + fprintf(output, " %02X", (unsigned char)*ptr++); + + } else + i = 8; + + for (; i; i--) + fprintf(output, " "); + + fprintf(output, " "); + + for (i = 16; i && size; i--, size--) { + + c = *buf++; + fprintf(output, "%c", c < 32 ? '.' : c); + + } + + fprintf(output, "\n"); + + } + +} + + |