2
* $Id: ntlm.h,v 1.9 2006/08/28 09:06:41 serassio Exp $
4
* AUTHOR: Andrew Doran <ad@interlude.eu.org>
6
* SQUID Web Proxy Cache http://www.squid-cache.org/
7
* ----------------------------------------------------------
9
* Squid is the result of efforts by numerous individuals from
10
* the Internet community; see the CONTRIBUTORS file for full
11
* details. Many organizations have provided support for Squid's
12
* development; see the SPONSORS file for full details. Squid is
13
* Copyrighted (C) 2001 by the Regents of the University of
14
* California; see the COPYRIGHT file for full details. Squid
15
* incorporates software developed and/or copyrighted by other
16
* sources; see the CREDITS file for full details.
18
* This program is free software; you can redistribute it and/or modify
19
* it under the terms of the GNU General Public License as published by
20
* the Free Software Foundation; either version 2 of the License, or
21
* (at your option) any later version.
23
* This program is distributed in the hope that it will be useful,
24
* but WITHOUT ANY WARRANTY; without even the implied warranty of
25
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26
* GNU General Public License for more details.
28
* You should have received a copy of the GNU General Public License
29
* along with this program; if not, write to the Free Software
30
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
37
/* undefine this to have strict protocol adherence. You don't really need
39
#define IGNORANCE_IS_BLISS
41
#include <sys/types.h>
43
/* All of this cruft is little endian */
44
#include "squid_endian.h"
46
/* NTLM request types that we know about */
49
/* Negotiation request sent by client */
50
struct ntlm_negotiate {
51
ntlmhdr hdr; /* NTLM header */
52
int32_t flags; /* Request flags */
53
strhdr domain; /* Domain we wish to authenticate in */
54
strhdr workstation; /* Client workstation name */
55
char pad[256]; /* String data */
58
/* Challenge request sent by server. */
59
struct ntlm_challenge {
60
ntlmhdr hdr; /* NTLM header */
61
strhdr target; /* Authentication target (domain/server ...) */
62
int32_t flags; /* Request flags */
63
u_char challenge[8]; /* Challenge string */
64
int16_t unknown[8]; /* Some sort of context data */
65
char pad[256]; /* String data */
68
/* Authentication request sent by client in response to challenge */
69
struct ntlm_authenticate {
70
ntlmhdr hdr; /* NTLM header */
71
strhdr lmresponse; /* LANMAN challenge response */
72
strhdr ntresponse; /* NT challenge response */
73
strhdr domain; /* Domain to authenticate against */
74
strhdr user; /* Username */
75
strhdr workstation; /* Workstation name */
76
strhdr sessionkey; /* Session key for server's use */
77
int32_t flags; /* Request flags */
78
char pad[256 * 6]; /* String data */
81
char *ntlmGetString(ntlmhdr * hdr, strhdr * str, int flags);
82
void ntlmMakeChallenge(struct ntlm_challenge *chal, int32_t flags);
83
int ntlmCheckHeader(ntlmhdr * hdr, int type);
84
int ntlmCheckNegotiation(struct ntlm_negotiate *neg);
85
int ntlmAuthenticate(struct ntlm_authenticate *neg);
87
#define safe_free(x) if (x) { free(x); x = NULL; }
91
/************* CONFIGURATION ***************/
93
* define this if you want debugging
101
/************* END CONFIGURATION ***************/
103
#include <sys/types.h>
105
extern int debug_enabled;
107
extern int fail_debug_enabled;
110
/* Debugging stuff */
112
#ifdef __GNUC__ /* this is really a gcc-ism */
116
static const char *__foo;
117
#define debug(X...) if (debug_enabled) { \
118
fprintf(stderr,"ntlm-auth[%ld](%s:%d): ", (long)getpid(), \
119
((__foo=strrchr(__FILE__,'/'))==NULL?__FILE__:__foo+1),\
123
#define debug(X...) /* */
127
debug(char *format,...)
132
if (debug_enabled || fail_debug_enabled) {
138
va_start(args, format);
139
fprintf(stderr, "ntlm-auth[%ld]: ", (long)getpid());
140
vfprintf(stderr, format, args);
143
fail_debug_enabled = 0;
146
#endif /* _SQUID_MSWIN_ */
149
#endif /* __GNUC__ */
152
/* A couple of harmless helper macros */
153
#define SEND(X) debug("sending '%s' to squid\n",X); printf(X "\n");
155
#define SEND2(X,Y...) debug("sending '" X "' to squid\n",Y); printf(X "\n",Y);
157
/* no gcc, no debugging. varargs macros are a gcc extension */
158
#define SEND2(X,Y) debug("sending '" X "' to squid\n",Y); printf(X "\n",Y);
161
#endif /* _NTLM_H_ */