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