On Jun 09, 2013, Blair Zajac wrote:

> On 6/9/13 3:29 PM, Blair Zajac wrote:
> > I recalled that PPC is big endian so hacked the below patch in and was
> > able to get fwknop to work. I wouldn't use the patch for a good commit,
> > as it doesn't support 64-bit PPC systems and its duplicated across two
> > files.
> 
> BTW, this is on Mac OS X 10.5.8 and the OS doesn't define BYTEORDER in a 
> standard header (I don't count ffi/*.h as standard headers):
> 
> $ find /usr/include -type f | xargs grep BYTEORDER
> /usr/include/ffi/fficonfig.h:#        define  BYTEORDER 1234
> /usr/include/ffi/fficonfig.h:#        define  BYTEORDER 1234
> /usr/include/ffi/fficonfig.h:#        define  BYTEORDER 4321
> /usr/include/ffi/fficonfig.h:#        define  BYTEORDER 4321
> /usr/include/libkern/_OSByteOrder.h:#ifndef _OS__OSBYTEORDER_H
> /usr/include/libkern/_OSByteOrder.h:#define _OS__OSBYTEORDER_H
> /usr/include/libkern/_OSByteOrder.h:#endif /* ! _OS__OSBYTEORDER_H */
> /usr/include/libkern/i386/_OSByteOrder.h:#ifndef _OS__OSBYTEORDERI386_H
> /usr/include/libkern/i386/_OSByteOrder.h:#define _OS__OSBYTEORDERI386_H
> /usr/include/libkern/i386/_OSByteOrder.h:#endif /* ! 
> _OS__OSBYTEORDERI386_H */
> /usr/include/libkern/i386/OSByteOrder.h:#ifndef _OS_OSBYTEORDERI386_H
> /usr/include/libkern/i386/OSByteOrder.h:#define _OS_OSBYTEORDERI386_H
> /usr/include/libkern/i386/OSByteOrder.h:#endif /* ! _OS_OSBYTEORDERI386_H */
> /usr/include/libkern/machine/OSByteOrder.h:#ifndef _OS_OSBYTEORDERMACHINE_H
> /usr/include/libkern/machine/OSByteOrder.h:#define _OS_OSBYTEORDERMACHINE_H
> /usr/include/libkern/machine/OSByteOrder.h:#endif /* ! 
> _OS_OSBYTEORDERMACHINE_H */
> /usr/include/libkern/OSByteOrder.h:#ifndef _OS_OSBYTEORDER_H
> /usr/include/libkern/OSByteOrder.h:#define _OS_OSBYTEORDER_H
> /usr/include/libkern/OSByteOrder.h:#endif /* ! _OS_OSBYTEORDER_H */
> /usr/include/libkern/ppc/OSByteOrder.h:#ifndef _OS_OSBYTEORDERPPC_H
> /usr/include/libkern/ppc/OSByteOrder.h:#define _OS_OSBYTEORDERPPC_H
> /usr/include/libkern/ppc/OSByteOrder.h:#endif /* ! _OS_OSBYTEORDERPPC_H */
> /usr/include/sys/sysctl.h:#define     HW_BYTEORDER     4              /* int: 
> machine byte 
> order */

Interesting, and thanks for the bug report for PPC systems.  Seems like
fwknop could have a more generic way of making a guess for an endian
value.  There is a section of code in lib/fko_common.h that does some of
this, but I think it could be extended:

http://www.cipherdyne.org/cgi-bin/gitweb.cgi?p=fwknop.git;a=blob;f=lib/fko_common.h;h=24bb14c1bbc18d44c1927f1af440bf473d533269;hb=refs/heads/master#l91

For example, does your system have either _BIG_ENDIAN or __BIG_ENDIAN__
defined?  If so, would the following patch work (which only defines
BYTEORDER if all other current measures have failed and then forces a
compile warning if this also fails)?:

diff --git a/lib/fko_common.h b/lib/fko_common.h
index 24bb14c..c42f16c 100644
--- a/lib/fko_common.h
+++ b/lib/fko_common.h
@@ -103,6 +103,14 @@
   #else
     #error unable to determine BYTEORDER
   #endif
+#elif defined(_BIG_ENDIAN)
+  #define BYTEORDER 4321
+#elif defined(__BIG_ENDIAN__)
+  #define BYTEORDER 4321
+#elif defined(_LITTLE_ENDIAN)
+  #define BYTEORDER 1234
+#elif defined(__LITTLE_ENDIAN__)
+  #define BYTEORDER 1234
+#else
+  #error unable to determine BYTEORDER
#endif

#ifdef WIN32


> Blair
> 
> 
> ------------------------------------------------------------------------------
> How ServiceNow helps IT people transform IT departments:
> 1. A cloud service to automate IT design, transition and operations
> 2. Dashboards that offer high-level views of enterprise services
> 3. A single system of record for all IT processes
> http://p.sf.net/sfu/servicenow-d2d-j
> _______________________________________________
> Fwknop-discuss mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/fwknop-discuss

------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
Fwknop-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fwknop-discuss

Reply via email to