]> git.ipfire.org Git - thirdparty/squid.git/blob - helpers/basic_auth/MSNT/rfcnb-priv.h
Major rewrite of proxy authentication to support other schemes than
[thirdparty/squid.git] / helpers / basic_auth / MSNT / rfcnb-priv.h
1 /* UNIX RFCNB (RFC1001/RFC1002) NetBIOS implementation
2 *
3 * Version 1.0
4 * RFCNB Defines
5 *
6 * Copyright (C) Richard Sharpe 1996
7 *
8 */
9
10 /*
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */
25
26 /* Defines we need */
27
28
29 #define GLOBAL extern
30
31 #include "rfcnb-error.h"
32 #include "rfcnb-common.h"
33 #include "byteorder.h"
34
35 #ifdef RFCNB_PORT
36 #define RFCNB_Default_Port RFCNB_PORT
37 #else
38 #define RFCNB_Default_Port 139
39 #endif
40
41 #define RFCNB_MAX_STATS 1
42
43 /* Protocol defines we need */
44
45 #define RFCNB_SESSION_MESSAGE 0
46 #define RFCNB_SESSION_REQUEST 0x81
47 #define RFCNB_SESSION_ACK 0x82
48 #define RFCNB_SESSION_REJ 0x83
49 #define RFCNB_SESSION_RETARGET 0x84
50 #define RFCNB_SESSION_KEEP_ALIVE 0x85
51
52 /* Structures */
53
54 typedef struct redirect_addr *redirect_ptr;
55
56 struct redirect_addr {
57
58 struct in_addr ip_addr;
59 int port;
60 redirect_ptr next;
61
62 };
63
64 typedef struct RFCNB_Con {
65
66 int fd; /* File descripter for TCP/IP connection */
67 int rfc_errno; /* last error */
68 int timeout; /* How many milli-secs before IO times out */
69 int redirects; /* How many times we were redirected */
70 struct redirect_addr *redirect_list; /* First is first address */
71 struct redirect_addr *last_addr;
72
73 } RFCNB_Con;
74
75 typedef char RFCNB_Hdr[4]; /* The header is 4 bytes long with */
76 /* char[0] as the type, char[1] the */
77 /* flags, and char[2..3] the length */
78
79 /* Macros to extract things from the header. These are for portability
80 * between architecture types where we are worried about byte order */
81
82 #define RFCNB_Pkt_Hdr_Len 4
83 #define RFCNB_Pkt_Sess_Len 72
84 #define RFCNB_Pkt_Retarg_Len 10
85 #define RFCNB_Pkt_Nack_Len 5
86 #define RFCNB_Pkt_Type_Offset 0
87 #define RFCNB_Pkt_Flags_Offset 1
88 #define RFCNB_Pkt_Len_Offset 2 /* Length is 2 bytes plus a flag bit */
89 #define RFCNB_Pkt_N1Len_Offset 4
90 #define RFCNB_Pkt_Called_Offset 5
91 #define RFCNB_Pkt_N2Len_Offset 38
92 #define RFCNB_Pkt_Calling_Offset 39
93 #define RFCNB_Pkt_Error_Offset 4
94 #define RFCNB_Pkt_IP_Offset 4
95 #define RFCNB_Pkt_Port_Offset 8
96
97 /* The next macro isolates the length of a packet, including the bit in the
98 * flags */
99
100 #define RFCNB_Pkt_Len(p) (PVAL(p, 3) | (PVAL(p, 2) << 8) | \
101 ((PVAL(p, RFCNB_Pkt_Flags_Offset) & 0x01) << 16))
102
103 #define RFCNB_Put_Pkt_Len(p, v) (p[1] = ((v >> 16) & 1)); \
104 (p[2] = ((v >> 8) & 0xFF)); \
105 (p[3] = (v & 0xFF));
106
107 #define RFCNB_Pkt_Type(p) (CVAL(p, RFCNB_Pkt_Type_Offset))
108
109 /*typedef struct RFCNB_Hdr {
110 *
111 * unsigned char type;
112 * unsigned char flags;
113 * int16 len;
114 *
115 * } RFCNB_Hdr;
116 *
117 * typedef struct RFCNB_Sess_Pkt {
118 * unsigned char type;
119 * unsigned char flags;
120 * int16 length;
121 * unsigned char n1_len;
122 * char called_name[33];
123 * unsigned char n2_len;
124 * char calling_name[33];
125 * } RFCNB_Sess_Pkt;
126 *
127 *
128 * typedef struct RFCNB_Nack_Pkt {
129 *
130 * struct RFCNB_Hdr hdr;
131 * unsigned char error;
132 *
133 * } RFCNB_Nack_Pkt;
134 *
135 * typedef struct RFCNB_Retarget_Pkt {
136 *
137 * struct RFCNB_Hdr hdr;
138 * int dest_ip;
139 * unsigned char port;
140 *
141 * } RFCNB_Redir_Pkt; */
142
143 /* Static variables */
144
145 /* Only declare this if not defined */
146
147 #ifndef RFCNB_ERRNO
148 extern int RFCNB_errno;
149 extern int RFCNB_saved_errno; /* Save this from point of error */
150 #endif