rfcnb-priv.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
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 
9 /* UNIX RFCNB (RFC1001/RFC1002) NetBIOS implementation
10  *
11  * Version 1.0
12  * RFCNB Defines
13  *
14  * Copyright (C) Richard Sharpe 1996
15  */
16 
17 /*
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  */
32 
33 #ifndef _RFCNB_RFCNB_PRIV_H
34 #define _RFCNB_RFCNB_PRIV_H
35 
36 /* Defines we need */
37 
38 typedef unsigned short uint16;
39 
40 #define GLOBAL extern
41 
42 #include "rfcnb/byteorder.h"
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
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 
69 typedef struct redirect_addr *redirect_ptr;
70 
71 struct redirect_addr {
72 
73  struct in_addr ip_addr;
74  int port;
75  redirect_ptr next;
76 
77 };
78 
79 typedef struct RFCNB_Con {
80 
81  int fd; /* File descripter for TCP/IP connection */
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 */
87 
88 } RFCNB_Con;
89 
90 typedef char RFCNB_Hdr[4]; /* The header is 4 bytes long with */
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
95  * between architecture types where we are worried about byte order */
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
103 #define RFCNB_Pkt_Len_Offset 2 /* Length is 2 bytes plus a flag bit */
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
113  * flags */
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)); \
119  ((p)[2] = (((v) >> 8) & 0xFF)); \
120  ((p)[3] = ((v) & 0xFF));
121 
122 #define RFCNB_Pkt_Type(p) (CVAL((p), RFCNB_Pkt_Type_Offset))
123 
124 #if UNUSED_CODE
125 typedef struct RFCNB_Hdr {
126  unsigned char type;
127  unsigned char flags;
128  int16 len;
129 } RFCNB_Hdr;
130 
131 typedef 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];
139 } RFCNB_Sess_Pkt;
140 
141 typedef struct RFCNB_Nack_Pkt {
142  struct RFCNB_Hdr hdr;
143  unsigned char error;
144 } RFCNB_Nack_Pkt;
145 
146 typedef struct RFCNB_Retarget_Pkt {
147  struct RFCNB_Hdr hdr;
148  int dest_ip;
149  unsigned char port;
150 } RFCNB_Redir_Pkt;
151 #endif /* UNUSED_CODE */
152 
153 /* Static variables */
154 
155 /* Only declare this if not defined */
156 
157 #ifndef RFCNB_ERRNO
158 extern int RFCNB_errno;
159 extern int RFCNB_saved_errno; /* Save this from point of error */
160 #endif
161 
162 #endif /* _RFCNB_RFCNB_PRIV_H */
163 
int errn
Definition: rfcnb-priv.h:82
struct redirect_addr * redirect_list
Definition: rfcnb-priv.h:85
int redirects
Definition: rfcnb-priv.h:84
int type
Definition: errorpage.cc:79
void error(char *format,...)
char RFCNB_Hdr[4]
Definition: rfcnb-priv.h:90
struct in_addr ip_addr
Definition: rfcnb-priv.h:73
struct redirect_addr * last_addr
Definition: rfcnb-priv.h:86
unsigned short uint16
Definition: rfcnb-priv.h:38
int timeout
Definition: rfcnb-priv.h:83
redirect_ptr next
Definition: rfcnb-priv.h:75
static int port
Definition: ldap_backend.cc:69
int unsigned int const char *desc STUB void int len
Definition: stub_fd.cc:20
int RFCNB_saved_errno
Definition: session.c:36
short int16
Definition: std-includes.h:39
struct redirect_addr * redirect_ptr
Definition: rfcnb-priv.h:69
struct RFCNB_Con RFCNB_Con
int RFCNB_errno
Definition: session.c:35

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors