Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

linux-ipsec: 64 bit patches to freeswan/lib

From: Peter Onion <ponion(at)srd.bt.co.uk>
Date: Tue Dec 15 1998 - 12:00:27 EST


This was created using

# cd /usr/src/freeswan-snap1998Nov30
# export DIFFDIR="lib"
#diff -urN $DIFFDIR/dogbert/usr/src/freeswan-snap1998Nov30/$DIFFDIR >
/tmp/$DIFFDIR.diffs

The version on dogbert is modified set.

diff -urN lib/addrtoa.c /dogbert/usr/src/freeswan-snap1998Nov30/lib/addrtoa.c

--- lib/addrtoa.c       Thu Jul 30 21:07:01 1998
+++ /dogbert/usr/src/freeswan-snap1998Nov30/lib/addrtoa.c       Tue Dec  8
12:14:49 1998
@@ -1,6 +1,15 @@

 #include "internal.h"
 #include "freeswan.h"  
+
+/* Because this code gets used in both kernel & user code it needs to use 
+   both __u32 (kernel) and u_int32_t (user) , so this kludges makes it work 
+   in both.  P.J.Onion
+*/
+#ifdef __KERNEL__
+#define u_int32_t __u32
+#endif
+
 #define        NBYTES  4               /* bytes in an address */
 #define        PERBYTE 4               /* three digits plus a dot or NUL */
 #define        BUFLEN  (NBYTES*PERBYTE)

@@ -19,10 +28,10 @@
char *dst; /* need not be valid if dstlen is 0 */
 size_t dstlen;
 {
-       unsigned long a = ntohl(addr.s_addr);
+       u_int32_t a = ntohl(addr.s_addr);
        int i;
        size_t n;
-       unsigned long byte;
+       u_int32_t byte;
        char buf[BUFLEN];
        char *p;
 
diff -urN lib/atoaddr.c /dogbert/usr/src/freeswan-snap1998Nov30/lib/atoaddr.c
--- lib/atoaddr.c       Tue Oct 13 23:51:40 1998
+++ /dogbert/usr/src/freeswan-snap1998Nov30/lib/atoaddr.c       Tue Dec  1
14:48:57 1998
@@ -83,7 +83,7 @@

 struct in_addr *addrp;
 {
        const char *oops;
-       unsigned long addr;
+       u_int32_t addr;
 
        if (srclen != 8)
                return "internal error, try8hex called with bad length";

@@ -130,7 +130,7 @@
const char *stop = src + srclen; /* just past end */ int byte; const char *oops; - unsigned long addr; + u_int32_t addr; int i; # define NBYTES 4 # define BYTE 8 diff -urN lib/atoasr.c /dogbert/usr/src/freeswan-snap1998Nov30/lib/atoasr.c --- lib/atoasr.c Thu Jul 30 21:07:02 1998 +++ /dogbert/usr/src/freeswan-snap1998Nov30/lib/atoasr.c Tue Dec 1
Do you need help?X
11:06:05 1998
@@ -15,7 +15,7 @@
        const char *stop;
        size_t mlen;
        const char *oops;
-       unsigned long bc;
+       //__u32 bc;
 
        if (srclen == 0)
                srclen = strlen(src);

diff -urN lib/atosa.c /dogbert/usr/src/freeswan-snap1998Nov30/lib/atosa.c --- lib/atosa.c Sun Oct 25 03:34:43 1998 +++ /dogbert/usr/src/freeswan-snap1998Nov30/lib/atosa.c Tue Dec 8 12:15:26 1998
@@ -29,9 +29,9 @@
        const char *addr;
        const char *spi;
        struct satype *sat;
-       unsigned long ul;
+       u_int32_t ul;
        const char *oops;
-#      define  MINLEN  5       /* ah0@0 is as short as it can get */
+#       define MINLEN  5       /* ah0@0 is as short as it can get */
 
        if (srclen == 0)
                srclen = strlen(src);

diff -urN lib/atosubnet.c
/dogbert/usr/src/freeswan-snap1998Nov30/lib/atosubnet.c
--- lib/atosubnet.c     Thu Aug 20 14:14:41 1998
+++ /dogbert/usr/src/freeswan-snap1998Nov30/lib/atosubnet.c     Tue Dec  1
14:49:48 1998
@@ -20,7 +20,7 @@
        const char *mask;
        size_t mlen;
        const char *oops;
-       unsigned long bc;
+       u_int32_t bc;
        static char def[] = DEFAULTSUBNET;
 #      define  DEFLEN  (sizeof(def) - 1)       /* -1 for NUL */
        static char defis[] = "0/0";

diff -urN lib/atoul.c /dogbert/usr/src/freeswan-snap1998Nov30/lib/atoul.c --- lib/atoul.c Tue Sep 29 19:43:02 1998 +++ /dogbert/usr/src/freeswan-snap1998Nov30/lib/atoul.c Tue Dec 8 14:15:09 1998
@@ -9,7 +9,7 @@

 const char *src;
 size_t srclen;                 /* 0 means strlen(src) */
 int base;                      /* 0 means figure it out */
-unsigned long *resultp;
+u_int32_t *resultp;
 {
        const char *stop;
        static char hex[] = "0123456789abcdef";

@@ -17,7 +17,7 @@
int d; char c; char *p; - unsigned long r; + u_int32_t r,MAX; unsigned long rlimit, dlimit; if (srclen == 0)
@@ -52,11 +52,15 @@
r = (r << 4) | d; } /* defer length check to catch invalid digits first */ - if (srclen > sizeof(unsigned long) * 2) + if (srclen > sizeof(u_int32_t) * 2) return "hex number too long"; } else { - rlimit = ULONG_MAX / base; - dlimit = ULONG_MAX - rlimit*base; + + MAX = ~0; + rlimit = MAX / base; /* These used to be ULONG_MAX, but there
Do you need more help?X
doesn't seem to be a portable + defined constant replacement that is correct + in 32 & 64 bit environments P.J.Onion */ + dlimit = MAX - rlimit*base; while (src < stop) { c = *src++; d = c - '0'; diff -urN lib/freeswan.h /dogbert/usr/src/freeswan-snap1998Nov30/lib/freeswan.h --- lib/freeswan.h Tue Oct 13 22:17:07 1998 +++ /dogbert/usr/src/freeswan-snap1998Nov30/lib/freeswan.h Tue Dec 1
16:33:00 1998
@@ -32,17 +32,18 @@
        const char *src,
        size_t srclen,          /* 0 means strlen(src) */
        int base,               /* 0 means figure it out */
-       unsigned long *resultp
+        unsigned int  *resultp
 );
 size_t                         /* space needed for full conversion */
 ultoa(
-       unsigned long n,
+       unsigned int n,
        int base,
        char *dst,
        size_t dstlen
 );
 #define        ULTOA_BUF       21      /* just large enough for largest
result, */
                                /* assuming 64-bit unsigned long! */
+                                /* Pity this wasn't assumed elsewhere ! PJO */
 
 /* Internet addresses */
 const char *                   /* NULL for success, else string literal */
diff -urN lib/goodmask.c /dogbert/usr/src/freeswan-snap1998Nov30/lib/goodmask.c
--- lib/goodmask.c      Thu Jul 30 21:07:03 1998
+++ /dogbert/usr/src/freeswan-snap1998Nov30/lib/goodmask.c      Tue Dec  1
16:40:15 1998
@@ -1,6 +1,12 @@

 #include "internal.h"
 #include "freeswan.h"  
+
+#ifdef __KERNEL__
+#define u_int32_t __u32
+#endif
+
+

 /*
  • goodmask - is this a good (^1+0+$) subnet mask?
    • You are not expected to understand this. See Henry S. Warren Jr,
      @@ -11,7 +17,7 @@
      goodmask(mask) struct in_addr mask; { - unsigned long x = ~ntohl(mask.s_addr); + u_int32_t x = ~ntohl(mask.s_addr);
        if ((((x|(x-1))+1)&x) == 0)
                return 1;

@@ -27,7 +33,7 @@

 masktobits(mask)
 struct in_addr mask;
 {
-       unsigned long m = ntohl(mask.s_addr);
+       u_int32_t m = ntohl(mask.s_addr);
        int masklen;
Can we help you?X
if (!goodmask(mask))

diff -urN lib/satoa.c /dogbert/usr/src/freeswan-snap1998Nov30/lib/satoa.c --- lib/satoa.c Sun Oct 25 03:34:43 1998 +++ /dogbert/usr/src/freeswan-snap1998Nov30/lib/satoa.c Tue Dec 1 11:09:11 1998
@@ -24,7 +24,7 @@
        size_t len;
        int base;
        struct typename *tn;
-       unsigned long ul;
+       //__u32 ul;
        char buf[30+ADDRTOA_BUF];
 
        switch (format) {

diff -urN lib/subnettoa.c
/dogbert/usr/src/freeswan-snap1998Nov30/lib/subnettoa.c
--- lib/subnettoa.c     Thu Jul 30 21:07:04 1998
+++ /dogbert/usr/src/freeswan-snap1998Nov30/lib/subnettoa.c     Tue Dec  1
16:39:58 1998
@@ -1,6 +1,12 @@

 #include "internal.h"
 #include "freeswan.h"  
+
+#ifdef __KERNEL__
+#define u_int32_t __u32
+#endif
+
+

 /*
  • subnettoa - convert address and mask to ASCII "addr/mask"
    • Output expresses the mask as a bit count if possible, else dotted decimal.
      @@ -38,7 +44,7 @@
        n = masktobits(mask);
        if (n >= 0)
-               len += ultoa((unsigned long)n, 10, p, rest);
+               len += ultoa((u_int32_t)n, 10, p, rest);
        else
                len += addrtoa(mask, 0, p, rest);
 

diff -urN lib/ultoa.c /dogbert/usr/src/freeswan-snap1998Nov30/lib/ultoa.c --- lib/ultoa.c Thu Jul 30 21:07:04 1998 +++ /dogbert/usr/src/freeswan-snap1998Nov30/lib/ultoa.c Tue Dec 1 16:38:21 1998
@@ -1,17 +1,22 @@

 #include "internal.h"
 #include "freeswan.h"  

+#ifdef __KERNEL__
+#define u_int32_t __u32
+#endif
+
+

 /*
- - ultoa - convert unsigned long to decimal ASCII + - ultoa - convert u_int32_t to decimal ASCII   */
 size_t                         /* length required for full conversion */
 ultoa(n, base, dst, dstlen)
-unsigned long n;
+u_int32_t n;
 int base;
 char *dst;                     /* need not be valid if dstlen is 0 */
 size_t dstlen;
 {
-       char buf[3*sizeof(unsigned long) + 1];
+       char buf[3*sizeof(u_int32_t) + 1];
        char *bufend = buf + sizeof(buf);
        size_t len;
        char *p;


----------------------------------

E-Mail: Peter Onion <ponion@srd.bt.co.uk> Date: 15-Dec-98
Time: 16:53:20

This message was sent by XFMail


Received on Tue Dec 15 13:11:25 1998

This archive was generated by hypermail 2.1.8 : Wed Aug 23 2006 - 12:59:29 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library