OpenVAS Scanner 21.4.1
smb.h
Go to the documentation of this file.
1/* Copyright (C) Andrew Tridgell 1992-2000
2 * Copyright (C) John H Terpstra 1996-2002
3 * Copyright (C) Luke Kenneth Casson Leighton 1996-2000
4 * Copyright (C) Paul Ashton 1998-2000
5 * Copyright (C) Simo Sorce 2001-2002
6 * Copyright (C) Martin Pool 2002
7 *
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
23 */
24
36#ifndef _SMB_H
37#define _SMB_H
38
39#include "charset.h"
40
41#include <ctype.h>
42#include <errno.h>
43#include <stdint.h>
44#include <stdio.h>
45#include <stdlib.h>
46#include <string.h>
47
48#define SMB_PORT1 445
49#define SMB_PORT2 139
50#define SMB_PORTS "445 139"
51
52/* offsets into message for common items */
53#define smb_com 8
54#define smb_rcls 9
55#define smb_reh 10
56#define smb_err 11
57#define smb_flg 13
58#define smb_flg2 14
59#define smb_pidhigh 16
60#define smb_ss_field 18
61#define smb_tid 28
62#define smb_pid 30
63#define smb_uid 32
64#define smb_mid 34
65#define smb_wct 36
66#define smb_vwv 37
67#define smb_vwv0 37
68#define smb_vwv1 39
69#define smb_vwv2 41
70#define smb_vwv3 43
71#define smb_vwv4 45
72#define smb_vwv5 47
73#define smb_vwv6 49
74#define smb_vwv7 51
75#define smb_vwv8 53
76#define smb_vwv9 55
77#define smb_vwv10 57
78#define smb_vwv11 59
79#define smb_vwv12 61
80#define smb_vwv13 63
81#define smb_vwv14 65
82#define smb_vwv15 67
83#define smb_vwv16 69
84#define smb_vwv17 71
85
86/* generic iconv conversion structure */
87typedef struct _smb_iconv_t
88{
89 size_t (*direct) (void *cd, const char **inbuf, size_t *inbytesleft,
90 char **outbuf, size_t *outbytesleft);
91 size_t (*pull) (void *cd, const char **inbuf, size_t *inbytesleft,
92 char **outbuf, size_t *outbytesleft);
93 size_t (*push) (void *cd, const char **inbuf, size_t *inbytesleft,
94 char **outbuf, size_t *outbytesleft);
98
99/* string manipulation flags - see clistr.c and srvstr.c */
100#define STR_TERMINATE 1
101#define STR_UPPER 2
102#define STR_ASCII 4
103#define STR_UNICODE 8
104#define STR_NOALIGN 16
105#define STR_TERMINATE_ASCII 128
106
107/* Sercurity mode bits. */
108#define NEGOTIATE_SECURITY_USER_LEVEL 0x01
109#define NEGOTIATE_SECURITY_CHALLENGE_RESPONSE 0x02
110#define NEGOTIATE_SECURITY_SIGNATURES_ENABLED 0x04
111#define NEGOTIATE_SECURITY_SIGNATURES_REQUIRED 0x08
112
113/* NT Flags2 bits - cifs6.txt section 3.1.2 */
114
115#define FLAGS2_LONG_PATH_COMPONENTS 0x0001
116#define FLAGS2_EXTENDED_ATTRIBUTES 0x0002
117#define FLAGS2_SMB_SECURITY_SIGNATURES 0x0004
118#define FLAGS2_UNKNOWN_BIT4 0x0010
119#define FLAGS2_IS_LONG_NAME 0x0040
120#define FLAGS2_EXTENDED_SECURITY 0x0800
121#define FLAGS2_DFS_PATHNAMES 0x1000
122#define FLAGS2_READ_PERMIT_EXECUTE 0x2000
123#define FLAGS2_32_BIT_ERROR_CODES 0x4000
124#define FLAGS2_UNICODE_STRINGS 0x8000
125
126#define FLAGS2_WIN2K_SIGNATURE 0xC852 /* Hack alert ! For now... JRA. */
127
128/* TCONX Flag (smb_vwv2). */
129#define TCONX_FLAG_EXTENDED_RESPONSE 0x8
130
131/* Capabilities. see ftp.microsoft.com/developr/drg/cifs/cifs/cifs4.txt */
132
133#define CAP_RAW_MODE 0x0001
134#define CAP_MPX_MODE 0x0002
135#define CAP_UNICODE 0x0004
136#define CAP_LARGE_FILES 0x0008
137#define CAP_NT_SMBS 0x0010
138#define CAP_RPC_REMOTE_APIS 0x0020
139#define CAP_STATUS32 0x0040
140#define CAP_LEVEL_II_OPLOCKS 0x0080
141#define CAP_LOCK_AND_READ 0x0100
142#define CAP_NT_FIND 0x0200
143#define CAP_DFS 0x1000
144#define CAP_W2K_SMBS 0x2000
145#define CAP_LARGE_READX 0x4000
146#define CAP_LARGE_WRITEX 0x8000
147#define CAP_UNIX \
148 0x800000 /* Capabilities for UNIX extensions. Created by HP. \
149 */
150#define CAP_EXTENDED_SECURITY 0x80000000
151
152/* protocol types. It assumes that higher protocols include lower protocols
153 * as subsets */
162};
163
164#ifdef WORDS_BIGENDIAN
165#define UCS2_SHIFT 8
166#else
167#define UCS2_SHIFT 0
168#endif
169
170/* turn a 7 bit character into a ucs2 character */
171#define UCS2_CHAR(c) ((c) << UCS2_SHIFT)
172
173/* return an ascii version of a ucs2 character */
174#define UCS2_TO_CHAR(c) (((c) >> UCS2_SHIFT) & 0xff)
175
176/* Copy into a smb_ucs2_tt from a possibly unaligned buffer. Return the copied
177 * smb_ucs2_tt */
178#define COPY_UCS2_CHAR(dest, src) \
179 (((unsigned char *) (dest))[0] = ((unsigned char *) (src))[0], \
180 ((unsigned char *) (dest))[1] = ((unsigned char *) (src))[1], (dest))
181
182/* 64 bit time (100 nanosec) 1601 - cifs6.txt, section 3.5, page 30, 4 byte
183 * aligned */
184typedef uint64_t NTTIME;
186#define SMB_MALLOC_P(type) (type *) malloc (sizeof (type))
188#define SMB_REALLOC(p, s) \
189 Realloc ((p), (s), True) /* Always frees p on error or s == 0 */
190#ifndef SMB_MALLOC
191#define SMB_MALLOC(s) malloc (s)
192#endif
194#define SMB_STRDUP(s) strdup (s)
195#define SMB_STRNDUP(s, n) strndup (s, n)
197#define smb_len(buf) \
198 (PVAL (buf, 3) | (PVAL (buf, 2) << 8) | ((PVAL (buf, 1) & 1) << 16))
199
200#ifndef MIN
201#define MIN(a, b) ((a) < (b) ? (a) : (b))
202#endif
203/*---------------------------------------------------------------------------------*/
204
205#endif /* _SMB_H */
Unix SMB/CIFS implementation. charset defines.
protocol_types
Definition: smb.h:154
@ PROTOCOL_LANMAN2
Definition: smb.h:159
@ PROTOCOL_COREPLUS
Definition: smb.h:157
@ PROTOCOL_CORE
Definition: smb.h:156
@ PROTOCOL_LANMAN1
Definition: smb.h:158
@ PROTOCOL_NT1
Definition: smb.h:160
@ PROTOCOL_NONE
Definition: smb.h:155
struct _smb_iconv_t * smb_iconv_t
uint64_t NTTIME
Definition: smb.h:183
Definition: smb.h:88
char * from_name
Definition: smb.h:96
void * cd_direct
Definition: smb.h:95
size_t(* push)(void *cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
Definition: smb.h:93
size_t(* pull)(void *cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
Definition: smb.h:91
size_t(* direct)(void *cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
Definition: smb.h:89
char * to_name
Definition: smb.h:96
void * cd_pull
Definition: smb.h:95
void * cd_push
Definition: smb.h:95