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