Fixes to get hmac_support and 2.5 changes working for the Windows lib and client...
authorDamien Stuart <dstuart@dstuart.org>
Sun, 5 May 2013 17:20:20 +0000 (13:20 -0400)
committerDamien Stuart <dstuart@dstuart.org>
Sun, 5 May 2013 17:20:20 +0000 (13:20 -0400)
client/spa_comm.c
client/utils.c
client/utils.h
common/common.h
lib/cipher_funcs.c
lib/fko_encryption.c
lib/fko_util.c
lib/fko_util.h
win32/fwknop-client.vcproj
win32/libfko.vcproj

index ae6d4a8..5a23837 100644 (file)
@@ -590,14 +590,14 @@ send_spa_packet(fko_ctx_t ctx, fko_cli_options_t *options)
     struct sockaddr_in  saddr, daddr;
     char                ip_str[INET_ADDRSTRLEN] = {0};  /* String used to contain the ip addres of an hostname */
     struct addrinfo     hints;                          /* Structure used to set hints to reslove hostname */
-
-    /* Initialize the hint buffer */
-    memset(&hints, 0 , sizeof(hints));
-
 #ifdef WIN32
     WSADATA wsa_data;
 #endif
 
+
+    /* Initialize the hint buffer */
+    memset(&hints, 0 , sizeof(hints));
+
     /* Get our spa data here.
     */
     res = fko_get_spa_data(ctx, &spa_data);
index d003df9..cb99e31 100644 (file)
@@ -31,7 +31,9 @@
 #include "common.h"
 #include "fwknop_common.h"
 #include "utils.h"
+#ifndef WIN32
 #include <arpa/inet.h>
+#endif
 
 static void *get_in_addr(struct sockaddr *sa);
 
index bf3711d..87abb36 100644 (file)
 #endif
 
 #include <sys/types.h>
-#include <sys/socket.h>
-#include <netdb.h>
+#ifdef WIN32
+  #include <winsock2.h>
+  #include <ws2tcpip.h>
+#else
+  #if HAVE_SYS_SOCKET_H
+    #include <sys/socket.h>
+  #endif
+  #include <netdb.h>
+#endif
 
 #define PROTOCOL_BUFSIZE    16      /*!< Maximum number of chars for a protocol string (TCP for example) */
 
index 5f5cee9..5039d77 100644 (file)
   #define S_IRUSR              _S_IREAD
   #define S_IWUSR              _S_IWRITE
   #define PATH_SEP      '\\'
+  // --DSS needed for VS versions before 2010
+  typedef __int8 int8_t;
+  typedef unsigned __int8 uint8_t;
+  typedef __int16 int16_t;
+  typedef unsigned __int16 uint16_t;
+  typedef __int32 int32_t;
+  typedef unsigned __int32 uint32_t;
+  typedef __int64 int64_t;
+  typedef unsigned __int64 uint64_t;
+
 #else
   #include <signal.h>
   #define PATH_SEP      '/'
index afb9d18..abfb573 100644 (file)
@@ -262,7 +262,7 @@ rij_encrypt(unsigned char *in, size_t in_len,
      * multiple of the Rijndael block size
     */
     pad_val = RIJNDAEL_BLOCKSIZE - (in_len % RIJNDAEL_BLOCKSIZE);
-    for (i = in_len; i < in_len+pad_val; i++)
+    for (i = (int)in_len; i < ((int)in_len+pad_val); i++)
         in[i] = pad_val;
 
     block_encrypt(&ctx, in, in_len+pad_val, ondx, ctx.iv);
index dd2b9c4..4ec929d 100644 (file)
@@ -569,7 +569,7 @@ fko_encryption_type(const char * const enc_data)
 /* Set the GPG recipient key name.
 */
 int
-fko_set_gpg_recipient(fko_ctx_t ctx, const char *recip)
+fko_set_gpg_recipient(fko_ctx_t ctx, const char * const recip)
 {
 #if HAVE_LIBGPGME
     int             res;
index bc98816..93b8ace 100644 (file)
@@ -347,4 +347,26 @@ strtol_wrapper(const char * const str, const int min,
     return val;
 }
 
+
+#ifdef WIN32
+/* Windows does not have strndup, so we well implement it here.
+ * This was the Public Domain C Library (PDCLib).
+*/
+char 
+*strndup( const char * s, size_t len )
+{
+    char* ns = NULL;
+    if(s) {
+        ns = malloc(len + 1);
+        if(ns) {
+            ns[len] = 0;
+            // strncpy to be pedantic about modification in multithreaded 
+            // applications
+            return strncpy(ns, s, len);
+        }
+    }
+    return ns;
+}
+#endif
+
 /***EOF***/
index b70849e..7ea67fb 100644 (file)
@@ -51,6 +51,10 @@ const char * msg_type_inttostr(const int type);
 size_t  strlcat(char *dst, const char *src, size_t siz);
 size_t  strlcpy(char *dst, const char *src, size_t siz);
 
+#ifdef WIN32
+char * strndup( const char * s, size_t len );
+#endif
+
 #endif /* FKO_UTIL_H */
 
 /***EOF***/
index 9148b2c..53a6a5e 100644 (file)
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\lib\fko_util.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="..\client\fwknop.c"\r
                                >\r
                        </File>\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\client\log_msg.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="..\client\spa_comm.c"\r
                                >\r
                        </File>\r
                        UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"\r
                        >\r
                        <File\r
+                               RelativePath="..\client\cmd_opts.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="..\common\common.h"\r
                                >\r
                        </File>\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\lib\fko_util.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="..\client\fwknop.h"\r
                                >\r
                        </File>\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\client\log_msg.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\common\netinet_common.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="..\client\spa_comm.h"\r
                                >\r
                        </File>\r
index 1eb779b..3ba753a 100644 (file)
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\lib\fko_hmac.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="..\lib\fko_message.c"\r
                                >\r
                        </File>\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\lib\fko_util.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath=".\getlogin.c"\r
                                >\r
                        </File>\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\lib\hmac.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="..\lib\md5.c"\r
                                >\r
                        </File>\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\common\common.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath=".\config.h"\r
                                >\r
                        </File>\r
                                >\r
                        </File>\r
                        <File\r
+                               RelativePath="..\lib\hmac.h"\r
+                               >\r
+                       </File>\r
+                       <File\r
                                RelativePath="..\lib\md5.h"\r
                                >\r
                        </File>\r