+
+
string.h \
strings.h \
sys/bitypes.h \
+ sys/bswap.h \
+ sys/endian.h \
sys/file.h \
sys/ioctl.h \
sys/param.h \
+
+
+
+
bcopy \
bswap_16 \
bswap_32 \
+ bswap16 \
+ bswap32 \
crypt \
fchmod \
getdtablesize \
getrlimit \
getrusage \
getspnam \
+ htobe16 \
+ htole16 \
lrand48 \
mallinfo \
mallocblksize \
dnl
dnl Duane Wessels, wessels@nlanr.net, February 1996 (autoconf v2.9)
dnl
-dnl $Id: configure.in,v 1.342 2003/07/28 20:41:05 robertc Exp $
+dnl $Id: configure.in,v 1.343 2003/08/05 21:40:00 robertc Exp $
dnl
dnl
dnl
AC_CONFIG_AUX_DIR(cfgaux)
AM_INIT_AUTOMAKE(squid, 3.0-PRE2-CVS)
AM_CONFIG_HEADER(include/autoconf.h)
-AC_REVISION($Revision: 1.342 $)dnl
+AC_REVISION($Revision: 1.343 $)dnl
AC_PREFIX_DEFAULT(/usr/local/squid)
AM_MAINTAINER_MODE
string.h \
strings.h \
sys/bitypes.h \
+ sys/bswap.h \
+ sys/endian.h \
sys/file.h \
sys/ioctl.h \
sys/param.h \
bcopy \
bswap_16 \
bswap_32 \
+ bswap16 \
+ bswap32 \
crypt \
fchmod \
getdtablesize \
getrlimit \
getrusage \
getspnam \
+ htobe16 \
+ htole16 \
lrand48 \
mallinfo \
mallocblksize \
#include "config.h"
#include "ntlmauth.h"
#include "ntlm.h"
+#include "squid_endian.h"
#include "util.h"
#include "smbval/smblib-common.h"
#include "smbval/rfcnb-error.h"
SEND("NA Broken authentication packet");
return;
}
- switch WSWAP(fast_header->type) {
+ switch le32toh(fast_header->type) {
case NTLM_NEGOTIATE:
SEND("NA Invalid negotiation request received");
return;
#include "config.h"
#include "ntlmauth.h"
+#include "squid_endian.h"
#include "ntlm.h"
#include "util.h"
memset(chal, 0, sizeof(*chal));
memcpy(chal->hdr.signature, "NTLMSSP", 8);
- chal->flags = WSWAP(0x00018206);
- chal->hdr.type = WSWAP(NTLM_CHALLENGE);
- chal->unknown[6] = SSWAP(0x003a);
+ chal->flags = htole32(0x00018206);
+ chal->hdr.type = htole32(NTLM_CHALLENGE);
+ chal->unknown[6] = htole16(0x003a);
d = (char *) chal + 48;
i = 0;
while (authenticate_ntlm_domain[i++]);
- chal->target.offset = WSWAP(48);
- chal->target.maxlen = SSWAP(i);
+ chal->target.offset = htole32(48);
+ chal->target.maxlen = htole16(i);
chal->target.len = chal->target.maxlen;
#ifdef NTLM_STATIC_CHALLENGE
if (type == NTLM_ANY)
return 0;
- if (WSWAP(hdr->type) != type) {
+ if (le32toh(hdr->type) != type) {
/* don't report this error - it's ok as we do a if() around this function */
// fprintf(stderr, "ntlmCheckHeader: type is %d, wanted %d\n",
- // WSWAP(hdr->type), type);
+ // le32toh(hdr->type), type);
return (-1);
}
return (0);
char *d, *sc;
int l, o;
- l = SSWAP(str->len);
- o = WSWAP(str->offset);
+ l = le16toh(str->len);
+ o = le32toh(str->offset);
/* Sanity checks. XXX values arbitrarialy chosen */
if (l <= 0 || l >= 32 || o >= 256) {
d = buf;
for (l >>= 1; l; s++, l--) {
- c = SSWAP(*s);
+ c = le16toh(*s);
if (c > 254 || c == '\0' || !isprint(c)) {
fprintf(stderr, "ntlmGetString: bad uni: %04x\n", c);
return (NULL);
ntlmMakeChallenge(&chal);
len =
sizeof(chal) - sizeof(chal.pad) +
- SSWAP(chal.target.maxlen);
+ le16toh(chal.target.maxlen);
data = (char *) base64_encode_bin((char *) &chal, len);
printf("TT %s\n", data);
} else if (strncasecmp(buf, "KK ", 3) == 0) {
ntlmMakeChallenge(&chal);
len =
sizeof(chal) - sizeof(chal.pad) +
- SSWAP(chal.target.maxlen);
+ le16toh(chal.target.maxlen);
data = (char *) base64_encode_bin((char *) &chal, len);
printf("CH %s\n", data);
} else if (!ntlmCheckHeader
/*
- * $Id: ntlm.h,v 1.5 2003/01/23 00:36:35 robertc Exp $
+ * $Id: ntlm.h,v 1.6 2003/08/05 21:40:02 robertc Exp $
*
* AUTHOR: Andrew Doran <ad@interlude.eu.org>
*
#include <sys/types.h>
/* All of this cruft is little endian */
-#ifdef WORDS_BIGENDIAN
-#define SSWAP(x) (bswap16((x)))
-#define WSWAP(x) (bswap32((x)))
-#else
-#define SSWAP(x) (x)
-#define WSWAP(x) (x)
-#endif
+#include "squid_endian.h"
/* NTLM request types that we know about */
#define NTLM_NEGOTIATE 1
#include "wbntlm.h"
#include "util.h"
+#include "squid_endian.h"
/* stdio.h is included in wbntlm.h */
#include <sys/types.h>
#include <sys/stat.h>
return;
}
/* Understand what we got */
- switch WSWAP(fast_header->type) {
+ switch le32toh(fast_header->type) {
case NTLM_NEGOTIATE:
authfail("-", "-", "Received neg-request while expecting auth packet");
return;
/* Define to 1 if you have the <bstring.h> header file. */
#undef HAVE_BSTRING_H
+/* Define to 1 if you have the `bswap16' function. */
+#undef HAVE_BSWAP16
+
+/* Define to 1 if you have the `bswap32' function. */
+#undef HAVE_BSWAP32
+
/* Define to 1 if you have the `bswap_16' function. */
#undef HAVE_BSWAP_16
/* Define to 1 if you have the <grp.h> header file. */
#undef HAVE_GRP_H
+/* Define to 1 if you have the `htobe16' function. */
+#undef HAVE_HTOBE16
+
+/* Define to 1 if you have the `htole16' function. */
+#undef HAVE_HTOLE16
+
/* int is defined in system headers */
#undef HAVE_INT
/* Define to 1 if you have the <sys/bitypes.h> header file. */
#undef HAVE_SYS_BITYPES_H
+/* Define to 1 if you have the <sys/bswap.h> header file. */
+#undef HAVE_SYS_BSWAP_H
+
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
*/
#undef HAVE_SYS_DIR_H
+/* Define to 1 if you have the <sys/endian.h> header file. */
+#undef HAVE_SYS_ENDIAN_H
+
/* Define to 1 if you have the <sys/file.h> header file. */
#undef HAVE_SYS_FILE_H
/*
- * $Id: ntlmauth.h,v 1.11 2003/05/12 18:49:11 hno Exp $
+ * $Id: ntlmauth.h,v 1.12 2003/08/05 21:40:04 robertc Exp $
*
* * * * * * * * Legal stuff * * * * * * *
*
#include "config.h"
/* All of this cruft is little endian */
-#ifdef WORDS_BIGENDIAN
-#define SSWAP(x) (bswap16((x)))
-#define WSWAP(x) (bswap32((x)))
-#else
-#define SSWAP(x) (x)
-#define WSWAP(x) (x)
-#endif
-
-#ifdef HAVE_BYTESWAP_H
-#include <byteswap.h>
-#define bswap16(x) bswap_16(x)
-#define bswap32(x) bswap_32(x)
-#else /* HAVE_BISTWAP_H */
-#define bswap16(x) (((((u_int16_t)x) >> 8) & 0xff) | ((((u_int16_t)x) & 0xff) << 8))
-#define bswap32(x) \
- (((((u_int32_t)x) & 0xff000000) >> 24) | ((((u_int32_t)x) & 0x00ff0000) >> 8) | \
- ((((u_int32_t)x) & 0x0000ff00) << 8) | ((((u_int32_t)x) & 0x000000ff) << 24))
-#endif /* HAVE_BITSWAP_H */
+#include "squid_endian.h"
/* Used internally. Microsoft seems to think this is right, I believe them.
* Right. */
--- /dev/null
+/*
+ * $Id: squid_endian.h,v 1.1 2003/08/05 21:40:07 robertc Exp $
+ *
+ * AUTHOR: Alan Barrett
+ *
+ * SQUID Web Proxy Cache http://www.squid-cache.org/
+ * ----------------------------------------------------------
+ *
+ * Squid is the result of efforts by numerous individuals from
+ * the Internet community; see the CONTRIBUTORS file for full
+ * details. Many organizations have provided support for Squid's
+ * development; see the SPONSORS file for full details. Squid is
+ * Copyrighted (C) 2001 by the Regents of the University of
+ * California; see the COPYRIGHT file for full details. Squid
+ * incorporates software developed and/or copyrighted by other
+ * sources; see the CREDITS file for full details.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ *
+ */
+
+#ifndef SQUID_ENDIAN_H
+#define SQUID_ENDIAN_H
+
+/*
+ * Macros to deal with byte swapping. These macros provide
+ * the following interface:
+ *
+ * // Byte-swap
+ * u_int16_t bswap16(u_int16_t);
+ * u_int32_t bswap32(u_int32_t);
+ *
+ * // Convert from host byte order to big-endian, and vice versa.
+ * u_int16_t htobe16(u_int16_t); // equivalent to htons()
+ * u_int32_t htobe32(u_int32_t); // equivalent to htonl()
+ * u_int16_t be16toh(u_int16_t); // equivalent to ntohs()
+ * u_int32_t be32toh(u_int32_t); // equivalent to ntohs()
+ *
+ * // Convert from host byte order to little-endian, and vice versa.
+ * u_int16_t htole16(u_int16_t);
+ * u_int32_t htole32(u_int32_t);
+ * u_int16_t le16toh(u_int16_t);
+ * u_int32_t le32toh(u_int32_t);
+ */
+
+#include "config.h"
+#include "squid_types.h"
+
+/*
+ * Some systems define bswap_16() and bswap_32() in <byteswap.h>
+ *
+ * Some systems define bswap16() and bswap32() in <sys/bswap.h>.
+ *
+ * Some systems define htobe16()/be16toh() and friends in <sys/endian.h>.
+ */
+#include <sys/types.h>
+#if HAVE_BYTESWAP_H
+# include <byteswap.h>
+#endif /* HAVE_BYTESWAP_H */
+#if HAVE_SYS_BSWAP_H
+# include <sys/bswap.h>
+#endif /* HAVE_MACHINE_BSWAP_H */
+#if HAVE_SYS_ENDIAN_H
+# include <sys/endian.h>
+#endif /* HAVE_SYS_ENDIAN_H */
+
+/*
+ * Define bswap16() and bswap32() in terms of bswap_16() and bswap_32(),
+ * or the hard way.
+ */
+#if ! HAVE_BSWAP16 && ! defined(bswap16)
+# if defined(bswap_16)
+# define bswap16(x) bswap_16(x)
+# else
+# define bswap16(x) \
+ ((((u_int16_t)x) >> 8) & 0xff) | ((((u_int16_t)x) & 0xff) << 8))
+# endif
+#endif /* ! HAVE_BSWAP16 && ! defined(bswap16) */
+#if ! HAVE_BSWAP32 && ! defined(bswap32)
+# if defined(bswap_32)
+# define bswap32(x) bswap_32(x)
+# else
+# define bswap32(x) \
+ (((((u_int32_t)x) & 0xff000000) >> 24) | \
+ ((((u_int32_t)x) & 0x00ff0000) >> 8) | \
+ ((((u_int32_t)x) & 0x0000ff00) << 8) | \
+ ((((u_int32_t)x) & 0x000000ff) << 24))
+# endif
+#endif /* ! HAVE_BSWAP32 && ! defined(bswap32) */
+
+/*
+ * Define htobe*()/be*toh() in terms of hton*()/ntoh*().
+ *
+ * XXX: If htobe16() is missing, we assume that the other *be*() functions
+ * are also missing.
+ */
+#if ! HAVE_HTOBE16 && ! defined(htobe16)
+# ifdef WORDS_BIGENDIAN
+# define htobe16(x) (x)
+# define htobe32(x) (x)
+# define be16toh(x) (x)
+# define be32toh(x) (x)
+# else /* ! WORDS_BIGENDIAN */
+# define htobe16(x) htons(x)
+# define htobe32(x) htonl(x)
+# define be16toh(x) ntohs(x)
+# define be32toh(x) ntohl(x)
+# endif /* ! WORDS_BIGENDIAN */
+#endif /* ! HAVE_HTOBE16 && ! defined(htobe16) */
+
+/*
+ * Define htole*()/le*toh() in terms of bswap*().
+ *
+ * XXX: If htole16() is missing, we assume that the other *le*() functions
+ * are also missing.
+ */
+#if ! HAVE_HTOLE16 && ! defined(htole16)
+# ifdef WORDS_BIGENDIAN
+# define htole16(x) bswap16(x)
+# define htole32(x) bswap32(x)
+# define le16toh(x) bswap16(x)
+# define le32toh(x) bswap32(x)
+# else /* ! WORDS_BIGENDIAN */
+ /*
+ * XXX: What about unusual byte orders like 3412 or 2143 ?
+ * Nothing else in squid seems to care about them,
+ * so we don't worry about them here either.
+ */
+# define htole16(x) (x)
+# define htole32(x) (x)
+# define le16toh(x) (x)
+# define le32toh(x) (x)
+# endif /* ! WORDS_BIGENDIAN */
+#endif /* ! HAVE_HTOLE16 && ! defined(htole16) */
+
+#endif /* SQUID_ENDIAN_H */
/*
- * $Id: ntlmauth.c,v 1.8 2003/01/23 00:37:01 robertc Exp $
+ * $Id: ntlmauth.c,v 1.9 2003/08/05 21:40:09 robertc Exp $
*
* * * * * * * * Legal stuff * * * * * * *
*
#endif
#include "ntlmauth.h"
+#include "squid_endian.h"
#include "util.h" /* for base64-related stuff */
#if UNUSED_CODE
lstring_zero(rv);
- l = SSWAP(str->len);
- o = WSWAP(str->offset);
+ l = le16toh(str->len);
+ o = le32toh(str->offset);
/* debug("fetch_string(plength=%d,l=%d,o=%d)\n",length,l,o); */
if (l < 0 || l > MAX_FIELD_LENGTH || o + l > length || o == 0) {
int l = (*payload_length);
memcpy(payload + l, toadd, toadd_length);
- hdr->len = SSWAP(toadd_length);
- hdr->maxlen = SSWAP(toadd_length);
- hdr->offset = WSWAP(l + base_offset); /* 48 is the base offset of the payload */
+ hdr->len = htole16(toadd_length);
+ hdr->maxlen = htole16(toadd_length);
+ hdr->offset = htole32(l + base_offset); /* 48 is the base offset of the payload */
(*payload_length) += toadd_length;
}
const char *encoded;
memset(&ch, 0, sizeof(ntlm_challenge)); /* reset */
memcpy(ch.signature, "NTLMSSP", 8); /* set the signature */
- ch.type = WSWAP(NTLM_CHALLENGE); /* this is a challenge */
+ ch.type = htole32(NTLM_CHALLENGE); /* this is a challenge */
ntlm_add_to_payload(ch.payload, &pl, &ch.target, domain, strlen(domain),
NTLM_CHALLENGE_HEADER_OFFSET);
- ch.flags = WSWAP(
+ ch.flags = htole32(
REQUEST_NON_NT_SESSION_KEY |
CHALLENGE_TARGET_IS_DOMAIN |
NEGOTIATE_ALWAYS_SIGN |