File: rfcnb-priv.h

package info (click to toggle)
squid 2.6.5-6etch5
  • links: PTS
  • area: main
  • in suites: etch
  • size: 12,540 kB
  • ctags: 13,801
  • sloc: ansic: 105,278; sh: 6,083; makefile: 1,297; perl: 1,245; awk: 40
file content (156 lines) | stat: -rw-r--r-- 4,103 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#ifndef __RFCNB_H__
#define __RFCNB_H__

/* UNIX RFCNB (RFC1001/RFC1002) NetBIOS implementation
 * 
 * Version 1.0
 * RFCNB Defines
 * 
 * Copyright (C) Richard Sharpe 1996
 * 
 */

/*
 * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

/* Defines we need */

typedef unsigned short uint16;

#define GLOBAL extern

#include "rfcnb-error.h"
#include "rfcnb-common.h"
#include "byteorder.h"

#ifdef RFCNB_PORT
#define RFCNB_Default_Port RFCNB_PORT
#else
#define RFCNB_Default_Port 139
#endif

#define RFCNB_MAX_STATS 1

/* Protocol defines we need */

#define RFCNB_SESSION_MESSAGE 0
#define RFCNB_SESSION_REQUEST 0x81
#define RFCNB_SESSION_ACK 0x82
#define RFCNB_SESSION_REJ 0x83
#define RFCNB_SESSION_RETARGET 0x84
#define RFCNB_SESSION_KEEP_ALIVE 0x85

/* Structures      */

typedef struct redirect_addr *redirect_ptr;

struct redirect_addr {

    struct in_addr ip_addr;
    int port;
    redirect_ptr next;

};

typedef struct RFCNB_Con {

    int fd;			/* File descripter for TCP/IP connection */
    int rfc_errno;		/* last error                            */
    int timeout;		/* How many milli-secs before IO times out */
    int redirects;		/* How many times we were redirected     */
    struct redirect_addr *redirect_list;	/* First is first address */
    struct redirect_addr *last_addr;

} RFCNB_Con;

typedef char RFCNB_Hdr[4];	/* The header is 4 bytes long with  */
				    /* char[0] as the type, char[1] the */
				    /* flags, and char[2..3] the length */

/* Macros to extract things from the header. These are for portability
 * between architecture types where we are worried about byte order     */

#define RFCNB_Pkt_Hdr_Len        4
#define RFCNB_Pkt_Sess_Len       72
#define RFCNB_Pkt_Retarg_Len     10
#define RFCNB_Pkt_Nack_Len       5
#define RFCNB_Pkt_Type_Offset    0
#define RFCNB_Pkt_Flags_Offset   1
#define RFCNB_Pkt_Len_Offset     2	/* Length is 2 bytes plus a flag bit */
#define RFCNB_Pkt_N1Len_Offset   4
#define RFCNB_Pkt_Called_Offset  5
#define RFCNB_Pkt_N2Len_Offset   38
#define RFCNB_Pkt_Calling_Offset 39
#define RFCNB_Pkt_Error_Offset   4
#define RFCNB_Pkt_IP_Offset      4
#define RFCNB_Pkt_Port_Offset    8

/* The next macro isolates the length of a packet, including the bit in the
 * flags                                                                   */

#define RFCNB_Pkt_Len(p)  (PVAL(p, 3) | (PVAL(p, 2) << 8) |     \
                          ((PVAL(p, RFCNB_Pkt_Flags_Offset) & 0x01) << 16))

#define RFCNB_Put_Pkt_Len(p, v) (p[1] = (((v) >> 16) & 1)); \
				(p[2] = (((v) >> 8) & 0xFF)); \
				(p[3] = ((v) & 0xFF));

#define RFCNB_Pkt_Type(p) (CVAL(p, RFCNB_Pkt_Type_Offset))

/*typedef struct RFCNB_Hdr {
 * 
 * unsigned char type;
 * unsigned char flags;
 * int16 len;
 * 
 * } RFCNB_Hdr;
 * 
 * typedef struct RFCNB_Sess_Pkt {
 * unsigned char type;
 * unsigned char flags;
 * int16 length;
 * unsigned char n1_len;
 * char called_name[33];
 * unsigned char n2_len;
 * char calling_name[33];
 * } RFCNB_Sess_Pkt;
 * 
 * 
 * typedef struct RFCNB_Nack_Pkt {
 * 
 * struct RFCNB_Hdr hdr;
 * unsigned char error;
 * 
 * } RFCNB_Nack_Pkt;
 * 
 * typedef struct RFCNB_Retarget_Pkt {
 * 
 * struct RFCNB_Hdr hdr;
 * int dest_ip;
 * unsigned char port;
 * 
 * } RFCNB_Redir_Pkt; */

/* Static variables */

/* Only declare this if not defined */

#ifndef RFCNB_ERRNO
extern int RFCNB_errno;
extern int RFCNB_saved_errno;	/* Save this from point of error */
#endif

#endif /* __RFCNB_H__ */