diff options
Diffstat (limited to 'relay')
-rw-r--r-- | relay/.cvsignore | 4 | ||||
-rw-r--r-- | relay/Makefile.am | 13 | ||||
-rw-r--r-- | relay/Makefile.in | 810 | ||||
-rw-r--r-- | relay/dhcrelay.8 | 355 | ||||
-rw-r--r-- | relay/dhcrelay.c | 2173 | ||||
-rw-r--r-- | relay/tests/Atffile | 5 | ||||
-rw-r--r-- | relay/tests/Kyuafile | 4 | ||||
-rw-r--r-- | relay/tests/Makefile.am | 49 | ||||
-rw-r--r-- | relay/tests/Makefile.in | 742 | ||||
-rw-r--r-- | relay/tests/relay_unittests.c | 431 |
10 files changed, 0 insertions, 4586 deletions
diff --git a/relay/.cvsignore b/relay/.cvsignore deleted file mode 100644 index f45af85c..00000000 --- a/relay/.cvsignore +++ /dev/null @@ -1,4 +0,0 @@ -.deps -Makefile -dhcrelay -dhcrelay.man8 diff --git a/relay/Makefile.am b/relay/Makefile.am deleted file mode 100644 index 5562b694..00000000 --- a/relay/Makefile.am +++ /dev/null @@ -1,13 +0,0 @@ -SUBDIRS = . tests - -AM_CPPFLAGS = -DLOCALSTATEDIR='"@localstatedir@"' - -sbin_PROGRAMS = dhcrelay -dhcrelay_SOURCES = dhcrelay.c -dhcrelay_LDADD = ../common/libdhcp.@A@ ../omapip/libomapi.@A@ \ - @BINDLIBIRSDIR@/libirs.@A@ \ - @BINDLIBDNSDIR@/libdns.@A@ \ - @BINDLIBISCCFGDIR@/libisccfg.@A@ \ - @BINDLIBISCDIR@/libisc.@A@ -man_MANS = dhcrelay.8 -EXTRA_DIST = $(man_MANS) diff --git a/relay/Makefile.in b/relay/Makefile.in deleted file mode 100644 index 955a068d..00000000 --- a/relay/Makefile.in +++ /dev/null @@ -1,810 +0,0 @@ -# Makefile.in generated by automake 1.16.5 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2021 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@ - -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -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@ -sbin_PROGRAMS = dhcrelay$(EXEEXT) -subdir = relay -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/includes/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -am__installdirs = "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man8dir)" -PROGRAMS = $(sbin_PROGRAMS) -am_dhcrelay_OBJECTS = dhcrelay.$(OBJEXT) -dhcrelay_OBJECTS = $(am_dhcrelay_OBJECTS) -dhcrelay_DEPENDENCIES = ../common/libdhcp.@A@ ../omapip/libomapi.@A@ -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/includes -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__maybe_remake_depfiles = depfiles -am__depfiles_remade = ./$(DEPDIR)/dhcrelay.Po -am__mv = mv -f -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(dhcrelay_SOURCES) -DIST_SOURCES = $(dhcrelay_SOURCES) -RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ - ctags-recursive dvi-recursive html-recursive info-recursive \ - install-data-recursive install-dvi-recursive \ - install-exec-recursive install-html-recursive \ - install-info-recursive install-pdf-recursive \ - install-ps-recursive install-recursive installcheck-recursive \ - installdirs-recursive pdf-recursive ps-recursive \ - tags-recursive uninstall-recursive -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; -am__vpath_adj = case $$p in \ - $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ - *) f=$$p;; \ - esac; -am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; -am__install_max = 40 -am__nobase_strip_setup = \ - srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` -am__nobase_strip = \ - for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" -am__nobase_list = $(am__nobase_strip_setup); \ - for p in $$list; do echo "$$p $$p"; done | \ - sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ - $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ - if (++n[$$2] == $(am__install_max)) \ - { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ - END { for (dir in files) print dir, files[dir] }' -am__base_list = \ - sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ - sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -am__uninstall_files_from_dir = { \ - test -z "$$files" \ - || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ - || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ - $(am__cd) "$$dir" && rm -f $$files; }; \ - } -man8dir = $(mandir)/man8 -NROFF = nroff -MANS = $(man_MANS) -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -am__recursive_targets = \ - $(RECURSIVE_TARGETS) \ - $(RECURSIVE_CLEAN_TARGETS) \ - $(am__extra_recursive_targets) -AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - distdir distdir-am -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -DIST_SUBDIRS = $(SUBDIRS) -am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -am__relativize = \ - dir0=`pwd`; \ - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ - sed_rest='s,^[^/]*/*,,'; \ - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ - sed_butlast='s,/*[^/]*$$,,'; \ - while test -n "$$dir1"; do \ - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ - if test "$$first" != "."; then \ - if test "$$first" = ".."; then \ - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ - else \ - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ - if test "$$first2" = "$$first"; then \ - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ - else \ - dir2="../$$dir2"; \ - fi; \ - dir0="$$dir0"/"$$first"; \ - fi; \ - fi; \ - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ - done; \ - reldir="$$dir2" -A = @A@ -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AR = @AR@ -ATF_BIN = @ATF_BIN@ -ATF_CFLAGS = @ATF_CFLAGS@ -ATF_LDFLAGS = @ATF_LDFLAGS@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BINDCONFIG = @BINDCONFIG@ -BINDDIR = @BINDDIR@ -BINDIOMUX = @BINDIOMUX@ -BINDLIBDNSDIR = @BINDLIBDNSDIR@ -BINDLIBIRSDIR = @BINDLIBIRSDIR@ -BINDLIBISCCFGDIR = @BINDLIBISCCFGDIR@ -BINDLIBISCDIR = @BINDLIBISCDIR@ -BINDLT = @BINDLT@ -BINDSRCDIR = @BINDSRCDIR@ -BINDSUBDIR = @BINDSUBDIR@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CSCOPE = @CSCOPE@ -CTAGS = @CTAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHLIBS = @DHLIBS@ -DISTCHECK_ATF_CONFIGURE_FLAG = @DISTCHECK_ATF_CONFIGURE_FLAG@ -DISTCHECK_LIBBIND_CONFIGURE_FLAG = @DISTCHECK_LIBBIND_CONFIGURE_FLAG@ -DISTCHECK_LIBTOOL_CONFIGURE_FLAG = @DISTCHECK_LIBTOOL_CONFIGURE_FLAG@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -ETAGS = @ETAGS@ -EXEEXT = @EXEEXT@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LDAP_CFLAGS = @LDAP_CFLAGS@ -LDAP_LIBS = @LDAP_LIBS@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LTLIBOBJS = @LTLIBOBJS@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MKDIR_P = @MKDIR_P@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -Q = @Q@ -RANLIB = @RANLIB@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -UNITTESTS = @UNITTESTS@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_CC = @ac_ct_CC@ -ac_prefix_program = @ac_prefix_program@ -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@ -builddir = @builddir@ -byte_order = @byte_order@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -pkgcfg_found = @pkgcfg_found@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -SUBDIRS = . tests -AM_CPPFLAGS = -DLOCALSTATEDIR='"@localstatedir@"' -dhcrelay_SOURCES = dhcrelay.c -dhcrelay_LDADD = ../common/libdhcp.@A@ ../omapip/libomapi.@A@ \ - @BINDLIBIRSDIR@/libirs.@A@ \ - @BINDLIBDNSDIR@/libdns.@A@ \ - @BINDLIBISCCFGDIR@/libisccfg.@A@ \ - @BINDLIBISCDIR@/libisc.@A@ - -man_MANS = dhcrelay.8 -EXTRA_DIST = $(man_MANS) -all: all-recursive - -.SUFFIXES: -.SUFFIXES: .c .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 ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign relay/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --foreign relay/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__maybe_remake_depfiles)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ - 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 -$(am__aclocal_m4_deps): -install-sbinPROGRAMS: $(sbin_PROGRAMS) - @$(NORMAL_INSTALL) - @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \ - if test -n "$$list"; then \ - echo " $(MKDIR_P) '$(DESTDIR)$(sbindir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(sbindir)" || exit 1; \ - fi; \ - for p in $$list; do echo "$$p $$p"; done | \ - sed 's/$(EXEEXT)$$//' | \ - while read p p1; do if test -f $$p \ - ; then echo "$$p"; echo "$$p"; else :; fi; \ - done | \ - sed -e 'p;s,.*/,,;n;h' \ - -e 's|.*|.|' \ - -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ - sed 'N;N;N;s,\n, ,g' | \ - $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ - { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ - if ($$2 == $$4) files[d] = files[d] " " $$1; \ - else { print "f", $$3 "/" $$4, $$1; } } \ - END { for (d in files) print "f", d, files[d] }' | \ - while read type dir files; do \ - if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ - test -z "$$files" || { \ - echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(sbindir)$$dir'"; \ - $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(sbindir)$$dir" || exit $$?; \ - } \ - ; done - -uninstall-sbinPROGRAMS: - @$(NORMAL_UNINSTALL) - @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \ - files=`for p in $$list; do echo "$$p"; done | \ - sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ - -e 's/$$/$(EXEEXT)/' \ - `; \ - test -n "$$list" || exit 0; \ - echo " ( cd '$(DESTDIR)$(sbindir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(sbindir)" && rm -f $$files - -clean-sbinPROGRAMS: - -test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS) - -dhcrelay$(EXEEXT): $(dhcrelay_OBJECTS) $(dhcrelay_DEPENDENCIES) $(EXTRA_dhcrelay_DEPENDENCIES) - @rm -f dhcrelay$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(dhcrelay_OBJECTS) $(dhcrelay_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dhcrelay.Po@am__quote@ # am--include-marker - -$(am__depfiles_remade): - @$(MKDIR_P) $(@D) - @echo '# dummy' >$@-t && $(am__mv) $@-t $@ - -am--depfiles: $(am__depfiles_remade) - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` -install-man8: $(man_MANS) - @$(NORMAL_INSTALL) - @list1=''; \ - list2='$(man_MANS)'; \ - test -n "$(man8dir)" \ - && test -n "`echo $$list1$$list2`" \ - || exit 0; \ - echo " $(MKDIR_P) '$(DESTDIR)$(man8dir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(man8dir)" || exit 1; \ - { for i in $$list1; do echo "$$i"; done; \ - if test -n "$$list2"; then \ - for i in $$list2; do echo "$$i"; done \ - | sed -n '/\.8[a-z]*$$/p'; \ - fi; \ - } | while read p; do \ - if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; echo "$$p"; \ - done | \ - sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \ - -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ - sed 'N;N;s,\n, ,g' | { \ - list=; while read file base inst; do \ - if test "$$base" = "$$inst"; then list="$$list $$file"; else \ - echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man8dir)/$$inst'"; \ - $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man8dir)/$$inst" || exit $$?; \ - fi; \ - done; \ - for i in $$list; do echo "$$i"; done | $(am__base_list) | \ - while read files; do \ - test -z "$$files" || { \ - echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man8dir)'"; \ - $(INSTALL_DATA) $$files "$(DESTDIR)$(man8dir)" || exit $$?; }; \ - done; } - -uninstall-man8: - @$(NORMAL_UNINSTALL) - @list=''; test -n "$(man8dir)" || exit 0; \ - files=`{ for i in $$list; do echo "$$i"; done; \ - l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ - sed -n '/\.8[a-z]*$$/p'; \ - } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \ - -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ - dir='$(DESTDIR)$(man8dir)'; $(am__uninstall_files_from_dir) - -# This directory's subdirectories are mostly independent; you can cd -# into them and run 'make' without going through this Makefile. -# To change the values of 'make' variables: instead of editing Makefiles, -# (1) if the variable is set in 'config.status', edit 'config.status' -# (which will cause the Makefiles to be regenerated when you run 'make'); -# (2) otherwise, pass the desired values on the 'make' command line. -$(am__recursive_targets): - @fail=; \ - if $(am__make_keepgoing); then \ - failcom='fail=yes'; \ - else \ - failcom='exit 1'; \ - fi; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-recursive -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-recursive - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-recursive - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -distdir: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) distdir-am - -distdir-am: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - $(am__make_dryrun) \ - || test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ - $(am__relativize); \ - new_distdir=$$reldir; \ - dir1=$$subdir; dir2="$(top_distdir)"; \ - $(am__relativize); \ - new_top_distdir=$$reldir; \ - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ - ($(am__cd) $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$new_top_distdir" \ - distdir="$$new_distdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - am__skip_mode_fix=: \ - distdir) \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-recursive -all-am: Makefile $(PROGRAMS) $(MANS) -installdirs: installdirs-recursive -installdirs-am: - for dir in "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man8dir)"; do \ - test -z "$$dir" || $(MKDIR_P) "$$dir"; \ - done -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-recursive - -clean-am: clean-generic clean-sbinPROGRAMS mostlyclean-am - -distclean: distclean-recursive - -rm -f ./$(DEPDIR)/dhcrelay.Po - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -html-am: - -info: info-recursive - -info-am: - -install-data-am: install-man - -install-dvi: install-dvi-recursive - -install-dvi-am: - -install-exec-am: install-sbinPROGRAMS - -install-html: install-html-recursive - -install-html-am: - -install-info: install-info-recursive - -install-info-am: - -install-man: install-man8 - -install-pdf: install-pdf-recursive - -install-pdf-am: - -install-ps: install-ps-recursive - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -f ./$(DEPDIR)/dhcrelay.Po - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-compile mostlyclean-generic - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: uninstall-man uninstall-sbinPROGRAMS - -uninstall-man: uninstall-man8 - -.MAKE: $(am__recursive_targets) install-am install-strip - -.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ - am--depfiles check check-am clean clean-generic \ - clean-sbinPROGRAMS cscopelist-am ctags ctags-am distclean \ - distclean-compile distclean-generic distclean-tags distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am install-dvi install-dvi-am \ - install-exec install-exec-am install-html install-html-am \ - install-info install-info-am install-man install-man8 \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-sbinPROGRAMS install-strip installcheck \ - installcheck-am installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-compile \ - mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ - uninstall-am uninstall-man uninstall-man8 \ - uninstall-sbinPROGRAMS - -.PRECIOUS: Makefile - - -# 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/relay/dhcrelay.8 b/relay/dhcrelay.8 deleted file mode 100644 index 9667e608..00000000 --- a/relay/dhcrelay.8 +++ /dev/null @@ -1,355 +0,0 @@ -.\" dhcrelay.8 -.\" -.\" Copyright (C) 2004-2022 Internet Systems Consortium, Inc. ("ISC") -.\" Copyright (c) 1997-2003 by Internet Software Consortium -.\" -.\" This Source Code Form is subject to the terms of the Mozilla Public -.\" License, v. 2.0. If a copy of the MPL was not distributed with this -.\" file, You can obtain one at http://mozilla.org/MPL/2.0/. -.\" -.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES -.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR -.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -.\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -.\" -.\" Internet Systems Consortium, Inc. -.\" PO Box 360 -.\" Newmarket, NH 03857 USA -.\" <info@isc.org> -.\" https://www.isc.org/ -.\" -.\" This software has been written for Internet Systems Consortium -.\" by Ted Lemon in cooperation with Vixie Enterprises. -.\" -.\" Support and other services are available for ISC products - see -.\" https://www.isc.org for more information or to learn more about ISC. -.\" -.\" $Id: dhcrelay.8,v 1.20 2012/05/14 23:17:43 sar Exp $ -.\" -.TH dhcrelay 8 -.SH NAME -dhcrelay - Dynamic Host Configuration Protocol Relay Agent -.SH SYNOPSIS -.B dhcrelay -[ -.B -4 -] -[ -.B -dqaD -] -[ -.B -p -.I port -| -.B -rp -.I relay-port -] -[ -.B -c -.I count -] -[ -.B -A -.I length -] -[ -.B -pf -.I pid-file -] -[ -.B --no-pid -] -[ -.B -m -.I append -| -.I replace -| -.I forward -| -.I discard -] -[ -.B -i -.I interface0 -[ -.B ... -.B -i -.I interfaceN -] -] -[ -.B -iu -.I interface0 -[ -.B ... -.B -iu -.I interfaceN -] -] -[ -.B -id -.I interface0 -[ -.B ... -.B -id -.I interfaceN -] -] -[ -.B -U -.I interface -] -[ -.B -g -.I ipaddr -] -.I server0 -[ -.I ...serverN -] -.PP -.B dhcrelay -6 -[ -.B -dqI -] -[ -.B -p -.I port -| -.B -rp -.I relay-port -] -[ -.B -c -.I count -] -[ -.B -pf -.I pid-file -] -[ -.B --no-pid -] -[ -.B -s -.I subscriber-id -] -.B -l -.I lower0 -[ -.B ... -.B -l -.I lowerN -] -.B -u -.I upper0 -[ -.B ... -.B -u -.I upperN -] -.SH DESCRIPTION -The Internet Systems Consortium DHCP Relay Agent, dhcrelay, provides a -means for relaying DHCP and BOOTP requests from a subnet to which -no DHCP server is directly connected to one or more DHCP servers on -other subnets. It supports both DHCPv4/BOOTP and DHCPv6 protocols. -.SH OPERATION -.PP -The DHCP Relay Agent listens for DHCPv4 or DHCPv6 queries from clients or -other relay agents on one or more interfaces, passing them along to -``upstream'' servers or relay agents as specified on the command line. -When a reply is received from upstream, it is multicast or unicast back -downstream to the source of the original request. -.SH COMMAND LINE -.PP -\fIProtocol selection options:\fR -.TP --6 -Run dhcrelay as a DHCPv6 relay agent. Incompatible with the \fB-4\fR -option. -.TP --4 -Run dhcrelay as a DHCPv4/BOOTP relay agent. This is the default mode of -operation, so the argument is not necessary, but may be specified for -clarity. Incompatible with \fB-6\fR. -.PP -\fISpecifying DHCPv4/BOOTP servers\fR -.PP -In DHCPv4 mode, a list of one or more server addresses must be specified on -the command line, to which DHCP/BOOTP queries should be relayed. -.PP -\fIOptions available for both DHCPv4 and DHCPv6:\fR -.TP --c \fIcount\fR -Maximum hop count. When forwarding packets, dhcrelay discards packets -which have reached a hop count of COUNT. Default is 10. Maximum is 255. -.TP --d -Force dhcrelay to run as a foreground process. Useful when running -dhcrelay under a debugger, or running out of inittab on System V systems. -.TP --p \fIport\fR -Listen and transmit on port PORT. This is mostly useful for debugging -purposes. Default is port 67 for DHCPv4/BOOTP, or port 547 for DHCPv6. -Incompatible with \fB-rp\fR. -.TP --rp \fIrelay-port\fR -Alternative source port for upstream (i.e toward the server) messages -with DHCPv4 RAI relay-port sub-option or DHCPv6 relay-source-port -option. Relay port support is only available if the code was compiled -with (./configure --enable-relay-port) and requires LPF or BPF link -layer access. -.TP --q -Quiet mode. Prevents dhcrelay6 from printing its network configuration -on startup. -.TP --pf pid-file -Path to alternate pid file. -.TP ---no-pid -Option to disable writing pid files. By default the program -will write a pid file. -.PP -\fIOptions available in DHCPv4 mode only:\fR -.TP --a -Append an agent option field to each request before forwarding it to -the server. Agent option fields in responses sent from servers to -clients will be stripped before forwarding such responses back to the -client. The agent option field will contain two agent options: the Circuit -ID suboption and the Remote ID suboption. Currently, the Circuit ID will -be the printable name of the interface on which the client request was -received. The client supports inclusion of a Remote ID suboption as well, -but this is not used by default. -.TP --A \fIlength\fR -Specify the maximum packet size to send to a DHCPv4/BOOTP server. This -might be done to allow sufficient space for addition of relay agent -options while still fitting into the Ethernet MTU size. -.TP --D -Drop packets from upstream servers if they contain Relay Agent -Information options that indicate they were generated in response to -a query that came via a different relay agent. If this option is not -specified, such packets will be relayed anyway. -.TP --g \fIipaddr\fR -When a package gets sent back to the client, replace the gateway's IP -address (giaddr) with the given \fIipaddr\fR. This can be used as a -workaround for bogus clients like Solaris 11 grub, which use the giaddr -instead of the announced router (3) to setup its default route. -.TP --i \fIifname\fR -Listen for DHCPv4/BOOTP traffic on interface \fIifname\fR. Multiple -interfaces may be specified by using more than one \fB-i\fR option. If -no interfaces are specified on the command line, dhcrelay will identify -all network interfaces, eliminating non-broadcast interfaces if possible, -and attempt to listen on all of them. -.TP --iu \fIifname\fR -Specifies an upstream network interface: an interface from which replies -from servers and other relay agents will be accepted. Multiple interfaces -may be specified by using more than one \fB-iu\fR option. This argument is - intended to be used in conjunction with one or more -i or -id arguments. -.TP --id \fIifname\fR -Specifies a downstream network interface: an interface from which requests -from clients and other relay agents will be accepted. Multiple interfaces -may be specified by using more than one \fB-id\fR option. This argument is -intended to be used in conjunction with one or more -i or -iu arguments. -.TP --m \fIappend\fR|\fIreplace\fR|\fIforward\fR|\fIdiscard\fR -Control the handling of incoming DHCPv4 packets which already contain -relay agent options. If such a packet does not have \fIgiaddr\fR set in -its header, the DHCP standard requires that the packet be discarded. -However, if \fIgiaddr\fR is set, the relay agent may handle the situation -in four ways: It may \fIappend\fR its own set of relay options to the -packet, leaving the supplied option field intact; it may \fIreplace\fR the -existing agent option field; it may \fIforward\fR the packet unchanged; or, -it may \fIdiscard\fR it. -.TP --U \fIifname\fR -Enables the addition of a RFC 3527 compliant link selection suboption for -clients directly connected to the relay. This RFC allows a relay to -specify two different IP addresses: one for the server to use when -communicating with the relay (giaddr) the other for choosing the subnet -for the client (the suboption). This can be useful if the server is -unable to send packets to the relay via the address used for the subnet. - -When enabled, dhcrelay will add an agent option (as per \fB-a\fR above) that -includes the link selection suboption to the forwarded packet. This will only -be done to packets received from clients that are directly connected to the -relay (i.e. giaddr is zero). The address used in the suboption will be that -of the link upon which the inbound packet was received (which would otherwise -be used for giaddr). The value of giaddr will be set to that of interface -\fIifname\fR. - -Only one interface should be marked in this fashion. Currently enabling -this option on an interface causes the relay to process all DHCP traffic -similar to the \fI-i\fR option, in the future we may split the two more -completely. - -This option is off by default. Note that enabling this option automatically -enables the \fB-a\fR option. - -Keep in mind that using options such as \fB-m replace\fR or \fB-m discard\fR -on relays upstream from one using \fB-U\fR can pose problems. The upstream -relay will wipe out the initial agent option containing the link selection -while leaving the re-purposed giaddr value in place, causing packets to go -astray. - -.PP -\fIOptions available in DHCPv6 mode only:\fR -.TP --I -Force use of the DHCPv6 Interface-ID option. This option is -automatically sent when there are two or more downstream interfaces -in use, to disambiguate between them. The \fB-I\fR option causes -dhcrelay to send the option even if there is only one downstream -interface. -.TP --s subscriber-id -Add an option with the specified subscriber-id into the packet. This -feature is for testing rather than production as it will put the same -subscriber-id into the packet for all clients. -.TP --l [\fIaddress%\fR]\fIifname\fR[\fI#index\fR] -Specifies the ``lower'' network interface for DHCPv6 relay mode: the -interface on which queries will be received from clients or from other -relay agents. At least one \fB-l\fR option must be included in the command -line when running in DHCPv6 mode. The interface name \fIifname\fR is a -mandatory parameter. The link address can be specified by \fIaddress%\fR; -if it isn't, dhcrelay will use the first non-link-local address configured -on the interface. The optional \fI#index\fR parameter specifies the -interface index. -.TP --u [\fIaddress%\fR]\fIifname\fR -Specifies the ``upper'' network interface for DHCPv6 relay mode: the -interface to which queries from clients and other relay agents should be -forwarded. At least one \fB-u\fR option must be included in the command -line when running in DHCPv6 mode. The interface name \fIifname\fR is a -mandatory parameter. The destination unicast or multicast address can be -specified by \fIaddress%\fR; if not specified, the relay agent will forward -to the DHCPv6 \fIAll_DHCP_Relay_Agents_and_Servers\fR multicast address. -.PP -It is possible to specify the same interface with different addresses -more than once, and even, when the system supports it, to use the same -interface as both upper and lower interfaces. -.SH SEE ALSO -dhclient(8), dhcpd(8), RFC3315, RFC2132, RFC2131. -.SH BUGS -.PP -Using the same interface on both upper and lower sides may cause -loops, so when running this way, the maximum hop count should be set -to a low value. -.PP -The loopback interface is not (yet) recognized as a valid interface. -.SH AUTHOR -.B dhcrelay(8) -To learn more about Internet Systems Consortium, see -.B https://www.isc.org diff --git a/relay/dhcrelay.c b/relay/dhcrelay.c deleted file mode 100644 index 946ef1b0..00000000 --- a/relay/dhcrelay.c +++ /dev/null @@ -1,2173 +0,0 @@ -/* dhcrelay.c - - DHCP/BOOTP Relay Agent. */ - -/* - * Copyright(c) 2004-2022 by Internet Systems Consortium, Inc.("ISC") - * Copyright(c) 1997-2003 by Internet Software Consortium - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Internet Systems Consortium, Inc. - * PO Box 360 - * Newmarket, NH 03857 USA - * <info@isc.org> - * https://www.isc.org/ - * - */ - -#include "dhcpd.h" -#include <syslog.h> -#include <signal.h> -#include <sys/time.h> -#include <isc/file.h> - -TIME default_lease_time = 43200; /* 12 hours... */ -TIME max_lease_time = 86400; /* 24 hours... */ -struct tree_cache *global_options[256]; - -struct option *requested_opts[2]; - -/* Needed to prevent linking against conflex.c. */ -int lexline; -int lexchar; -char *token_line; -char *tlname; - -const char *path_dhcrelay_pid = _PATH_DHCRELAY_PID; -isc_boolean_t no_dhcrelay_pid = ISC_FALSE; -/* False (default) => we write and use a pid file */ -isc_boolean_t no_pid_file = ISC_FALSE; - -int bogus_agent_drops = 0; /* Packets dropped because agent option - field was specified and we're not relaying - packets that already have an agent option - specified. */ -int bogus_giaddr_drops = 0; /* Packets sent to us to relay back to a - client, but with a bogus giaddr. */ -int client_packets_relayed = 0; /* Packets relayed from client to server. */ -int server_packet_errors = 0; /* Errors sending packets to servers. */ -int server_packets_relayed = 0; /* Packets relayed from server to client. */ -int client_packet_errors = 0; /* Errors sending packets to clients. */ - -int add_agent_options = 0; /* If nonzero, add relay agent options. */ -int add_rfc3527_suboption = 0; /* If nonzero, add RFC3527 link selection sub-option. */ - -int agent_option_errors = 0; /* Number of packets forwarded without - agent options because there was no room. */ -int drop_agent_mismatches = 0; /* If nonzero, drop server replies that - don't have matching circuit-id's. */ -int corrupt_agent_options = 0; /* Number of packets dropped because - relay agent information option was bad. */ -int missing_agent_option = 0; /* Number of packets dropped because no - RAI option matching our ID was found. */ -int bad_circuit_id = 0; /* Circuit ID option in matching RAI option - did not match any known circuit ID. */ -int missing_circuit_id = 0; /* Circuit ID option in matching RAI option - was missing. */ -int max_hop_count = 10; /* Maximum hop count */ - -int no_daemon = 0; -int dfd[2] = { -1, -1 }; - -#ifdef DHCPv6 - /* Force use of DHCPv6 interface-id option. */ -isc_boolean_t use_if_id = ISC_FALSE; -#endif - - /* Maximum size of a packet with agent options added. */ -int dhcp_max_agent_option_packet_length = DHCP_MTU_MIN; - - /* What to do about packets we're asked to relay that - already have a relay option: */ -enum { forward_and_append, /* Forward and append our own relay option. */ - forward_and_replace, /* Forward, but replace theirs with ours. */ - forward_untouched, /* Forward without changes. */ - discard } agent_relay_mode = forward_and_replace; - -extern u_int16_t local_port; -extern u_int16_t remote_port; - -/* Relay agent server list. */ -struct server_list { - struct server_list *next; - struct sockaddr_in to; -} *servers; - -struct interface_info *uplink = NULL; -isc_boolean_t use_fake_gw = ISC_FALSE; -struct in_addr gw = {0}; - -#ifdef DHCPv6 -struct stream_list { - struct stream_list *next; - struct interface_info *ifp; - struct sockaddr_in6 link; - int id; -} *downstreams, *upstreams; - -#ifndef UNIT_TEST -static struct stream_list *parse_downstream(char *); -static struct stream_list *parse_upstream(char *); -static void setup_streams(void); -#endif /* UNIT_TEST */ - -/* - * A pointer to a subscriber id to add to the message we forward. - * This is primarily for testing purposes as we only have one id - * for the entire relay and don't determine one per client which - * would be more useful. - */ -char *dhcrelay_sub_id = NULL; -#endif - -#ifndef UNIT_TEST -static void do_relay4(struct interface_info *, struct dhcp_packet *, - unsigned int, unsigned int, struct iaddr, - struct hardware *); -#endif /* UNIT_TEST */ - -extern int add_relay_agent_options(struct interface_info *, - struct dhcp_packet *, unsigned, - struct in_addr); -extern int find_interface_by_agent_option(struct dhcp_packet *, - struct interface_info **, u_int8_t *, int); - -extern int strip_relay_agent_options(struct interface_info *, - struct interface_info **, - struct dhcp_packet *, unsigned); - -#ifndef UNIT_TEST -static void request_v4_interface(const char* name, int flags); - -static const char copyright[] = -"Copyright 2004-2022 Internet Systems Consortium."; -static const char arr[] = "All rights reserved."; -static const char message[] = -"Internet Systems Consortium DHCP Relay Agent"; -static const char url[] = -"For info, please visit https://www.isc.org/software/dhcp/"; - -char *progname; - -#ifdef DHCPv6 -#ifdef RELAY_PORT -#define DHCRELAY_USAGE \ -"Usage: %s [-4] [-d] [-q] [-a] [-D]\n" \ -" [-A <length>] [-c <hops>]\n" \ -" [-p <port> | -rp <relay-port>]\n" \ -" [-pf <pid-file>] [--no-pid]\n"\ -" [-m append|replace|forward|discard]\n" \ -" [-i interface0 [ ... -i interfaceN]\n" \ -" [-iu interface0 [ ... -iu interfaceN]\n" \ -" [-id interface0 [ ... -id interfaceN]\n" \ -" [-U interface] [-g <ip-address>]\n" \ -" server0 [ ... serverN]\n\n" \ -" %s -6 [-d] [-q] [-I] [-c <hops>]\n" \ -" [-p <port> | -rp <relay-port>]\n" \ -" [-pf <pid-file>] [--no-pid]\n" \ -" [-s <subscriber-id>]\n" \ -" -l lower0 [ ... -l lowerN]\n" \ -" -u upper0 [ ... -u upperN]\n" \ -" lower (client link): [address%%]interface[#index]\n" \ -" upper (server link): [address%%]interface\n\n" \ -" %s {--version|--help|-h}" -#else -#define DHCRELAY_USAGE \ -"Usage: %s [-4] [-d] [-q] [-a] [-D]\n" \ -" [-A <length>] [-c <hops>] [-p <port>]\n" \ -" [-pf <pid-file>] [--no-pid]\n"\ -" [-m append|replace|forward|discard]\n" \ -" [-i interface0 [ ... -i interfaceN]\n" \ -" [-iu interface0 [ ... -iu interfaceN]\n" \ -" [-id interface0 [ ... -id interfaceN]\n" \ -" [-U interface] [-g <ip-address>]\n" \ -" server0 [ ... serverN]\n\n" \ -" %s -6 [-d] [-q] [-I] [-c <hops>] [-p <port>]\n" \ -" [-pf <pid-file>] [--no-pid]\n" \ -" [-s <subscriber-id>]\n" \ -" -l lower0 [ ... -l lowerN]\n" \ -" -u upper0 [ ... -u upperN]\n" \ -" lower (client link): [address%%]interface[#index]\n" \ -" upper (server link): [address%%]interface\n\n" \ -" %s {--version|--help|-h}" -#endif -#else /* !DHCPv6 */ -#ifdef RELAY_PORT -#define DHCRELAY_USAGE \ -"Usage: %s [-d] [-q] [-a] [-D] [-A <length>] [-c <hops>]\n" \ -" [-p <port> | -rp <relay-port>]\n" \ -" [-pf <pid-file>] [--no-pid]\n" \ -" [-m append|replace|forward|discard]\n" \ -" [-i interface0 [ ... -i interfaceN]\n" \ -" [-iu interface0 [ ... -iu interfaceN]\n" \ -" [-id interface0 [ ... -id interfaceN]\n" \ -" [-U interface] [-g <ip-address>]\n" \ -" server0 [ ... serverN]\n\n" \ -" %s {--version|--help|-h}" -#else -#define DHCRELAY_USAGE \ -"Usage: %s [-d] [-q] [-a] [-D] [-A <length>] [-c <hops>] [-p <port>]\n" \ -" [-pf <pid-file>] [--no-pid]\n" \ -" [-m append|replace|forward|discard]\n" \ -" [-i interface0 [ ... -i interfaceN]\n" \ -" [-iu interface0 [ ... -iu interfaceN]\n" \ -" [-id interface0 [ ... -id interfaceN]\n" \ -" [-U interface] [-g <ip-address>]\n" \ -" server0 [ ... serverN]\n\n" \ -" %s {--version|--help|-h}" -#endif -#endif - -/*! - * - * \brief Print the generic usage message - * - * If the user has provided an incorrect command line print out - * the description of the command line. The arguments provide - * a way for the caller to request more specific information about - * the error be printed as well. Mostly this will be that some - * command doesn't include its argument. - * - * \param sfmt - The basic string and format for the specific error - * \param sarg - Generally the offending argument from the command line. - * - * \return Nothing - */ -static const char use_noarg[] = "No argument for command: %s"; -#ifdef RELAY_PORT -static const char use_port_defined[] = "Port already set, %s inappropriate"; -#if !defined (USE_BPF_RECEIVE) && !defined (USE_LPF_RECEIVE) -static const char bpf_sock_support[] = "Only LPF and BPF are supported: %s"; -#endif -#endif -#ifdef DHCPv6 -static const char use_badproto[] = "Protocol already set, %s inappropriate"; -static const char use_v4command[] = "Command not used for DHCPv6: %s"; -static const char use_v6command[] = "Command not used for DHCPv4: %s"; -#endif - -static void -usage(const char *sfmt, const char *sarg) { - log_info("%s %s", message, PACKAGE_VERSION); - log_info(copyright); - log_info(arr); - log_info(url); - - /* If desired print out the specific error message */ -#ifdef PRINT_SPECIFIC_CL_ERRORS - if (sfmt != NULL) - log_error(sfmt, sarg); -#endif - - log_fatal(DHCRELAY_USAGE, -#ifdef DHCPv6 - isc_file_basename(progname), -#endif - isc_file_basename(progname), - isc_file_basename(progname)); -} - -int -main(int argc, char **argv) { - isc_result_t status; - struct servent *ent; - struct server_list *sp = NULL; - char *service_local = NULL, *service_remote = NULL; - u_int16_t port_local = 0, port_remote = 0; - int quiet = 0; - int fd; - int i; -#ifdef RELAY_PORT - int port_defined = 0; -#endif -#ifdef DHCPv6 - struct stream_list *sl = NULL; - int local_family_set = 0; -#endif - -#ifdef OLD_LOG_NAME - progname = "dhcrelay"; -#else - progname = argv[0]; -#endif - - /* Make sure that file descriptors 0(stdin), 1,(stdout), and - 2(stderr) are open. To do this, we assume that when we - open a file the lowest available file descriptor is used. */ - fd = open("/dev/null", O_RDWR); - if (fd == 0) - fd = open("/dev/null", O_RDWR); - if (fd == 1) - fd = open("/dev/null", O_RDWR); - if (fd == 2) - log_perror = 0; /* No sense logging to /dev/null. */ - else if (fd != -1) - close(fd); - - openlog(isc_file_basename(progname), DHCP_LOG_OPTIONS, LOG_DAEMON); - -#if !defined(DEBUG) - setlogmask(LOG_UPTO(LOG_INFO)); -#endif - - /* Parse arguments changing no_daemon */ - for (i = 1; i < argc; i++) { - if (!strcmp(argv[i], "-d")) { - no_daemon = 1; - } else if (!strcmp(argv[i], "--version")) { - log_info("isc-dhcrelay-%s", PACKAGE_VERSION); - exit(0); - } else if (!strcmp(argv[i], "--help") || - !strcmp(argv[i], "-h")) { - log_info(DHCRELAY_USAGE, -#ifdef DHCPv6 - isc_file_basename(progname), -#endif - isc_file_basename(progname), - isc_file_basename(progname)); - exit(0); - } - } - /* When not forbidden prepare to become a daemon */ - if (!no_daemon) { - int pid; - - if (pipe(dfd) == -1) - log_fatal("Can't get pipe: %m"); - if ((pid = fork ()) < 0) - log_fatal("Can't fork daemon: %m"); - if (pid != 0) { - /* Parent: wait for the child to start */ - int n; - - (void) close(dfd[1]); - do { - char buf; - - n = read(dfd[0], &buf, 1); - if (n == 1) - _exit(0); - } while (n == -1 && errno == EINTR); - _exit(1); - } - /* Child */ - (void) close(dfd[0]); - } - - - /* Set up the isc and dns library managers */ - status = dhcp_context_create(DHCP_CONTEXT_PRE_DB, NULL, NULL); - if (status != ISC_R_SUCCESS) - log_fatal("Can't initialize context: %s", - isc_result_totext(status)); - - /* Set up the OMAPI. */ - status = omapi_init(); - if (status != ISC_R_SUCCESS) - log_fatal("Can't initialize OMAPI: %s", - isc_result_totext(status)); - - /* Set up the OMAPI wrappers for the interface object. */ - interface_setup(); - - for (i = 1; i < argc; i++) { - if (!strcmp(argv[i], "-4")) { -#ifdef DHCPv6 - if (local_family_set && (local_family == AF_INET6)) { - usage(use_badproto, "-4"); - } - local_family_set = 1; - local_family = AF_INET; - } else if (!strcmp(argv[i], "-6")) { - if (local_family_set && (local_family == AF_INET)) { - usage(use_badproto, "-6"); - } - local_family_set = 1; - local_family = AF_INET6; -#endif - } else if (!strcmp(argv[i], "-d")) { - /* no_daemon = 1; */ - } else if (!strcmp(argv[i], "-q")) { - quiet = 1; - quiet_interface_discovery = 1; - } else if (!strcmp(argv[i], "-p")) { - if (++i == argc) - usage(use_noarg, argv[i-1]); -#ifdef RELAY_PORT - if (port_defined) - usage(use_port_defined, argv[i-1]); - port_defined = 1; -#endif - local_port = validate_port(argv[i]); - log_debug("binding to user-specified port %d", - ntohs(local_port)); -#ifdef RELAY_PORT - } else if (!strcmp(argv[i], "-rp")) { - if (++i == argc) - usage(use_noarg, argv[i-1]); - if (port_defined) - usage(use_port_defined, argv[i-1]); - port_defined = 1; - relay_port = validate_port(argv[i]); - log_debug("binding to user-specified relay port %d", - ntohs(relay_port)); - add_agent_options = 1; -#endif - } else if (!strcmp(argv[i], "-c")) { - int hcount; - if (++i == argc) - usage(use_noarg, argv[i-1]); - hcount = atoi(argv[i]); - if (hcount <= 255) - max_hop_count= hcount; - else - usage("Bad hop count to -c: %s", argv[i]); - } else if (!strcmp(argv[i], "-i")) { -#ifdef DHCPv6 - if (local_family_set && (local_family == AF_INET6)) { - usage(use_v4command, argv[i]); - } - local_family_set = 1; - local_family = AF_INET; -#endif - if (++i == argc) { - usage(use_noarg, argv[i-1]); - } - - request_v4_interface(argv[i], INTERFACE_STREAMS); - } else if (!strcmp(argv[i], "-iu")) { -#ifdef DHCPv6 - if (local_family_set && (local_family == AF_INET6)) { - usage(use_v4command, argv[i]); - } - local_family_set = 1; - local_family = AF_INET; -#endif - if (++i == argc) { - usage(use_noarg, argv[i-1]); - } - - request_v4_interface(argv[i], INTERFACE_UPSTREAM); - } else if (!strcmp(argv[i], "-id")) { -#ifdef DHCPv6 - if (local_family_set && (local_family == AF_INET6)) { - usage(use_v4command, argv[i]); - } - local_family_set = 1; - local_family = AF_INET; -#endif - if (++i == argc) { - usage(use_noarg, argv[i-1]); - } - - request_v4_interface(argv[i], INTERFACE_DOWNSTREAM); - } else if (!strcmp(argv[i], "-a")) { -#ifdef DHCPv6 - if (local_family_set && (local_family == AF_INET6)) { - usage(use_v4command, argv[i]); - } - local_family_set = 1; - local_family = AF_INET; -#endif - add_agent_options = 1; - } else if (!strcmp(argv[i], "-A")) { -#ifdef DHCPv6 - if (local_family_set && (local_family == AF_INET6)) { - usage(use_v4command, argv[i]); - } - local_family_set = 1; - local_family = AF_INET; -#endif - if (++i == argc) - usage(use_noarg, argv[i-1]); - - dhcp_max_agent_option_packet_length = atoi(argv[i]); - - if (dhcp_max_agent_option_packet_length > DHCP_MTU_MAX) - log_fatal("%s: packet length exceeds " - "longest possible MTU\n", - argv[i]); - } else if (!strcmp(argv[i], "-m")) { -#ifdef DHCPv6 - if (local_family_set && (local_family == AF_INET6)) { - usage(use_v4command, argv[i]); - } - local_family_set = 1; - local_family = AF_INET; -#endif - if (++i == argc) - usage(use_noarg, argv[i-1]); - if (!strcasecmp(argv[i], "append")) { - agent_relay_mode = forward_and_append; - } else if (!strcasecmp(argv[i], "replace")) { - agent_relay_mode = forward_and_replace; - } else if (!strcasecmp(argv[i], "forward")) { - agent_relay_mode = forward_untouched; - } else if (!strcasecmp(argv[i], "discard")) { - agent_relay_mode = discard; - } else - usage("Unknown argument to -m: %s", argv[i]); - } else if (!strcmp(argv [i], "-U")) { - if (++i == argc) - usage(use_noarg, argv[i-1]); - - if (uplink) { - usage("more than one uplink (-U) specified: %s" - ,argv[i]); - } - - /* Allocate the uplink interface */ - status = interface_allocate(&uplink, MDL); - if (status != ISC_R_SUCCESS) { - log_fatal("%s: uplink interface_allocate: %s", - argv[i], isc_result_totext(status)); - } - - if (strlen(argv[i]) >= sizeof(uplink->name)) { - log_fatal("%s: uplink name too long," - " it cannot exceed: %ld characters", - argv[i], (long)(sizeof(uplink->name) - 1)); - } - - uplink->name[sizeof(uplink->name) - 1] = 0x00; - strncpy(uplink->name, argv[i], - sizeof(uplink->name) - 1); - interface_snorf(uplink, (INTERFACE_REQUESTED | - INTERFACE_STREAMS)); - - /* Turn on -a, in case they don't do so explicitly */ - add_agent_options = 1; - add_rfc3527_suboption = 1; - } else if (!strcmp(argv[i], "-g")) { - if (++i == argc) - usage(use_noarg, argv[i-1]); -#ifdef DHCPv6 - if (local_family_set && (local_family == AF_INET6)) { - usage(use_v4command, argv[i]); - } - local_family_set = 1; - local_family = AF_INET; -#endif - if (inet_pton(AF_INET, argv[i], &gw) <= 0) { - usage("Invalid gateway address '%s'", argv[i]); - } else { - use_fake_gw = ISC_TRUE; - } - } else if (!strcmp(argv[i], "-D")) { -#ifdef DHCPv6 - if (local_family_set && (local_family == AF_INET6)) { - usage(use_v4command, argv[i]); - } - local_family_set = 1; - local_family = AF_INET; -#endif - drop_agent_mismatches = 1; -#ifdef DHCPv6 - } else if (!strcmp(argv[i], "-I")) { - if (local_family_set && (local_family == AF_INET)) { - usage(use_v6command, argv[i]); - } - local_family_set = 1; - local_family = AF_INET6; - use_if_id = ISC_TRUE; - } else if (!strcmp(argv[i], "-l")) { - if (local_family_set && (local_family == AF_INET)) { - usage(use_v6command, argv[i]); - } - local_family_set = 1; - local_family = AF_INET6; - if (downstreams != NULL) - use_if_id = ISC_TRUE; - if (++i == argc) - usage(use_noarg, argv[i-1]); - sl = parse_downstream(argv[i]); - sl->next = downstreams; - downstreams = sl; - } else if (!strcmp(argv[i], "-u")) { - if (local_family_set && (local_family == AF_INET)) { - usage(use_v6command, argv[i]); - } - local_family_set = 1; - local_family = AF_INET6; - if (++i == argc) - usage(use_noarg, argv[i-1]); - sl = parse_upstream(argv[i]); - sl->next = upstreams; - upstreams = sl; - } else if (!strcmp(argv[i], "-s")) { - if (local_family_set && (local_family == AF_INET)) { - usage(use_v6command, argv[i]); - } - local_family_set = 1; - local_family = AF_INET6; - if (++i == argc) - usage(use_noarg, argv[i-1]); - dhcrelay_sub_id = argv[i]; -#endif - } else if (!strcmp(argv[i], "-pf")) { - if (++i == argc) - usage(use_noarg, argv[i-1]); - path_dhcrelay_pid = argv[i]; - no_dhcrelay_pid = ISC_TRUE; - } else if (!strcmp(argv[i], "--no-pid")) { - no_pid_file = ISC_TRUE; - } else if (argv[i][0] == '-') { - usage("Unknown command: %s", argv[i]); - } else { - struct hostent *he; - struct in_addr ia, *iap = NULL; - -#ifdef DHCPv6 - if (local_family_set && (local_family == AF_INET6)) { - usage(use_v4command, argv[i]); - } - local_family_set = 1; - local_family = AF_INET; -#endif - if (inet_aton(argv[i], &ia)) { - iap = &ia; - } else { - he = gethostbyname(argv[i]); - if (!he) { - log_error("%s: host unknown", argv[i]); - } else { - iap = ((struct in_addr *) - he->h_addr_list[0]); - } - } - - if (iap) { - sp = ((struct server_list *) - dmalloc(sizeof *sp, MDL)); - if (!sp) - log_fatal("no memory for server.\n"); - sp->next = servers; - servers = sp; - memcpy(&sp->to.sin_addr, iap, sizeof *iap); - } - } - } - -#if defined(RELAY_PORT) && \ - !defined (USE_BPF_RECEIVE) && !defined (USE_LPF_RECEIVE) - if (relay_port && (local_family == AF_INET)) - usage(bpf_sock_support, "-rp"); -#endif - - /* - * If the user didn't specify a pid file directly - * find one from environment variables or defaults - */ - if (no_dhcrelay_pid == ISC_FALSE) { - if (local_family == AF_INET) { - path_dhcrelay_pid = getenv("PATH_DHCRELAY_PID"); - if (path_dhcrelay_pid == NULL) - path_dhcrelay_pid = _PATH_DHCRELAY_PID; - } -#ifdef DHCPv6 - else { - path_dhcrelay_pid = getenv("PATH_DHCRELAY6_PID"); - if (path_dhcrelay_pid == NULL) - path_dhcrelay_pid = _PATH_DHCRELAY6_PID; - } -#endif - } - - if (!quiet) { - log_info("%s %s", message, PACKAGE_VERSION); - log_info(copyright); - log_info(arr); - log_info(url); - } else - log_perror = 0; - - /* Set default port */ - if (local_family == AF_INET) { - service_local = "bootps"; - service_remote = "bootpc"; - port_local = htons(67); - port_remote = htons(68); - } -#ifdef DHCPv6 - else { - service_local = "dhcpv6-server"; - service_remote = "dhcpv6-client"; - port_local = htons(547); - port_remote = htons(546); - } -#endif - - if (!local_port) { - ent = getservbyname(service_local, "udp"); - if (ent) - local_port = ent->s_port; - else - local_port = port_local; - - ent = getservbyname(service_remote, "udp"); - if (ent) - remote_port = ent->s_port; - else - remote_port = port_remote; - - endservent(); - } - - if (local_family == AF_INET) { - /* We need at least one server */ - if (servers == NULL) { - log_fatal("No servers specified."); - } - - - /* Set up the server sockaddrs. */ - for (sp = servers; sp; sp = sp->next) { - sp->to.sin_port = local_port; - sp->to.sin_family = AF_INET; -#ifdef HAVE_SA_LEN - sp->to.sin_len = sizeof sp->to; -#endif - } - } -#ifdef DHCPv6 - else { - unsigned code; - - /* We need at least one upstream and one downstream interface */ - if (upstreams == NULL || downstreams == NULL) { - log_info("Must specify at least one lower " - "and one upper interface.\n"); - usage(NULL, NULL); - } - - /* Set up the initial dhcp option universe. */ - initialize_common_option_spaces(); - - /* Check requested options. */ - code = D6O_RELAY_MSG; - if (!option_code_hash_lookup(&requested_opts[0], - dhcpv6_universe.code_hash, - &code, 0, MDL)) - log_fatal("Unable to find the RELAY_MSG " - "option definition."); - code = D6O_INTERFACE_ID; - if (!option_code_hash_lookup(&requested_opts[1], - dhcpv6_universe.code_hash, - &code, 0, MDL)) - log_fatal("Unable to find the INTERFACE_ID " - "option definition."); - } -#endif - - /* Get the current time... */ - gettimeofday(&cur_tv, NULL); - - /* Discover all the network interfaces. */ - discover_interfaces(DISCOVER_RELAY); - -#ifdef DHCPv6 - if (local_family == AF_INET6) - setup_streams(); -#endif - - /* Become a daemon... */ - if (!no_daemon) { - char buf = 0; - FILE *pf; - int pfdesc; - - log_perror = 0; - - /* Signal parent we started successfully. */ - if (dfd[0] != -1 && dfd[1] != -1) { - if (write(dfd[1], &buf, 1) != 1) - log_fatal("write to parent: %m"); - (void) close(dfd[1]); - dfd[0] = dfd[1] = -1; - } - - /* Create the pid file. */ - if (no_pid_file == ISC_FALSE) { - pfdesc = open(path_dhcrelay_pid, - O_CREAT | O_TRUNC | O_WRONLY, 0644); - - if (pfdesc < 0) { - log_error("Can't create %s: %m", - path_dhcrelay_pid); - } else { - pf = fdopen(pfdesc, "w"); - if (!pf) - log_error("Can't fdopen %s: %m", - path_dhcrelay_pid); - else { - fprintf(pf, "%ld\n",(long)getpid()); - fclose(pf); - } - } - } - - (void) close(0); - (void) close(1); - (void) close(2); - (void) setsid(); - - IGNORE_RET (chdir("/")); - } - - /* Set up the packet handler... */ - if (local_family == AF_INET) - bootp_packet_handler = do_relay4; -#ifdef DHCPv6 - else - dhcpv6_packet_handler = do_packet6; -#endif - -#if defined(ENABLE_GENTLE_SHUTDOWN) - /* no signal handlers until we deal with the side effects */ - /* install signal handlers */ - signal(SIGINT, dhcp_signal_handler); /* control-c */ - signal(SIGTERM, dhcp_signal_handler); /* kill */ -#endif - - /* Start dispatching packets and timeouts... */ - dispatch(); - - /* In fact dispatch() never returns. */ - return (0); -} - -static void -do_relay4(struct interface_info *ip, struct dhcp_packet *packet, - unsigned int length, unsigned int from_port, struct iaddr from, - struct hardware *hfrom) { - struct server_list *sp; - struct sockaddr_in to; - struct interface_info *out; - struct hardware hto, *htop; - - if (packet->hlen > sizeof packet->chaddr) { - log_info("Discarding packet with invalid hlen, received on " - "%s interface.", ip->name); - return; - } - if (ip->address_count < 1 || ip->addresses == NULL) { - log_info("Discarding packet received on %s interface that " - "has no IPv4 address assigned.", ip->name); - return; - } - - /* Find the interface that corresponds to the giaddr - in the packet. */ - if (packet->giaddr.s_addr) { - for (out = interfaces; out; out = out->next) { - int i; - - for (i = 0 ; i < out->address_count ; i++ ) { - if (out->addresses[i].s_addr == - packet->giaddr.s_addr) { - i = -1; - break; - } - } - - if (i == -1) - break; - } - } else { - out = NULL; - } - - /* If it's a bootreply, forward it to the client. */ - if (packet->op == BOOTREPLY) { - if (!(ip->flags & INTERFACE_UPSTREAM)) { - log_debug("Dropping reply received on %s", ip->name); - return; - } - - log_debug("BOOTREPLY giaddr: %s\n", inet_ntoa(packet->giaddr)); - if (!(packet->flags & htons(BOOTP_BROADCAST)) && - can_unicast_without_arp(out)) { - to.sin_addr = packet->yiaddr; - to.sin_port = remote_port; - - /* and hardware address is not broadcast */ - htop = &hto; - } else { - to.sin_addr.s_addr = htonl(INADDR_BROADCAST); - to.sin_port = remote_port; - - /* hardware address is broadcast */ - htop = NULL; - } - to.sin_family = AF_INET; -#ifdef HAVE_SA_LEN - to.sin_len = sizeof to; -#endif - - memcpy(&hto.hbuf[1], packet->chaddr, packet->hlen); - hto.hbuf[0] = packet->htype; - hto.hlen = packet->hlen + 1; - - /* Wipe out the agent relay options and, if possible, figure - out which interface to use based on the contents of the - option that we put on the request to which the server is - replying. */ - if (!(length = - strip_relay_agent_options(ip, &out, packet, length))) - return; - - if (!out) { - log_error("Packet to bogus giaddr %s.\n", - inet_ntoa(packet->giaddr)); - ++bogus_giaddr_drops; - return; - } - - if (use_fake_gw) { - packet->giaddr = gw; - } - - if (send_packet(out, NULL, packet, length, out->addresses[0], - &to, htop) < 0) { - ++server_packet_errors; - } else { - log_debug("Forwarded BOOTREPLY for %s to %s", - print_hw_addr(packet->htype, packet->hlen, - packet->chaddr), - inet_ntoa(to.sin_addr)); - - ++server_packets_relayed; - } - return; - } - - /* If giaddr matches one of our addresses, ignore the packet - - we just sent it. */ - if (out) - return; - - if (!(ip->flags & INTERFACE_DOWNSTREAM)) { - log_debug("Dropping request received on %s", ip->name); - return; - } - - /* Add relay agent options if indicated. If something goes wrong, - * drop the packet. Note this may set packet->giaddr if RFC3527 - * is enabled. */ - if (!(length = add_relay_agent_options(ip, packet, length, - ip->addresses[0]))) - return; - - /* If giaddr is not already set, Set it so the server can - figure out what net it's from and so that we can later - forward the response to the correct net. If it's already - set, the response will be sent directly to the relay agent - that set giaddr, so we won't see it. */ - if (!packet->giaddr.s_addr) - packet->giaddr = ip->addresses[0]; - if (packet->hops < max_hop_count) - packet->hops = packet->hops + 1; - else - return; - - /* Otherwise, it's a BOOTREQUEST, so forward it to all the - servers. */ - for (sp = servers; sp; sp = sp->next) { - if (send_packet((fallback_interface - ? fallback_interface : interfaces), - NULL, packet, length, ip->addresses[0], - &sp->to, NULL) < 0) { - ++client_packet_errors; - } else { - log_debug("Forwarded BOOTREQUEST for %s to %s", - print_hw_addr(packet->htype, packet->hlen, - packet->chaddr), - inet_ntoa(sp->to.sin_addr)); - ++client_packets_relayed; - } - } - -} - -#endif /* UNIT_TEST */ - -/* Strip any Relay Agent Information options from the DHCP packet - option buffer. If there is a circuit ID suboption, look up the - outgoing interface based upon it. */ - -int -strip_relay_agent_options(struct interface_info *in, - struct interface_info **out, - struct dhcp_packet *packet, - unsigned length) { - int is_dhcp = 0; - u_int8_t *op, *nextop, *sp, *max; - int good_agent_option = 0; - int status; - - /* If we're not adding agent options to packets, we're not taking - them out either. */ - if (!add_agent_options) - return (length); - - /* If there's no cookie, it's a bootp packet, so we should just - forward it unchanged. */ - if (memcmp(packet->options, DHCP_OPTIONS_COOKIE, 4)) - return (length); - - max = ((u_int8_t *)packet) + length; - sp = op = &packet->options[4]; - - while (op < max) { - switch(*op) { - /* Skip padding... */ - case DHO_PAD: - if (sp != op) - *sp = *op; - ++op; - ++sp; - continue; - - /* If we see a message type, it's a DHCP packet. */ - case DHO_DHCP_MESSAGE_TYPE: - is_dhcp = 1; - goto skip; - break; - - /* Quit immediately if we hit an End option. */ - case DHO_END: - if (sp != op) - *sp++ = *op++; - goto out; - - case DHO_DHCP_AGENT_OPTIONS: - /* We shouldn't see a relay agent option in a - packet before we've seen the DHCP packet type, - but if we do, we have to leave it alone. */ - if (!is_dhcp) - goto skip; - - /* Do not process an agent option if it exceeds the - * buffer. Fail this packet. - */ - nextop = op + op[1] + 2; - if (nextop > max) - return (0); - - status = find_interface_by_agent_option(packet, - out, op + 2, - op[1]); - if (status == -1 && drop_agent_mismatches) - return (0); - if (status) - good_agent_option = 1; - op = nextop; - break; - - skip: - /* Skip over other options. */ - default: - /* Fail if processing this option will exceed the - * buffer(op[1] is malformed). - */ - nextop = op + op[1] + 2; - if (nextop > max) - return (0); - - if (sp != op) { - size_t mlen = op[1] + 2; - memmove(sp, op, mlen); - sp += mlen; - if (sp > max) { - return (0); - } - - op = nextop; - } else - op = sp = nextop; - - break; - } - } - out: - - /* If it's not a DHCP packet, we're not supposed to touch it. */ - if (!is_dhcp) - return (length); - - /* If none of the agent options we found matched, or if we didn't - find any agent options, count this packet as not having any - matching agent options, and if we're relying on agent options - to determine the outgoing interface, drop the packet. */ - - if (!good_agent_option) { - ++missing_agent_option; - if (drop_agent_mismatches) - return (0); - } - - /* Adjust the length... */ - if (sp != op) { - length = sp -((u_int8_t *)packet); - - /* Make sure the packet isn't short(this is unlikely, - but WTH) */ - if (length < BOOTP_MIN_LEN) { - memset(sp, DHO_PAD, BOOTP_MIN_LEN - length); - length = BOOTP_MIN_LEN; - } - } - return (length); -} - - -/* Find an interface that matches the circuit ID specified in the - Relay Agent Information option. If one is found, store it through - the pointer given; otherwise, leave the existing pointer alone. - - We actually deviate somewhat from the current specification here: - if the option buffer is corrupt, we suggest that the caller not - respond to this packet. If the circuit ID doesn't match any known - interface, we suggest that the caller to drop the packet. Only if - we find a circuit ID that matches an existing interface do we tell - the caller to go ahead and process the packet. */ - -int -find_interface_by_agent_option(struct dhcp_packet *packet, - struct interface_info **out, - u_int8_t *buf, int len) { - int i = 0; - u_int8_t *circuit_id = 0; - unsigned circuit_id_len = 0; - struct interface_info *ip; - - while (i < len) { - /* If the next agent option overflows the end of the - packet, the agent option buffer is corrupt. */ - if (i + 1 == len || - i + buf[i + 1] + 2 > len) { - ++corrupt_agent_options; - return (-1); - } - switch(buf[i]) { - /* Remember where the circuit ID is... */ - case RAI_CIRCUIT_ID: - circuit_id = &buf[i + 2]; - circuit_id_len = buf[i + 1]; - i += circuit_id_len + 2; - continue; - - default: - i += buf[i + 1] + 2; - break; - } - } - - /* If there's no circuit ID, it's not really ours, tell the caller - it's no good. */ - if (!circuit_id) { - ++missing_circuit_id; - return (-1); - } - - /* Scan the interface list looking for an interface whose - name matches the one specified in circuit_id. */ - - for (ip = interfaces; ip; ip = ip->next) { - if (ip->circuit_id && - ip->circuit_id_len == circuit_id_len && - !memcmp(ip->circuit_id, circuit_id, circuit_id_len)) - break; - } - - /* If we got a match, use it. */ - if (ip) { - *out = ip; - return (1); - } - - /* If we didn't get a match, the circuit ID was bogus. */ - ++bad_circuit_id; - return (-1); -} - -/* - * Examine a packet to see if it's a candidate to have a Relay - * Agent Information option tacked onto its tail. If it is, tack - * the option on. - */ -int -add_relay_agent_options(struct interface_info *ip, struct dhcp_packet *packet, - unsigned length, struct in_addr giaddr) { - int is_dhcp = 0, mms; - unsigned optlen; - u_int8_t *op, *nextop, *sp, *max, *end_pad = NULL; - int adding_link_select; - - /* If we're not adding agent options to packets, we can skip - this. */ - if (!add_agent_options) - return (length); - - /* If there's no cookie, it's a bootp packet, so we should just - forward it unchanged. */ - if (memcmp(packet->options, DHCP_OPTIONS_COOKIE, 4)) - return (length); - - max = ((u_int8_t *)packet) + dhcp_max_agent_option_packet_length; - - /* Add link selection suboption if enabled and we're the first relay */ - adding_link_select = (add_rfc3527_suboption - && (packet->giaddr.s_addr == 0)); - - /* Commence processing after the cookie. */ - sp = op = &packet->options[4]; - - while (op < max) { - switch(*op) { - /* Skip padding... */ - case DHO_PAD: - /* Remember the first pad byte so we can commandeer - * padded space. - * - * XXX: Is this really a good idea? Sure, we can - * seemingly reduce the packet while we're looking, - * but if the packet was signed by the client then - * this padding is part of the checksum(RFC3118), - * and its nonpresence would break authentication. - */ - if (end_pad == NULL) - end_pad = sp; - - if (sp != op) - *sp++ = *op++; - else - sp = ++op; - - continue; - - /* If we see a message type, it's a DHCP packet. */ - case DHO_DHCP_MESSAGE_TYPE: - is_dhcp = 1; - goto skip; - - /* - * If there's a maximum message size option, we - * should pay attention to it - */ - case DHO_DHCP_MAX_MESSAGE_SIZE: - mms = ntohs(*(op + 2)); - if (mms < dhcp_max_agent_option_packet_length && - mms >= DHCP_MTU_MIN) - max = ((u_int8_t *)packet) + mms; - goto skip; - - /* Quit immediately if we hit an End option. */ - case DHO_END: - goto out; - - case DHO_DHCP_AGENT_OPTIONS: - /* We shouldn't see a relay agent option in a - packet before we've seen the DHCP packet type, - but if we do, we have to leave it alone. */ - if (!is_dhcp) - goto skip; - - end_pad = NULL; - - /* There's already a Relay Agent Information option - in this packet. How embarrassing. Decide what - to do based on the mode the user specified. */ - - switch(agent_relay_mode) { - case forward_and_append: - goto skip; - case forward_untouched: - return (length); - case discard: - return (0); - case forward_and_replace: - default: - break; - } - - /* Skip over the agent option and start copying - if we aren't copying already. */ - op += op[1] + 2; - break; - - skip: - /* Skip over other options. */ - default: - /* Fail if processing this option will exceed the - * buffer(op[1] is malformed). - */ - nextop = op + op[1] + 2; - if (nextop > max) - return (0); - - end_pad = NULL; - - if (sp != op) { - size_t mlen = op[1] + 2; - memmove(sp, op, mlen); - sp += mlen; - if (sp > max) { - return (0); - } - - op = nextop; - } else - op = sp = nextop; - - break; - } - } - out: - - /* If it's not a DHCP packet, we're not supposed to touch it. */ - if (!is_dhcp) - return (length); - - /* If the packet was padded out, we can store the agent option - at the beginning of the padding. */ - - if (end_pad != NULL) - sp = end_pad; - -#if 0 - /* Remember where the end of the packet was after parsing - it. */ - op = sp; -#endif - - /* Sanity check. Had better not ever happen. */ - if ((ip->circuit_id_len > 255) ||(ip->circuit_id_len < 1)) - log_fatal("Circuit ID length %d out of range [1-255] on " - "%s\n", ip->circuit_id_len, ip->name); - optlen = ip->circuit_id_len + 2; /* RAI_CIRCUIT_ID + len */ - - if (ip->remote_id) { - if (ip->remote_id_len > 255 || ip->remote_id_len < 1) - log_fatal("Remote ID length %d out of range [1-255] " - "on %s\n", ip->remote_id_len, ip->name); - optlen += ip->remote_id_len + 2; /* RAI_REMOTE_ID + len */ - } - - if (adding_link_select) { - optlen += 6; - } - -#ifdef RELAY_PORT - if (relay_port) { - optlen += 2; - } -#endif - - /* We do not support relay option fragmenting(multiple options to - * support an option data exceeding 255 bytes). - */ - if ((optlen < 3) ||(optlen > 255)) - log_fatal("Total agent option length(%u) out of range " - "[3 - 255] on %s\n", optlen, ip->name); - - /* - * Is there room for the option, its code+len, and DHO_END? - * If not, forward without adding the option. - */ - if (max - sp >= optlen + 3) { - log_debug("Adding %d-byte relay agent option", optlen + 3); - - /* Okay, cons up *our* Relay Agent Information option. */ - *sp++ = DHO_DHCP_AGENT_OPTIONS; - *sp++ = optlen; - - /* Copy in the circuit id... */ - *sp++ = RAI_CIRCUIT_ID; - *sp++ = ip->circuit_id_len; - memcpy(sp, ip->circuit_id, ip->circuit_id_len); - sp += ip->circuit_id_len; - - /* Copy in remote ID... */ - if (ip->remote_id) { - *sp++ = RAI_REMOTE_ID; - *sp++ = ip->remote_id_len; - memcpy(sp, ip->remote_id, ip->remote_id_len); - sp += ip->remote_id_len; - } - - /* RFC3527: Use the inbound packet's interface address in - * the link selection suboption and set the outbound giaddr - * to the uplink address. */ - if (adding_link_select) { - *sp++ = RAI_LINK_SELECT; - *sp++ = 4u; - memcpy(sp, &giaddr.s_addr, 4); - sp += 4; - packet->giaddr = uplink->addresses[0]; - log_debug ("Adding link selection suboption" - " with addr: %s", inet_ntoa(giaddr)); - } - -#ifdef RELAY_PORT - /* draft-ietf-dhc-relay-port-10.txt section 5.1 */ - if (relay_port) { - *sp++ = RAI_RELAY_PORT; - *sp++ = 0u; - } -#endif - } else { - ++agent_option_errors; - log_error("No room in packet (used %d of %d) " - "for %d-byte relay agent option: omitted", - (int) (sp - ((u_int8_t *) packet)), - (int) (max - ((u_int8_t *) packet)), - optlen + 3); - } - - /* - * Deposit an END option unless the packet is full (shouldn't - * be possible). - */ - if (sp < max) - *sp++ = DHO_END; - - /* Recalculate total packet length. */ - length = sp -((u_int8_t *)packet); - - /* Make sure the packet isn't short(this is unlikely, but WTH) */ - if (length < BOOTP_MIN_LEN) { - memset(sp, DHO_PAD, BOOTP_MIN_LEN - length); - return (BOOTP_MIN_LEN); - } - - return (length); -} - -#ifdef DHCPv6 -#ifndef UNIT_TEST -/* - * Parse a downstream argument: [address%]interface[#index]. - */ -static struct stream_list * -parse_downstream(char *arg) { - struct stream_list *dp, *up; - struct interface_info *ifp = NULL; - char *ifname, *addr, *iid; - isc_result_t status; - - if (!supports_multiple_interfaces(ifp) && - (downstreams != NULL)) - log_fatal("No support for multiple interfaces."); - - /* Decode the argument. */ - ifname = strchr(arg, '%'); - if (ifname == NULL) { - ifname = arg; - addr = NULL; - } else { - *ifname++ = '\0'; - addr = arg; - } - iid = strchr(ifname, '#'); - if (iid != NULL) { - *iid++ = '\0'; - } - if (strlen(ifname) >= sizeof(ifp->name)) { - usage("Interface name '%s' too long", ifname); - } - - /* Don't declare twice. */ - for (dp = downstreams; dp; dp = dp->next) { - if (strcmp(ifname, dp->ifp->name) == 0) - log_fatal("Down interface '%s' declared twice.", - ifname); - } - - /* Share with up side? */ - for (up = upstreams; up; up = up->next) { - if (strcmp(ifname, up->ifp->name) == 0) { - log_info("parse_downstream: Interface '%s' is " - "both down and up.", ifname); - ifp = up->ifp; - break; - } - } - - /* New interface. */ - if (ifp == NULL) { - status = interface_allocate(&ifp, MDL); - if (status != ISC_R_SUCCESS) - log_fatal("%s: interface_allocate: %s", - arg, isc_result_totext(status)); - strcpy(ifp->name, ifname); - if (interfaces) { - interface_reference(&ifp->next, interfaces, MDL); - interface_dereference(&interfaces, MDL); - } - interface_reference(&interfaces, ifp, MDL); - } - ifp->flags |= INTERFACE_REQUESTED | INTERFACE_DOWNSTREAM; - - /* New downstream. */ - dp = (struct stream_list *) dmalloc(sizeof(*dp), MDL); - if (!dp) - log_fatal("No memory for downstream."); - dp->ifp = ifp; - if (iid != NULL) { - dp->id = atoi(iid); - } else { - dp->id = -1; - } - /* !addr case handled by setup. */ - if (addr && (inet_pton(AF_INET6, addr, &dp->link.sin6_addr) <= 0)) - log_fatal("Bad link address '%s'", addr); - - return dp; -} - -/* - * Parse an upstream argument: [address]%interface. - */ -static struct stream_list * -parse_upstream(char *arg) { - struct stream_list *up, *dp; - struct interface_info *ifp = NULL; - char *ifname, *addr; - isc_result_t status; - - /* Decode the argument. */ - ifname = strchr(arg, '%'); - if (ifname == NULL) { - ifname = arg; - addr = All_DHCP_Servers; - } else { - *ifname++ = '\0'; - addr = arg; - } - if (strlen(ifname) >= sizeof(ifp->name)) { - log_fatal("Interface name '%s' too long", ifname); - } - - /* Shared up interface? */ - for (up = upstreams; up; up = up->next) { - if (strcmp(ifname, up->ifp->name) == 0) { - ifp = up->ifp; - break; - } - } - for (dp = downstreams; dp; dp = dp->next) { - if (strcmp(ifname, dp->ifp->name) == 0) { - log_info("parse_upstream: Interface '%s' is " - "both down and up.", ifname); - ifp = dp->ifp; - break; - } - } - - /* New interface. */ - if (ifp == NULL) { - status = interface_allocate(&ifp, MDL); - if (status != ISC_R_SUCCESS) - log_fatal("%s: interface_allocate: %s", - arg, isc_result_totext(status)); - strcpy(ifp->name, ifname); - if (interfaces) { - interface_reference(&ifp->next, interfaces, MDL); - interface_dereference(&interfaces, MDL); - } - interface_reference(&interfaces, ifp, MDL); - } - ifp->flags |= INTERFACE_REQUESTED | INTERFACE_UPSTREAM; - - /* New upstream. */ - up = (struct stream_list *) dmalloc(sizeof(*up), MDL); - if (up == NULL) - log_fatal("No memory for upstream."); - - up->ifp = ifp; - - if (inet_pton(AF_INET6, addr, &up->link.sin6_addr) <= 0) - log_fatal("Bad address %s", addr); - - return up; -} - -/* - * Setup downstream interfaces. - */ -static void -setup_streams(void) { - struct stream_list *dp, *up; - int i; - isc_boolean_t link_is_set; - - for (dp = downstreams; dp; dp = dp->next) { - /* Check interface */ - if (dp->ifp->v6address_count == 0) - log_fatal("Interface '%s' has no IPv6 addresses.", - dp->ifp->name); - - /* Check/set link. */ - if (IN6_IS_ADDR_UNSPECIFIED(&dp->link.sin6_addr)) - link_is_set = ISC_FALSE; - else - link_is_set = ISC_TRUE; - for (i = 0; i < dp->ifp->v6address_count; i++) { - if (IN6_IS_ADDR_LINKLOCAL(&dp->ifp->v6addresses[i])) - continue; - if (!link_is_set) - break; - if (!memcmp(&dp->ifp->v6addresses[i], - &dp->link.sin6_addr, - sizeof(dp->link.sin6_addr))) - break; - } - if (i == dp->ifp->v6address_count) - log_fatal("Interface %s does not have global IPv6 " - "address assigned.", dp->ifp->name); - if (!link_is_set) - memcpy(&dp->link.sin6_addr, - &dp->ifp->v6addresses[i], - sizeof(dp->link.sin6_addr)); - - /* Set interface-id. */ - if (dp->id == -1) - dp->id = dp->ifp->index; - } - - for (up = upstreams; up; up = up->next) { - up->link.sin6_port = local_port; - up->link.sin6_family = AF_INET6; -#ifdef HAVE_SA_LEN - up->link.sin6_len = sizeof(up->link); -#endif - - if (up->ifp->v6address_count == 0) - log_fatal("Interface '%s' has no IPv6 addresses.", - up->ifp->name); - - /* RFC 3315 Sec 20 - "If the relay agent relays messages to - * the All_DHCP_Servers address or other multicast addresses, - * it sets the Hop Limit field to 32." */ - if (IN6_IS_ADDR_MULTICAST(&up->link.sin6_addr)) { - set_multicast_hop_limit(up->ifp, HOP_COUNT_LIMIT); - } - } -} - -/* - * Add DHCPv6 agent options here. - */ -static const int required_forw_opts[] = { - D6O_INTERFACE_ID, - D6O_SUBSCRIBER_ID, -#if defined(RELAY_PORT) - D6O_RELAY_SOURCE_PORT, -#endif - D6O_RELAY_MSG, - 0 -}; - -/* - * Process a packet upwards, i.e., from client to server. - */ -static void -process_up6(struct packet *packet, struct stream_list *dp) { - char forw_data[65535]; - unsigned cursor; - struct dhcpv6_relay_packet *relay; - struct option_state *opts; - struct stream_list *up; - u_int16_t relay_client_port = 0; - - /* Check if the message should be relayed to the server. */ - switch (packet->dhcpv6_msg_type) { - case DHCPV6_SOLICIT: - case DHCPV6_REQUEST: - case DHCPV6_CONFIRM: - case DHCPV6_RENEW: - case DHCPV6_REBIND: - case DHCPV6_RELEASE: - case DHCPV6_DECLINE: - case DHCPV6_INFORMATION_REQUEST: - case DHCPV6_RELAY_FORW: - case DHCPV6_LEASEQUERY: - case DHCPV6_DHCPV4_QUERY: - log_info("Relaying %s from %s port %d going up.", - dhcpv6_type_names[packet->dhcpv6_msg_type], - piaddr(packet->client_addr), - ntohs(packet->client_port)); - break; - - case DHCPV6_ADVERTISE: - case DHCPV6_REPLY: - case DHCPV6_RECONFIGURE: - case DHCPV6_RELAY_REPL: - case DHCPV6_LEASEQUERY_REPLY: - case DHCPV6_DHCPV4_RESPONSE: - log_info("Discarding %s from %s port %d going up.", - dhcpv6_type_names[packet->dhcpv6_msg_type], - piaddr(packet->client_addr), - ntohs(packet->client_port)); - return; - - default: - log_info("Unknown %d type from %s port %d going up.", - packet->dhcpv6_msg_type, - piaddr(packet->client_addr), - ntohs(packet->client_port)); - return; - } - - /* Build the relay-forward header. */ - relay = (struct dhcpv6_relay_packet *) forw_data; - cursor = offsetof(struct dhcpv6_relay_packet, options); - relay->msg_type = DHCPV6_RELAY_FORW; - if (packet->dhcpv6_msg_type == DHCPV6_RELAY_FORW) { - if (packet->dhcpv6_hop_count >= max_hop_count) { - log_info("Hop count exceeded,"); - return; - } - relay->hop_count = packet->dhcpv6_hop_count + 1; - if (dp) { - memcpy(&relay->link_address, &dp->link.sin6_addr, 16); - } else { - /* On smart relay add: && !global. */ - if (!use_if_id && downstreams->next) { - log_info("Shan't get back the interface."); - return; - } - memset(&relay->link_address, 0, 16); - } - - if (packet->client_port != htons(547)) { - relay_client_port = packet->client_port; - } - } else { - relay->hop_count = 0; - if (!dp) - return; - memcpy(&relay->link_address, &dp->link.sin6_addr, 16); - } - memcpy(&relay->peer_address, packet->client_addr.iabuf, 16); - - /* Get an option state. */ - opts = NULL; - if (!option_state_allocate(&opts, MDL)) { - log_fatal("No memory for upwards options."); - } - - /* Add an interface-id (if used). */ - if (use_if_id) { - int if_id; - - if (dp) { - if_id = dp->id; - } else if (!downstreams->next) { - if_id = downstreams->id; - } else { - log_info("Don't know the interface."); - option_state_dereference(&opts, MDL); - return; - } - - if (!save_option_buffer(&dhcpv6_universe, opts, - NULL, (unsigned char *) &if_id, - sizeof(int), - D6O_INTERFACE_ID, 0)) { - log_error("Can't save interface-id."); - option_state_dereference(&opts, MDL); - return; - } - } - - /* Add a subscriber-id if desired. */ - /* This is for testing rather than general use */ - if (dhcrelay_sub_id != NULL) { - if (!save_option_buffer(&dhcpv6_universe, opts, NULL, - (unsigned char *) dhcrelay_sub_id, - strlen(dhcrelay_sub_id), - D6O_SUBSCRIBER_ID, 0)) { - log_error("Can't save subsriber-id."); - option_state_dereference(&opts, MDL); - return; - } - } - - -#if defined(RELAY_PORT) - /* - * If we use a non-547 UDP source port or if we have received - * from a downstream relay agent uses a non-547 port, we need - * to include the RELAY-SOURCE-PORT option. The "Downstream - * UDP Port" field value in the option allow us to send - * relay-reply message back to the downstream relay agent - * with the correct UDP source port. - */ - if (relay_port || relay_client_port) { - if (!save_option_buffer(&dhcpv6_universe, opts, NULL, - (unsigned char *) &relay_client_port, - sizeof(u_int16_t), - D6O_RELAY_SOURCE_PORT, 0)) { - log_error("Can't save relay-source-port."); - option_state_dereference(&opts, MDL); - return; - } - } -#else - /* Avoid unused but set warning, */ - (void)(relay_client_port); -#endif - - /* Add the relay-msg carrying the packet. */ - if (!save_option_buffer(&dhcpv6_universe, opts, - NULL, (unsigned char *) packet->raw, - packet->packet_length, - D6O_RELAY_MSG, 0)) { - log_error("Can't save relay-msg."); - option_state_dereference(&opts, MDL); - return; - } - - /* Finish the relay-forward message. */ - cursor += store_options6(forw_data + cursor, - sizeof(forw_data) - cursor, - opts, packet, - required_forw_opts, NULL); - option_state_dereference(&opts, MDL); - - /* Send it to all upstreams. */ - for (up = upstreams; up; up = up->next) { - send_packet6(up->ifp, (unsigned char *) forw_data, - (size_t) cursor, &up->link); - } -} - -/* - * Process a packet downwards, i.e., from server to client. - */ -static void -process_down6(struct packet *packet) { - struct stream_list *dp; - struct option_cache *oc; - struct data_string relay_msg; - const struct dhcpv6_packet *msg; - struct data_string if_id; -#if defined(RELAY_PORT) - struct data_string down_port; -#endif - struct sockaddr_in6 to; - struct iaddr peer; - - /* The packet must be a relay-reply message. */ - if (packet->dhcpv6_msg_type != DHCPV6_RELAY_REPL) { - if (packet->dhcpv6_msg_type < dhcpv6_type_name_max) - log_info("Discarding %s from %s port %d going down.", - dhcpv6_type_names[packet->dhcpv6_msg_type], - piaddr(packet->client_addr), - ntohs(packet->client_port)); - else - log_info("Unknown %d type from %s port %d going down.", - packet->dhcpv6_msg_type, - piaddr(packet->client_addr), - ntohs(packet->client_port)); - return; - } - - /* Inits. */ - memset(&relay_msg, 0, sizeof(relay_msg)); - memset(&if_id, 0, sizeof(if_id)); -#if defined(RELAY_PORT) - memset(&down_port, 0, sizeof(down_port)); -#endif - memset(&to, 0, sizeof(to)); - to.sin6_family = AF_INET6; -#ifdef HAVE_SA_LEN - to.sin6_len = sizeof(to); -#endif - to.sin6_port = remote_port; - peer.len = 16; - - /* Get the relay-msg option (carrying the message to relay). */ - oc = lookup_option(&dhcpv6_universe, packet->options, D6O_RELAY_MSG); - if (oc == NULL) { - log_info("No relay-msg."); - return; - } - if (!evaluate_option_cache(&relay_msg, packet, NULL, NULL, - packet->options, NULL, - &global_scope, oc, MDL) || - (relay_msg.len < offsetof(struct dhcpv6_packet, options))) { - log_error("Can't evaluate relay-msg."); - goto cleanup; - } - msg = (const struct dhcpv6_packet *) relay_msg.data; - - /* Get the interface-id (if exists) and the downstream. */ - oc = lookup_option(&dhcpv6_universe, packet->options, - D6O_INTERFACE_ID); - if (oc != NULL) { - int if_index; - - if (!evaluate_option_cache(&if_id, packet, NULL, NULL, - packet->options, NULL, - &global_scope, oc, MDL) || - (if_id.len != sizeof(int))) { - log_info("Can't evaluate interface-id."); - goto cleanup; - } - memcpy(&if_index, if_id.data, sizeof(int)); - for (dp = downstreams; dp; dp = dp->next) { - if (dp->id == if_index) - break; - } - } else { - if (use_if_id) { - /* Require an interface-id. */ - log_info("No interface-id."); - goto cleanup; - } - for (dp = downstreams; dp; dp = dp->next) { - /* Get the first matching one. */ - if (!memcmp(&dp->link.sin6_addr, - &packet->dhcpv6_link_address, - sizeof(struct in6_addr))) - break; - } - } - /* Why bother when there is no choice. */ - if (!dp && downstreams && !downstreams->next) - dp = downstreams; - if (!dp) { - log_info("Can't find the down interface."); - goto cleanup; - } - memcpy(peer.iabuf, &packet->dhcpv6_peer_address, peer.len); - to.sin6_addr = packet->dhcpv6_peer_address; - - /* Check if we should relay the carried message. */ - switch (msg->msg_type) { - /* Relay-Reply of for another relay, not a client. */ - case DHCPV6_RELAY_REPL: - to.sin6_port = local_port; - -#if defined(RELAY_PORT) - oc = lookup_option(&dhcpv6_universe, packet->options, - D6O_RELAY_SOURCE_PORT); - if (oc != NULL) { - u_int16_t down_relay_port; - - memset(&down_port, 0, sizeof(down_port)); - if (!evaluate_option_cache(&down_port, packet, NULL, - NULL, packet->options, NULL, - &global_scope, oc, MDL) || - (down_port.len != sizeof(u_int16_t))) { - log_info("Can't evaluate down " - "relay-source-port."); - goto cleanup; - } - memcpy(&down_relay_port, down_port.data, - sizeof(u_int16_t)); - /* - * If the down_relay_port value is non-zero, - * that means our downstream relay agent uses - * a non-547 UDP source port sending - * relay-forw message to us. We need to use - * the same UDP port sending reply back. - */ - if (down_relay_port) { - to.sin6_port = down_relay_port; - } - } -#endif - - /* Fall into: */ - - case DHCPV6_ADVERTISE: - case DHCPV6_REPLY: - case DHCPV6_RECONFIGURE: - case DHCPV6_RELAY_FORW: - case DHCPV6_LEASEQUERY_REPLY: - case DHCPV6_DHCPV4_RESPONSE: - log_info("Relaying %s to %s port %d down.", - dhcpv6_type_names[msg->msg_type], - piaddr(peer), - ntohs(to.sin6_port)); - break; - - case DHCPV6_SOLICIT: - case DHCPV6_REQUEST: - case DHCPV6_CONFIRM: - case DHCPV6_RENEW: - case DHCPV6_REBIND: - case DHCPV6_RELEASE: - case DHCPV6_DECLINE: - case DHCPV6_INFORMATION_REQUEST: - case DHCPV6_LEASEQUERY: - case DHCPV6_DHCPV4_QUERY: - log_info("Discarding %s to %s port %d down.", - dhcpv6_type_names[msg->msg_type], - piaddr(peer), - ntohs(to.sin6_port)); - goto cleanup; - - default: - log_info("Unknown %d type to %s port %d down.", - msg->msg_type, - piaddr(peer), - ntohs(to.sin6_port)); - goto cleanup; - } - - /* Send the message to the downstream. */ - send_packet6(dp->ifp, (unsigned char *) relay_msg.data, - (size_t) relay_msg.len, &to); - - cleanup: - if (relay_msg.data != NULL) - data_string_forget(&relay_msg, MDL); - if (if_id.data != NULL) - data_string_forget(&if_id, MDL); -} -#endif /* UNIT_TEST */ - -/* - * Called by the dispatch packet handler with a decoded packet. - */ -void -dhcpv6(struct packet *packet) { -#ifndef UNIT_TEST - struct stream_list *dp; - - /* Try all relay-replies downwards. */ - if (packet->dhcpv6_msg_type == DHCPV6_RELAY_REPL) { - process_down6(packet); - return; - } - /* Others are candidates to go up if they come from down. */ - for (dp = downstreams; dp; dp = dp->next) { - if (packet->interface != dp->ifp) - continue; - process_up6(packet, dp); - return; - } - /* Relay-forward could work from an unknown interface. */ - if (packet->dhcpv6_msg_type == DHCPV6_RELAY_FORW) { - process_up6(packet, NULL); - return; - } - - log_info("Can't process packet from interface '%s'.", - packet->interface->name); -#endif /* UNIT_TEST */ -} -#endif /* DHCPv6 */ - -/* Stub routines needed for linking with DHCP libraries. */ -void -bootp(struct packet *packet) { - return; -} - -void -dhcp(struct packet *packet) { - return; -} - -#if defined(DHCPv6) && defined(DHCP4o6) -isc_result_t dhcpv4o6_handler(omapi_object_t *h) -{ - return ISC_R_NOTIMPLEMENTED; -} -#endif - -void -classify(struct packet *p, struct class *c) { - return; -} - -int -check_collection(struct packet *p, struct lease *l, struct collection *c) { - return 0; -} - -isc_result_t -find_class(struct class **class, const char *c1, const char *c2, int i) { - return ISC_R_NOTFOUND; -} - -int -parse_allow_deny(struct option_cache **oc, struct parse *p, int i) { - return 0; -} - -isc_result_t -dhcp_set_control_state(control_object_state_t oldstate, - control_object_state_t newstate) { - char buf = 0; - - if (newstate != server_shutdown) - return ISC_R_SUCCESS; - - /* Log shutdown on signal. */ - log_info("Received signal %d, initiating shutdown.", shutdown_signal); - - if (no_pid_file == ISC_FALSE) - (void) unlink(path_dhcrelay_pid); - - if (!no_daemon && dfd[0] != -1 && dfd[1] != -1) { - IGNORE_RET(write(dfd[1], &buf, 1)); - (void) close(dfd[1]); - dfd[0] = dfd[1] = -1; - } - exit(0); -} - -/*! - * - * \brief Allocate an interface as requested with a given set of flags - * - * The requested interface is allocated, its flags field is set to - * INTERFACE_REQUESTED OR'd with the given flags, and then added to - * the list of interfaces. - * - * \param name - name of the requested interface - * \param flags - additional flags for the interface - * - * \return Nothing - */ -void request_v4_interface(const char* name, int flags) { - struct interface_info *tmp = NULL; - int len = strlen(name); - isc_result_t status; - - if (len >= sizeof(tmp->name)) { - log_fatal("%s: interface name too long (is %d)", name, len); - } - - status = interface_allocate(&tmp, MDL); - if (status != ISC_R_SUCCESS) { - log_fatal("%s: interface_allocate: %s", name, - isc_result_totext(status)); - } - - log_debug("Requesting: %s as upstream: %c downstream: %c", name, - (flags & INTERFACE_UPSTREAM ? 'Y' : 'N'), - (flags & INTERFACE_DOWNSTREAM ? 'Y' : 'N')); - - memcpy(tmp->name, name, len); - interface_snorf(tmp, (INTERFACE_REQUESTED | flags)); - interface_dereference(&tmp, MDL); -} diff --git a/relay/tests/Atffile b/relay/tests/Atffile deleted file mode 100644 index c854582c..00000000 --- a/relay/tests/Atffile +++ /dev/null @@ -1,5 +0,0 @@ -Content-Type: application/X-atf-atffile; version="1" - -prop: test-suite = dhcrelay - -tp-glob: *_unittests diff --git a/relay/tests/Kyuafile b/relay/tests/Kyuafile deleted file mode 100644 index f0aa5b3b..00000000 --- a/relay/tests/Kyuafile +++ /dev/null @@ -1,4 +0,0 @@ -syntax(2) -test_suite('dhcrelay') - -atf_test_program{name='relay_unittests'} diff --git a/relay/tests/Makefile.am b/relay/tests/Makefile.am deleted file mode 100644 index fce3115a..00000000 --- a/relay/tests/Makefile.am +++ /dev/null @@ -1,49 +0,0 @@ -SUBDIRS = . - -AM_CPPFLAGS = $(ATF_CFLAGS) -DUNIT_TEST -I$(top_srcdir)/includes -AM_CPPFLAGS += -I@BINDDIR@/include -I$(top_srcdir) -AM_CPPFLAGS += -DLOCALSTATEDIR='"."' - -EXTRA_DIST = Atffile Kyuafile - -# for autotools debugging only -info: - @echo "ATF_CFLAGS=$(ATF_CFLAGS)" - @echo "ATF_LDFLAGS=$(ATF_LDFLAGS)" - @echo "ATF_LIBS=$(ATF_LIBS)" - -DHCPSRC = ../dhcrelay.c - -DHCPLIBS = $(top_builddir)/common/libdhcp.@A@ \ - $(top_builddir)/omapip/libomapi.@A@ \ - @BINDLIBIRSDIR@/libirs.@A@ \ - @BINDLIBDNSDIR@/libdns.@A@ \ - @BINDLIBISCCFGDIR@/libisccfg.@A@ \ - @BINDLIBISCDIR@/libisc.@A@ - -ATF_TESTS = -if HAVE_ATF - -ATF_TESTS += relay_unittests - -relay_unittests_SOURCES = $(DHCPSRC) -relay_unittests_SOURCES += relay_unittests.c - -relay_unittests_LDADD = $(ATF_LDFLAGS) -relay_unittests_LDADD += $(DHCPLIBS) - -check: $(ATF_TESTS) - @if test $(top_srcdir) != ${top_builddir}; then \ - cp $(top_srcdir)/relay/tests/Atffile Atffile; \ - cp $(top_srcdir)/relay/tests/Kyuafile Kyuafile; \ - fi - sh ${top_builddir}/tests/unittest.sh - -distclean-local: - @if test $(top_srcdir) != ${top_builddir}; then \ - rm -f Atffile Kyuafile; \ - fi - -endif - -check_PROGRAMS = $(ATF_TESTS) diff --git a/relay/tests/Makefile.in b/relay/tests/Makefile.in deleted file mode 100644 index caef4fa1..00000000 --- a/relay/tests/Makefile.in +++ /dev/null @@ -1,742 +0,0 @@ -# Makefile.in generated by automake 1.16.5 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994-2021 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@ -VPATH = @srcdir@ -am__is_gnu_make = { \ - if test -z '$(MAKELEVEL)'; then \ - false; \ - elif test -n '$(MAKE_HOST)'; then \ - true; \ - elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ - true; \ - else \ - false; \ - fi; \ -} -am__make_running_with_option = \ - case $${target_option-} in \ - ?) ;; \ - *) echo "am__make_running_with_option: internal error: invalid" \ - "target option '$${target_option-}' specified" >&2; \ - exit 1;; \ - esac; \ - has_opt=no; \ - sane_makeflags=$$MAKEFLAGS; \ - if $(am__is_gnu_make); then \ - sane_makeflags=$$MFLAGS; \ - else \ - case $$MAKEFLAGS in \ - *\\[\ \ ]*) \ - bs=\\; \ - sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ - | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ - esac; \ - fi; \ - skip_next=no; \ - strip_trailopt () \ - { \ - flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ - }; \ - for flg in $$sane_makeflags; do \ - test $$skip_next = yes && { skip_next=no; continue; }; \ - case $$flg in \ - *=*|--*) continue;; \ - -*I) strip_trailopt 'I'; skip_next=yes;; \ - -*I?*) strip_trailopt 'I';; \ - -*O) strip_trailopt 'O'; skip_next=yes;; \ - -*O?*) strip_trailopt 'O';; \ - -*l) strip_trailopt 'l'; skip_next=yes;; \ - -*l?*) strip_trailopt 'l';; \ - -[dEDm]) skip_next=yes;; \ - -[JT]) skip_next=yes;; \ - esac; \ - case $$flg in \ - *$$target_option*) has_opt=yes; break;; \ - esac; \ - done; \ - test $$has_opt = yes -am__make_dryrun = (target_option=n; $(am__make_running_with_option)) -am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) -pkgdatadir = $(datadir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkglibexecdir = $(libexecdir)/@PACKAGE@ -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -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@ -@HAVE_ATF_TRUE@am__append_1 = relay_unittests -check_PROGRAMS = $(am__EXEEXT_2) -subdir = relay/tests -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/includes/config.h -CONFIG_CLEAN_FILES = -CONFIG_CLEAN_VPATH_FILES = -@HAVE_ATF_TRUE@am__EXEEXT_1 = relay_unittests$(EXEEXT) -am__EXEEXT_2 = $(am__EXEEXT_1) -am__relay_unittests_SOURCES_DIST = ../dhcrelay.c relay_unittests.c -am__objects_1 = dhcrelay.$(OBJEXT) -@HAVE_ATF_TRUE@am_relay_unittests_OBJECTS = $(am__objects_1) \ -@HAVE_ATF_TRUE@ relay_unittests.$(OBJEXT) -relay_unittests_OBJECTS = $(am_relay_unittests_OBJECTS) -am__DEPENDENCIES_1 = -am__DEPENDENCIES_2 = $(top_builddir)/common/libdhcp.@A@ \ - $(top_builddir)/omapip/libomapi.@A@ -@HAVE_ATF_TRUE@relay_unittests_DEPENDENCIES = $(am__DEPENDENCIES_1) \ -@HAVE_ATF_TRUE@ $(am__DEPENDENCIES_2) -AM_V_P = $(am__v_P_@AM_V@) -am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) -am__v_P_0 = false -am__v_P_1 = : -AM_V_GEN = $(am__v_GEN_@AM_V@) -am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) -am__v_GEN_0 = @echo " GEN " $@; -am__v_GEN_1 = -AM_V_at = $(am__v_at_@AM_V@) -am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) -am__v_at_0 = @ -am__v_at_1 = -DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/includes -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__maybe_remake_depfiles = depfiles -am__depfiles_remade = ./$(DEPDIR)/dhcrelay.Po \ - ./$(DEPDIR)/relay_unittests.Po -am__mv = mv -f -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -AM_V_CC = $(am__v_CC_@AM_V@) -am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) -am__v_CC_0 = @echo " CC " $@; -am__v_CC_1 = -CCLD = $(CC) -LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ -AM_V_CCLD = $(am__v_CCLD_@AM_V@) -am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) -am__v_CCLD_0 = @echo " CCLD " $@; -am__v_CCLD_1 = -SOURCES = $(relay_unittests_SOURCES) -DIST_SOURCES = $(am__relay_unittests_SOURCES_DIST) -RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ - ctags-recursive dvi-recursive html-recursive info-recursive \ - install-data-recursive install-dvi-recursive \ - install-exec-recursive install-html-recursive \ - install-info-recursive install-pdf-recursive \ - install-ps-recursive install-recursive installcheck-recursive \ - installdirs-recursive pdf-recursive ps-recursive \ - tags-recursive uninstall-recursive -am__can_run_installinfo = \ - case $$AM_UPDATE_INFO_DIR in \ - n|no|NO) false;; \ - *) (install-info --version) >/dev/null 2>&1;; \ - esac -RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ - distclean-recursive maintainer-clean-recursive -am__recursive_targets = \ - $(RECURSIVE_TARGETS) \ - $(RECURSIVE_CLEAN_TARGETS) \ - $(am__extra_recursive_targets) -AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ - distdir distdir-am -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) -# Read a list of newline-separated strings from the standard input, -# and print each of them once, without duplicates. Input order is -# *not* preserved. -am__uniquify_input = $(AWK) '\ - BEGIN { nonempty = 0; } \ - { items[$$0] = 1; nonempty = 1; } \ - END { if (nonempty) { for (i in items) print i; }; } \ -' -# Make sure the list of sources is unique. This is necessary because, -# e.g., the same source file might be shared among _SOURCES variables -# for different programs/libraries. -am__define_uniq_tagged_files = \ - list='$(am__tagged_files)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | $(am__uniquify_input)` -DIST_SUBDIRS = $(SUBDIRS) -am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -am__relativize = \ - dir0=`pwd`; \ - sed_first='s,^\([^/]*\)/.*$$,\1,'; \ - sed_rest='s,^[^/]*/*,,'; \ - sed_last='s,^.*/\([^/]*\)$$,\1,'; \ - sed_butlast='s,/*[^/]*$$,,'; \ - while test -n "$$dir1"; do \ - first=`echo "$$dir1" | sed -e "$$sed_first"`; \ - if test "$$first" != "."; then \ - if test "$$first" = ".."; then \ - dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ - dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ - else \ - first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ - if test "$$first2" = "$$first"; then \ - dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ - else \ - dir2="../$$dir2"; \ - fi; \ - dir0="$$dir0"/"$$first"; \ - fi; \ - fi; \ - dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ - done; \ - reldir="$$dir2" -A = @A@ -ACLOCAL = @ACLOCAL@ -AMTAR = @AMTAR@ -AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ -AR = @AR@ -ATF_BIN = @ATF_BIN@ -ATF_CFLAGS = @ATF_CFLAGS@ -ATF_LDFLAGS = @ATF_LDFLAGS@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -BINDCONFIG = @BINDCONFIG@ -BINDDIR = @BINDDIR@ -BINDIOMUX = @BINDIOMUX@ -BINDLIBDNSDIR = @BINDLIBDNSDIR@ -BINDLIBIRSDIR = @BINDLIBIRSDIR@ -BINDLIBISCCFGDIR = @BINDLIBISCCFGDIR@ -BINDLIBISCDIR = @BINDLIBISCDIR@ -BINDLT = @BINDLT@ -BINDSRCDIR = @BINDSRCDIR@ -BINDSUBDIR = @BINDSUBDIR@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CSCOPE = @CSCOPE@ -CTAGS = @CTAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -DHLIBS = @DHLIBS@ -DISTCHECK_ATF_CONFIGURE_FLAG = @DISTCHECK_ATF_CONFIGURE_FLAG@ -DISTCHECK_LIBBIND_CONFIGURE_FLAG = @DISTCHECK_LIBBIND_CONFIGURE_FLAG@ -DISTCHECK_LIBTOOL_CONFIGURE_FLAG = @DISTCHECK_LIBTOOL_CONFIGURE_FLAG@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -ETAGS = @ETAGS@ -EXEEXT = @EXEEXT@ -GREP = @GREP@ -INSTALL = @INSTALL@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LDAP_CFLAGS = @LDAP_CFLAGS@ -LDAP_LIBS = @LDAP_LIBS@ -LDFLAGS = @LDFLAGS@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LTLIBOBJS = @LTLIBOBJS@ -MAINT = @MAINT@ -MAKEINFO = @MAKEINFO@ -MKDIR_P = @MKDIR_P@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_URL = @PACKAGE_URL@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -Q = @Q@ -RANLIB = @RANLIB@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STRIP = @STRIP@ -UNITTESTS = @UNITTESTS@ -VERSION = @VERSION@ -abs_builddir = @abs_builddir@ -abs_srcdir = @abs_srcdir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ -ac_ct_CC = @ac_ct_CC@ -ac_prefix_program = @ac_prefix_program@ -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@ -builddir = @builddir@ -byte_order = @byte_order@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -pkgcfg_found = @pkgcfg_found@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -srcdir = @srcdir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -top_build_prefix = @top_build_prefix@ -top_builddir = @top_builddir@ -top_srcdir = @top_srcdir@ -SUBDIRS = . -AM_CPPFLAGS = $(ATF_CFLAGS) -DUNIT_TEST -I$(top_srcdir)/includes \ - -I@BINDDIR@/include -I$(top_srcdir) -DLOCALSTATEDIR='"."' -EXTRA_DIST = Atffile Kyuafile -DHCPSRC = ../dhcrelay.c -DHCPLIBS = $(top_builddir)/common/libdhcp.@A@ \ - $(top_builddir)/omapip/libomapi.@A@ \ - @BINDLIBIRSDIR@/libirs.@A@ \ - @BINDLIBDNSDIR@/libdns.@A@ \ - @BINDLIBISCCFGDIR@/libisccfg.@A@ \ - @BINDLIBISCDIR@/libisc.@A@ - -ATF_TESTS = $(am__append_1) -@HAVE_ATF_TRUE@relay_unittests_SOURCES = $(DHCPSRC) relay_unittests.c -@HAVE_ATF_TRUE@relay_unittests_LDADD = $(ATF_LDFLAGS) $(DHCPLIBS) -all: all-recursive - -.SUFFIXES: -.SUFFIXES: .c .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 ) \ - && { if test -f $@; then exit 0; else break; fi; }; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign relay/tests/Makefile'; \ - $(am__cd) $(top_srcdir) && \ - $(AUTOMAKE) --foreign relay/tests/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__maybe_remake_depfiles)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ - 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 -$(am__aclocal_m4_deps): - -clean-checkPROGRAMS: - -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) - -relay_unittests$(EXEEXT): $(relay_unittests_OBJECTS) $(relay_unittests_DEPENDENCIES) $(EXTRA_relay_unittests_DEPENDENCIES) - @rm -f relay_unittests$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(relay_unittests_OBJECTS) $(relay_unittests_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dhcrelay.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/relay_unittests.Po@am__quote@ # am--include-marker - -$(am__depfiles_remade): - @$(MKDIR_P) $(@D) - @echo '# dummy' >$@-t && $(am__mv) $@-t $@ - -am--depfiles: $(am__depfiles_remade) - -.c.o: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< - -.c.obj: -@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` - -dhcrelay.o: ../dhcrelay.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT dhcrelay.o -MD -MP -MF $(DEPDIR)/dhcrelay.Tpo -c -o dhcrelay.o `test -f '../dhcrelay.c' || echo '$(srcdir)/'`../dhcrelay.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/dhcrelay.Tpo $(DEPDIR)/dhcrelay.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../dhcrelay.c' object='dhcrelay.o' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o dhcrelay.o `test -f '../dhcrelay.c' || echo '$(srcdir)/'`../dhcrelay.c - -dhcrelay.obj: ../dhcrelay.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT dhcrelay.obj -MD -MP -MF $(DEPDIR)/dhcrelay.Tpo -c -o dhcrelay.obj `if test -f '../dhcrelay.c'; then $(CYGPATH_W) '../dhcrelay.c'; else $(CYGPATH_W) '$(srcdir)/../dhcrelay.c'; fi` -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/dhcrelay.Tpo $(DEPDIR)/dhcrelay.Po -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='../dhcrelay.c' object='dhcrelay.obj' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o dhcrelay.obj `if test -f '../dhcrelay.c'; then $(CYGPATH_W) '../dhcrelay.c'; else $(CYGPATH_W) '$(srcdir)/../dhcrelay.c'; fi` - -# This directory's subdirectories are mostly independent; you can cd -# into them and run 'make' without going through this Makefile. -# To change the values of 'make' variables: instead of editing Makefiles, -# (1) if the variable is set in 'config.status', edit 'config.status' -# (which will cause the Makefiles to be regenerated when you run 'make'); -# (2) otherwise, pass the desired values on the 'make' command line. -$(am__recursive_targets): - @fail=; \ - if $(am__make_keepgoing); then \ - failcom='fail=yes'; \ - else \ - failcom='exit 1'; \ - fi; \ - dot_seen=no; \ - target=`echo $@ | sed s/-recursive//`; \ - case "$@" in \ - distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ - *) list='$(SUBDIRS)' ;; \ - esac; \ - for subdir in $$list; do \ - echo "Making $$target in $$subdir"; \ - if test "$$subdir" = "."; then \ - dot_seen=yes; \ - local_target="$$target-am"; \ - else \ - local_target="$$target"; \ - fi; \ - ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ - || eval $$failcom; \ - done; \ - if test "$$dot_seen" = "no"; then \ - $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ - fi; test -z "$$fail" - -ID: $(am__tagged_files) - $(am__define_uniq_tagged_files); mkid -fID $$unique -tags: tags-recursive -TAGS: tags - -tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - set x; \ - here=`pwd`; \ - if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ - include_option=--etags-include; \ - empty_fix=.; \ - else \ - include_option=--include; \ - empty_fix=; \ - fi; \ - list='$(SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - test ! -f $$subdir/TAGS || \ - set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ - fi; \ - done; \ - $(am__define_uniq_tagged_files); \ - shift; \ - if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - if test $$# -gt 0; then \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - "$$@" $$unique; \ - else \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$unique; \ - fi; \ - fi -ctags: ctags-recursive - -CTAGS: ctags -ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) - $(am__define_uniq_tagged_files); \ - test -z "$(CTAGS_ARGS)$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && $(am__cd) $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) "$$here" -cscopelist: cscopelist-recursive - -cscopelist-am: $(am__tagged_files) - list='$(am__tagged_files)'; \ - case "$(srcdir)" in \ - [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ - *) sdir=$(subdir)/$(srcdir) ;; \ - esac; \ - for i in $$list; do \ - if test -f "$$i"; then \ - echo "$(subdir)/$$i"; \ - else \ - echo "$$sdir/$$i"; \ - fi; \ - done >> $(top_builddir)/cscope.files - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -distdir: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) distdir-am - -distdir-am: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ - list='$(DISTFILES)'; \ - dist_files=`for file in $$list; do echo $$file; done | \ - sed -e "s|^$$srcdirstrip/||;t" \ - -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ - case $$dist_files in \ - */*) $(MKDIR_P) `echo "$$dist_files" | \ - sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ - sort -u` ;; \ - esac; \ - for file in $$dist_files; do \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - if test -d $$d/$$file; then \ - dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test -d "$(distdir)/$$file"; then \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ - find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ - fi; \ - cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ - else \ - test -f "$(distdir)/$$file" \ - || cp -p $$d/$$file "$(distdir)/$$file" \ - || exit 1; \ - fi; \ - done - @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ - if test "$$subdir" = .; then :; else \ - $(am__make_dryrun) \ - || test -d "$(distdir)/$$subdir" \ - || $(MKDIR_P) "$(distdir)/$$subdir" \ - || exit 1; \ - dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ - $(am__relativize); \ - new_distdir=$$reldir; \ - dir1=$$subdir; dir2="$(top_distdir)"; \ - $(am__relativize); \ - new_top_distdir=$$reldir; \ - echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ - echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ - ($(am__cd) $$subdir && \ - $(MAKE) $(AM_MAKEFLAGS) \ - top_distdir="$$new_top_distdir" \ - distdir="$$new_distdir" \ - am__remove_distdir=: \ - am__skip_length_check=: \ - am__skip_mode_fix=: \ - distdir) \ - || exit 1; \ - fi; \ - done -check-am: all-am - $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) -check: check-recursive -all-am: Makefile -installdirs: installdirs-recursive -installdirs-am: -install: install-recursive -install-exec: install-exec-recursive -install-data: install-data-recursive -uninstall: uninstall-recursive - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-recursive -install-strip: - if test -z '$(STRIP)'; then \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - install; \ - else \ - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ - fi -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -@HAVE_ATF_FALSE@distclean-local: -clean: clean-recursive - -clean-am: clean-checkPROGRAMS clean-generic mostlyclean-am - -distclean: distclean-recursive - -rm -f ./$(DEPDIR)/dhcrelay.Po - -rm -f ./$(DEPDIR)/relay_unittests.Po - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-local distclean-tags - -dvi: dvi-recursive - -dvi-am: - -html: html-recursive - -html-am: - -info-am: - -install-data-am: - -install-dvi: install-dvi-recursive - -install-dvi-am: - -install-exec-am: - -install-html: install-html-recursive - -install-html-am: - -install-info: install-info-recursive - -install-info-am: - -install-man: - -install-pdf: install-pdf-recursive - -install-pdf-am: - -install-ps: install-ps-recursive - -install-ps-am: - -installcheck-am: - -maintainer-clean: maintainer-clean-recursive - -rm -f ./$(DEPDIR)/dhcrelay.Po - -rm -f ./$(DEPDIR)/relay_unittests.Po - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-recursive - -mostlyclean-am: mostlyclean-compile mostlyclean-generic - -pdf: pdf-recursive - -pdf-am: - -ps: ps-recursive - -ps-am: - -uninstall-am: - -.MAKE: $(am__recursive_targets) check-am install-am install-strip - -.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ - am--depfiles check check-am clean clean-checkPROGRAMS \ - clean-generic cscopelist-am ctags ctags-am distclean \ - distclean-compile distclean-generic distclean-local \ - distclean-tags distdir dvi dvi-am html html-am info info-am \ - install install-am install-data install-data-am install-dvi \ - install-dvi-am install-exec install-exec-am install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-ps install-ps-am \ - install-strip installcheck installcheck-am installdirs \ - installdirs-am maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \ - ps ps-am tags tags-am uninstall uninstall-am - -.PRECIOUS: Makefile - - -# for autotools debugging only -info: - @echo "ATF_CFLAGS=$(ATF_CFLAGS)" - @echo "ATF_LDFLAGS=$(ATF_LDFLAGS)" - @echo "ATF_LIBS=$(ATF_LIBS)" - -@HAVE_ATF_TRUE@check: $(ATF_TESTS) -@HAVE_ATF_TRUE@ @if test $(top_srcdir) != ${top_builddir}; then \ -@HAVE_ATF_TRUE@ cp $(top_srcdir)/relay/tests/Atffile Atffile; \ -@HAVE_ATF_TRUE@ cp $(top_srcdir)/relay/tests/Kyuafile Kyuafile; \ -@HAVE_ATF_TRUE@ fi -@HAVE_ATF_TRUE@ sh ${top_builddir}/tests/unittest.sh - -@HAVE_ATF_TRUE@distclean-local: -@HAVE_ATF_TRUE@ @if test $(top_srcdir) != ${top_builddir}; then \ -@HAVE_ATF_TRUE@ rm -f Atffile Kyuafile; \ -@HAVE_ATF_TRUE@ fi - -# 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/relay/tests/relay_unittests.c b/relay/tests/relay_unittests.c deleted file mode 100644 index ceb409f6..00000000 --- a/relay/tests/relay_unittests.c +++ /dev/null @@ -1,431 +0,0 @@ -/* - * Copyright (C) 2019-2022 Internet Systems Consortium, Inc. ("ISC") - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Internet Systems Consortium, Inc. - * PO Box 360 - * Newmarket, NH 03857 USA - * <info@isc.org> - * https://www.isc.org/ - * - */ - -#include "config.h" -#include <atf-c.h> -#include <omapip/omapip_p.h> -#include "dhcpd.h" - -/* @brief Externs for dhcrelay.c functions under test */ -extern int add_agent_options; -extern int add_relay_agent_options(struct interface_info *, - struct dhcp_packet *, unsigned, - struct in_addr); - -extern int find_interface_by_agent_option(struct dhcp_packet *, - struct interface_info **, - u_int8_t *, int); - -extern int strip_relay_agent_options(struct interface_info *, - struct interface_info **, - struct dhcp_packet *, unsigned); - -/* @brief Add the given option data to a DHCPv4 packet -* -* It first fills the packet.options buffer with the given pad character. -* Next it copies the DHCP magic cookie value into the beginning of the -* options buffer. Finally it appends the given data after the cookie. -* -* @param packet pointer to the packet -* @param data pointer to the option data to copy into the packet's options -* buffer -* @param len length of the option data to copy -* @param pad byte value with which to initialize the packet's options buffer -* -* @return returns the new length of the packet -*/ -unsigned set_packet_options(struct dhcp_packet *packet, - unsigned char* data, unsigned len, - unsigned char pad) { - unsigned new_len; - memset(packet->options, pad, DHCP_MAX_OPTION_LEN); - - // Add the COOKIE - new_len = 4; - memcpy(packet->options, DHCP_OPTIONS_COOKIE, new_len); - - new_len += len; - if (new_len > DHCP_MAX_OPTION_LEN) { - return(0); - } - - memcpy(&packet->options[4], data, len); - return(new_len + DHCP_FIXED_NON_UDP); -} - -/* @brief Checks two sets of option data for equalit -* -* It constructs the expected options content by creating an options buffer -* filled with the pad value. Next it copies the DHCP magic cookie value -* into the beginning of the buffer and then appends the expected data after -* the cookie. It the compares this buffer to the actual buffer passed in -* for equality and returns the result. -* -* @param actual_options pointer to the packet::options to be checked -* @param expected_data pointer to the expected options data (everything after -* the DHCP cookie) -* @param data_len length of the expected options data -* @param pad byte value with which to initialize the packet's options buffer -* -* @return zero it the sets of data match, non-zero otherwise -*/ -int check_with_pad(unsigned char* actual_options, - unsigned char *expected_data, - unsigned data_len, unsigned char pad) { - - unsigned char exp_options[DHCP_MAX_OPTION_LEN]; - unsigned new_len; - - memset(exp_options, pad, DHCP_MAX_OPTION_LEN); - new_len = 4; - memcpy(exp_options, DHCP_OPTIONS_COOKIE, new_len); - - new_len += data_len; - if (new_len > DHCP_MAX_OPTION_LEN) { - return(-1); - } - - memcpy(&exp_options[4], expected_data, data_len); - return (memcmp(actual_options, exp_options, DHCP_MAX_OPTION_LEN)); -} - -ATF_TC(strip_relay_agent_options_test); - -ATF_TC_HEAD(strip_relay_agent_options_test, tc) { - atf_tc_set_md_var(tc, "descr", "tests strip_relay-agent_options"); -} - -/* This Test exercises strip_relay_agent_options() function */ -ATF_TC_BODY(strip_relay_agent_options_test, tc) { - - struct interface_info ifaces; - struct interface_info *matched; - struct dhcp_packet packet; - unsigned len; - int ret; - - memset(&ifaces, 0x0, sizeof(ifaces)); - matched = 0; - memset(&packet, 0x0, sizeof(packet)); - len = 0; - - /* Make sure an empty packet is harmless. We set add_agent_options = 1 - * to avoid early return when it's 0. */ - add_agent_options = 1; - ret = strip_relay_agent_options(&ifaces, &matched, &packet, len); - if (ret != 0) { - atf_tc_fail("empty packet failed"); - } - - { - /* - * Uses valid input option data to verify that: - * - When add_agent_options is false, the output option data is the - * the same as the input option data (i.e. nothing removed) - * - When add_agent_options is true, 0 length relay agent option has - * been removed from the output option data - * - When add_agent_options is true, a relay agent option has - * been removed from the output option data - * - */ - - unsigned char input_data[] = { - 0x35, 0x00, /* DHCP_TYPE = DISCOVER */ - 0x52, 0x08, 0x01, 0x06, 0x65, /* Relay Agent Option, len = 8 */ - 0x6e, 0x70, 0x30, 0x73, 0x4f, - - 0x42, 0x02, 0x00, 0x10, /* Opt 0x42, len = 2 */ - 0x43, 0x00 /* Opt 0x43, len = 0 */ - }; - - unsigned char input_data2[] = { - 0x35, 0x00, /* DHCP_TYPE = DISCOVER */ - 0x52, 0x00, /* Relay Agent Option, len = 0 */ - 0x42, 0x02, 0x00, 0x10, /* Opt 0x42, len = 2 */ - 0x43, 0x00 /* Opt 0x43, len = 0 */ - }; - - unsigned char output_data[] = { - 0x35, 0x00, /* DHCP_TYPE = DISCOVER */ - 0x42, 0x02, 0x00, 0x10, /* Opt 0x42, len = 2 */ - 0x43, 0x00 /* Opt 0x43, len = 0 */ - }; - - unsigned char pad = 0x0; - len = set_packet_options(&packet, input_data, sizeof(input_data), pad); - if (len == 0) { - atf_tc_fail("input_data: set_packet_options failed"); - } - - /* When add_agent_options = 0, no change should occur */ - add_agent_options = 0; - ret = strip_relay_agent_options(&ifaces, &matched, &packet, len); - if (ret != len) { - atf_tc_fail("expected unchanged len %d, returned %d", len, ret); - } - - if (check_with_pad(packet.options, input_data, sizeof(input_data), - pad) != 0) { - atf_tc_fail("expected unchanged data, does not match"); - } - - /* When add_agent_options = 1, it should remove the eight byte - * relay agent option. */ - add_agent_options = 1; - - /* Beause the inbound option data is less than the BOOTP_MIN_LEN, - * the output data should get padded out to BOOTP_MIN_LEN - * padded out to BOOTP_MIN_LEN */ - ret = strip_relay_agent_options(&ifaces, &matched, &packet, len); - if (ret != BOOTP_MIN_LEN) { - atf_tc_fail("input_data: len of %d, returned %d", - BOOTP_MIN_LEN, ret); - } - - if (check_with_pad(packet.options, output_data, sizeof(output_data), - pad) != 0) { - atf_tc_fail("input_data: expected data does not match"); - } - - /* Now let's repeat it with a relay agent option 0 bytes in length. */ - len = set_packet_options(&packet, input_data2, sizeof(input_data2), pad); - if (len == 0) { - atf_tc_fail("input_data2 set_packet_options failed"); - } - - /* Because the inbound option data is less than the BOOTP_MIN_LEN, - * the output data should get padded out to BOOTP_MIN_LEN - * padded out to BOOTP_MIN_LEN */ - ret = strip_relay_agent_options(&ifaces, &matched, &packet, len); - if (ret != BOOTP_MIN_LEN) { - atf_tc_fail("input_data2: len of %d, returned %d", - BOOTP_MIN_LEN, ret); - } - - if (check_with_pad(packet.options, output_data, sizeof(output_data), - pad) != 0) { - atf_tc_fail("input_data2: expected output does not match"); - } - } - - { - /* Verify that oversized packet filled with long options does not - * cause overrun */ - - /* We borrowed this union from discover.c:got_one() */ - union { - unsigned char packbuf [4095]; /* Packet input buffer. - * Must be as large as largest - * possible MTU. */ - struct dhcp_packet packet; - } u; - - unsigned char input_data[] = { - 0x35, 0x00, /* DHCP_TYPE = DISCOVER */ - 0x52, 0x00, /* Relay Agent Option, len = 0 */ - 0x42, 0x02, 0x00, 0x10, /* Opt 0x42, len = 2 */ - 0x43, 0x00 /* Opt 0x43, len = 0 */ - }; - - /* We'll pad it 0xFE, that way wherever we hit for "length" we'll - * have length of 254. Increasing the odds we'll push over the end. */ - unsigned char pad = 0xFE; - memset(u.packbuf, pad, 4095); - - len = set_packet_options(&u.packet, input_data, sizeof(input_data), pad); - if (len == 0) { - atf_tc_fail("overrun: set_packet_options failed"); - } - - /* Enable option stripping by setting add_agent_options = 1 */ - add_agent_options = 1; - - /* strip_relay_agent_options() should detect the overrun and return 0 */ - ret = strip_relay_agent_options(&ifaces, &matched, &u.packet, 4095); - if (ret != 0) { - atf_tc_fail("overrun expected return len = 0, we got %d", ret); - } - } -} - -ATF_TC(add_relay_agent_options_test); - -ATF_TC_HEAD(add_relay_agent_options_test, tc) { - atf_tc_set_md_var(tc, "descr", "tests agent_relay-agent_options"); -} - -/* This Test exercises add_relay_agent_options() function */ -ATF_TC_BODY(add_relay_agent_options_test, tc) { - - struct interface_info ifc; - struct dhcp_packet packet; - unsigned len; - int ret; - struct in_addr giaddr; - - giaddr.s_addr = inet_addr("192.0.1.1"); - - u_int8_t circuit_id[] = { 0x01,0x02,0x03,0x04,0x05,0x06 }; - u_int8_t remote_id[] = { 0x11,0x22,0x33,0x44,0x55,0x66 }; - - memset(&ifc, 0x0, sizeof(ifc)); - ifc.circuit_id = circuit_id; - ifc.circuit_id_len = sizeof(circuit_id); - ifc.remote_id = remote_id; - ifc.remote_id_len = sizeof(remote_id); - - memset(&packet, 0x0, sizeof(packet)); - len = 0; - - /* Make sure an empty packet is harmless */ - ret = add_relay_agent_options(&ifc, &packet, len, giaddr); - if (ret != 0) { - atf_tc_fail("empty packet failed"); - } - - { - /* - * Uses valid input option data to verify that: - * - When add_agent_options is false, the output option data is the - * the same as the input option data (i.e. nothing removed) - * - When add_agent_options is true, the relay agent option has - * been removed from the output option data - * - When add_agent_options is true, 0 length relay agent option has - * been removed from the output option data - * - */ - - unsigned char input_data[] = { - 0x35, 0x00, /* DHCP_TYPE = DISCOVER */ - 0x52, 0x08, 0x01, 0x06, 0x65, /* Relay Agent Option, len = 8 */ - 0x6e, 0x70, 0x30, 0x73, 0x4f, - 0x42, 0x02, 0x00, 0x10, /* Opt 0x42, len = 2 */ - 0x43, 0x00 /* Opt 0x43, len = 0 */ - }; - - unsigned char input_data2[] = { - 0x35, 0x00, /* DHCP_TYPE = DISCOVER */ - 0x52, 0x00, /* Relay Agent Option, len = 0 */ - 0x42, 0x02, 0x00, 0x10, /* Opt 0x42, len = 2 */ - 0x43, 0x00 /* Opt 0x43, len = 0 */ - }; - - unsigned char output_data[] = { - 0x35, 0x00, /* DHCP_TYPE = DISCOVER */ - 0x42, 0x02, 0x00, 0x10, /* Opt 0x42, len = 2 */ - 0x43, 0x00, /* Opt 0x43, len = 0 */ - 0x52, 0x10, /* Relay Agent, len = 16 */ - 0x1, 0x6, /* Circuit id, len = 6 */ - 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, - 0x2, 0x6, /* Remete id, len = 6 */ - 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0xff - }; - - unsigned char pad = 0x0; - len = set_packet_options(&packet, input_data, sizeof(input_data), pad); - if (len == 0) { - atf_tc_fail("input_data: set_packet_options failed"); - } - - /* When add_agent_options = 0, no change should occur */ - add_agent_options = 0; - ret = add_relay_agent_options(&ifc, &packet, len, giaddr); - if (ret != len) { - atf_tc_fail("expected unchanged len %d, returned %d", len, ret); - } - - if (check_with_pad(packet.options, input_data, sizeof(input_data), - pad) != 0) { - atf_tc_fail("expected unchanged data, does not match"); - } - - /* When add_agent_options = 1, it should remove the eight byte - * relay agent option. */ - add_agent_options = 1; - - /* Because the inbound option data is less than the BOOTP_MIN_LEN, - * the output data should get padded out to BOOTP_MIN_LEN - * padded out to BOOTP_MIN_LEN */ - ret = add_relay_agent_options(&ifc, &packet, len, giaddr); - if (ret != BOOTP_MIN_LEN) { - atf_tc_fail("input_data: len of %d, returned %d", - BOOTP_MIN_LEN, ret); - } - - if (check_with_pad(packet.options, output_data, sizeof(output_data), - pad) != 0) { - atf_tc_fail("input_data: expected data does not match"); - } - - /* Now let's repeat it with a relay agent option 0 bytes in length. */ - len = set_packet_options(&packet, input_data2, sizeof(input_data2), - pad); - if (len == 0) { - atf_tc_fail("input_data2 set_packet_options failed"); - } - - /* Because the inbound option data is less than the BOOTP_MIN_LEN, - * the output data should get padded out to BOOTP_MIN_LEN - * padded out to BOOTP_MIN_LEN */ - ret = add_relay_agent_options(&ifc, &packet, len, giaddr); - if (ret != BOOTP_MIN_LEN) { - atf_tc_fail("input_data2: len of %d, returned %d", - BOOTP_MIN_LEN, ret); - } - - if (check_with_pad(packet.options, output_data, sizeof(output_data), - pad) != 0) { - atf_tc_fail("input_data2: expected output does not match"); - } - } -} - -ATF_TC(gwaddr_override_test); - -ATF_TC_HEAD(gwaddr_override_test, tc) { - atf_tc_set_md_var(tc, "descr", "tests that gateway addr (giaddr) field can be overridden"); -} - -extern isc_boolean_t use_fake_gw; -extern struct in_addr gw; - -/* This basic test checks if the new gwaddr override (-g) option is disabled by default */ -ATF_TC_BODY(gwaddr_override_test, tc) { - - if (use_fake_gw == ISC_TRUE) { - atf_tc_fail("the gwaddr override should be disabled by default"); - } - char txt[16] = {0}; - inet_ntop(AF_INET, &gw, txt, sizeof(txt)); - if (strncmp(txt, "0.0.0.0", 8) != 0) { - atf_tc_fail("the default gwaddr override value should be 0.0.0.0, but is %s", txt); - } -} - -ATF_TP_ADD_TCS(tp) { - ATF_TP_ADD_TC(tp, strip_relay_agent_options_test); - ATF_TP_ADD_TC(tp, add_relay_agent_options_test); - ATF_TP_ADD_TC(tp, gwaddr_override_test); - - return (atf_no_error()); -} |