[Pkg-privacy-commits] [onioncat] 166/340: merged Windows branch into trunk
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 13:04:36 UTC 2015
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch debian
in repository onioncat.
commit 6bfa04076c364fc7a162b33c9e0c90ebf6d6d139
Author: eagle <eagle at 58e1ccc2-750e-0410-8d0d-f93ca75ab447>
Date: Sun Mar 1 21:12:54 2009 +0000
merged Windows branch into trunk
git-svn-id: http://www.cypherpunk.at/svn/onioncat/trunk@486 58e1ccc2-750e-0410-8d0d-f93ca75ab447
---
ChangeLog | 1 +
Makefile.am | 4 +-
Makefile.in | 4 +-
config.h.in | 3 +
configure | 28 +-
configure.ac | 4 +-
src/Makefile.am | 2 +-
src/Makefile.in | 5 +-
src/cygwin/Makefile.am | 2 +
{man => src/cygwin}/Makefile.in | 160 +++++----
src/cygwin/ocat_cygwin.h | 61 ++++
src/cygwin/openbsd_netinet_icmp6.h | 655 ++++++++++++++++++++++++++++++++++
src/cygwin/openbsd_netinet_if_ether.h | 248 +++++++++++++
src/cygwin/openbsd_netinet_ip6.h | 276 ++++++++++++++
src/ocat.c | 10 +-
src/ocat.h | 46 +--
src/ocat_wintuntap.c | 308 ++++++++++++++++
src/ocateth.c | 28 ++
src/ocatroute.c | 15 +
src/ocatsetup.c | 14 +-
src/ocattun.c | 42 ++-
21 files changed, 1785 insertions(+), 131 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d3db35c..67b378f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,5 @@
* version 0.1.12
+ - Windows branch merges into trunk
- syslogging implemented
* version 0.1.11
diff --git a/Makefile.am b/Makefile.am
index 8d5eee9..48715bc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = src man
-DIST_SUBDIRS = src man
+SUBDIRS = src man src/cygwin
+DIST_SUBDIRS = src/cygwin src man
dist_doc_DATA = README
diff --git a/Makefile.in b/Makefile.in
index ce1f2ab..25c6a73 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -162,8 +162,8 @@ sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-SUBDIRS = src man
-DIST_SUBDIRS = src man
+SUBDIRS = src man src/cygwin
+DIST_SUBDIRS = src/cygwin src man
dist_doc_DATA = README
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
diff --git a/config.h.in b/config.h.in
index 874163d..8c3db70 100644
--- a/config.h.in
+++ b/config.h.in
@@ -12,6 +12,9 @@
/* Define to 1 if you have the <endian.h> header file. */
#undef HAVE_ENDIAN_H
+/* Define to 1 if you have the `ether_ntoa' function. */
+#undef HAVE_ETHER_NTOA
+
/* Define to 1 if you have the `ether_ntoa_r' function. */
#undef HAVE_ETHER_NTOA_R
diff --git a/configure b/configure
index a0136d8..e8974c8 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.61 for onioncat 0.1.12-484M.
+# Generated by GNU Autoconf 2.61 for onioncat 0.1.12-485M.
#
# Report bugs to <rahra at cypherpunk.at>.
#
@@ -574,8 +574,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='onioncat'
PACKAGE_TARNAME='onioncat'
-PACKAGE_VERSION='0.1.12-484M'
-PACKAGE_STRING='onioncat 0.1.12-484M'
+PACKAGE_VERSION='0.1.12-485M'
+PACKAGE_STRING='onioncat 0.1.12-485M'
PACKAGE_BUGREPORT='rahra at cypherpunk.at'
# Factoring default headers for most tests.
@@ -1206,7 +1206,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures onioncat 0.1.12-484M to adapt to many kinds of systems.
+\`configure' configures onioncat 0.1.12-485M to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1272,7 +1272,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of onioncat 0.1.12-484M:";;
+ short | recursive ) echo "Configuration of onioncat 0.1.12-485M:";;
esac
cat <<\_ACEOF
@@ -1362,7 +1362,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-onioncat configure 0.1.12-484M
+onioncat configure 0.1.12-485M
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1376,7 +1376,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by onioncat $as_me 0.1.12-484M, which was
+It was created by onioncat $as_me 0.1.12-485M, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
@@ -2066,7 +2066,7 @@ fi
# Define the identity of the package.
PACKAGE='onioncat'
- VERSION='0.1.12-484M'
+ VERSION='0.1.12-485M'
cat >>confdefs.h <<_ACEOF
@@ -2217,7 +2217,7 @@ ac_config_headers="$ac_config_headers config.h"
cat >>confdefs.h <<\_ACEOF
-#define SVN_REVISION "484M"
+#define SVN_REVISION "485M"
_ACEOF
@@ -4794,7 +4794,8 @@ fi
-for ac_func in strlcat strlcpy ether_ntoa_r readline
+
+for ac_func in strlcat strlcpy ether_ntoa ether_ntoa_r readline
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
{ echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -4888,7 +4889,7 @@ fi
done
-ac_config_files="$ac_config_files Makefile src/Makefile man/Makefile"
+ac_config_files="$ac_config_files Makefile src/cygwin/Makefile src/Makefile man/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -5300,7 +5301,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by onioncat $as_me 0.1.12-484M, which was
+This file was extended by onioncat $as_me 0.1.12-485M, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -5353,7 +5354,7 @@ Report bugs to <bug-autoconf at gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-onioncat config.status 0.1.12-484M
+onioncat config.status 0.1.12-485M
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
@@ -5470,6 +5471,7 @@ do
"config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
"depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+ "src/cygwin/Makefile") CONFIG_FILES="$CONFIG_FILES src/cygwin/Makefile" ;;
"src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
"man/Makefile") CONFIG_FILES="$CONFIG_FILES man/Makefile" ;;
diff --git a/configure.ac b/configure.ac
index 38d7ee4..a431c26 100644
--- a/configure.ac
+++ b/configure.ac
@@ -122,8 +122,8 @@ AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
#AC_FUNC_STRFTIME
#AC_FUNC_VPRINTF
#AC_CHECK_FUNCS([clock_gettime memset select socket strchr strerror])
-AC_CHECK_FUNCS([strlcat strlcpy ether_ntoa_r readline])
+AC_CHECK_FUNCS([strlcat strlcpy ether_ntoa ether_ntoa_r readline])
-AC_CONFIG_FILES([Makefile src/Makefile man/Makefile])
+AC_CONFIG_FILES([Makefile src/cygwin/Makefile src/Makefile man/Makefile])
AC_OUTPUT
diff --git a/src/Makefile.am b/src/Makefile.am
index 95b3b60..5a0f1d1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,4 @@
bin_PROGRAMS = ocat
-ocat_SOURCES = ocat.c ocatlog.c ocatroute.c ocatthread.c ocattun.c ocatv6conv.c ocatcompat.c ocatpeer.c ocatsetup.c ocatipv4route.c ocateth.c ocatsocks.c ocatlibe.c ocatctrl.c ocatipv6route.c ocaticmp.c
+ocat_SOURCES = ocat.c ocatlog.c ocatroute.c ocatthread.c ocattun.c ocatv6conv.c ocatcompat.c ocatpeer.c ocatsetup.c ocatipv4route.c ocateth.c ocatsocks.c ocatlibe.c ocatctrl.c ocatipv6route.c ocaticmp.c ocat_wintuntap.c
include_HEADERS = ocat.h strlcpy.c strlcat.c
diff --git a/src/Makefile.in b/src/Makefile.in
index 48eaf6c..2cdcd04 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -50,7 +50,7 @@ am_ocat_OBJECTS = ocat.$(OBJEXT) ocatlog.$(OBJEXT) ocatroute.$(OBJEXT) \
ocatcompat.$(OBJEXT) ocatpeer.$(OBJEXT) ocatsetup.$(OBJEXT) \
ocatipv4route.$(OBJEXT) ocateth.$(OBJEXT) ocatsocks.$(OBJEXT) \
ocatlibe.$(OBJEXT) ocatctrl.$(OBJEXT) ocatipv6route.$(OBJEXT) \
- ocaticmp.$(OBJEXT)
+ ocaticmp.$(OBJEXT) ocat_wintuntap.$(OBJEXT)
ocat_OBJECTS = $(am_ocat_OBJECTS)
ocat_LDADD = $(LDADD)
DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
@@ -157,7 +157,7 @@ sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-ocat_SOURCES = ocat.c ocatlog.c ocatroute.c ocatthread.c ocattun.c ocatv6conv.c ocatcompat.c ocatpeer.c ocatsetup.c ocatipv4route.c ocateth.c ocatsocks.c ocatlibe.c ocatctrl.c ocatipv6route.c ocaticmp.c
+ocat_SOURCES = ocat.c ocatlog.c ocatroute.c ocatthread.c ocattun.c ocatv6conv.c ocatcompat.c ocatpeer.c ocatsetup.c ocatipv4route.c ocateth.c ocatsocks.c ocatlibe.c ocatctrl.c ocatipv6route.c ocaticmp.c ocat_wintuntap.c
include_HEADERS = ocat.h strlcpy.c strlcat.c
all: all-am
@@ -226,6 +226,7 @@ distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ocat.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ocat_wintuntap.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ocatcompat.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ocatctrl.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ocateth.Po at am__quote@
diff --git a/src/cygwin/Makefile.am b/src/cygwin/Makefile.am
new file mode 100644
index 0000000..cf195af
--- /dev/null
+++ b/src/cygwin/Makefile.am
@@ -0,0 +1,2 @@
+include_HEADERS = ocat_cygwin.h openbsd_netinet_icmp6.h openbsd_netinet_if_ether.h openbsd_netinet_ip6.h
+
diff --git a/man/Makefile.in b/src/cygwin/Makefile.in
similarity index 66%
copy from man/Makefile.in
copy to src/cygwin/Makefile.in
index af25ced..dd3d132 100644
--- a/man/Makefile.in
+++ b/src/cygwin/Makefile.in
@@ -13,6 +13,7 @@
# PARTICULAR PURPOSE.
@SET_MAKE@
+
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@@ -29,8 +30,9 @@ POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
-subdir = man
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+subdir = src/cygwin
+DIST_COMMON = $(include_HEADERS) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
@@ -40,10 +42,17 @@ CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
-man1dir = $(mandir)/man1
-am__installdirs = "$(DESTDIR)$(man1dir)"
-NROFF = nroff
-MANS = $(man_MANS)
+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 = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(includedir)"
+includeHEADERS_INSTALL = $(INSTALL_HEADER)
+HEADERS = $(include_HEADERS)
+ETAGS = etags
+CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
@@ -129,8 +138,7 @@ sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-EXTRA_DIST = ocat.1
-man_MANS = ocat.1
+include_HEADERS = ocat_cygwin.h openbsd_netinet_icmp6.h openbsd_netinet_if_ether.h openbsd_netinet_ip6.h
all: all-am
.SUFFIXES:
@@ -143,9 +151,9 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
exit 1;; \
esac; \
done; \
- echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu man/Makefile'; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/cygwin/Makefile'; \
cd $(top_srcdir) && \
- $(AUTOMAKE) --gnu man/Makefile
+ $(AUTOMAKE) --gnu src/cygwin/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
@@ -163,57 +171,70 @@ $(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-install-man1: $(man1_MANS) $(man_MANS)
+install-includeHEADERS: $(include_HEADERS)
@$(NORMAL_INSTALL)
- test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)"
- @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \
- l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
- for i in $$l2; do \
- case "$$i" in \
- *.1*) list="$$list $$i" ;; \
- esac; \
- done; \
- for i in $$list; do \
- if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
- else file=$$i; fi; \
- ext=`echo $$i | sed -e 's/^.*\\.//'`; \
- case "$$ext" in \
- 1*) ;; \
- *) ext='1' ;; \
- esac; \
- inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
- inst=`echo $$inst | sed -e 's/^.*\///'`; \
- inst=`echo $$inst | sed '$(transform)'`.$$ext; \
- echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
- $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst"; \
+ test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)"
+ @list='$(include_HEADERS)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ f=$(am__strip_dir) \
+ echo " $(includeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(includedir)/$$f'"; \
+ $(includeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(includedir)/$$f"; \
done
-uninstall-man1:
+
+uninstall-includeHEADERS:
@$(NORMAL_UNINSTALL)
- @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \
- l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
- for i in $$l2; do \
- case "$$i" in \
- *.1*) list="$$list $$i" ;; \
- esac; \
- done; \
- for i in $$list; do \
- ext=`echo $$i | sed -e 's/^.*\\.//'`; \
- case "$$ext" in \
- 1*) ;; \
- *) ext='1' ;; \
- esac; \
- inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
- inst=`echo $$inst | sed -e 's/^.*\///'`; \
- inst=`echo $$inst | sed '$(transform)'`.$$ext; \
- echo " rm -f '$(DESTDIR)$(man1dir)/$$inst'"; \
- rm -f "$(DESTDIR)$(man1dir)/$$inst"; \
+ @list='$(include_HEADERS)'; for p in $$list; do \
+ f=$(am__strip_dir) \
+ echo " rm -f '$(DESTDIR)$(includedir)/$$f'"; \
+ rm -f "$(DESTDIR)$(includedir)/$$f"; \
done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
tags: TAGS
-TAGS:
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
ctags: CTAGS
-CTAGS:
-
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
@@ -243,9 +264,9 @@ distdir: $(DISTFILES)
done
check-am: all-am
check: check-am
-all-am: Makefile $(MANS)
+all-am: Makefile $(HEADERS)
installdirs:
- for dir in "$(DESTDIR)$(man1dir)"; do \
+ for dir in "$(DESTDIR)$(includedir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
@@ -278,7 +299,7 @@ clean-am: clean-generic mostlyclean-am
distclean: distclean-am
-rm -f Makefile
-distclean-am: clean-am distclean-generic
+distclean-am: clean-am distclean-generic distclean-tags
dvi: dvi-am
@@ -290,7 +311,7 @@ info: info-am
info-am:
-install-data-am: install-man
+install-data-am: install-includeHEADERS
install-dvi: install-dvi-am
@@ -300,7 +321,7 @@ install-html: install-html-am
install-info: install-info-am
-install-man: install-man1
+install-man:
install-pdf: install-pdf-am
@@ -324,22 +345,21 @@ ps: ps-am
ps-am:
-uninstall-am: uninstall-man
-
-uninstall-man: uninstall-man1
+uninstall-am: uninstall-includeHEADERS
.MAKE: install-am install-strip
-.PHONY: all all-am check check-am clean clean-generic distclean \
- distclean-generic 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-man1 install-pdf install-pdf-am install-ps \
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ ctags distclean 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-includeHEADERS install-info install-info-am \
+ install-man install-pdf install-pdf-am install-ps \
install-ps-am install-strip installcheck installcheck-am \
installdirs maintainer-clean maintainer-clean-generic \
- mostlyclean mostlyclean-generic pdf pdf-am ps ps-am uninstall \
- uninstall-am uninstall-man uninstall-man1
+ mostlyclean mostlyclean-generic pdf pdf-am ps ps-am tags \
+ uninstall uninstall-am uninstall-includeHEADERS
# 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.
diff --git a/src/cygwin/ocat_cygwin.h b/src/cygwin/ocat_cygwin.h
new file mode 100644
index 0000000..481af68
--- /dev/null
+++ b/src/cygwin/ocat_cygwin.h
@@ -0,0 +1,61 @@
+/* Copyright 2008-2009 Bernhard R. Fischer.
+ *
+ * This file is part of OnionCat.
+ *
+ * OnionCat is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OnionCat is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OnionCat. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/** This file contains missing headers for the IPv6 system part of
+ * OnionCat.
+ * There are several definitions at the beginning.
+ *
+ * At the bottom it includes three header files files which
+ * are taken directly from OpenBSD. Those files have been
+ * truncated by unnecessary code lines mainly the KERNEL stuff.
+ */
+
+#ifndef OCAT_CYGWIN_H
+#define OCAT_CYGWIN_H
+
+#ifndef IPPROTO_NONE
+#define IPPROTO_NONE 59
+#endif
+#ifndef MSG_DONTWAIT
+#define MSG_DONTWAIT 0x40
+#endif
+#ifndef IPPROTO_ICMPV6
+#define IPPROTO_ICMPV6 58
+#endif
+
+// this seems to be missing in Cygwin/w32api 1.5.25-15 IPv6 extension 0.22
+// (2008/07/05) (author contacted on 2009/02/24)
+#ifndef IPV6_ADDR_MC_SCOPE
+#define IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f)
+#endif
+
+//! '__packed' is defined in OpenBSD's sys/cdefs.h
+#define __packed __attribute__((packed))
+
+//! 'LIST_ENTRY' is defined in OpenBSD's sys/queue.h
+#define LIST_ENTRY(type) \
+struct { \
+ struct type *le_next; /* next element */ \
+ struct type **le_prev; /* address of previous next element */ \
+}
+
+#include "openbsd_netinet_ip6.h"
+#include "openbsd_netinet_icmp6.h"
+#include "openbsd_netinet_if_ether.h"
+
+#endif
+
diff --git a/src/cygwin/openbsd_netinet_icmp6.h b/src/cygwin/openbsd_netinet_icmp6.h
new file mode 100644
index 0000000..cdfeae6
--- /dev/null
+++ b/src/cygwin/openbsd_netinet_icmp6.h
@@ -0,0 +1,655 @@
+/* Copyright 2008-2009 Bernhard R. Fischer.
+ *
+ * This file is part of OnionCat.
+ *
+ * OnionCat is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OnionCat is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OnionCat. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*! This file is taken originally from OpenBSD and has been truncated
+ * by unnecessary code lines within this context. */
+
+
+/* $OpenBSD: icmp6.h,v 1.32 2006/07/06 02:56:58 brad Exp $ */
+/* $KAME: icmp6.h,v 1.84 2003/04/23 10:26:51 itojun Exp $ */
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ip_icmp.h 8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _NETINET_ICMP6_H_
+#define _NETINET_ICMP6_H_
+
+#define ICMPV6_PLD_MAXLEN 1232 /* IPV6_MMTU - sizeof(struct ip6_hdr)
+ - sizeof(struct icmp6_hdr) */
+
+struct icmp6_hdr {
+ u_int8_t icmp6_type; /* type field */
+ u_int8_t icmp6_code; /* code field */
+ u_int16_t icmp6_cksum; /* checksum field */
+ union {
+ u_int32_t icmp6_un_data32[1]; /* type-specific field */
+ u_int16_t icmp6_un_data16[2]; /* type-specific field */
+ u_int8_t icmp6_un_data8[4]; /* type-specific field */
+ } icmp6_dataun;
+} __packed;
+
+#define icmp6_data32 icmp6_dataun.icmp6_un_data32
+#define icmp6_data16 icmp6_dataun.icmp6_un_data16
+#define icmp6_data8 icmp6_dataun.icmp6_un_data8
+#define icmp6_pptr icmp6_data32[0] /* parameter prob */
+#define icmp6_mtu icmp6_data32[0] /* packet too big */
+#define icmp6_id icmp6_data16[0] /* echo request/reply */
+#define icmp6_seq icmp6_data16[1] /* echo request/reply */
+#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
+
+#define ICMP6_DST_UNREACH 1 /* dest unreachable, codes: */
+#define ICMP6_PACKET_TOO_BIG 2 /* packet too big */
+#define ICMP6_TIME_EXCEEDED 3 /* time exceeded, code: */
+#define ICMP6_PARAM_PROB 4 /* ip6 header bad */
+
+#define ICMP6_ECHO_REQUEST 128 /* echo service */
+#define ICMP6_ECHO_REPLY 129 /* echo reply */
+#define MLD_LISTENER_QUERY 130 /* multicast listener query */
+#define MLD_LISTENER_REPORT 131 /* multicast listener report */
+#define MLD_LISTENER_DONE 132 /* multicast listener done */
+
+/* RFC2292 decls */
+#define ICMP6_MEMBERSHIP_QUERY 130 /* group membership query */
+#define ICMP6_MEMBERSHIP_REPORT 131 /* group membership report */
+#define ICMP6_MEMBERSHIP_REDUCTION 132 /* group membership termination */
+
+#ifndef _KERNEL
+/* the followings are for backward compatibility to old KAME apps. */
+#define MLD6_LISTENER_QUERY MLD_LISTENER_QUERY
+#define MLD6_LISTENER_REPORT MLD_LISTENER_REPORT
+#define MLD6_LISTENER_DONE MLD_LISTENER_DONE
+#endif
+
+#define ND_ROUTER_SOLICIT 133 /* router solicitation */
+#define ND_ROUTER_ADVERT 134 /* router advertisement */
+#define ND_NEIGHBOR_SOLICIT 135 /* neighbor solicitation */
+#define ND_NEIGHBOR_ADVERT 136 /* neighbor advertisement */
+#define ND_REDIRECT 137 /* redirect */
+
+#define ICMP6_ROUTER_RENUMBERING 138 /* router renumbering */
+
+#define ICMP6_WRUREQUEST 139 /* who are you request */
+#define ICMP6_WRUREPLY 140 /* who are you reply */
+#define ICMP6_FQDN_QUERY 139 /* FQDN query */
+#define ICMP6_FQDN_REPLY 140 /* FQDN reply */
+#define ICMP6_NI_QUERY 139 /* node information request */
+#define ICMP6_NI_REPLY 140 /* node information reply */
+
+/* The definitions below are experimental. TBA */
+#define MLD_MTRACE_RESP 200 /* mtrace response(to sender) */
+#define MLD_MTRACE 201 /* mtrace messages */
+
+#ifndef _KERNEL
+/* the followings are for backward compatibility to old KAME apps. */
+#define MLD6_MTRACE_RESP MLD_MTRACE_RESP
+#define MLD6_MTRACE MLD_MTRACE
+#endif
+
+#define ICMP6_MAXTYPE 201
+
+#define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
+#define ICMP6_DST_UNREACH_ADMIN 1 /* administratively prohibited */
+#define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /* not a neighbor(obsolete) */
+#define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
+#define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
+#define ICMP6_DST_UNREACH_NOPORT 4 /* port unreachable */
+
+#define ICMP6_TIME_EXCEED_TRANSIT 0 /* ttl==0 in transit */
+#define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* ttl==0 in reass */
+
+#define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
+#define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized next header */
+#define ICMP6_PARAMPROB_OPTION 2 /* unrecognized option */
+
+#define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
+
+#define ICMP6_NI_SUBJ_IPV6 0 /* Query Subject is an IPv6 address */
+#define ICMP6_NI_SUBJ_FQDN 1 /* Query Subject is a Domain name */
+#define ICMP6_NI_SUBJ_IPV4 2 /* Query Subject is an IPv4 address */
+
+#define ICMP6_NI_SUCCESS 0 /* node information successful reply */
+#define ICMP6_NI_REFUSED 1 /* node information request is refused */
+#define ICMP6_NI_UNKNOWN 2 /* unknown Qtype */
+
+#define ICMP6_ROUTER_RENUMBERING_COMMAND 0 /* rr command */
+#define ICMP6_ROUTER_RENUMBERING_RESULT 1 /* rr result */
+#define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET 255 /* rr seq num reset */
+
+/* Used in kernel only */
+#define ND_REDIRECT_ONLINK 0 /* redirect to an on-link node */
+#define ND_REDIRECT_ROUTER 1 /* redirect to a better router */
+
+/*
+ * Multicast Listener Discovery
+ */
+struct mld_hdr {
+ struct icmp6_hdr mld_icmp6_hdr;
+ struct in6_addr mld_addr; /* multicast address */
+} __packed;
+
+/* definitions to provide backward compatibility to old KAME applications */
+#ifndef _KERNEL
+#define mld6_hdr mld_hdr
+#define mld6_type mld_type
+#define mld6_code mld_code
+#define mld6_cksum mld_cksum
+#define mld6_maxdelay mld_maxdelay
+#define mld6_reserved mld_reserved
+#define mld6_addr mld_addr
+#endif
+
+/* shortcut macro definitions */
+#define mld_type mld_icmp6_hdr.icmp6_type
+#define mld_code mld_icmp6_hdr.icmp6_code
+#define mld_cksum mld_icmp6_hdr.icmp6_cksum
+#define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0]
+#define mld_reserved mld_icmp6_hdr.icmp6_data16[1]
+
+/*
+ * Neighbor Discovery
+ */
+
+struct nd_router_solicit { /* router solicitation */
+ struct icmp6_hdr nd_rs_hdr;
+ /* could be followed by options */
+} __packed;
+
+#define nd_rs_type nd_rs_hdr.icmp6_type
+#define nd_rs_code nd_rs_hdr.icmp6_code
+#define nd_rs_cksum nd_rs_hdr.icmp6_cksum
+#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
+
+struct nd_router_advert { /* router advertisement */
+ struct icmp6_hdr nd_ra_hdr;
+ u_int32_t nd_ra_reachable; /* reachable time */
+ u_int32_t nd_ra_retransmit; /* retransmit timer */
+ /* could be followed by options */
+} __packed;
+
+#define nd_ra_type nd_ra_hdr.icmp6_type
+#define nd_ra_code nd_ra_hdr.icmp6_code
+#define nd_ra_cksum nd_ra_hdr.icmp6_cksum
+#define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
+#define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
+#define ND_RA_FLAG_MANAGED 0x80
+#define ND_RA_FLAG_OTHER 0x40
+#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
+
+struct nd_neighbor_solicit { /* neighbor solicitation */
+ struct icmp6_hdr nd_ns_hdr;
+ struct in6_addr nd_ns_target; /*target address */
+ /* could be followed by options */
+} __packed;
+
+#define nd_ns_type nd_ns_hdr.icmp6_type
+#define nd_ns_code nd_ns_hdr.icmp6_code
+#define nd_ns_cksum nd_ns_hdr.icmp6_cksum
+#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
+
+struct nd_neighbor_advert { /* neighbor advertisement */
+ struct icmp6_hdr nd_na_hdr;
+ struct in6_addr nd_na_target; /* target address */
+ /* could be followed by options */
+} __packed;
+
+#define nd_na_type nd_na_hdr.icmp6_type
+#define nd_na_code nd_na_hdr.icmp6_code
+#define nd_na_cksum nd_na_hdr.icmp6_cksum
+#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
+#if _BYTE_ORDER == _BIG_ENDIAN
+#define ND_NA_FLAG_ROUTER 0x80000000
+#define ND_NA_FLAG_SOLICITED 0x40000000
+#define ND_NA_FLAG_OVERRIDE 0x20000000
+#else
+#if _BYTE_ORDER == _LITTLE_ENDIAN
+#define ND_NA_FLAG_ROUTER 0x80
+#define ND_NA_FLAG_SOLICITED 0x40
+#define ND_NA_FLAG_OVERRIDE 0x20
+#endif
+#endif
+
+struct nd_redirect { /* redirect */
+ struct icmp6_hdr nd_rd_hdr;
+ struct in6_addr nd_rd_target; /* target address */
+ struct in6_addr nd_rd_dst; /* destination address */
+ /* could be followed by options */
+} __packed;
+
+#define nd_rd_type nd_rd_hdr.icmp6_type
+#define nd_rd_code nd_rd_hdr.icmp6_code
+#define nd_rd_cksum nd_rd_hdr.icmp6_cksum
+#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
+
+struct nd_opt_hdr { /* Neighbor discovery option header */
+ u_int8_t nd_opt_type;
+ u_int8_t nd_opt_len;
+ /* followed by option specific data*/
+} __packed;
+
+#define ND_OPT_SOURCE_LINKADDR 1
+#define ND_OPT_TARGET_LINKADDR 2
+#define ND_OPT_PREFIX_INFORMATION 3
+#define ND_OPT_REDIRECTED_HEADER 4
+#define ND_OPT_MTU 5
+
+struct nd_opt_prefix_info { /* prefix information */
+ u_int8_t nd_opt_pi_type;
+ u_int8_t nd_opt_pi_len;
+ u_int8_t nd_opt_pi_prefix_len;
+ u_int8_t nd_opt_pi_flags_reserved;
+ u_int32_t nd_opt_pi_valid_time;
+ u_int32_t nd_opt_pi_preferred_time;
+ u_int32_t nd_opt_pi_reserved2;
+ struct in6_addr nd_opt_pi_prefix;
+} __packed;
+
+#define ND_OPT_PI_FLAG_ONLINK 0x80
+#define ND_OPT_PI_FLAG_AUTO 0x40
+
+struct nd_opt_rd_hdr { /* redirected header */
+ u_int8_t nd_opt_rh_type;
+ u_int8_t nd_opt_rh_len;
+ u_int16_t nd_opt_rh_reserved1;
+ u_int32_t nd_opt_rh_reserved2;
+ /* followed by IP header and data */
+} __packed;
+
+struct nd_opt_mtu { /* MTU option */
+ u_int8_t nd_opt_mtu_type;
+ u_int8_t nd_opt_mtu_len;
+ u_int16_t nd_opt_mtu_reserved;
+ u_int32_t nd_opt_mtu_mtu;
+} __packed;
+
+/*
+ * icmp6 namelookup
+ */
+
+struct icmp6_namelookup {
+ struct icmp6_hdr icmp6_nl_hdr;
+ u_int8_t icmp6_nl_nonce[8];
+ int32_t icmp6_nl_ttl;
+#if 0
+ u_int8_t icmp6_nl_len;
+ u_int8_t icmp6_nl_name[3];
+#endif
+ /* could be followed by options */
+} __packed;
+
+/*
+ * icmp6 node information
+ */
+struct icmp6_nodeinfo {
+ struct icmp6_hdr icmp6_ni_hdr;
+ u_int8_t icmp6_ni_nonce[8];
+ /* could be followed by reply data */
+} __packed;
+
+#define ni_type icmp6_ni_hdr.icmp6_type
+#define ni_code icmp6_ni_hdr.icmp6_code
+#define ni_cksum icmp6_ni_hdr.icmp6_cksum
+#define ni_qtype icmp6_ni_hdr.icmp6_data16[0]
+#define ni_flags icmp6_ni_hdr.icmp6_data16[1]
+
+#define NI_QTYPE_NOOP 0 /* NOOP */
+#define NI_QTYPE_SUPTYPES 1 /* Supported Qtypes */
+#define NI_QTYPE_FQDN 2 /* FQDN (draft 04) */
+#define NI_QTYPE_DNSNAME 2 /* DNS Name */
+#define NI_QTYPE_NODEADDR 3 /* Node Addresses */
+#define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */
+
+#if _BYTE_ORDER == _BIG_ENDIAN
+#define NI_SUPTYPE_FLAG_COMPRESS 0x1
+#define NI_FQDN_FLAG_VALIDTTL 0x1
+#elif _BYTE_ORDER == _LITTLE_ENDIAN
+#define NI_SUPTYPE_FLAG_COMPRESS 0x0100
+#define NI_FQDN_FLAG_VALIDTTL 0x0100
+#endif
+
+#ifdef NAME_LOOKUPS_04
+#if _BYTE_ORDER == _BIG_ENDIAN
+#define NI_NODEADDR_FLAG_LINKLOCAL 0x1
+#define NI_NODEADDR_FLAG_SITELOCAL 0x2
+#define NI_NODEADDR_FLAG_GLOBAL 0x4
+#define NI_NODEADDR_FLAG_ALL 0x8
+#define NI_NODEADDR_FLAG_TRUNCATE 0x10
+#define NI_NODEADDR_FLAG_ANYCAST 0x20 /* just experimental. not in spec */
+#elif _BYTE_ORDER == _LITTLE_ENDIAN
+#define NI_NODEADDR_FLAG_LINKLOCAL 0x0100
+#define NI_NODEADDR_FLAG_SITELOCAL 0x0200
+#define NI_NODEADDR_FLAG_GLOBAL 0x0400
+#define NI_NODEADDR_FLAG_ALL 0x0800
+#define NI_NODEADDR_FLAG_TRUNCATE 0x1000
+#define NI_NODEADDR_FLAG_ANYCAST 0x2000 /* just experimental. not in spec */
+#endif
+#else /* draft-ietf-ipngwg-icmp-name-lookups-05 (and later?) */
+#if _BYTE_ORDER == _BIG_ENDIAN
+#define NI_NODEADDR_FLAG_TRUNCATE 0x1
+#define NI_NODEADDR_FLAG_ALL 0x2
+#define NI_NODEADDR_FLAG_COMPAT 0x4
+#define NI_NODEADDR_FLAG_LINKLOCAL 0x8
+#define NI_NODEADDR_FLAG_SITELOCAL 0x10
+#define NI_NODEADDR_FLAG_GLOBAL 0x20
+#define NI_NODEADDR_FLAG_ANYCAST 0x40 /* just experimental. not in spec */
+#elif _BYTE_ORDER == _LITTLE_ENDIAN
+#define NI_NODEADDR_FLAG_TRUNCATE 0x0100
+#define NI_NODEADDR_FLAG_ALL 0x0200
+#define NI_NODEADDR_FLAG_COMPAT 0x0400
+#define NI_NODEADDR_FLAG_LINKLOCAL 0x0800
+#define NI_NODEADDR_FLAG_SITELOCAL 0x1000
+#define NI_NODEADDR_FLAG_GLOBAL 0x2000
+#define NI_NODEADDR_FLAG_ANYCAST 0x4000 /* just experimental. not in spec */
+#endif
+#endif
+
+struct ni_reply_fqdn {
+ u_int32_t ni_fqdn_ttl; /* TTL */
+ u_int8_t ni_fqdn_namelen; /* length in octets of the FQDN */
+ u_int8_t ni_fqdn_name[3]; /* XXX: alignment */
+} __packed;
+
+/*
+ * Router Renumbering. as router-renum-08.txt
+ */
+struct icmp6_router_renum { /* router renumbering header */
+ struct icmp6_hdr rr_hdr;
+ u_int8_t rr_segnum;
+ u_int8_t rr_flags;
+ u_int16_t rr_maxdelay;
+ u_int32_t rr_reserved;
+} __packed;
+
+#define ICMP6_RR_FLAGS_TEST 0x80
+#define ICMP6_RR_FLAGS_REQRESULT 0x40
+#define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
+#define ICMP6_RR_FLAGS_SPECSITE 0x10
+#define ICMP6_RR_FLAGS_PREVDONE 0x08
+
+#define rr_type rr_hdr.icmp6_type
+#define rr_code rr_hdr.icmp6_code
+#define rr_cksum rr_hdr.icmp6_cksum
+#define rr_seqnum rr_hdr.icmp6_data32[0]
+
+struct rr_pco_match { /* match prefix part */
+ u_int8_t rpm_code;
+ u_int8_t rpm_len;
+ u_int8_t rpm_ordinal;
+ u_int8_t rpm_matchlen;
+ u_int8_t rpm_minlen;
+ u_int8_t rpm_maxlen;
+ u_int16_t rpm_reserved;
+ struct in6_addr rpm_prefix;
+} __packed;
+
+#define RPM_PCO_ADD 1
+#define RPM_PCO_CHANGE 2
+#define RPM_PCO_SETGLOBAL 3
+#define RPM_PCO_MAX 4
+
+struct rr_pco_use { /* use prefix part */
+ u_int8_t rpu_uselen;
+ u_int8_t rpu_keeplen;
+ u_int8_t rpu_ramask;
+ u_int8_t rpu_raflags;
+ u_int32_t rpu_vltime;
+ u_int32_t rpu_pltime;
+ u_int32_t rpu_flags;
+ struct in6_addr rpu_prefix;
+} __packed;
+#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x80
+#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x40
+
+#if _BYTE_ORDER == _BIG_ENDIAN
+#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000
+#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000
+#elif _BYTE_ORDER == _LITTLE_ENDIAN
+#define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80
+#define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40
+#endif
+
+struct rr_result { /* router renumbering result message */
+ u_int16_t rrr_flags;
+ u_int8_t rrr_ordinal;
+ u_int8_t rrr_matchedlen;
+ u_int32_t rrr_ifid;
+ struct in6_addr rrr_prefix;
+} __packed;
+#if _BYTE_ORDER == _BIG_ENDIAN
+#define ICMP6_RR_RESULT_FLAGS_OOB 0x0002
+#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001
+#elif _BYTE_ORDER == _LITTLE_ENDIAN
+#define ICMP6_RR_RESULT_FLAGS_OOB 0x0200
+#define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100
+#endif
+
+/*
+ * icmp6 filter structures.
+ */
+
+struct icmp6_filter {
+ u_int32_t icmp6_filt[8];
+};
+
+#define ICMP6_FILTER_SETPASS(type, filterp) \
+ (((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31)))
+#define ICMP6_FILTER_SETBLOCK(type, filterp) \
+ (((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31)))
+#define ICMP6_FILTER_WILLPASS(type, filterp) \
+ ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
+#define ICMP6_FILTER_WILLBLOCK(type, filterp) \
+ ((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
+
+/*
+ * Variables related to this implementation
+ * of the internet control message protocol version 6.
+ */
+struct icmp6errstat {
+ u_int64_t icp6errs_dst_unreach_noroute;
+ u_int64_t icp6errs_dst_unreach_admin;
+ u_int64_t icp6errs_dst_unreach_beyondscope;
+ u_int64_t icp6errs_dst_unreach_addr;
+ u_int64_t icp6errs_dst_unreach_noport;
+ u_int64_t icp6errs_packet_too_big;
+ u_int64_t icp6errs_time_exceed_transit;
+ u_int64_t icp6errs_time_exceed_reassembly;
+ u_int64_t icp6errs_paramprob_header;
+ u_int64_t icp6errs_paramprob_nextheader;
+ u_int64_t icp6errs_paramprob_option;
+ u_int64_t icp6errs_redirect; /* we regard redirect as an error here */
+ u_int64_t icp6errs_unknown;
+};
+
+struct icmp6stat {
+/* statistics related to icmp6 packets generated */
+ u_int64_t icp6s_error; /* # of calls to icmp6_error */
+ u_int64_t icp6s_canterror; /* no error because old was icmp */
+ u_int64_t icp6s_toofreq; /* no error because rate limitation */
+ u_int64_t icp6s_outhist[256];
+/* statistics related to input message processed */
+ u_int64_t icp6s_badcode; /* icmp6_code out of range */
+ u_int64_t icp6s_tooshort; /* packet < sizeof(struct icmp6_hdr) */
+ u_int64_t icp6s_checksum; /* bad checksum */
+ u_int64_t icp6s_badlen; /* calculated bound mismatch */
+ /*
+ * number of responses: this member is inherited from netinet code, but
+ * for netinet6 code, it is already available in icp6s_outhist[].
+ */
+ u_int64_t icp6s_reflect;
+ u_int64_t icp6s_inhist[256];
+ u_int64_t icp6s_nd_toomanyopt; /* too many ND options */
+ struct icmp6errstat icp6s_outerrhist;
+#define icp6s_odst_unreach_noroute \
+ icp6s_outerrhist.icp6errs_dst_unreach_noroute
+#define icp6s_odst_unreach_admin icp6s_outerrhist.icp6errs_dst_unreach_admin
+#define icp6s_odst_unreach_beyondscope \
+ icp6s_outerrhist.icp6errs_dst_unreach_beyondscope
+#define icp6s_odst_unreach_addr icp6s_outerrhist.icp6errs_dst_unreach_addr
+#define icp6s_odst_unreach_noport icp6s_outerrhist.icp6errs_dst_unreach_noport
+#define icp6s_opacket_too_big icp6s_outerrhist.icp6errs_packet_too_big
+#define icp6s_otime_exceed_transit \
+ icp6s_outerrhist.icp6errs_time_exceed_transit
+#define icp6s_otime_exceed_reassembly \
+ icp6s_outerrhist.icp6errs_time_exceed_reassembly
+#define icp6s_oparamprob_header icp6s_outerrhist.icp6errs_paramprob_header
+#define icp6s_oparamprob_nextheader \
+ icp6s_outerrhist.icp6errs_paramprob_nextheader
+#define icp6s_oparamprob_option icp6s_outerrhist.icp6errs_paramprob_option
+#define icp6s_oredirect icp6s_outerrhist.icp6errs_redirect
+#define icp6s_ounknown icp6s_outerrhist.icp6errs_unknown
+ u_int64_t icp6s_pmtuchg; /* path MTU changes */
+ u_int64_t icp6s_nd_badopt; /* bad ND options */
+ u_int64_t icp6s_badns; /* bad neighbor solicitation */
+ u_int64_t icp6s_badna; /* bad neighbor advertisement */
+ u_int64_t icp6s_badrs; /* bad router advertisement */
+ u_int64_t icp6s_badra; /* bad router advertisement */
+ u_int64_t icp6s_badredirect; /* bad redirect message */
+};
+
+/*
+ * Names for ICMP sysctl objects
+ */
+#define ICMPV6CTL_STATS 1
+#define ICMPV6CTL_REDIRACCEPT 2 /* accept/process redirects */
+#define ICMPV6CTL_REDIRTIMEOUT 3 /* redirect cache time */
+#if 0 /*obsoleted*/
+#define ICMPV6CTL_ERRRATELIMIT 5 /* ICMPv6 error rate limitation */
+#endif
+#define ICMPV6CTL_ND6_PRUNE 6
+#define ICMPV6CTL_ND6_DELAY 8
+#define ICMPV6CTL_ND6_UMAXTRIES 9
+#define ICMPV6CTL_ND6_MMAXTRIES 10
+#define ICMPV6CTL_ND6_USELOOPBACK 11
+/*#define ICMPV6CTL_ND6_PROXYALL 12 obsoleted, do not reuse here */
+#define ICMPV6CTL_NODEINFO 13
+#define ICMPV6CTL_ERRPPSLIMIT 14 /* ICMPv6 error pps limitation */
+#define ICMPV6CTL_ND6_MAXNUDHINT 15
+#define ICMPV6CTL_MTUDISC_HIWAT 16
+#define ICMPV6CTL_MTUDISC_LOWAT 17
+#define ICMPV6CTL_ND6_DEBUG 18
+#define ICMPV6CTL_ND6_DRLIST 19
+#define ICMPV6CTL_ND6_PRLIST 20
+#define ICMPV6CTL_MAXID 21
+
+#define ICMPV6CTL_NAMES { \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { "rediraccept", CTLTYPE_INT }, \
+ { "redirtimeout", CTLTYPE_INT }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+ { "nd6_prune", CTLTYPE_INT }, \
+ { 0, 0 }, \
+ { "nd6_delay", CTLTYPE_INT }, \
+ { "nd6_umaxtries", CTLTYPE_INT }, \
+ { "nd6_mmaxtries", CTLTYPE_INT }, \
+ { "nd6_useloopback", CTLTYPE_INT }, \
+ { 0, 0 }, \
+ { "nodeinfo", CTLTYPE_INT }, \
+ { "errppslimit", CTLTYPE_INT }, \
+ { "nd6_maxnudhint", CTLTYPE_INT }, \
+ { "mtudisc_hiwat", CTLTYPE_INT }, \
+ { "mtudisc_lowat", CTLTYPE_INT }, \
+ { "nd6_debug", CTLTYPE_INT }, \
+ { 0, 0 }, \
+ { 0, 0 }, \
+}
+
+#define ICMPV6CTL_VARS { \
+ NULL, \
+ NULL, \
+ &icmp6_rediraccept, \
+ &icmp6_redirtimeout, \
+ NULL, \
+ NULL, \
+ &nd6_prune, \
+ NULL, \
+ &nd6_delay, \
+ &nd6_umaxtries, \
+ &nd6_mmaxtries, \
+ &nd6_useloopback, \
+ NULL, \
+ &icmp6_nodeinfo, \
+ &icmp6errppslim, \
+ &nd6_maxnudhint, \
+ &icmp6_mtudisc_hiwat, \
+ &icmp6_mtudisc_lowat, \
+ &nd6_debug, \
+ NULL, \
+ NULL, \
+}
+
+#define RTF_PROBEMTU RTF_PROTO1
+
+#endif /* _NETINET_ICMP6_H_ */
+
diff --git a/src/cygwin/openbsd_netinet_if_ether.h b/src/cygwin/openbsd_netinet_if_ether.h
new file mode 100644
index 0000000..0edc6d1
--- /dev/null
+++ b/src/cygwin/openbsd_netinet_if_ether.h
@@ -0,0 +1,248 @@
+/* Copyright 2008-2009 Bernhard R. Fischer.
+ *
+ * This file is part of OnionCat.
+ *
+ * OnionCat is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OnionCat is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OnionCat. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*! This file is taken originally from OpenBSD and has been truncated
+ * by unnecessary code lines within this context. */
+
+
+/* $OpenBSD: if_ether.h,v 1.40 2008/04/18 09:16:14 djm Exp $ */
+/* $NetBSD: if_ether.h,v 1.22 1996/05/11 13:00:00 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)if_ether.h 8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _NETINET_IF_ETHER_H_
+#define _NETINET_IF_ETHER_H_
+
+/*
+ * Some basic Ethernet constants.
+ */
+#define ETHER_ADDR_LEN 6 /* Ethernet address length */
+#define ETHER_TYPE_LEN 2 /* Ethernet type field length */
+#define ETHER_CRC_LEN 4 /* Ethernet CRC length */
+#define ETHER_HDR_LEN ((ETHER_ADDR_LEN * 2) + ETHER_TYPE_LEN)
+#define ETHER_MIN_LEN 64 /* Minimum frame length, CRC included */
+#define ETHER_MAX_LEN 1518 /* Maximum frame length, CRC included */
+#define ETHER_MAX_DIX_LEN 1536 /* Maximum DIX frame length */
+
+/*
+ * Some Ethernet extensions.
+ */
+#define ETHER_VLAN_ENCAP_LEN 4 /* len of 802.1Q VLAN encapsulation */
+
+/*
+ * Mbuf adjust factor to force 32-bit alignment of IP header.
+ * Drivers should do m_adj(m, ETHER_ALIGN) when setting up a
+ * receive so the upper layers get the IP header properly aligned
+ * past the 14-byte Ethernet header.
+ */
+#define ETHER_ALIGN 2 /* driver adjust for IP hdr alignment */
+
+/*
+ * Ethernet address - 6 octets
+ */
+struct ether_addr {
+ u_int8_t ether_addr_octet[ETHER_ADDR_LEN];
+};
+
+/*
+ * The length of the combined header.
+ */
+struct ether_header {
+ u_int8_t ether_dhost[ETHER_ADDR_LEN];
+ u_int8_t ether_shost[ETHER_ADDR_LEN];
+ u_int16_t ether_type;
+};
+
+
+#define ETHER_IS_MULTICAST(addr) (*(addr) & 0x01) /* is address mcast/bcast? */
+
+#define ETHERMTU (ETHER_MAX_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN)
+#define ETHERMIN (ETHER_MIN_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN)
+
+/*
+ * Ethernet CRC32 polynomials (big- and little-endian verions).
+ */
+#define ETHER_CRC_POLY_LE 0xedb88320
+#define ETHER_CRC_POLY_BE 0x04c11db6
+
+/*
+ * Ethernet-specific mbuf flags.
+ */
+#define M_HASFCS M_LINK0 /* FCS included at end of frame */
+
+#if 0
+/*
+ * Ethernet Address Resolution Protocol.
+ *
+ * See RFC 826 for protocol description. Structure below is adapted
+ * to resolving internet addresses. Field names used correspond to
+ * RFC 826.
+ */
+struct ether_arp {
+ struct arphdr ea_hdr; /* fixed-size header */
+ u_int8_t arp_sha[ETHER_ADDR_LEN]; /* sender hardware address */
+ u_int8_t arp_spa[4]; /* sender protocol address */
+ u_int8_t arp_tha[ETHER_ADDR_LEN]; /* target hardware address */
+ u_int8_t arp_tpa[4]; /* target protocol address */
+};
+#define arp_hrd ea_hdr.ar_hrd
+#define arp_pro ea_hdr.ar_pro
+#define arp_hln ea_hdr.ar_hln
+#define arp_pln ea_hdr.ar_pln
+#define arp_op ea_hdr.ar_op
+
+/*
+ * Structure shared between the ethernet driver modules and
+ * the address resolution code. For example, each ec_softc or il_softc
+ * begins with this structure.
+ */
+struct arpcom {
+ struct ifnet ac_if; /* network-visible interface */
+ u_int8_t ac_enaddr[ETHER_ADDR_LEN]; /* ethernet hardware address */
+ char ac__pad[2]; /* pad for some machines */
+ LIST_HEAD(, ether_multi) ac_multiaddrs; /* list of multicast addrs */
+ int ac_multicnt; /* length of ac_multiaddrs */
+ int ac_multirangecnt; /* number of mcast ranges */
+
+};
+
+struct llinfo_arp {
+ LIST_ENTRY(llinfo_arp) la_list;
+ struct rtentry *la_rt;
+ struct mbuf *la_hold; /* last packet until resolved/timeout */
+ long la_asked; /* last time we QUERIED for this addr */
+#define la_timer la_rt->rt_rmx.rmx_expire /* deletion time in seconds */
+};
+
+struct sockaddr_inarp {
+ u_int8_t sin_len;
+ u_int8_t sin_family;
+ u_int16_t sin_port;
+ struct in_addr sin_addr;
+ struct in_addr sin_srcaddr;
+ u_int16_t sin_tos;
+ u_int16_t sin_other;
+#define SIN_PROXY 1
+};
+#endif
+
+/*
+ * IP and ethernet specific routing flags
+ */
+#define RTF_USETRAILERS RTF_PROTO1 /* use trailers */
+#define RTF_ANNOUNCE RTF_PROTO2 /* announce new arp entry */
+#define RTF_PERMANENT_ARP RTF_PROTO3 /* only manual overwrite of entry */
+
+
+/*
+ * Ethernet multicast address structure. There is one of these for each
+ * multicast address or range of multicast addresses that we are supposed
+ * to listen to on a particular interface. They are kept in a linked list,
+ * rooted in the interface's arpcom structure. (This really has nothing to
+ * do with ARP, or with the Internet address family, but this appears to be
+ * the minimally-disrupting place to put it.)
+ */
+struct ether_multi {
+ u_int8_t enm_addrlo[ETHER_ADDR_LEN]; /* low or only address of range */
+ u_int8_t enm_addrhi[ETHER_ADDR_LEN]; /* high or only address of range */
+ struct arpcom *enm_ac; /* back pointer to arpcom */
+ u_int enm_refcount; /* no. claims to this addr/range */
+ LIST_ENTRY(ether_multi) enm_list;
+};
+
+/*
+ * Structure used by macros below to remember position when stepping through
+ * all of the ether_multi records.
+ */
+struct ether_multistep {
+ struct ether_multi *e_enm;
+};
+
+/*
+ * Macro for looking up the ether_multi record for a given range of Ethernet
+ * multicast addresses connected to a given arpcom structure. If no matching
+ * record is found, "enm" returns NULL.
+ */
+#define ETHER_LOOKUP_MULTI(addrlo, addrhi, ac, enm) \
+ /* u_int8_t addrlo[ETHER_ADDR_LEN]; */ \
+ /* u_int8_t addrhi[ETHER_ADDR_LEN]; */ \
+ /* struct arpcom *ac; */ \
+ /* struct ether_multi *enm; */ \
+{ \
+ for ((enm) = LIST_FIRST(&(ac)->ac_multiaddrs); \
+ (enm) != LIST_END(&(ac)->ac_multiaddrs) && \
+ (bcmp((enm)->enm_addrlo, (addrlo), ETHER_ADDR_LEN) != 0 || \
+ bcmp((enm)->enm_addrhi, (addrhi), ETHER_ADDR_LEN) != 0); \
+ (enm) = LIST_NEXT((enm), enm_list)); \
+}
+
+/*
+ * Macro to step through all of the ether_multi records, one at a time.
+ * The current position is remembered in "step", which the caller must
+ * provide. ETHER_FIRST_MULTI(), below, must be called to initialize "step"
+ * and get the first record. Both macros return a NULL "enm" when there
+ * are no remaining records.
+ */
+#define ETHER_NEXT_MULTI(step, enm) \
+ /* struct ether_multistep step; */ \
+ /* struct ether_multi *enm; */ \
+{ \
+ if (((enm) = (step).e_enm) != NULL) \
+ (step).e_enm = LIST_NEXT((enm), enm_list); \
+}
+
+#define ETHER_FIRST_MULTI(step, ac, enm) \
+ /* struct ether_multistep step; */ \
+ /* struct arpcom *ac; */ \
+ /* struct ether_multi *enm; */ \
+{ \
+ (step).e_enm = LIST_FIRST(&(ac)->ac_multiaddrs); \
+ ETHER_NEXT_MULTI((step), (enm)); \
+}
+
+
+#endif /* _NETINET_IF_ETHER_H_ */
+
diff --git a/src/cygwin/openbsd_netinet_ip6.h b/src/cygwin/openbsd_netinet_ip6.h
new file mode 100644
index 0000000..73829c0
--- /dev/null
+++ b/src/cygwin/openbsd_netinet_ip6.h
@@ -0,0 +1,276 @@
+/* Copyright 2008-2009 Bernhard R. Fischer.
+ *
+ * This file is part of OnionCat.
+ *
+ * OnionCat is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OnionCat is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OnionCat. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*! This file is taken originally from OpenBSD and has been truncated
+ * by unnecessary code lines within this context. */
+
+
+/* $OpenBSD: ip6.h,v 1.18 2006/12/09 01:12:28 itojun Exp $ */
+/* $KAME: ip6.h,v 1.45 2003/06/05 04:46:38 keiichi Exp $ */
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)ip.h 8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _NETINET_IP6_H_
+#define _NETINET_IP6_H_
+
+/*
+ * Definition for internet protocol version 6.
+ * RFC 2460
+ */
+
+struct ip6_hdr {
+ union {
+ struct ip6_hdrctl {
+ u_int32_t ip6_un1_flow; /* 20 bits of flow-ID */
+ u_int16_t ip6_un1_plen; /* payload length */
+ u_int8_t ip6_un1_nxt; /* next header */
+ u_int8_t ip6_un1_hlim; /* hop limit */
+ } ip6_un1;
+ u_int8_t ip6_un2_vfc; /* 4 bits version, top 4 bits class */
+ } ip6_ctlun;
+ struct in6_addr ip6_src; /* source address */
+ struct in6_addr ip6_dst; /* destination address */
+} __packed;
+
+#define ip6_vfc ip6_ctlun.ip6_un2_vfc
+#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
+#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
+#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt
+#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim
+#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
+
+#define IPV6_VERSION 0x60
+#define IPV6_VERSION_MASK 0xf0
+
+#if _BYTE_ORDER == _BIG_ENDIAN
+#define IPV6_FLOWINFO_MASK 0x0fffffff /* flow info (28 bits) */
+#define IPV6_FLOWLABEL_MASK 0x000fffff /* flow label (20 bits) */
+#else
+#if _BYTE_ORDER == _LITTLE_ENDIAN
+#define IPV6_FLOWINFO_MASK 0xffffff0f /* flow info (28 bits) */
+#define IPV6_FLOWLABEL_MASK 0xffff0f00 /* flow label (20 bits) */
+#endif /* _LITTLE_ENDIAN */
+#endif
+#if 1
+/* ECN bits proposed by Sally Floyd */
+#define IP6TOS_CE 0x01 /* congestion experienced */
+#define IP6TOS_ECT 0x02 /* ECN-capable transport */
+#endif
+
+/*
+ * Extension Headers
+ */
+struct ip6_ext {
+ u_int8_t ip6e_nxt;
+ u_int8_t ip6e_len;
+} __packed;
+
+/* Hop-by-Hop options header */
+/* XXX should we pad it to force alignment on an 8-byte boundary? */
+struct ip6_hbh {
+ u_int8_t ip6h_nxt; /* next header */
+ u_int8_t ip6h_len; /* length in units of 8 octets */
+ /* followed by options */
+} __packed;
+
+/* Destination options header */
+/* XXX should we pad it to force alignment on an 8-byte boundary? */
+struct ip6_dest {
+ u_int8_t ip6d_nxt; /* next header */
+ u_int8_t ip6d_len; /* length in units of 8 octets */
+ /* followed by options */
+} __packed;
+
+/* Option types and related macros */
+#define IP6OPT_PAD1 0x00 /* 00 0 00000 */
+#define IP6OPT_PADN 0x01 /* 00 0 00001 */
+#define IP6OPT_JUMBO 0xC2 /* 11 0 00010 = 194 */
+#define IP6OPT_NSAP_ADDR 0xC3 /* 11 0 00011 */
+#define IP6OPT_TUNNEL_LIMIT 0x04 /* 00 0 00100 */
+#define IP6OPT_ROUTER_ALERT 0x05 /* 00 0 00101 (RFC3542, recommended) */
+
+#define IP6OPT_RTALERT_LEN 4
+#define IP6OPT_RTALERT_MLD 0 /* Datagram contains an MLD message */
+#define IP6OPT_RTALERT_RSVP 1 /* Datagram contains an RSVP message */
+#define IP6OPT_RTALERT_ACTNET 2 /* contains an Active Networks msg */
+#define IP6OPT_MINLEN 2
+
+#define IP6OPT_TYPE(o) ((o) & 0xC0)
+#define IP6OPT_TYPE_SKIP 0x00
+#define IP6OPT_TYPE_DISCARD 0x40
+#define IP6OPT_TYPE_FORCEICMP 0x80
+#define IP6OPT_TYPE_ICMP 0xC0
+
+#define IP6OPT_MUTABLE 0x20
+
+/* IPv6 options: common part */
+struct ip6_opt {
+ u_int8_t ip6o_type;
+ u_int8_t ip6o_len;
+} __packed;
+
+/* Jumbo Payload Option */
+struct ip6_opt_jumbo {
+ u_int8_t ip6oj_type;
+ u_int8_t ip6oj_len;
+ u_int8_t ip6oj_jumbo_len[4];
+} __packed;
+#define IP6OPT_JUMBO_LEN 6
+
+/* NSAP Address Option */
+struct ip6_opt_nsap {
+ u_int8_t ip6on_type;
+ u_int8_t ip6on_len;
+ u_int8_t ip6on_src_nsap_len;
+ u_int8_t ip6on_dst_nsap_len;
+ /* followed by source NSAP */
+ /* followed by destination NSAP */
+} __packed;
+
+/* Tunnel Limit Option */
+struct ip6_opt_tunnel {
+ u_int8_t ip6ot_type;
+ u_int8_t ip6ot_len;
+ u_int8_t ip6ot_encap_limit;
+} __packed;
+
+/* Router Alert Option */
+struct ip6_opt_router {
+ u_int8_t ip6or_type;
+ u_int8_t ip6or_len;
+ u_int8_t ip6or_value[2];
+} __packed;
+/* Router alert values (in network byte order) */
+#if _BYTE_ORDER == _BIG_ENDIAN
+#define IP6_ALERT_MLD 0x0000
+#define IP6_ALERT_RSVP 0x0001
+#define IP6_ALERT_AN 0x0002
+#else
+#if _BYTE_ORDER == _LITTLE_ENDIAN
+#define IP6_ALERT_MLD 0x0000
+#define IP6_ALERT_RSVP 0x0100
+#define IP6_ALERT_AN 0x0200
+#endif /* _LITTLE_ENDIAN */
+#endif
+
+/* Routing header */
+struct ip6_rthdr {
+ u_int8_t ip6r_nxt; /* next header */
+ u_int8_t ip6r_len; /* length in units of 8 octets */
+ u_int8_t ip6r_type; /* routing type */
+ u_int8_t ip6r_segleft; /* segments left */
+ /* followed by routing type specific data */
+} __packed;
+
+/* Type 0 Routing header */
+struct ip6_rthdr0 {
+ u_int8_t ip6r0_nxt; /* next header */
+ u_int8_t ip6r0_len; /* length in units of 8 octets */
+ u_int8_t ip6r0_type; /* always zero */
+ u_int8_t ip6r0_segleft; /* segments left */
+ u_int32_t ip6r0_reserved; /* reserved field */
+} __packed;
+
+/* Fragment header */
+struct ip6_frag {
+ u_int8_t ip6f_nxt; /* next header */
+ u_int8_t ip6f_reserved; /* reserved field */
+ u_int16_t ip6f_offlg; /* offset, reserved, and flag */
+ u_int32_t ip6f_ident; /* identification */
+} __packed;
+
+#if _BYTE_ORDER == _BIG_ENDIAN
+#define IP6F_OFF_MASK 0xfff8 /* mask out offset from _offlg */
+#define IP6F_RESERVED_MASK 0x0006 /* reserved bits in ip6f_offlg */
+#define IP6F_MORE_FRAG 0x0001 /* more-fragments flag */
+#else /* _BYTE_ORDER == _LITTLE_ENDIAN */
+#define IP6F_OFF_MASK 0xf8ff /* mask out offset from _offlg */
+#define IP6F_RESERVED_MASK 0x0600 /* reserved bits in ip6f_offlg */
+#define IP6F_MORE_FRAG 0x0100 /* more-fragments flag */
+#endif /* _BYTE_ORDER == _LITTLE_ENDIAN */
+
+/*
+ * Internet implementation parameters.
+ */
+#define IPV6_MAXHLIM 255 /* maximum hoplimit */
+#define IPV6_DEFHLIM 64 /* default hlim */
+#define IPV6_FRAGTTL 120 /* ttl for fragment packets, in slowtimo tick */
+#define IPV6_HLIMDEC 1 /* subtracted when forwarding */
+
+#define IPV6_MMTU 1280 /* minimal MTU and reassembly. 1024 + 256 */
+#define IPV6_MAXPACKET 65535 /* ip6 max packet size without Jumbo payload*/
+
+#endif /* _NETINET_IP6_H_ */
+
diff --git a/src/ocat.c b/src/ocat.c
index 80d97ca..e34096b 100644
--- a/src/ocat.c
+++ b/src/ocat.c
@@ -171,10 +171,14 @@ void cleanup_system(void)
log_msg(LOG_NOTICE, "waiting for system cleanup...");
// close tunnel interface
+#ifdef __CYGWIN__
+ (void) win_close_tun();
+#else
log_debug("closing tunfd %d (and %d)", CNF(tunfd[0]), CNF(tunfd[1]));
oe_close(CNF(tunfd[0]));
if (CNF(tunfd[0]) != CNF(tunfd[1]))
oe_close(CNF(tunfd[1]));
+#endif
// close and delete all peers
log_debug("deleting peers");
@@ -385,7 +389,11 @@ int main(int argc, char *argv[])
#ifndef WITHOUT_TUN
// create TUN device
- CNF(tunfd[0]) = CNF(tunfd[1]) = tun_alloc(CNF(tunname), CNF(ocat_addr));
+ if ((CNF(tunfd[0]) = CNF(tunfd[1]) = tun_alloc(CNF(tunname), sizeof(CNF(tunname)), CNF(ocat_addr))) == -1)
+ {
+ log_msg(LOG_CRIT, "error opening TUN/TAP device");
+ exit(1);
+ }
#endif
log_msg(LOG_INFO, "IPv6 address %s", ip6addr);
diff --git a/src/ocat.h b/src/ocat.h
index 7332ca2..0ea56dc 100644
--- a/src/ocat.h
+++ b/src/ocat.h
@@ -97,6 +97,13 @@
#endif
*/
+#ifdef __CYGWIN__
+#include "cygwin/ocat_cygwin.h"
+#endif
+
+#ifndef ETHERTYPE_IP
+#define ETHERTYPE_IP 0x0800
+#endif
#ifndef ETHERTYPE_IPV6
#define ETHERTYPE_IPV6 0x86dd
#endif
@@ -148,6 +155,7 @@
//! Standard buffer size 1024 bytes
#define SIZE_1K 1024
+#define SIZE_256 256
#define DEQUEUER_WAKEUP 3
//! maximum number a packet stays in queue
@@ -259,7 +267,7 @@ struct OcatSetup
//! name of tunnel charcter device
char *tun_dev;
//! tunnel interface name
- char tunname[IFNAMSIZ];
+ char tunname[SIZE_256];
int ipv4_enable;
struct in_addr ocat_addr4;
int ocat_addr4_mask;
@@ -454,33 +462,6 @@ typedef struct OcatCtrlHdr
*/
-#ifndef HAVE_STRUCT_IP6_HDR
-struct ip6_hdr
- {
- union
- {
- struct ip6_hdrctl
- {
- uint32_t ip6_un1_flow; /* 4 bits version, 8 bits TC,
- 20 bits flow-ID */
- uint16_t ip6_un1_plen; /* payload length */
- uint8_t ip6_un1_nxt; /* next header */
- uint8_t ip6_un1_hlim; /* hop limit */
- } ip6_un1;
- uint8_t ip6_un2_vfc; /* 4 bits version, top 4 bits tclass */
- } ip6_ctlun;
- struct in6_addr ip6_src; /* source address */
- struct in6_addr ip6_dst; /* destination address */
- };
-
-#define ip6_vfc ip6_ctlun.ip6_un2_vfc
-#define ip6_flow ip6_ctlun.ip6_un1.ip6_un1_flow
-#define ip6_plen ip6_ctlun.ip6_un1.ip6_un1_plen
-#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt
-#define ip6_hlim ip6_ctlun.ip6_un1.ip6_un1_hlim
-#define ip6_hops ip6_ctlun.ip6_un1.ip6_un1_hlim
-#endif
-
#ifndef WITHOUT_TUN
#ifdef __FreeBSD__
#define TUN_DEV "/dev/tun0"
@@ -521,7 +502,7 @@ const char *inet_ntops(const struct sockaddr *, struct sockaddr_str *);
/* ocattun.c */
#ifndef WITHOUT_TUN
-int tun_alloc(char *, struct in6_addr);
+int tun_alloc(char *, int, struct in6_addr);
#endif
/* ocatroute.c */
@@ -618,6 +599,13 @@ struct in6_addr *ipv6_lookup_route(const struct in6_addr *);
void ipv6_print_routes(FILE *);
int ipv6_parse_route(const char *);
+#ifdef __CYGWIN__
+/* ocat_wintuntap.c */
+int win_open_tun(char *, int);
+int win_close_tun(void);
+int win_read_tun(char *, int);
+int win_write_tun(const char *, int);
+#endif
#endif
diff --git a/src/ocat_wintuntap.c b/src/ocat_wintuntap.c
new file mode 100644
index 0000000..6e7b69a
--- /dev/null
+++ b/src/ocat_wintuntap.c
@@ -0,0 +1,308 @@
+/* Copyright 2008-2009 Bernhard R. Fischer.
+ *
+ * This file is part of OnionCat.
+ *
+ * OnionCat is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OnionCat is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with OnionCat. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*! This file contains the Windows code for accessing the OpenVPN TAP driver.
+ * This driver must be installed in order to run OnionCat on Windows.
+ *
+ * The source code of this file was originally written by Wolfgang Ginolas for
+ * his P2PVPN project (http://www.p2pvpn.org/) and was by his permission
+ * adapted (thanks) to the needs for OnionCat.
+ */
+
+#ifdef __CYGWIN__
+
+#include "ocat.h"
+
+#include <windows.h>
+#include <objbase.h>
+#include <winioctl.h>
+
+
+// this is the registry directory where the drivers reside in
+#define ADAPTER_KEY "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}"
+// this registry directory contains also information about network drivers
+#define NETWORK_CONNECTIONS_KEY "SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}"
+// I changed this from tap0801
+#define TAP_COMPONENT_ID "tap0901"
+
+#define USERMODEDEVICEDIR "\\\\.\\Global\\"
+#define TAPSUFFIX ".tap"
+
+#define TAP_CONTROL_CODE(request,method) \
+ CTL_CODE (FILE_DEVICE_UNKNOWN, request, method, FILE_ANY_ACCESS)
+
+#define TAP_IOCTL_GET_MAC TAP_CONTROL_CODE (1, METHOD_BUFFERED)
+#define TAP_IOCTL_GET_VERSION TAP_CONTROL_CODE (2, METHOD_BUFFERED)
+#define TAP_IOCTL_GET_MTU TAP_CONTROL_CODE (3, METHOD_BUFFERED)
+#define TAP_IOCTL_GET_INFO TAP_CONTROL_CODE (4, METHOD_BUFFERED)
+#define TAP_IOCTL_CONFIG_POINT_TO_POINT TAP_CONTROL_CODE (5, METHOD_BUFFERED)
+#define TAP_IOCTL_SET_MEDIA_STATUS TAP_CONTROL_CODE (6, METHOD_BUFFERED)
+#define TAP_IOCTL_CONFIG_DHCP_MASQ TAP_CONTROL_CODE (7, METHOD_BUFFERED)
+#define TAP_IOCTL_GET_LOG_LINE TAP_CONTROL_CODE (8, METHOD_BUFFERED)
+#define TAP_IOCTL_CONFIG_DHCP_SET_OPT TAP_CONTROL_CODE (9, METHOD_BUFFERED)
+
+
+typedef struct TapData
+{
+ HANDLE fd;
+ HANDLE read_event;
+ HANDLE write_event;
+ OVERLAPPED read_overlapped;
+ OVERLAPPED write_overlapped;
+} TapData_t;
+
+
+static TapData_t tapData_;
+
+
+int findTapDevice(char *deviceID, int deviceIDLen, char *deviceName, int deviceNameLen)
+{
+ HKEY adapterKey, key;
+ int i;
+ DWORD len;
+ char keyI[1024], keyName[1024], componentId[256];
+
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, ADAPTER_KEY, 0, KEY_READ, &adapterKey) != ERROR_SUCCESS)
+ {
+ log_msg(LOG_ERR, "RegOpenKeyEx \"%s\" failed. Error = %ld", ADAPTER_KEY, GetLastError());
+ return -1;
+ }
+
+ deviceID[0] = '\0';
+ for (i = 0; deviceID[0] == '\0' &&
+ ERROR_SUCCESS == RegEnumKey(adapterKey, i, keyI, sizeof(keyI)); i++)
+ {
+ snprintf(keyName, sizeof(keyName), "%s\\%s", ADAPTER_KEY, keyI);
+
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyName, 0, KEY_READ, &key) != ERROR_SUCCESS)
+ {
+ log_msg(LOG_ERR, "RegOpenKeyEx \"%s\" failed. Error = %ld", keyName, GetLastError());
+ return -1;
+ }
+
+ len = sizeof(componentId);
+ if ((RegQueryValueEx(key, "ComponentId", NULL, NULL, componentId, &len) == ERROR_SUCCESS)
+ && !strcmp(componentId, TAP_COMPONENT_ID))
+ {
+ len = deviceIDLen;
+ RegQueryValueEx(key, "NetCfgInstanceId", NULL, NULL, deviceID, &len);
+ log_debug("ComponentId = \"%s\", NetCfgInstanceId = \"%s\"", componentId, deviceID);
+ }
+
+ RegCloseKey(key);
+ }
+
+ RegCloseKey(adapterKey);
+
+ if (!deviceID[0])
+ return -1;
+
+ snprintf(keyName, sizeof(keyName), "%s\\%s\\Connection", NETWORK_CONNECTIONS_KEY, deviceID);
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyName, 0, KEY_READ, &key) != ERROR_SUCCESS)
+ {
+ log_msg(LOG_ERR, "RegOpenKeyEx \"%s\" failed. Error = %ld", keyName, GetLastError());
+ return -1;
+ }
+
+ len = deviceNameLen;
+ if (RegQueryValueEx(key, "Name", NULL, NULL, deviceName, &len) != ERROR_SUCCESS)
+ {
+ log_msg(LOG_ERR, "RegQueryValueEx \"%s\" failed. Error = %ld", key, GetLastError());
+ RegCloseKey(key);
+ return -1;
+ }
+
+ RegCloseKey(key);
+ return 0;
+}
+
+
+/*! Open TAP driver. */
+int win_open_tun(char *dev, int s)
+{
+ char deviceId[SIZE_256], deviceName[SIZE_256], tapPath[SIZE_256];
+ TapData_t *tapData = &tapData_;
+ unsigned long len = 0;
+ int status;
+
+ if (findTapDevice(deviceId, sizeof(deviceId), deviceName, sizeof(deviceName)) == -1)
+ {
+ log_msg(LOG_ALERT, "could not find TAP driver with componentId \"%s\". Probly not installed",
+ TAP_COMPONENT_ID);
+ return -1;
+ }
+
+ log_debug("TAP found. deviceId = \"%s\", deviceName = \"%s\"", deviceId, deviceName);
+
+ snprintf(tapPath, sizeof(tapPath), "%s%s%s", USERMODEDEVICEDIR, deviceId, TAPSUFFIX);
+ log_debug("creating file at \"%s\"", tapPath);
+ tapData->fd = CreateFile( tapPath, GENERIC_READ | GENERIC_WRITE, 0, 0,
+ OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED, 0 );
+
+ if (tapData->fd == INVALID_HANDLE_VALUE)
+ {
+ log_msg(LOG_ALERT, "CreateFile failed. Error = %ld", GetLastError());
+ return -1;
+ }
+
+ status = TRUE;
+ // FIXME: return value should be handled!
+ DeviceIoControl(tapData->fd, TAP_IOCTL_SET_MEDIA_STATUS, &status, sizeof
+ (status), &status, sizeof (status), &len, NULL);
+
+ // FIXME: return value should be handled!
+ tapData->read_event = CreateEvent(NULL, FALSE, FALSE, NULL);
+ // FIXME: return value should be handled!
+ tapData->write_event = CreateEvent(NULL, FALSE, FALSE, NULL);
+
+ tapData->read_overlapped.Offset = 0;
+ tapData->read_overlapped.OffsetHigh = 0;
+ tapData->read_overlapped.hEvent = tapData->read_event;
+
+ tapData->write_overlapped.Offset = 0;
+ tapData->write_overlapped.OffsetHigh = 0;
+ tapData->write_overlapped.hEvent = tapData->write_event;
+
+ // set IPv6 address
+ // % netsh interface ipv6 add address "LAN-Verbindung 2" fd87:d87e:eb43:0:84:2100:0:8421
+ // add route
+ // % netsh interface ipv6 add route fd87:d87e:eb43::/48 "LAN-Verbindung 2"
+
+ strlcpy(dev, deviceName, s);
+ return 0;
+}
+
+
+/*! Close TAP driver. */
+int win_close_tun(void)
+{
+ if (!CloseHandle(tapData_.fd))
+ {
+ log_msg(LOG_ERR, "CloseHandle failed. Error = %ld", GetLastError());
+ return -1;
+ }
+ return 0;
+}
+
+
+int win_write_tun(const char *jb, int len)
+{
+ TapData_t *tapData = &tapData_;
+ DWORD written, err;
+
+ log_debug("WriteFile %d bytes", len);
+ if (!GetOverlappedResult(tapData->fd, &tapData->write_overlapped, &written, FALSE))
+ {
+ err = GetLastError();
+ log_debug("GetOverlappedResult failed. Error = %ld", err);
+ if (err == ERROR_IO_INCOMPLETE)
+ {
+ log_debug("IO_COMPLETE, WaitForSingleObject");
+ if ((err = WaitForSingleObject(tapData->write_event, INFINITE)) == WAIT_FAILED)
+ log_msg(LOG_ERR, "WaitForSingleObject failed. Error = %ld", GetLastError());
+ else
+ log_debug("WaitForSingleObject returen %08lx", err);
+ }
+ }
+
+ if (!WriteFile(tapData->fd, jb, len, &written, &tapData->write_overlapped))
+ {
+ if ((err = GetLastError()) != ERROR_IO_PENDING)
+ {
+ log_msg(LOG_ERR, "error writing %ld", err);
+ return -1;
+ }
+ else
+ log_debug("IO_PENDING");
+ }
+
+ return written;
+}
+
+
+/*! Read from TAP driver. */
+int win_read_tun(char *buf, int n)
+{
+ TapData_t *tapData = &tapData_;
+ DWORD len, err;
+
+ log_debug("ReadFile max. %d bytes", n);
+ if (!ReadFile(tapData->fd, buf, n, &len, &tapData->read_overlapped))
+ {
+ // check if I/O is still pending
+ if ((err = GetLastError()) == ERROR_IO_PENDING)
+ {
+ for (err = WAIT_TIMEOUT; err == WAIT_TIMEOUT;)
+ {
+ log_debug("ReadFile pending...");
+ if ((err = WaitForSingleObject(tapData->read_event, SELECT_TIMEOUT * 1000)) == WAIT_FAILED)
+ log_msg(LOG_ERR, "WaitForSingleObject failed. Error = %ld", GetLastError());
+ log_debug("WaitForSingleObject returned %08lx", err);
+ }
+
+ if (!GetOverlappedResult(tapData->fd, &tapData->read_overlapped, &len, FALSE))
+ {
+ // GetOverlappedResult may fail if buffer was too small
+ err = GetLastError();
+ if (err == ERROR_IO_INCOMPLETE)
+ log_msg(LOG_WARNING, "GetOverlappedResult return INCOMPLETE...unhandled");
+ else
+ log_msg(LOG_WARNING, "GetOverlappedResult failed. Error = %ld", err);
+ }
+ else
+ log_debug("overlapped_read returned %ld bytes", len);
+ }
+ else
+ log_debug("ReadFile returned %ld bytes", err);
+ }
+
+ return len;
+}
+
+#if 0
+#define BUFLEN 1500
+int main()
+{
+ char buf[BUFLEN];
+ int len, i;
+
+ memset(&tapData_, 0, sizeof(tapData_));
+
+ win_open_tun();
+ printf("opened....");
+
+ //win_write_tun(buf, 10);
+ for (;;)
+ {
+ len = win_read_tun(buf, BUFLEN);
+
+ printf("read %d bytes\n", len);
+ for (i = 0; i < len; i++)
+ printf("%02x ", buf[i] & 0xff);
+ printf("\n\n");
+ }
+
+ win_close_tun();
+
+
+
+ return 0;
+}
+#endif
+
+#endif /* __CYGWIN__ */
+
diff --git a/src/ocateth.c b/src/ocateth.c
index 748181f..ed6f8dd 100644
--- a/src/ocateth.c
+++ b/src/ocateth.c
@@ -281,9 +281,15 @@ int ndp_solicit(const struct in6_addr *src, const struct in6_addr *dst)
ndp6->icmp6.icmp6_cksum = checksum(ckb, ntohs(ndp6->ip6.ip6_plen) + sizeof(struct ip6_psh));
free_ckbuf(ckb);
+#ifdef __CYGWIN__
+ log_debug("writing %d bytes ndp solicitation to TAP driver", sizeof(buf) - 4);
+ // FIXME: there's no error checking
+ win_write_tun(buf + 4, sizeof(buf) - 4);
+#else
log_debug("writing %d bytes ndp solicitation to tunfd %d", sizeof(buf), CNF(tunfd[1]));
if (write(CNF(tunfd[1]), buf, sizeof(buf)) < sizeof(buf))
log_msg(LOG_ERR, "short write to tun fd %d", CNF(tunfd[1]));
+#endif
return 0;
}
@@ -376,9 +382,15 @@ int ndp_soladv(char *buf, int rlen)
ndp6->ndp_adv.nd_na_hdr.icmp6_cksum = checksum(ckb, ntohs(ndp6->ip6.ip6_plen) + sizeof(struct ip6_psh));
free_ckbuf(ckb);
+#ifdef __CYGWIN__
+ log_debug("writing %d bytes to TAP driver", rlen);
+ // FIXME: there's no error checking
+ win_write_tun(buf + 4, rlen - 4);
+#else
log_debug("writing %d bytes to tunfd %d", rlen, CNF(tunfd[1]));
if (write(CNF(tunfd[1]), buf, rlen) < rlen)
log_msg(LOG_ERR, "short write");
+#endif
return 0;
}
@@ -462,6 +474,22 @@ int eth_check(char *buf, int len)
}
+#ifndef HAVE_ETHER_NTOA
+
+#define ETHER_ADDR_BUF_SIZE 18
+static char ether_addr_buf_[ETHER_ADDR_BUF_SIZE];
+
+char *ether_ntoa(const struct ether_addr *addr)
+{
+ snprintf(ether_addr_buf_, ETHER_ADDR_BUF_SIZE, "%02x:%02x:%02x:%02x:%02x:%02x",
+ addr->ether_addr_octet[0], addr->ether_addr_octet[1], addr->ether_addr_octet[2],
+ addr->ether_addr_octet[3], addr->ether_addr_octet[4], addr->ether_addr_octet[5]);
+ return ether_addr_buf_;
+}
+
+#endif
+
+
#ifndef HAVE_ETHER_NTOA_R
static pthread_mutex_t ether_ntoa_mutex_ = PTHREAD_MUTEX_INITIALIZER;
diff --git a/src/ocatroute.c b/src/ocatroute.c
index 33ef8cc..af4d37e 100644
--- a/src/ocatroute.c
+++ b/src/ocatroute.c
@@ -520,8 +520,13 @@ void *socket_receiver(void *p)
else if (*peer->tunhdr == CNF(fhd_key[IPV4_KEY]))
eh->ether_type = htons(ETHERTYPE_IP);
+#ifdef __CYGWIN__
+ if (win_write_tun(buf + 4, len + sizeof(struct ether_header)) != (len + sizeof(struct ether_header)))
+ log_msg(LOG_ERR, "could not write %d bytes to WinTAP", len + sizeof(struct ether_header));
+#else
if (write(CNF(tunfd[1]), buf, len + 4 + sizeof(struct ether_header)) != (len + 4 + sizeof(struct ether_header)))
log_msg(LOG_ERR, "could not write %d bytes to tunnel %d", len + 4 + sizeof(struct ether_header), CNF(tunfd[1]));
+#endif
}
}
else
@@ -789,6 +794,15 @@ void packet_forwarder(void)
if (term_req())
break;
+#ifdef __CYGWIN__
+ log_debug("reading from WinTAP");
+ if ((rlen = win_read_tun(buf + 4, FRAME_SIZE - 4)) == -1)
+ {
+ log_debug("win_read_tun failed. restarting");
+ continue;
+ }
+ rlen += 4;
+#else
#ifdef __OpenBSD__
// workaround for OpenBSD userland threads
fcntl(CNF(tunfd[0]), F_SETFL, fcntl(CNF(tunfd[0]), F_GETFL) & ~O_NONBLOCK);
@@ -811,6 +825,7 @@ void packet_forwarder(void)
log_debug("restarting");
continue;
}
+#endif
log_debug("received on tunfd %d, framesize %d + 4", CNF(tunfd[0]), rlen - 4);
diff --git a/src/ocatsetup.c b/src/ocatsetup.c
index e4c105e..4534e8d 100644
--- a/src/ocatsetup.c
+++ b/src/ocatsetup.c
@@ -30,7 +30,11 @@ static struct sockaddr_in6 socks_dst6_;
static struct sockaddr_in ctrl_listen_;
static struct sockaddr_in6 ctrl_listen6_;
static struct sockaddr *ctrl_listen_ptr_[] =
- {(struct sockaddr*) &ctrl_listen_, (struct sockaddr*) &ctrl_listen6_, NULL};
+ {(struct sockaddr*) &ctrl_listen_,
+#ifndef __CYGWIN__
+ (struct sockaddr*) &ctrl_listen6_,
+#endif
+ NULL};
static int ctrl_fd_[2] = {-1, -1};
struct OcatSetup setup_ =
@@ -50,7 +54,11 @@ struct OcatSetup setup_ =
{'\0'}, // tunname
0, TOR_PREFIX4, TOR_PREFIX4_MASK,
NULL, 1,
+#ifdef __CYGWIN__
+ 1,
+#else
0, // use_tap
+#endif
{0x00, 0x00, 0x6c, 0x00, 0x00, 0x00}, // ocat_hwaddr (OnionCat MAC address)
PID_FILE,
NULL, NULL, // logfile
@@ -84,7 +92,11 @@ struct OcatSetup setup_ =
// oc_listen_fd
ctrl_fd_,
// oc_listen_cnt
+#ifdef __CYGWIN__
+ 1
+#else
2
+#endif
};
diff --git a/src/ocattun.c b/src/ocattun.c
index 3b1dab7..ad53f7b 100644
--- a/src/ocattun.c
+++ b/src/ocattun.c
@@ -1,4 +1,4 @@
-/* Copyright 2008 Bernhard R. Fischer, Daniel Haslinger.
+/* Copyright 2008-2009 Bernhard R. Fischer.
*
* This file is part of OnionCat.
*
@@ -32,7 +32,7 @@ char *tun_dev_ = TUN_DEV;
#define IFCBUF 1024
-int tun_alloc(char *dev, struct in6_addr addr)
+int tun_alloc(char *dev, int dev_s, struct in6_addr addr)
{
struct ifreq ifr;
int fd;
@@ -41,12 +41,38 @@ int tun_alloc(char *dev, struct in6_addr addr)
char buf[IFCBUF];
struct in_addr netmask = {CNF(ocat_addr4_mask)};
- log_debug("opening tun \"%s\"", tun_dev_);
- if ((fd = open(tun_dev_, O_RDWR)) < 0)
- log_msg(LOG_EMERG, "could not open tundev %s: %s", tun_dev_, strerror(errno)), exit(1);
inet_ntop(AF_INET6, &addr, astr, INET6_ADDRSTRLEN);
inet_ntop(AF_INET, &CNF(ocat_addr4), astr4, INET_ADDRSTRLEN);
+#ifdef __CYGWIN__
+ if ((fd = win_open_tun(dev, dev_s)) == -1)
+ return -1;
+
+ // set IPv6 address
+ // 181 // % netsh interface ipv6 add address "LAN-Verbindung 2" fd87:d87e:eb43:0:84:2100:0:8421
+ // 182 // add route
+ // 183 // % netsh interface ipv6 add route fd87:d87e:eb43::/48 "LAN-Verbindung 2"
+
+ snprintf(buf, sizeof(buf), "netsh interface ipv6 add address \"%s\" %s", dev, astr);
+ log_debug("setting IP on tun: \"%s\"", buf);
+ if (system(buf) == -1)
+ log_msg(LOG_ERR, "could not exec \"%s\": \"%s\"", buf, strerror(errno));
+
+ snprintf(buf, sizeof(buf), "netsh interface ipv6 add route %s/%d \"%s\"", astr, TOR_PREFIX_LEN, dev);
+ log_debug("setting IP routing: \"%s\"", buf);
+ if (system(buf) == -1)
+ log_msg(LOG_ERR, "could not exec \"%s\": \"%s\"", buf, strerror(errno));
+
+ return 0;
+#endif
+
+ log_debug("opening tun \"%s\"", tun_dev_);
+ if ((fd = open(tun_dev_, O_RDWR)) < 0)
+ {
+ log_msg(LOG_EMERG, "could not open tundev %s: %s", tun_dev_, strerror(errno));
+ return -1;
+ }
+
#ifdef __linux__
memset(&ifr, 0, sizeof(ifr));
@@ -134,7 +160,7 @@ int tun_alloc(char *dev, struct in6_addr addr)
if (ioctl(fd, TUNSIFHEAD, &prm) == -1)
log_msg(LOG_EMERG, "could not ioctl:TUNSIFHEAD: %s", strerror(errno)), exit(1);
-#endif
+#endif /* __linux__ */
if (!CNF(use_tap))
@@ -175,7 +201,7 @@ int tun_alloc(char *dev, struct in6_addr addr)
// bring up tap device
if (CNF(use_tap))
{
- snprintf(buf, sizeof(buf), "ifconfig %s up", dev);
+ snprintf(buf, sizeof(buf), "ifconfig %s up", dev);
log_msg(LOG_INFO, "bringing up TAP device \"%s\"", buf);
if (system(buf) == -1)
log_msg(LOG_ERR, "could not exec \"%s\": \"%s\"", buf, strerror(errno));
@@ -184,5 +210,5 @@ int tun_alloc(char *dev, struct in6_addr addr)
return fd;
}
-#endif
+#endif /* WITHOUT_TUN */
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onioncat.git
More information about the Pkg-privacy-commits
mailing list