]> git.ipfire.org Git - thirdparty/squid.git/blob - lib/rfcnb/rfcnb-priv.h
Merged from trunk 13172.
[thirdparty/squid.git] / lib / rfcnb / 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 #ifndef _RFCNB_RFCNB_PRIV_H
27 #define _RFCNB_RFCNB_PRIV_H
28
29 /* Defines we need */
30
31 typedef unsigned short uint16;
32
33 #define GLOBAL extern
34
35 #include "rfcnb/byteorder.h"
36 #include "rfcnb/rfcnb-common.h"
37 #include "rfcnb/rfcnb-error.h"
38
39 #if HAVE_NETINET_IN_H
40 #include <netinet/in.h>
41 #endif
42
43 #ifdef RFCNB_PORT
44 #define RFCNB_Default_Port RFCNB_PORT
45 #else
46 #define RFCNB_Default_Port 139
47 #endif
48
49 #define RFCNB_MAX_STATS 1
50
51 /* Protocol defines we need */
52
53 #define RFCNB_SESSION_MESSAGE 0
54 #define RFCNB_SESSION_REQUEST 0x81
55 #define RFCNB_SESSION_ACK 0x82
56 #define RFCNB_SESSION_REJ 0x83
57 #define RFCNB_SESSION_RETARGET 0x84
58 #define RFCNB_SESSION_KEEP_ALIVE 0x85
59
60 /* Structures */
61
62 typedef struct redirect_addr *redirect_ptr;
63
64 struct redirect_addr {
65
66 struct in_addr ip_addr;
67 int port;
68 redirect_ptr next;
69
70 };
71
72 typedef struct RFCNB_Con {
73
74 int fd; /* File descripter for TCP/IP connection */
75 int errn; /* last error */
76 int timeout; /* How many milli-secs before IO times out */
77 int redirects; /* How many times we were redirected */
78 struct redirect_addr *redirect_list; /* First is first address */
79 struct redirect_addr *last_addr;
80
81 } RFCNB_Con;
82
83 typedef char RFCNB_Hdr[4]; /* The header is 4 bytes long with */
84 /* char[0] as the type, char[1] the */
85 /* flags, and char[2..3] the length */
86
87 /* Macros to extract things from the header. These are for portability
88 * between architecture types where we are worried about byte order */
89
90 #define RFCNB_Pkt_Hdr_Len 4
91 #define RFCNB_Pkt_Sess_Len 72
92 #define RFCNB_Pkt_Retarg_Len 10
93 #define RFCNB_Pkt_Nack_Len 5
94 #define RFCNB_Pkt_Type_Offset 0
95 #define RFCNB_Pkt_Flags_Offset 1
96 #define RFCNB_Pkt_Len_Offset 2 /* Length is 2 bytes plus a flag bit */
97 #define RFCNB_Pkt_N1Len_Offset 4
98 #define RFCNB_Pkt_Called_Offset 5
99 #define RFCNB_Pkt_N2Len_Offset 38
100 #define RFCNB_Pkt_Calling_Offset 39
101 #define RFCNB_Pkt_Error_Offset 4
102 #define RFCNB_Pkt_IP_Offset 4
103 #define RFCNB_Pkt_Port_Offset 8
104
105 /* The next macro isolates the length of a packet, including the bit in the
106 * flags */
107
108 #define RFCNB_Pkt_Len(p) (PVAL((p), 3) | (PVAL((p), 2) << 8) | \
109 ((PVAL((p), RFCNB_Pkt_Flags_Offset) & 0x01) << 16))
110
111 #define RFCNB_Put_Pkt_Len(p, v) ((p)[1] = (((v) >> 16) & 1)); \
112 ((p)[2] = (((v) >> 8) & 0xFF)); \
113 ((p)[3] = ((v) & 0xFF));
114
115 #define RFCNB_Pkt_Type(p) (CVAL((p), RFCNB_Pkt_Type_Offset))
116
117 #if UNUSED_CODE
118 typedef struct RFCNB_Hdr {
119 unsigned char type;
120 unsigned char flags;
121 int16 len;
122 } RFCNB_Hdr;
123
124 typedef struct RFCNB_Sess_Pkt {
125 unsigned char type;
126 unsigned char flags;
127 int16 length;
128 unsigned char n1_len;
129 char called_name[33];
130 unsigned char n2_len;
131 char calling_name[33];
132 } RFCNB_Sess_Pkt;
133
134 typedef struct RFCNB_Nack_Pkt {
135 struct RFCNB_Hdr hdr;
136 unsigned char error;
137 } RFCNB_Nack_Pkt;
138
139 typedef struct RFCNB_Retarget_Pkt {
140 struct RFCNB_Hdr hdr;
141 int dest_ip;
142 unsigned char port;
143 } RFCNB_Redir_Pkt;
144 #endif /* UNUSED_CODE */
145
146 /* Static variables */
147
148 /* Only declare this if not defined */
149
150 #ifndef RFCNB_ERRNO
151 extern int RFCNB_errno;
152 extern int RFCNB_saved_errno; /* Save this from point of error */
153 #endif
154
155 #endif /* _RFCNB_RFCNB_PRIV_H */