--- knocker-0.7.1.orig/tclean
+++ knocker-0.7.1/tclean
@@ -0,0 +1,358 @@
+# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am
+
+# Copyright (C) 1994, 1995-8, 1999 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.
+
+# Makefile.am file for knocker
+# Edited by Gabriele Giorgetti <g.gabriele@europe.com>
+
+# This file is processed by automake
+
+
+SHELL = @SHELL@
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+
+bindir = @bindir@
+sbindir = @sbindir@
+libexecdir = @libexecdir@
+datadir = @datadir@
+sysconfdir = @sysconfdir@
+sharedstatedir = @sharedstatedir@
+localstatedir = @localstatedir@
+libdir = @libdir@
+infodir = @infodir@
+mandir = @mandir@
+includedir = @includedir@
+oldincludedir = /usr/include
+
+DESTDIR =
+
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+
+top_builddir = .
+
+ACLOCAL = @ACLOCAL@
+AUTOCONF = @AUTOCONF@
+AUTOMAKE = @AUTOMAKE@
+AUTOHEADER = @AUTOHEADER@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+transform = @program_transform_name@
+
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+CC = @CC@
+MAKEINFO = @MAKEINFO@
+PACKAGE = @PACKAGE@
+VERSION = @VERSION@
+
+SUBDIRS = src docs
+
+DIST_SUBDIRS = $(SUBDIRS) docs
+
+# All the rest of the distributed files
+EXTRA_DIST =  	AUTHORS 		BUGS            	COPYING                 INSTALL                 README			TO-DO    		autogen.sh		ChangeLog
+
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = config.h
+CONFIG_CLEAN_FILES = 
+DIST_COMMON =  README ./stamp-h.in AUTHORS COPYING ChangeLog INSTALL \
+Makefile.am Makefile.in NEWS aclocal.m4 config.h.in configure \
+configure.in install-sh missing mkinstalldirs
+
+
+DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
+
+TAR = tar
+GZIP_ENV = --best
+all: all-redirect
+.SUFFIXES:
+$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) 
+	cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps Makefile
+
+Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
+	cd $(top_builddir) \
+	  && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+$(ACLOCAL_M4):  configure.in 
+	cd $(srcdir) && $(ACLOCAL)
+
+config.status: $(srcdir)/configure.in $(CONFIG_STATUS_DEPENDENCIES)
+	$(SHELL) ./config.status --recheck
+$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
+	cd $(srcdir) && $(AUTOCONF)
+
+config.h: stamp-h
+	@if test ! -f $@; then \
+		rm -f stamp-h; \
+		$(MAKE) stamp-h; \
+	else :; fi
+stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status
+	cd $(top_builddir) \
+	  && CONFIG_FILES= CONFIG_HEADERS=config.h \
+	     $(SHELL) ./config.status
+	@echo timestamp > stamp-h 2> /dev/null
+$(srcdir)/config.h.in: $(srcdir)/stamp-h.in
+	@if test ! -f $@; then \
+		rm -f $(srcdir)/stamp-h.in; \
+		$(MAKE) $(srcdir)/stamp-h.in; \
+	else :; fi
+$(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) 
+	cd $(top_srcdir) && $(AUTOHEADER)
+	@echo timestamp > $(srcdir)/stamp-h.in 2> /dev/null
+
+mostlyclean-hdr:
+
+clean-hdr:
+
+distclean-hdr:
+	-rm -f config.h
+
+maintainer-clean-hdr:
+
+# 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.
+
+@SET_MAKE@
+
+all-recursive install-data-recursive install-exec-recursive \
+installdirs-recursive install-recursive uninstall-recursive  \
+check-recursive installcheck-recursive info-recursive dvi-recursive:
+	@set fnord $(MAKEFLAGS); amf=$$2; \
+	dot_seen=no; \
+	target=`echo $@ | sed s/-recursive//`; \
+	list='$(SUBDIRS)'; 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; \
+	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	   || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
+	done; \
+	if test "$$dot_seen" = "no"; then \
+	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+	fi; test -z "$$fail"
+
+mostlyclean-recursive clean-recursive distclean-recursive \
+maintainer-clean-recursive:
+	@set fnord $(MAKEFLAGS); amf=$$2; \
+	dot_seen=no; \
+	rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \
+	  rev="$$subdir $$rev"; \
+	  test "$$subdir" = "." && dot_seen=yes; \
+	done; \
+	test "$$dot_seen" = "no" && rev=". $$rev"; \
+	target=`echo $@ | sed s/-recursive//`; \
+	for subdir in $$rev; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	   || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
+	done && test -z "$$fail"
+tags-recursive:
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+	done
+
+tags: TAGS
+
+ID: $(HEADERS) $(SOURCES) $(LISP)
+	list='$(SOURCES) $(HEADERS)'; \
+	unique=`for i in $$list; do echo $$i; done | \
+	  awk '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	here=`pwd` && cd $(srcdir) \
+	  && mkid -f$$here/ID $$unique $(LISP)
+
+TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+   if test "$$subdir" = .; then :; else \
+	    test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
+   fi; \
+	done; \
+	list='$(SOURCES) $(HEADERS)'; \
+	unique=`for i in $$list; do echo $$i; done | \
+	  awk '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \
+	  || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP) -o $$here/TAGS)
+
+mostlyclean-tags:
+
+clean-tags:
+
+distclean-tags:
+	-rm -f TAGS ID
+
+maintainer-clean-tags:
+
+distdir = $(PACKAGE)-$(VERSION)
+top_distdir = $(distdir)
+
+# This target untars the dist file and tries a VPATH configuration.  Then
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
+distcheck: dist
+	-rm -rf $(distdir)
+	GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz
+	mkdir $(distdir)/=build
+	mkdir $(distdir)/=inst
+	dc_install_base=`cd $(distdir)/=inst && pwd`; \
+	cd $(distdir)/=build \
+	  && ../configure --srcdir=.. --prefix=$$dc_install_base \
+	  && $(MAKE) $(AM_MAKEFLAGS) \
+	  && $(MAKE) $(AM_MAKEFLAGS) dvi \
+	  && $(MAKE) $(AM_MAKEFLAGS) check \
+	  && $(MAKE) $(AM_MAKEFLAGS) install \
+	  && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+	  && $(MAKE) $(AM_MAKEFLAGS) dist
+	-rm -rf $(distdir)
+	@banner="$(distdir).tar.gz is ready for distribution"; \
+	dashes=`echo "$$banner" | sed s/./=/g`; \
+	echo "$$dashes"; \
+	echo "$$banner"; \
+	echo "$$dashes"
+dist: distdir
+	-chmod -R a+r $(distdir)
+	GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
+	-rm -rf $(distdir)
+dist-all: distdir
+	-chmod -R a+r $(distdir)
+	GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
+	-rm -rf $(distdir)
+distdir: $(DISTFILES)
+	-rm -rf $(distdir)
+	mkdir $(distdir)
+	-chmod 777 $(distdir)
+	@for file in $(DISTFILES); do \
+	  d=$(srcdir); \
+	  if test -d $$d/$$file; then \
+	    cp -pr $$d/$$file $(distdir)/$$file; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+	    || cp -p $$d/$$file $(distdir)/$$file || :; \
+	  fi; \
+	done
+	for subdir in $(DIST_SUBDIRS); do \
+	  if test "$$subdir" = .; then :; else \
+	    test -d $(distdir)/$$subdir \
+	    || mkdir $(distdir)/$$subdir \
+	    || exit 1; \
+	    chmod 777 $(distdir)/$$subdir; \
+	    (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \
+	      || exit 1; \
+	  fi; \
+	done
+info-am:
+info: info-recursive
+dvi-am:
+dvi: dvi-recursive
+check-am: all-am
+check: check-recursive
+installcheck-am:
+installcheck: installcheck-recursive
+all-recursive-am: config.h
+	$(MAKE) $(AM_MAKEFLAGS) all-recursive
+
+install-exec-am:
+install-exec: install-exec-recursive
+
+install-data-am:
+install-data: install-data-recursive
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+install: install-recursive
+uninstall-am:
+uninstall: uninstall-recursive
+all-am: Makefile config.h
+all-redirect: all-recursive-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
+installdirs: installdirs-recursive
+installdirs-am:
+
+
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-rm -f Makefile $(CONFIG_CLEAN_FILES)
+	-rm -f config.cache config.log stamp-h stamp-h[0-9]*
+
+maintainer-clean-generic:
+mostlyclean-am:  mostlyclean-hdr mostlyclean-tags mostlyclean-generic
+
+mostlyclean: mostlyclean-recursive
+
+clean-am:  clean-hdr clean-tags clean-generic mostlyclean-am
+
+clean: clean-recursive
+
+distclean-am:  distclean-hdr distclean-tags distclean-generic clean-am
+
+distclean: distclean-recursive
+	-rm -f config.status
+
+maintainer-clean-am:  maintainer-clean-hdr maintainer-clean-tags \
+		maintainer-clean-generic distclean-am
+	@echo "This command is intended for maintainers to use;"
+	@echo "it deletes files that may require special tools to rebuild."
+
+maintainer-clean: maintainer-clean-recursive
+	-rm -f config.status
+
+.PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \
+install-data-recursive uninstall-data-recursive install-exec-recursive \
+uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \
+all-recursive check-recursive installcheck-recursive info-recursive \
+dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \
+maintainer-clean-recursive tags tags-recursive mostlyclean-tags \
+distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
+dvi-am dvi check check-am installcheck-am installcheck all-recursive-am \
+install-exec-am install-exec install-data-am install-data install-am \
+install uninstall-am uninstall all-redirect all-am all installdirs-am \
+installdirs mostlyclean-generic distclean-generic clean-generic \
+maintainer-clean-generic clean mostlyclean distclean maintainer-clean
+
+
+# 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:
--- knocker-0.7.1.orig/src/knocker_user.c
+++ knocker-0.7.1/src/knocker_user.c
@@ -82,7 +82,7 @@
       _dir_create (user->dir);
     }
 
-  if (knocker_user_is_root)
+  if (knocker_user_is_root())
     user->super = 1;
   else
     user->super = 0;
--- knocker-0.7.1.orig/src/knocker_args.h
+++ knocker-0.7.1/src/knocker_args.h
@@ -33,6 +33,12 @@
   /* host to scan, got with lasthost  */
 #define LAST_HOST_LONG_OPT  "--last-host"
 
+  /* preferred address family for hosts */
+#define HOST_IPV4_SHORT_OPT "-4"
+#define HOST_IPV4_LONG_OPT "--ipv4"
+#define HOST_IPV6_SHORT_OPT "-6"
+#define HOST_IPV6_LONG_OPT "--ipv6"
+
   /* single port number */
 #define SINGLE_PORT_SHORT_OPT "-P"
 #define SINGLE_PORT_LONG_OPT  "--port"
@@ -82,6 +88,7 @@
   char           *hname;      /* hostname string */
   char           *hip;        /* host IP string  */
   char           *lfname;     /* logfile name */
+  int            hfamily;     /* desired address domain */
   unsigned int   port;        /* Single port number, -P */
   unsigned int   sport;       /* Start port number, -SP */
   unsigned int   eport;       /* End port number, -EP   */
--- knocker-0.7.1.orig/src/knocker_core.c
+++ knocker-0.7.1/src/knocker_core.c
@@ -33,13 +33,13 @@
 
 static int knocker_core_init_socket_data (knocker_core_socket_t * sock);
 static void knocker_core_free_socket_data (knocker_core_socket_t * sock);
-static int knocker_core_open_socket (knocker_core_socket_t * sock, int protocol);
+static int knocker_core_open_socket (knocker_core_socket_t * sock, int family, int protocol);
 static void knocker_core_close_socket (knocker_core_socket_t * sock);
 
 static int knocker_core_init_host_data (knocker_core_host_t * host);
 static void knocker_core_free_host_data (knocker_core_host_t * host);
 
-static int knocker_core_gethostbyname (knocker_core_host_t * hinfo, const char *hostname);
+static int knocker_core_gethostbyname (knocker_core_host_t * hinfo, const char *hostname, int family);
 static int knocker_core_getservbyport (char *service, unsigned int port, int protocol);
 
 static char *knocker_core_get_host_name_string (knocker_core_host_t * hinfo);
@@ -364,7 +364,7 @@
   fprintf (stderr, "debug: connecting to port: %d\n", port);
 #endif
 
-  if (knocker_core_open_socket (&data->socket, PROTO_TCP) == KNOCKER_SOCKET_ERROR)
+  if (knocker_core_open_socket (&data->socket, data->host.hostaddr.ss_family, PROTO_TCP) == KNOCKER_SOCKET_ERROR)
     {
 #ifdef DEBUG
       fprintf (stderr, "debug: socket error, couldn't connect.\n");
@@ -372,12 +372,16 @@
       return -1;
     }
 
-  data->host.sockaddr_in.sin_family = AF_INET;
-  data->host.sockaddr_in.sin_port = htons (port);
-  data->host.sockaddr_in.sin_addr = *((struct in_addr *) data->host.info->h_addr);
-  memset (&(data->host.sockaddr_in.sin_zero), 0, 8);
+  memcpy (&(data->host.sockaddr_st), &(data->host.hostaddr), data->host.addrlen);
+  switch (data->host.hostaddr.ss_family) {
+    case AF_INET6:
+      ((struct sockaddr_in6 *) &(data->host.sockaddr_st))->sin6_port = htons (port);
+    case AF_INET:
+    default:
+      ((struct sockaddr_in *) &(data->host.sockaddr_st))->sin_port = htons (port);
+  }
 
-  if (!connect (data->socket.fd, (struct sockaddr *) &data->host.sockaddr_in, sizeof (struct sockaddr)))
+  if (!connect (data->socket.fd, (struct sockaddr *) &data->host.sockaddr_st, data->host.addrlen))
     /* here the port is open */
     {
       knocker_core_close_socket (&data->socket);
@@ -401,9 +405,9 @@
    ============================================================================
    ============================================================================
 */
-char *knocker_core_resolve_host (knocker_core_portscan_data_t * data, const char *hostname)
+char *knocker_core_resolve_host (knocker_core_portscan_data_t * data, const char *hostname, int family)
 {
-  if (knocker_core_gethostbyname (&data->host, hostname) == -1)
+  if (knocker_core_gethostbyname (&data->host, hostname, family) == -1)
     return NULL;
   else
     return (data->host.ip);
@@ -506,14 +510,14 @@
    ============================================================================
    ============================================================================
 */
-static int knocker_core_open_socket (knocker_core_socket_t * sock, int protocol)
+static int knocker_core_open_socket (knocker_core_socket_t * sock, int family, int protocol)
 {
 #ifdef DEBUG
   fprintf (stderr, "debug: function knocker_core_open_socket (...) called.\n");
 #endif
   if (protocol == PROTO_TCP)
     {
-      if ((sock->fd = socket (AF_INET, SOCK_STREAM, 0)) == KNOCKER_SOCKET_ERROR)
+      if ((sock->fd = socket (family, SOCK_STREAM, 0)) == KNOCKER_SOCKET_ERROR)
         {
 #ifdef DEBUG
           fprintf (stderr, "debug: couldn't open the socket: ");
@@ -524,7 +528,7 @@
     }
   else if (protocol == PROTO_UDP)
     {
-      if ((sock->fd = socket (AF_INET, SOCK_DGRAM, 0)) == KNOCKER_SOCKET_ERROR)
+      if ((sock->fd = socket (family, SOCK_DGRAM, 0)) == KNOCKER_SOCKET_ERROR)
         {
 #ifdef DEBUG
           fprintf (stderr, "debug: couldn't open the socket: ");
@@ -579,13 +583,47 @@
    ============================================================================
    ============================================================================
 */
-static int knocker_core_gethostbyname (knocker_core_host_t * hinfo, const char *hostname)
+static int knocker_core_gethostbyname (knocker_core_host_t * hinfo, const char *hostname, int family)
 {
-  if ((hinfo->info = gethostbyname (hostname)) == NULL)
+  struct addrinfo hints, *res, *ai;
+  char hostip[INET6_ADDRSTRLEN];
+  int err, fd;
+
+  memset (&hints, 0, sizeof (hints));
+  hints.ai_family = family;
+  hints.ai_flags = AI_ADDRCONFIG;
+
+  if ( (err = getaddrinfo (hostname, NULL, &hints, &res)) ) {
+#ifdef DEBUG
+    fprintf (stderr, "debug: knocker_core_gethostbyname(): %s", gai_strerror(err));
+#endif
+    return -1;
+  }
+
+  for (ai = res; ai; ai = ai->ai_next) {
+    if ( (ai->ai_family != AF_INET) && (ai->ai_family != AF_INET6) )
+      continue;
+
+    fd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
+    if (fd < 0)
+      continue;
+    /* Valid socket indicates a functional address; accept it. */
+    close (fd);
+    hinfo->addrlen = ai->ai_addrlen;
+    memcpy(&(hinfo->hostaddr), ai->ai_addr, ai->ai_addrlen);
+    break;
+  }
+
+  if (res)
+    freeaddrinfo(res);
+
+  if (ai == NULL)
     return -1;
 
   knocker_core_set_host_name_string (hinfo, hostname);
-  knocker_core_set_host_ip_string (hinfo, inet_ntoa (*(struct in_addr *) *hinfo->info->h_addr_list));
+  getnameinfo ((struct sockaddr *) &(hinfo->hostaddr), hinfo->addrlen,
+      hostip, sizeof (hostip), NULL, 0, NI_NUMERICHOST);
+  knocker_core_set_host_ip_string (hinfo, hostip);
 
   return 0;
 }
--- knocker-0.7.1.orig/src/knocker_conf.c
+++ knocker-0.7.1/src/knocker_conf.c
@@ -223,6 +223,8 @@
 {
   char *tmpp = malloc (strlen (line));
   char *p = malloc (strlen (line));
+  char *tmpp_orig = tmpp;
+  char *p_orig = p;
 
   /* Check if the option is present in the line */
   tmpp = strstr (line, opt);
@@ -234,7 +236,7 @@
 
   if (!_isblank (*tmpp) || *tmpp != KNOCKER_OPTION_TOKEN)
     {
-      free (tmpp);
+      free (tmpp_orig);
       return 0;
     }
 
@@ -247,8 +249,7 @@
 
   strcpy (value, p);
 
-  /* free(p); this cause knocker to segfault */
-  /* well I have to know why... */
+  free(p_orig);
 
   return 1;
 }
--- knocker-0.7.1.orig/src/knocker_core.h
+++ knocker-0.7.1/src/knocker_core.h
@@ -135,8 +135,9 @@
 */
 
 typedef struct {
-  struct hostent                   *info;        /* hostent structure */
-  struct sockaddr_in               sockaddr_in;  /* sockaddr_in structure */
+  struct sockaddr_storage          hostaddr;     /* template address */
+  socklen_t                        addrlen;      /* active length */
+  struct sockaddr_storage          sockaddr_st;  /* working address */
   char                             *name;        /* hostname string   */
   char                             *ip;          /* host IP address string */
 } knocker_core_host_t;
@@ -185,7 +186,7 @@
 int   knocker_core_validate_port_number (unsigned int port);
 
 /* returns host ip address on success, NULL on failure */
-char *knocker_core_resolve_host (knocker_core_portscan_data_t *data, const char *hostname);
+char *knocker_core_resolve_host (knocker_core_portscan_data_t *data, const char *hostname, int family);
 
 /* return the hostname string from the structure */
 char *knocker_core_get_hostname (knocker_core_portscan_data_t *data);
@@ -203,13 +204,13 @@
 
 static int  knocker_core_init_socket_data   (knocker_core_socket_t *sock);
 static void knocker_core_free_socket_data   (knocker_core_socket_t *sock);
-static int  knocker_core_open_socket   (knocker_core_socket_t *sock, int protocol);
+static int  knocker_core_open_socket   (knocker_core_socket_t *sock, int family, int protocol);
 static void knocker_core_close_socket  (knocker_core_socket_t *sock);
 
 static int  knocker_core_init_host_data   (knocker_core_host_t *host);
 static void knocker_core_free_host_data   (knocker_core_host_t *host);
 
-static int   knocker_core_gethostbyname    (knocker_core_host_t *hinfo, const char *hostname);
+static int   knocker_core_gethostbyname    (knocker_core_host_t *hinfo, const char *hostname, int family);
 static int   knocker_core_getservbyport    (char *service, unsigned int port, int protocol);
 
 static char *knocker_core_get_host_name_string (knocker_core_host_t *hinfo);
--- knocker-0.7.1.orig/src/knocker_args.c
+++ knocker-0.7.1/src/knocker_args.c
@@ -80,9 +80,11 @@
   fprintf (stdout, "      %s              performs again the last port scan\n", LAST_SCAN_LONG_OPT);
   fprintf (stdout, "\n");
   fprintf (stdout, "Extra options:\n");
+  fprintf (stdout, "      %s,  %s              only IPv4 host addressing\n", HOST_IPV4_SHORT_OPT, HOST_IPV4_LONG_OPT);
+  fprintf (stdout, "      %s,  %s              only IPv6 host addressing\n", HOST_IPV6_SHORT_OPT, HOST_IPV6_LONG_OPT);
   fprintf (stdout, "      %s,  %s             quiet mode (no console output, logs to file)\n", QUIET_MODE_SHORT_OPT, QUIET_MODE_LONG_OPT);
   fprintf (stdout, "      %s, %s <logfile> log scan results to the specified file\n", ENABLE_LOGFILE_SHORT_OPT, ENABLE_LOGFILE_LONG_OPT);
-  fprintf (stdout, "      %s, %s          disable fency output\n", NO_FENCY_SHORT_OPT, NO_FENCY_LONG_OPT);
+  fprintf (stdout, "      %s, %s          disable fancy output\n", NO_FENCY_SHORT_OPT, NO_FENCY_LONG_OPT);
   fprintf (stdout, "      %s, %s         disable colored output\n", NO_COLORS_SHORT_OPT, NO_COLORS_LONG_OPT);
   fprintf (stdout, "\n");
   fprintf (stdout, "      %s              let you configure %s\n", CONFIGURE_LONG_OPT, PACKAGE);
@@ -105,6 +107,7 @@
   args->hname = NULL;
   args->hip = NULL;
   args->lfname = NULL;
+  args->hfamily = AF_UNSPEC;
   args->port = 0;
   args->sport = 0;
   args->eport = 0;
@@ -189,6 +192,16 @@
             }
           return (0);           /* we should have all arguments here */
         }
+      else if ((!strcmp (argv[i], HOST_IPV4_SHORT_OPT)) || (!strcmp (argv[i], HOST_IPV4_LONG_OPT)))
+        {
+          /* Accept only IPv4 addressing. */
+          args->hfamily = AF_INET;
+        }
+      else if ((!strcmp (argv[i], HOST_IPV6_SHORT_OPT)) || (!strcmp (argv[i], HOST_IPV6_LONG_OPT)))
+        {
+          /* Accept only IPv6 addressing. */
+          args->hfamily = AF_INET6;
+        }
       else if ((!strcmp (argv[i], NO_FENCY_SHORT_OPT)) || (!strcmp (argv[i], NO_FENCY_LONG_OPT)))
         {
           /* Disable fency output */
--- knocker-0.7.1.orig/src/knocker_main.c
+++ knocker-0.7.1/src/knocker_main.c
@@ -67,12 +67,12 @@
 
   knocker_args_init (&knocker_args, FALSE, FALSE, TRUE);
 
-  knocker_args_parse (&knocker_args, argc, argv);
-
   if (knocker_conf_parse () < 0)
     /* write a default conf file for the user if it is not already there. */
     knocker_conf_write_default ();
 
+  knocker_args_parse (&knocker_args, argc, argv);
+  
   knocker_core_init_portscan_data (&pscan_data);
 
   if (knocker_args.fency)
@@ -132,7 +132,7 @@
 */
 static void resolve (void)
 {
-  if (knocker_core_resolve_host (&pscan_data, knocker_args.hname) == NULL)
+  if (knocker_core_resolve_host (&pscan_data, knocker_args.hname, knocker_args.hfamily) == NULL)
     {
       knocker_output_resolve_error (knocker_args.hname);
       knocker_log_resolve_error (knocker_args.hname);
