summaryrefslogtreecommitdiffstats
path: root/src/lib/gssapi/generic/gssapiP_generic.h
diff options
context:
space:
mode:
authorTheodore Tso <tytso@mit.edu>1994-06-10 03:15:51 +0000
committerTheodore Tso <tytso@mit.edu>1994-06-10 03:15:51 +0000
commit9f848ddada00ab926f70bd892b199f875404e26a (patch)
treeeae359aaf7803bf6c9639105b6d9305314d3d054 /src/lib/gssapi/generic/gssapiP_generic.h
parent21cedd566d71b3debcf7bb0a4f941c6a5977d8bd (diff)
downloadkrb5-9f848ddada00ab926f70bd892b199f875404e26a.tar.gz
krb5-9f848ddada00ab926f70bd892b199f875404e26a.tar.xz
krb5-9f848ddada00ab926f70bd892b199f875404e26a.zip
Updates from OpenVision, before beta 4 release
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@3696 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/gssapi/generic/gssapiP_generic.h')
-rw-r--r--src/lib/gssapi/generic/gssapiP_generic.h32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/lib/gssapi/generic/gssapiP_generic.h b/src/lib/gssapi/generic/gssapiP_generic.h
index 5d82755681..7626ce411d 100644
--- a/src/lib/gssapi/generic/gssapiP_generic.h
+++ b/src/lib/gssapi/generic/gssapiP_generic.h
@@ -31,6 +31,8 @@
#include "gssapi_generic_err.h"
#include <errno.h>
+#include <sys/types.h>
+#include <netinet/in.h>
/** helper macros **/
@@ -38,15 +40,23 @@
(((o1)->length == (o2)->length) && \
(memcmp((o1)->elements,(o2)->elements,(o1)->length) == 0))
-#define TWRITE_INT(ptr, tmp, num) \
- (tmp) = htonl(num); \
- memcpy(ptr, (char *) &(tmp), sizeof(tmp)); \
- (ptr) += sizeof(tmp);
-
-#define TREAD_INT(ptr, num) \
- memcpy((char *) &(num), (char *) (ptr), sizeof(num)); \
- (num) = ntohl(num); \
- (ptr) += sizeof(num);
+/* this code knows that an int on the wire is 32 bits. The type of
+ num should be at least this big, or the extra shifts may do weird
+ things */
+
+#define TWRITE_INT(ptr, num, bigend) \
+ (ptr)[0] = (bigend)?((num)>>24):((num)&0xff); \
+ (ptr)[1] = (bigend)?(((num)>>16)&0xff):(((num)>>8)&0xff); \
+ (ptr)[2] = (bigend)?(((num)>>8)&0xff):(((num)>>16)&0xff); \
+ (ptr)[3] = (bigend)?((num)&0xff):((num)>>24); \
+ (ptr) += 4;
+
+#define TREAD_INT(ptr, num, bigend) \
+ (num) = (((ptr)[0]<<((bigend)?24: 0)) | \
+ ((ptr)[1]<<((bigend)?16: 8)) | \
+ ((ptr)[2]<<((bigend)? 8:16)) | \
+ ((ptr)[3]<<((bigend)? 0:24))); \
+ (ptr) += 4;
#define TWRITE_STR(ptr, str, len) \
memcpy((ptr), (char *) (str), (len)); \
@@ -56,8 +66,8 @@
(str) = (ptr); \
(ptr) += (len);
-#define TWRITE_BUF(ptr, tmp, buf) \
- TWRITE_INT((ptr), (tmp), (buf).length); \
+#define TWRITE_BUF(ptr, buf, bigend) \
+ TWRITE_INT((ptr), (buf).length, (bigend)); \
TWRITE_STR((ptr), (buf).value, (buf).length);
/** malloc wrappers; these may actually do something later */