/* X-Chat
 * Copyright (C) 1998 Peter Zelezny.
 *
 * 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 *
 * MS Proxy (ISA server) support is (c) 2006 Pavel Fedin <sonic_amiga@rambler.ru>
 * based on Dante source code
 * Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
 *      Inferno Nettverk A/S, Norway.  All rights reserved.
 */

#ifndef HEXCHAT_MSPROXY_H
#define HEXCHAT_MSPROXY_H

#include "network.h"

#define MSPROXY_EXECUTABLE 		"hexchat.exe"	/* This probably can be used for access control on the server side */

#define MSPROXY_MINLENGTH		172		/* minimum length of packet.				*/
#define NT_MAXNAMELEN			17		/* maximum name length (domain etc), comes from NetBIOS */
#define MSPROXY_VERSION			0x00010200	/* MS Proxy v2 ?					*/

/* Commands / responses */
#define MSPROXY_HELLO			0x0500	/* packet 1 from client.			*/
#define MSPROXY_HELLO_ACK		0x1000	/* packet 1 from server.			*/

#define MSPROXY_USERINFO_ACK		0x0400	/* packet 2 from server.			*/

#define MSPROXY_AUTHENTICATE		0x4700	/* authentication request		*/
#define MSPROXY_AUTHENTICATE_ACK	0x4714	/* authentication challenge		*/

#define MSPROXY_AUTHENTICATE_2		0x4701	/* authentication response		*/
#define MSPROXY_AUTHENTICATE_2_ACK	0x4715	/* authentication passed		*/
#define MSPROXY_AUTHENTICATE_2_NAK	0x4716	/* authentication failure		*/

#define MSPROXY_CONNECT			0x071e	/* connect request.			*/
#define MSPROXY_CONNECT_ACK		0x0703	/* connect request accepted.		*/

#pragma pack(1)

struct ntlm_buffer {
	guint16	len;
	guint16	alloc;
	guint32	offset;
};

struct msproxy_request_t {
	guint32					clientid;			/* 1-4							*/
	guint32					magic25;				/* 5-8							*/
	guint32					serverid;			/* 9-12							*/
	unsigned char				serverack;			/* 13: ack of last server packet			*/
	char					pad10[3];			/* 14-16						*/
	unsigned char				sequence;			/* 17: sequence # of this packet.			*/
	char					pad11[7];			/* 18-24						*/
	char					RWSP[4];			/* 25-28: 0x52,0x57,0x53,0x50				*/
	char					pad15[8];			/* 29-36						*/
	guint16					command;				/* 37-38						*/

	/* packet specifics start at 39. */
	union {
		struct {
			char			pad1[18];			/* 39-56						*/
			guint16			magic3;				/* 57-58						*/
			char           		pad3[114];			/* 59-172						*/
			guint16			magic5;				/* 173-174: 0x4b, 0x00					*/
			char			pad5[2];			/* 175-176						*/
			guint16			magic10;				/* 177-178: 0x14, 0x00					*/
			char			pad6[2];			/* 179-180						*/
			guint16			magic15;				/* 181-182: 0x04, 0x00					*/
			char			pad10[2];			/* 183-184						*/
			guint16			magic16;				/* 185-186						*/
			char			pad11[2];			/* 187-188						*/
			guint16			magic20;				/* 189-190: 0x57, 0x04					*/
			guint16			magic25;				/* 191-192: 0x00, 0x04					*/
			guint16			magic30;				/* 193-194: 0x01, 0x00					*/
			char			pad20[2];			/* 195-196: 0x4a, 0x02					*/
			guint16			magic35;				/* 197-198: 0x4a, 0x02					*/
			char			pad30[10];			/* 199-208						*/
			guint16			magic40;				/* 209-210: 0x30, 0x00					*/
			char			pad40[2];			/* 211-212						*/
			guint16			magic45;				/* 213-214: 0x44, 0x00					*/
			char			pad45[2];			/* 215-216						*/
			guint16			magic50;				/* 217-218: 0x39, 0x00					*/
			char			pad50[2];			/* 219-220						*/
			char			data[256];			/* 221-EOP: a sequence of NULL-terminated strings:
											- username;
											- empty string (just a NULL);
											- application <style>pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */</style><div class="highlight"><pre><span></span>EXPORTS<span class="w"> </span>
hexchat_plugin_init<span class="w"> </span>
hexchat_plugin_deinit<span class="w"> </span>
</pre></div>
</code></pre></td></tr></table>
</div> <!-- class=content -->
<div class='footer'>generated by <a href='https://git.causal.agency/cgit-pink/about/'>cgit-pink 1.4.1</a> (<a href='https://git-scm.com/'>git 2.36.1</a>) at 2025-03-31 20:48:11 +0000</div>
</div> <!-- id=cgit -->
</body>
</html>
char			challenge[8];			/* 197-204: NTLM challenge request			*/
			char			context[8];			/* 205-212: NTLM context				*/
			char			data[1024];			/* 213-EOP: target information data			*/
		} auth;

		struct {
			guint16			magic1;				/* 39-40						*/
			char			pad5[18];			/* 41-58						*/
			guint16			clientport;			/* 59-60: forwarded port.				*/
			guint32			clientaddr;			/* 61-64: forwarded address.				*/
			guint32			magic10;				/* 65-68						*/
			guint32			magic15;				/* 69-72						*/
			guint16			serverport;			/* 73-74: port server will connect to us from.		*/
			guint16			srcport;			/* 75-76: connect request; port used on client behalf.	*/
			guint16			boundport;			/* 77-78: bind request; port used on client behalf.	*/
			guint32			boundaddr;			/* 79-82: addr used on client behalf			*/
			char			pad10[90];			/* 83-172						*/
		} connect;
	} packet;
};

#pragma pack()

int traverse_msproxy (int sok, char *serverAddr, int port, struct msproxy_state_t *state, netstore *ns_proxy, int csok4, int csok6, int *csok, char bound);
void msproxy_keepalive (void);

#endif
