diff -Naur -x '*.sdf' -x .version -x version.c -x '*.orig' -x '*.vcxproj.user' -x '*.exe' -x '*.dll' -x '*.obj' -x '*.lib' -x '*.exp' -x '*.bin' -x '*.pdb' -x '*.log' -x '*.tlog*' -x BuildLog.htm -x '*.bsc' -x '*.lastbuildstate' -x ntp_keyword.h -x keyword-gen-utd -x messages.h -x messages.rc -x messages.res -x '*.suo' -x Win32-out -x Win32-tmp -x x64-out -x x64-tmp -x Debug -x .vs -x '*.VC.db' -x '*.vcxproj' -x '*.vcxproj.filters' ntp-4.2.8p10.orig/ntpd/refclock_hopfser.c ntp-4.2.8p10/ntpd/refclock_hopfser.c
--- ntp-4.2.8p10.orig/ntpd/refclock_hopfser.c	2012-06-02 02:02:30.000000000 +0200
+++ ntp-4.2.8p10/ntpd/refclock_hopfser.c	2017-11-30 16:54:38.659116200 +0100
@@ -8,6 +8,15 @@
  * latest source and further information can be found at:
  * http://www.ATLSoft.de/ntp
  *
+ *********************************************************************
+ * Support for Hopf Clockmouse hardware by Michael Dreher <michael(a)5dot1.de>
+ *  V0.90 of this mode (shipped as separate patch)
+ *  use "mode 1" in the server configuration command to activate the ClockMouse driver instead of the 6021 driver
+ *  see https://www.mikrocontroller.net/topic/108641 for more information about the protocol and background
+ *  and also updated versions of this driver
+ *  example configuration:
+ server 127.127.38.1 iburst minpoll 8 maxpoll 12 mode 1 # don't use maxpoll values less than 8
+ fudge 127.127.38.1 time1 +0.212 # I'm still investigating the exact value and the reason where this comes from to get rid of it
  */
 
 #ifdef HAVE_CONFIG_H
@@ -63,6 +72,7 @@
  */
 #define	DEVICE		"/dev/hopfclock%d" 	/* device name and unit */
 #define	SPEED232	B9600		    	/* uart speed (9600 baud) */
+#define	SPEEDCM232	B300		    	/* uart speed (300 baud) */
 
 
 #define STX 0x02
@@ -74,12 +84,34 @@
 #define REC_QUEUE_EMPTY       0
 #define REC_QUEUE_FULL        1
 
+/* mode parameter in the "SERVER" configuration command */
+#define HOPF_SERIAL_CLOCKTYPE_6021 (0)
+#define HOPF_SERIAL_CLOCKTYPE_CLOCKMOUSE (1) // HKW ClockController
+#define HOPF_SERIAL_CLOCKTYPE_LAST (1) // the highest known clock type
+
 #define	HOPF_OPMODE	0x0C	/* operation mode mask */
 #define HOPF_INVALID	0x00	/* no time code available */
 #define HOPF_INTERNAL	0x04	/* internal clock */
 #define HOPF_RADIO	0x08	/* radio clock */
 #define HOPF_RADIOHP	0x0C	/* high precision radio clock */
 
+/* status flags for clockmouse */
+#define	HOPFCM_ST_VALID	0x01	/* clock is valid (although the previous DCF77 reception might have not been ok) */
+#define	HOPFCM_ST_PREV_RECP_OK	0x02	/* the previous DCF77 reception was ok */
+#define	HOPFCM_ST_FIRST_RECP_ABORTED	0x04	/* receptions has been aborted  */
+#define	HOPFCM_ST_BATTERY_LOW	0x08	/* battery is low  */
+
+/* dcf77 flags for clockmouse */
+#define	HOPFCM_DCF_LEAP_ANNOUNCE	0x08	/* leap second annoucement (DCF77 bit 19)*/
+#define	HOPFCM_DCF_CET	0x04	/* normal time: CET (DCF77 bit 18)*/
+#define	HOPFCM_DCF_CEST	0x02	/* daylight saving time: CEST (DCF77 bit 17)*/
+// must have different meaning or is inverted, example value: 200151221111753 => DST_SW_ANNOUNCE would be set
+//#define	HOPFCM_DCF_DST_SW_ANNOUNCE	0x01	/* daylight saving switch annoucement (DCF77 bit 16)*/
+
+/* flags for status and dcf77 flags of clockmouse */
+#define	HOPFCM_FIXED_MASK	0x70	/* fixed bits mask */
+#define	HOPFCM_FIXED_VAL	0x30	/* fixed bits value */
+
 /*
  * hopfclock unit control structure.
  */
@@ -113,6 +145,13 @@
 	NOFLAGS			/* not used */
 };
 
+#define CLK_REALTYPE(x) ((int)(((x)->ttl) & 0x7F))
+#define CLK_TYPE(x)	((CLK_REALTYPE(x) > HOPF_SERIAL_CLOCKTYPE_LAST) ? HOPF_SERIAL_CLOCKTYPE_6021 : CLK_REALTYPE(x))
+int hopfserial_check_clocktype(struct peer *peer, u_int clocktype)
+{
+	return (clocktype == CLK_TYPE(peer));
+}
+
 /*
  * hopfserial_start - open the devices and initialize data for processing
  */
@@ -132,8 +171,62 @@
 	/* LDISC_STD, LDISC_RAW
 	 * Open serial port. Use CLK line discipline, if available.
 	 */
-	fd = refclock_open(gpsdev, SPEED232, LDISC_CLK);
-	if (fd <= 0) {
+	fd = refclock_open(gpsdev, hopfserial_check_clocktype(peer, HOPF_SERIAL_CLOCKTYPE_CLOCKMOUSE) ? SPEEDCM232 : SPEED232, LDISC_CLK);
+
+	if (hopfserial_check_clocktype(peer, HOPF_SERIAL_CLOCKTYPE_CLOCKMOUSE) && (fd >= 0))
+	{
+		int rc = -1000;
+		struct termios tios;
+		int mode;
+		if ((fd < 0) || (tcgetattr(fd, &tios) != 0)) {
+				rc = -1;
+		}
+		else
+		{
+			tios.c_iflag = IGNBRK | IGNPAR | IXANY;
+			tios.c_oflag = 0;
+			tios.c_cflag = CS8 | CSTOPB | CREAD | HUPCL | CLOCAL | CRTSCTS;
+			tios.c_lflag = 0;
+			tios.c_cc[VMIN] = 0;
+			tios.c_cc[VTIME] = 20; // 2 seconds, read this: http://unixwiz.net/techtips/termios-vmin-vtime.html
+			cfsetispeed(&tios, hopfserial_check_clocktype(peer, HOPF_SERIAL_CLOCKTYPE_CLOCKMOUSE) ? SPEEDCM232 : SPEED232);
+			cfsetospeed(&tios, hopfserial_check_clocktype(peer, HOPF_SERIAL_CLOCKTYPE_CLOCKMOUSE) ? SPEEDCM232 : SPEED232);
+			if (tcsetattr(fd, TCSANOW, &tios) != 0) {
+				rc = -2;
+			}
+			else
+			{
+				if ((fd < 0) || (ioctl(fd, TIOCMGET, &mode) != 0)) {
+					rc = -3;
+				}
+				else
+				{
+					// 1. when DTR is high for around 8 seconds, the clock will be reset to 0
+					// 2. DCF77 reception only works when BREAK condition is not set
+					// (it will start around 12s after BREAK has been cleared), therefore a MINPOLL value
+					// of 3 to 5 minutes has to be used otherwise the clock will no longer be synchronized.
+					// To save the battery life, a MINPOLL of 24h is enough, because between that the receiver
+					// runs as quartz clock and doesn't do DCF77 reception.
+					mode &= ~(TIOCM_DTR | TIOCM_RTS); // this is the important part of the initialization, must normally be 0
+					if(ioctl(fd, TIOCMSET, &mode) != 0) {
+							rc = -4;
+					}
+					else
+					{
+						rc = 0; // success
+					}
+				}
+			}
+		}
+
+		if (rc != 0)
+		{
+			close(fd);
+			fd = -1;
+		}
+	}
+
+	if (fd < 0) {
 #ifdef DEBUG
 		printf("hopfSerialClock(%d) start: open %s failed\n", unit, gpsdev);
 #endif
@@ -199,8 +292,6 @@
 		free(up);
 }
 
-
-
 /*
  * hopfserial_receive - receive data from the serial interface
  */
@@ -216,9 +307,13 @@
 
 	int	synch;	/* synchhronization indicator */
 	int	DoW;	/* Day of Week */
+	unsigned char dcf77bits = 0;
+	unsigned char statusbits = 0;
 
 	int	day, month;	/* ddd conversion */
-	int	converted;
+	int	converted = 0;
+	double utcOffset = 0.0; // time zone correction (because DCF77 is CET or CEST and not UTC)
+	double serialTelegramOffset = 0.0; // serial telegram transit time compensation
 
 	/*
 	 * Initialize pointers and read the timecode and timestamp.
@@ -238,27 +333,68 @@
 	if (pp->lencode == 0)
 		return;
 
-	converted = sscanf(pp->a_lastcode,
+	int fieldCntMustValue = -1;
+	if (hopfserial_check_clocktype(peer, HOPF_SERIAL_CLOCKTYPE_CLOCKMOUSE))
+	{
+
+		if (pp->io.fd >= 0)
+			ioctl(pp->io.fd, TIOCCBRK, 0); // clear BREAK condition (has been set in hopfserial_poll())
+
+		int i = 0;
+		fieldCntMustValue = 9;
+		if (pp->lencode >= 15)
+		{
+			for (i = 0; i < 15; i++)
+			{
+				if ((pp->a_lastcode[i] & HOPFCM_FIXED_MASK) != HOPFCM_FIXED_VAL)
+					break;
+			}
+		}
+		if (i != 15) // only if all characters match the check above
+		{
+			converted = 0;
+		}
+		else
+		{
+			converted = sscanf(pp->a_lastcode,
+				"%2d%2d%2d%1d%2d%2d%2d%1c%1c",
+				&pp->hour,
+				&pp->minute,
+				&pp->second,
+				&DoW,
+				&day,
+				&month,
+				&pp->year,
+				&dcf77bits,
+				&statusbits
+				);
+			DoW = DoW % 7; // the protocol range is from 1 (monday) to 7 (sunday), map to 0 (sunday) to 6 (saturday)
+		}
+	}
+	else
+	{
+		fieldCntMustValue = 8;
+		converted = sscanf(pp->a_lastcode,
 #if 1
-	       "%1x%1x%2d%2d%2d%2d%2d%2d",   /* ...cr,lf */
+			"%1x%1x%2d%2d%2d%2d%2d%2d",   /* ...cr,lf */
 #else
-	       "%*c%1x%1x%2d%2d%2d%2d%2d%2d", /* stx...cr,lf,etx */
+			"%*c%1x%1x%2d%2d%2d%2d%2d%2d", /* stx...cr,lf,etx */
 #endif
-	       &synch,
-	       &DoW,
-	       &pp->hour,
-	       &pp->minute,
-	       &pp->second,
-	       &day,
-	       &month,
-	       &pp->year);
-
+			&synch,
+			&DoW,
+			&pp->hour,
+			&pp->minute,
+			&pp->second,
+			&day,
+			&month,
+			&pp->year);
+	}
 
 	/*
 	  Validate received values at least enough to prevent internal
 	  array-bounds problems, etc.
 	*/
-	if ((8 != converted) || (pp->hour < 0) || (pp->hour > 23) ||
+	if ((fieldCntMustValue != converted) || (pp->hour < 0) || (pp->hour > 23) ||
 	   (pp->minute < 0) || (pp->minute > 59) || (pp->second < 0) ||
 	   (pp->second > 60) /*Allow for leap seconds.*/ ||
 	   (day < 1) || (day > 31) ||
@@ -280,51 +416,83 @@
 	if(pp->year < YEAR_PIVOT) { pp->year += 100; }		/* < 98 */
 	pp->year += 1900;
 
-	/* preparation for timecode ntpq rl command ! */
+	if (hopfserial_check_clocktype(peer, HOPF_SERIAL_CLOCKTYPE_CLOCKMOUSE))
+	{
+		if (statusbits & HOPFCM_ST_BATTERY_LOW)
+		{
+			// TODO: output error "battery low"
+		}
 
-#if 0
-	snprintf(pp->a_lastcode, sizeof(pp->a_lastcode),
-		 "STATUS: %1X%1X, DATE: %02d.%02d.%04d  TIME: %02d:%02d:%02d",
-		 synch,
-		 DoW,
-		 day,
-		 month,
-		 pp->year,
-		 pp->hour,
-		 pp->minute,
-		 pp->second);
+		if (! (statusbits & HOPFCM_ST_PREV_RECP_OK))
+		{
+			// TODO: output error "previous reception not ok"
+		}
 
-	pp->lencode = strlen(pp->a_lastcode);
-	if ((synch && 0xc) == 0 ){  /* time ok? */
-		refclock_report(peer, CEVNT_BADTIME);
-		pp->leap = LEAP_NOTINSYNC;
-		return;
-	}
-#endif
-	/*
-	 * If clock has no valid status then report error and exit
-	 */
-	if ((synch & HOPF_OPMODE) == HOPF_INVALID ){  /* time ok? */
-		refclock_report(peer, CEVNT_BADTIME);
-		pp->leap = LEAP_NOTINSYNC;
-		return;
+		/*
+		* If clock has no valid status then report error and exit
+		*/
+		if (((statusbits & (HOPFCM_ST_VALID | HOPFCM_ST_FIRST_RECP_ABORTED | HOPFCM_ST_BATTERY_LOW)) != (HOPFCM_ST_VALID))
+			|| (!(dcf77bits & HOPFCM_DCF_CET) == !(dcf77bits & HOPFCM_DCF_CEST)) // these bits must not be identical
+			)
+		{  /* time ok? */
+			refclock_report(peer, CEVNT_BADTIME);
+			pp->leap = LEAP_NOTINSYNC;
+			return;
+		}
+
+		// TODO: handle LEAP annoucement
+		utcOffset = (dcf77bits & HOPFCM_DCF_CEST) ? -2.0*60*60 : -1.0*60*60;
+
+		// TODO: do we have to add the 20ms wait time for the last character of the telegram (VTIME) here or is the end the CR character and not a timeout condition?
+		serialTelegramOffset = ((15 + 1) * (1 + 8 + 1)) / 300.0; // + 0.020 ; // telegram len=15 byte data+CR, frame len=1+8+1, 300 baud
 	}
+	else
+	{
+		/* preparation for timecode ntpq rl command ! */
 
-	/*
-	 * Test if time is running on internal quarz
-	 * if CLK_FLAG1 is set, sychronize even if no radio operation
-	 */
+#if 0
+		snprintf(pp->a_lastcode, sizeof(pp->a_lastcode),
+			 "STATUS: %1X%1X, DATE: %02d.%02d.%04d  TIME: %02d:%02d:%02d",
+			 synch,
+			 DoW,
+			 day,
+			 month,
+			 pp->year,
+			 pp->hour,
+			 pp->minute,
+			 pp->second);
 
-	if ((synch & HOPF_OPMODE) == HOPF_INTERNAL){
-		if ((pp->sloppyclockflag & CLK_FLAG1) == 0) {
+		pp->lencode = strlen(pp->a_lastcode);
+		if ((synch && 0xc) == 0 ){  /* time ok? */
+			refclock_report(peer, CEVNT_BADTIME);
+			pp->leap = LEAP_NOTINSYNC;
+			return;
+		}
+#endif
+		/*
+		 * If clock has no valid status then report error and exit
+		 */
+		if ((synch & HOPF_OPMODE) == HOPF_INVALID ){  /* time ok? */
 			refclock_report(peer, CEVNT_BADTIME);
 			pp->leap = LEAP_NOTINSYNC;
 			return;
 		}
-	}
 
+		/*
+		 * Test if time is running on internal quarz
+		 * if CLK_FLAG1 is set, sychronize even if no radio operation
+		 */
+
+		if ((synch & HOPF_OPMODE) == HOPF_INTERNAL){
+			if ((pp->sloppyclockflag & CLK_FLAG1) == 0) {
+				refclock_report(peer, CEVNT_BADTIME);
+				pp->leap = LEAP_NOTINSYNC;
+				return;
+			}
+		}
+	}
 
-	if (!refclock_process(pp)) {
+	if (!refclock_process_f(pp, pp->fudgetime1 + utcOffset + serialTelegramOffset)) {
 		refclock_report(peer, CEVNT_BADTIME);
 		return;
 	}
@@ -364,6 +532,16 @@
 	record_clock_stats(&peer->srcadr, pp->a_lastcode);
 #endif
 
+	if (hopfserial_check_clocktype(peer, HOPF_SERIAL_CLOCKTYPE_CLOCKMOUSE))
+	{
+		// TODO: don't do this too often. When BREAK is set, the DCF77 reception is off, that means there should be
+		// pause for 5 minutes (at least 2) between polling the time
+		if ((pp->io.fd == 0) || (ioctl(pp->io.fd, TIOCSBRK, 0) != 0)) // set BREAK condition
+		{
+			// failed
+		}
+	}
+
 	return;
 }
 
diff -Naur -x '*.sdf' -x .version -x version.c -x '*.orig' -x '*.vcxproj.user' -x '*.exe' -x '*.dll' -x '*.obj' -x '*.lib' -x '*.exp' -x '*.bin' -x '*.pdb' -x '*.log' -x '*.tlog*' -x BuildLog.htm -x '*.bsc' -x '*.lastbuildstate' -x ntp_keyword.h -x keyword-gen-utd -x messages.h -x messages.rc -x messages.res -x '*.suo' -x Win32-out -x Win32-tmp -x x64-out -x x64-tmp -x Debug -x .vs -x '*.VC.db' -x '*.vcxproj' -x '*.vcxproj.filters' ntp-4.2.8p10.orig/ports/winnt/include/config.h ntp-4.2.8p10/ports/winnt/include/config.h
--- ntp-4.2.8p10.orig/ports/winnt/include/config.h	2016-04-27 21:45:16.000000000 +0200
+++ ntp-4.2.8p10/ports/winnt/include/config.h	2017-11-22 09:38:09.196665100 +0100
@@ -166,6 +166,8 @@
  */
 #define ISC_STATIC_WIN	1
 
+#define LEAP_SMEAR 1
+
 /*
  * ntp_rfc2553.h has cruft under #ifdef SYS_WINNT which is
  * appropriate for older Microsoft IPv6 definitions, such
diff -Naur -x '*.sdf' -x .version -x version.c -x '*.orig' -x '*.vcxproj.user' -x '*.exe' -x '*.dll' -x '*.obj' -x '*.lib' -x '*.exp' -x '*.bin' -x '*.pdb' -x '*.log' -x '*.tlog*' -x BuildLog.htm -x '*.bsc' -x '*.lastbuildstate' -x ntp_keyword.h -x keyword-gen-utd -x messages.h -x messages.rc -x messages.res -x '*.suo' -x Win32-out -x Win32-tmp -x x64-out -x x64-tmp -x Debug -x .vs -x '*.VC.db' -x '*.vcxproj' -x '*.vcxproj.filters' ntp-4.2.8p10.orig/ports/winnt/include/termios.h ntp-4.2.8p10/ports/winnt/include/termios.h
--- ntp-4.2.8p10.orig/ports/winnt/include/termios.h	2016-10-04 08:36:17.000000000 +0200
+++ ntp-4.2.8p10/ports/winnt/include/termios.h	2017-11-22 09:38:09.243483700 +0100
@@ -199,6 +199,8 @@
 #define TIOCMSET	2
 #define TIOCMBIC	3
 #define TIOCMBIS	4
+#define TIOCSBRK    5
+#define TIOCCBRK	6
 
 /* NOP cfsetospeed() and cfsetispeed() for now */
 #define cfsetospeed(dcb, spd)	(0)
diff -Naur -x '*.sdf' -x .version -x version.c -x '*.orig' -x '*.vcxproj.user' -x '*.exe' -x '*.dll' -x '*.obj' -x '*.lib' -x '*.exp' -x '*.bin' -x '*.pdb' -x '*.log' -x '*.tlog*' -x BuildLog.htm -x '*.bsc' -x '*.lastbuildstate' -x ntp_keyword.h -x keyword-gen-utd -x messages.h -x messages.rc -x messages.res -x '*.suo' -x Win32-out -x Win32-tmp -x x64-out -x x64-tmp -x Debug -x .vs -x '*.VC.db' -x '*.vcxproj' -x '*.vcxproj.filters' ntp-4.2.8p10.orig/ports/winnt/libntp/termios.c ntp-4.2.8p10/ports/winnt/libntp/termios.c
--- ntp-4.2.8p10.orig/ports/winnt/libntp/termios.c	2016-10-04 08:36:17.000000000 +0200
+++ ntp-4.2.8p10/ports/winnt/libntp/termios.c	2017-11-22 09:38:09.259089900 +0100
@@ -582,6 +582,14 @@
 		result = ioctl_tiocmset(h, &modctl);
 		break;
 
+	case TIOCSBRK:
+		result = SetCommBreak(h) ? 0 : -1;
+		break;
+
+	case TIOCCBRK:
+		result = ClearCommBreak(h) ? 0 : -1;
+		break;
+
 	default:
 		errno = EINVAL;
 		result = -1;
diff -Naur -x '*.sdf' -x .version -x version.c -x '*.orig' -x '*.vcxproj.user' -x '*.exe' -x '*.dll' -x '*.obj' -x '*.lib' -x '*.exp' -x '*.bin' -x '*.pdb' -x '*.log' -x '*.tlog*' -x BuildLog.htm -x '*.bsc' -x '*.lastbuildstate' -x ntp_keyword.h -x keyword-gen-utd -x messages.h -x messages.rc -x messages.res -x '*.suo' -x Win32-out -x Win32-tmp -x x64-out -x x64-tmp -x Debug -x .vs -x '*.VC.db' -x '*.vcxproj' -x '*.vcxproj.filters' ntp-4.2.8p10.orig/ports/winnt/ntpd/nt_clockstuff.c ntp-4.2.8p10/ports/winnt/ntpd/nt_clockstuff.c
--- ntp-4.2.8p10.orig/ports/winnt/ntpd/nt_clockstuff.c	2015-07-16 09:36:08.000000000 +0200
+++ ntp-4.2.8p10/ports/winnt/ntpd/nt_clockstuff.c	2017-11-22 09:38:09.321514700 +0100
@@ -40,6 +40,7 @@
 #include "ntp_unixtime.h"
 #include "ntp_timer.h"
 #include "ntp_assert.h"
+#include "ntp_fp.h"
 #include "ntp_leapsec.h"
 #include "clockstuff.h"
 #include "ntservice.h"
diff -Naur -x '*.sdf' -x .version -x version.c -x '*.orig' -x '*.vcxproj.user' -x '*.exe' -x '*.dll' -x '*.obj' -x '*.lib' -x '*.exp' -x '*.bin' -x '*.pdb' -x '*.log' -x '*.tlog*' -x BuildLog.htm -x '*.bsc' -x '*.lastbuildstate' -x ntp_keyword.h -x keyword-gen-utd -x messages.h -x messages.rc -x messages.res -x '*.suo' -x Win32-out -x Win32-tmp -x x64-out -x x64-tmp -x Debug -x .vs -x '*.VC.db' -x '*.vcxproj' -x '*.vcxproj.filters' ntp-4.2.8p10.orig/ports/winnt/vs2015/common.props ntp-4.2.8p10/ports/winnt/vs2015/common.props
--- ntp-4.2.8p10.orig/ports/winnt/vs2015/common.props	2016-04-27 21:54:10.000000000 +0200
+++ ntp-4.2.8p10/ports/winnt/vs2015/common.props	2017-11-22 10:08:17.089338700 +0100
@@ -1,60 +1,60 @@
-﻿<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ImportGroup Label="PropertySheets">
-  </ImportGroup>
-  <PropertyGroup Label="UserMacros">
-    <OutBaseDir>$(SolutionDir)\$(Platform)-out\$(Configuration)</OutBaseDir>
-    <TmpBaseDir>$(SolutionDir)\$(Platform)-tmp\$(Configuration)</TmpBaseDir>
-  </PropertyGroup>
-  <PropertyGroup>
-    <_ProjectFileVersion>12.0.30501.0</_ProjectFileVersion>
-    <OutDir>$(OutBaseDir)\</OutDir>
-    <IntDir>$(TmpBaseDir)\$(TargetName)\</IntDir>
-    <LinkIncremental>false</LinkIncremental>
-  </PropertyGroup>
-  <ItemDefinitionGroup>
-    <BuildLog>
-      <Path>$(IntDir)BuildLog.htm</Path>
-    </BuildLog>
-    <ClCompile>
-      <AdditionalIncludeDirectories>$(VC_IncludePath);..\..\include;..\..\..\..\lib\isc\win32\include;..\..\..\..\include;..\..\..\..\lib\isc\include;..\..\..\..\sntp\libopts;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>_CONSOLE;_WINDOWS;WIN32;SYS_WINNT;HAVE_CONFIG_H;HAVE_ARC4RANDOM_BUF;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <StringPooling>true</StringPooling>
-      <ExceptionHandling />
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <RuntimeTypeInfo>false</RuntimeTypeInfo>
-      <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
-      <ObjectFileName>$(IntDir)</ObjectFileName>
-      <XMLDocumentationFileName>$(IntDir)</XMLDocumentationFileName>
-      <BrowseInformation>true</BrowseInformation>
-      <SuppressStartupBanner>true</SuppressStartupBanner>
-      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
-      <CompileAs>CompileAsC</CompileAs>
-      <DisableSpecificWarnings>4996;4267;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
-      <WarningLevel>Level3</WarningLevel>
-      <MultiProcessorCompilation>true</MultiProcessorCompilation>
-    </ClCompile>
-    <Link>
-      <AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
-      <Version>4.2</Version>
-      <SuppressStartupBanner>true</SuppressStartupBanner>
-      <AdditionalLibraryDirectories>$(TmpBaseDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
-      <SubSystem>Console</SubSystem>
-      <OptimizeReferences>true</OptimizeReferences>
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>
-      <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
-      <RandomizedBaseAddress>false</RandomizedBaseAddress>
-      <DataExecutionPrevention>false</DataExecutionPrevention>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemGroup>
-    <BuildMacro Include="OutBaseDir">
-      <Value>$(OutBaseDir)</Value>
-    </BuildMacro>
-    <BuildMacro Include="TmpBaseDir">
-      <Value>$(TmpBaseDir)</Value>
-    </BuildMacro>
-  </ItemGroup>
+﻿<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ImportGroup Label="PropertySheets">
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros">
+    <OutBaseDir>$(SolutionDir)\$(Platform)-out\$(Configuration)</OutBaseDir>
+    <TmpBaseDir>$(SolutionDir)\$(Platform)-tmp\$(Configuration)</TmpBaseDir>
+  </PropertyGroup>
+  <PropertyGroup>
+    <_ProjectFileVersion>12.0.30501.0</_ProjectFileVersion>
+    <OutDir>$(OutBaseDir)\</OutDir>
+    <IntDir>$(TmpBaseDir)\$(TargetName)\</IntDir>
+    <LinkIncremental>false</LinkIncremental>
+  </PropertyGroup>
+  <ItemDefinitionGroup>
+    <BuildLog>
+      <Path>$(IntDir)BuildLog.htm</Path>
+    </BuildLog>
+    <ClCompile>
+      <AdditionalIncludeDirectories>$(VC_IncludePath);..\..\include;..\..\..\..\lib\isc\win32\include;..\..\..\..\include;..\..\..\..\lib\isc\include;..\..\..\..\sntp\libopts;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>_CONSOLE;_WINDOWS;WIN32;SYS_WINNT;HAVE_CONFIG_H;HAVE_ARC4RANDOM_BUF;_CRT_SECURE_NO_WARNINGS;_USE_MATH_DEFINES;HAVE_UINT32_T;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <StringPooling>true</StringPooling>
+      <ExceptionHandling />
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <RuntimeTypeInfo>false</RuntimeTypeInfo>
+      <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
+      <ObjectFileName>$(IntDir)</ObjectFileName>
+      <XMLDocumentationFileName>$(IntDir)</XMLDocumentationFileName>
+      <BrowseInformation>true</BrowseInformation>
+      <SuppressStartupBanner>true</SuppressStartupBanner>
+      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+      <CompileAs>CompileAsC</CompileAs>
+      <DisableSpecificWarnings>4996;4267;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+      <WarningLevel>Level3</WarningLevel>
+      <MultiProcessorCompilation>true</MultiProcessorCompilation>
+    </ClCompile>
+    <Link>
+      <AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <Version>4.2</Version>
+      <SuppressStartupBanner>true</SuppressStartupBanner>
+      <AdditionalLibraryDirectories>$(TmpBaseDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+      <ProgramDatabaseFile>$(OutDir)$(ProjectName).pdb</ProgramDatabaseFile>
+      <SubSystem>Console</SubSystem>
+      <OptimizeReferences>true</OptimizeReferences>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
+      <RandomizedBaseAddress>false</RandomizedBaseAddress>
+      <DataExecutionPrevention>false</DataExecutionPrevention>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <BuildMacro Include="OutBaseDir">
+      <Value>$(OutBaseDir)</Value>
+    </BuildMacro>
+    <BuildMacro Include="TmpBaseDir">
+      <Value>$(TmpBaseDir)</Value>
+    </BuildMacro>
+  </ItemGroup>
 </Project>
\ No newline at end of file
diff -Naur -x '*.sdf' -x .version -x version.c -x '*.orig' -x '*.vcxproj.user' -x '*.exe' -x '*.dll' -x '*.obj' -x '*.lib' -x '*.exp' -x '*.bin' -x '*.pdb' -x '*.log' -x '*.tlog*' -x BuildLog.htm -x '*.bsc' -x '*.lastbuildstate' -x ntp_keyword.h -x keyword-gen-utd -x messages.h -x messages.rc -x messages.res -x '*.suo' -x Win32-out -x Win32-tmp -x x64-out -x x64-tmp -x Debug -x .vs -x '*.VC.db' -x '*.vcxproj' -x '*.vcxproj.filters' ntp-4.2.8p10.orig/ports/winnt/vs2015/debug.props ntp-4.2.8p10/ports/winnt/vs2015/debug.props
--- ntp-4.2.8p10.orig/ports/winnt/vs2015/debug.props	2017-02-01 10:47:13.000000000 +0100
+++ ntp-4.2.8p10/ports/winnt/vs2015/debug.props	2017-11-22 09:47:14.548653400 +0100
@@ -1,24 +1,24 @@
-﻿<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ImportGroup Label="PropertySheets">
-  </ImportGroup>
-  <PropertyGroup Label="UserMacros" />
-  <PropertyGroup>
-    <_ProjectFileVersion>12.0.30501.0</_ProjectFileVersion>
-    <_PropertySheetDisplayName>debug-x86</_PropertySheetDisplayName>
-  </PropertyGroup>
-  <ItemDefinitionGroup>
-    <ClCompile>
-      <Optimization>Disabled</Optimization>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-      <AdditionalIncludeDirectories>$(OPENSSL_INC);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>_DEBUG;OPENSSL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
-    </ClCompile>
-    <Link>
-      <TargetMachine>MachineX86</TargetMachine>
-      <AdditionalLibraryDirectories>$(OPENSSL_LIB)\vc</AdditionalLibraryDirectories>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemGroup />
+﻿<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ImportGroup Label="PropertySheets">
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup>
+    <_ProjectFileVersion>12.0.30501.0</_ProjectFileVersion>
+    <_PropertySheetDisplayName>debug-x86</_PropertySheetDisplayName>
+  </PropertyGroup>
+  <ItemDefinitionGroup>
+    <ClCompile>
+      <Optimization>Disabled</Optimization>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <AdditionalIncludeDirectories>$(OPENSSL_INC);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+    </ClCompile>
+    <Link>
+      <TargetMachine>MachineX86</TargetMachine>
+      <AdditionalLibraryDirectories>$(OPENSSL_LIB)\vc</AdditionalLibraryDirectories>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup />
 </Project>
\ No newline at end of file
diff -Naur -x '*.sdf' -x .version -x version.c -x '*.orig' -x '*.vcxproj.user' -x '*.exe' -x '*.dll' -x '*.obj' -x '*.lib' -x '*.exp' -x '*.bin' -x '*.pdb' -x '*.log' -x '*.tlog*' -x BuildLog.htm -x '*.bsc' -x '*.lastbuildstate' -x ntp_keyword.h -x keyword-gen-utd -x messages.h -x messages.rc -x messages.res -x '*.suo' -x Win32-out -x Win32-tmp -x x64-out -x x64-tmp -x Debug -x .vs -x '*.VC.db' -x '*.vcxproj' -x '*.vcxproj.filters' ntp-4.2.8p10.orig/ports/winnt/vs2015/debug-x64.props ntp-4.2.8p10/ports/winnt/vs2015/debug-x64.props
--- ntp-4.2.8p10.orig/ports/winnt/vs2015/debug-x64.props	2017-02-01 10:47:13.000000000 +0100
+++ ntp-4.2.8p10/ports/winnt/vs2015/debug-x64.props	2017-11-22 09:47:14.548653400 +0100
@@ -1,24 +1,24 @@
-﻿<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ImportGroup Label="PropertySheets">
-  </ImportGroup>
-  <PropertyGroup Label="UserMacros" />
-  <PropertyGroup>
-    <_ProjectFileVersion>12.0.30501.0</_ProjectFileVersion>
-    <_PropertySheetDisplayName>debug-x64</_PropertySheetDisplayName>
-  </PropertyGroup>
-  <ItemDefinitionGroup>
-    <ClCompile>
-      <Optimization>Disabled</Optimization>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-      <AdditionalIncludeDirectories>$(OPENSSL64_INC);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>_DEBUG;OPENSSL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
-    </ClCompile>
-    <Link>
-      <TargetMachine>MachineX64</TargetMachine>
-      <AdditionalLibraryDirectories>$(OPENSSL64_LIB)\vc</AdditionalLibraryDirectories>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemGroup />
+﻿<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ImportGroup Label="PropertySheets">
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup>
+    <_ProjectFileVersion>12.0.30501.0</_ProjectFileVersion>
+    <_PropertySheetDisplayName>debug-x64</_PropertySheetDisplayName>
+  </PropertyGroup>
+  <ItemDefinitionGroup>
+    <ClCompile>
+      <Optimization>Disabled</Optimization>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <AdditionalIncludeDirectories>$(OPENSSL64_INC);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
+    </ClCompile>
+    <Link>
+      <TargetMachine>MachineX64</TargetMachine>
+      <AdditionalLibraryDirectories>$(OPENSSL64_LIB)\vc</AdditionalLibraryDirectories>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup />
 </Project>
\ No newline at end of file
diff -Naur -x '*.sdf' -x .version -x version.c -x '*.orig' -x '*.vcxproj.user' -x '*.exe' -x '*.dll' -x '*.obj' -x '*.lib' -x '*.exp' -x '*.bin' -x '*.pdb' -x '*.log' -x '*.tlog*' -x BuildLog.htm -x '*.bsc' -x '*.lastbuildstate' -x ntp_keyword.h -x keyword-gen-utd -x messages.h -x messages.rc -x messages.res -x '*.suo' -x Win32-out -x Win32-tmp -x x64-out -x x64-tmp -x Debug -x .vs -x '*.VC.db' -x '*.vcxproj' -x '*.vcxproj.filters' ntp-4.2.8p10.orig/ports/winnt/vs2015/release.props ntp-4.2.8p10/ports/winnt/vs2015/release.props
--- ntp-4.2.8p10.orig/ports/winnt/vs2015/release.props	2017-02-01 10:47:13.000000000 +0100
+++ ntp-4.2.8p10/ports/winnt/vs2015/release.props	2017-11-22 09:47:14.564255100 +0100
@@ -1,25 +1,25 @@
-﻿<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ImportGroup Label="PropertySheets">
-  </ImportGroup>
-  <PropertyGroup Label="UserMacros" />
-  <PropertyGroup>
-    <_ProjectFileVersion>12.0.30501.0</_ProjectFileVersion>
-    <_PropertySheetDisplayName>release-x86</_PropertySheetDisplayName>
-  </PropertyGroup>
-  <ItemDefinitionGroup>
-    <ClCompile>
-      <Optimization>Full</Optimization>
-      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
-      <WholeProgramOptimization>true</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>$(OPENSSL_INC);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>NDEBUG;OPENSSL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
-    </ClCompile>
-    <Link>
-      <TargetMachine>MachineX86</TargetMachine>
-      <AdditionalLibraryDirectories>$(OPENSSL_LIB)\vc</AdditionalLibraryDirectories>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemGroup />
+﻿<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ImportGroup Label="PropertySheets">
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup>
+    <_ProjectFileVersion>12.0.30501.0</_ProjectFileVersion>
+    <_PropertySheetDisplayName>release-x86</_PropertySheetDisplayName>
+  </PropertyGroup>
+  <ItemDefinitionGroup>
+    <ClCompile>
+      <Optimization>Full</Optimization>
+      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
+      <WholeProgramOptimization>true</WholeProgramOptimization>
+      <AdditionalIncludeDirectories>$(OPENSSL_INC);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+    </ClCompile>
+    <Link>
+      <TargetMachine>MachineX86</TargetMachine>
+      <AdditionalLibraryDirectories>$(OPENSSL_LIB)\vc</AdditionalLibraryDirectories>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup />
 </Project>
\ No newline at end of file
diff -Naur -x '*.sdf' -x .version -x version.c -x '*.orig' -x '*.vcxproj.user' -x '*.exe' -x '*.dll' -x '*.obj' -x '*.lib' -x '*.exp' -x '*.bin' -x '*.pdb' -x '*.log' -x '*.tlog*' -x BuildLog.htm -x '*.bsc' -x '*.lastbuildstate' -x ntp_keyword.h -x keyword-gen-utd -x messages.h -x messages.rc -x messages.res -x '*.suo' -x Win32-out -x Win32-tmp -x x64-out -x x64-tmp -x Debug -x .vs -x '*.VC.db' -x '*.vcxproj' -x '*.vcxproj.filters' ntp-4.2.8p10.orig/ports/winnt/vs2015/release-x64.props ntp-4.2.8p10/ports/winnt/vs2015/release-x64.props
--- ntp-4.2.8p10.orig/ports/winnt/vs2015/release-x64.props	2017-02-01 10:47:13.000000000 +0100
+++ ntp-4.2.8p10/ports/winnt/vs2015/release-x64.props	2017-11-22 09:47:14.564255100 +0100
@@ -1,25 +1,25 @@
-﻿<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ImportGroup Label="PropertySheets">
-  </ImportGroup>
-  <PropertyGroup Label="UserMacros" />
-  <PropertyGroup>
-    <_ProjectFileVersion>12.0.30501.0</_ProjectFileVersion>
-    <_PropertySheetDisplayName>release-x64</_PropertySheetDisplayName>
-  </PropertyGroup>
-  <ItemDefinitionGroup>
-    <ClCompile>
-      <Optimization>Full</Optimization>
-      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
-      <WholeProgramOptimization>true</WholeProgramOptimization>
-      <AdditionalIncludeDirectories>$(OPENSSL64_INC);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>NDEBUG;OPENSSL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
-    </ClCompile>
-    <Link>
-      <TargetMachine>MachineX64</TargetMachine>
-      <AdditionalLibraryDirectories>$(OPENSSL64_LIB)\vc</AdditionalLibraryDirectories>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemGroup />
+﻿<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ImportGroup Label="PropertySheets">
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup>
+    <_ProjectFileVersion>12.0.30501.0</_ProjectFileVersion>
+    <_PropertySheetDisplayName>release-x64</_PropertySheetDisplayName>
+  </PropertyGroup>
+  <ItemDefinitionGroup>
+    <ClCompile>
+      <Optimization>Full</Optimization>
+      <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
+      <WholeProgramOptimization>true</WholeProgramOptimization>
+      <AdditionalIncludeDirectories>$(OPENSSL64_INC);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+    </ClCompile>
+    <Link>
+      <TargetMachine>MachineX64</TargetMachine>
+      <AdditionalLibraryDirectories>$(OPENSSL64_LIB)\vc</AdditionalLibraryDirectories>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup />
 </Project>
\ No newline at end of file
