3882 Remove xmod & friends
[illumos-gate.git] / usr / src / uts / common / smbsrv / netbios.h
blob4b1f7814e0ca036aeb74b31dc19879df914573cd
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _SMBSRV_NETBIOS_H
27 #define _SMBSRV_NETBIOS_H
30 * NetBIOS over TCP/IP interface definitions. NetBIOS over TCP/IP is
31 * documented in the following RFC documents:
33 * RFC 1001: Protocol Standard for a NetBIOS Service on a TCP/UDP
34 * Transport: Concepts and Methods
36 * RFC 1002: Protocol Standard for a NetBIOS Service on a TCP/UDP
37 * Transport: Detailed Specifications
39 * These documents reference RCF883.
40 * RFC 883: Domain Names - Implementation and Specification
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
49 * NetBIOS names in NetBIOS packets are valid domain names as defined in
50 * RFC 883. Each label is limited to 63 bytes with an overall length of
51 * 255 bytes as described in RFC 1002 section 4.1. This is known as
52 * second-level encoding. In first-level encoding the label lengths are
53 * represented as dots (.).
55 * RFC 1001 section 14.1 describes first-level encoding of the NetBIOS
56 * name (hostname) and scope. The ASCII name is padded to 15 bytes using
57 * spaces and a one byte type or suffix is written to the 16th byte.
58 * This is then encoded as a 32 byte string.
60 * NetBIOS Name: NetBIOS
61 * NetBIOS Scope: DOMAIN.COM
62 * First Level: EOGFHEECEJEPFDCACACACACACACACACA.DOMAIN.COM
63 * Second Level: <32>EOGFHEECEJEPFDCACACACACACACACACA<6>DOMAIN<3>COM<0>
65 #define NETBIOS_NAME_SZ 16
66 #define NETBIOS_ENCODED_NAME_SZ 32
67 #define NETBIOS_LABEL_MAX 63
68 #define NETBIOS_DOMAIN_NAME_MAX 255
69 #define NETBIOS_DOMAIN_NAME_BUFLEN (NETBIOS_DOMAIN_NAME_MAX + 1)
70 #define NETBIOS_SESSION_REQUEST_DATA_LENGTH \
71 ((NETBIOS_ENCODED_NAME_SZ + 2) * 2)
73 #define NETBIOS_HDR_SZ 4 /* bytes */
76 * NetBIOS name type/suffix: 16th byte of the NetBIOS name.
77 * The NetBIOS suffix is used by to identify computer services.
79 #define NBT_WKSTA 0x00 /* Workstation Service */
80 #define NBT_CLIENT 0x03 /* Messenger Service */
81 #define NBT_RASSRVR 0x06 /* RAS Server Service */
82 #define NBT_DMB 0x1B /* Domain Master Browser */
83 #define NBT_IP 0x1C /* Domain Controller */
84 #define NBT_MB 0x1D /* Master Browser */
85 #define NBT_BS 0x1E /* Browser Elections */
86 #define NBT_NETDDE 0x1F /* NetDDE Service */
87 #define NBT_SERVER 0x20 /* Server Service */
88 #define NBT_RASCLNT 0x21 /* RAS Client Service */
91 * Session Packet Types (RFC 1002 4.3.1).
93 #define SESSION_MESSAGE 0x00
94 #define SESSION_REQUEST 0x81
95 #define POSITIVE_SESSION_RESPONSE 0x82
96 #define NEGATIVE_SESSION_RESPONSE 0x83
97 #define RETARGET_SESSION_RESPONSE 0x84
98 #define SESSION_KEEP_ALIVE 0x85
101 * NEGATIVE SESSION RESPONSE packet error code values (RFC 1002 4.3.4).
103 #define SESSION_NOT_LISTENING_ON_CALLED_NAME 0x80
104 #define SESSION_NOT_LISTENING_FOR_CALLING_NAME 0x81
105 #define SESSION_CALLED_NAME_NOT_PRESENT 0x82
106 #define SESSION_INSUFFICIENT_RESOURCES 0x83
107 #define SESSION_UNSPECIFIED_ERROR 0x8F
110 * Time conversions
112 #define MILLISECONDS 1
113 #define SECONDS (1000 * MILLISECONDS)
114 #define MINUTES (60 * SECONDS)
115 #define HOURS (60 * MINUTES)
116 #define TO_SECONDS(x) ((x) / 1000)
117 #define TO_MILLISECONDS(x) ((x) * 1000)
120 * DATAGRAM service definitions
122 #define DATAGRAM_DESTINATION_NAME_NOT_PRESENT 0x82
123 #define DATAGRAM_INVALID_SOURCE_NAME_FORMAT 0x83
124 #define DATAGRAM_INVALID_DESTINATION_NAME_FORMAT 0x84
126 #define MAX_DATAGRAM_LENGTH 576
127 #define DATAGRAM_HEADER_LENGTH 14
128 #define DATAGRAM_ERR_HEADER_LENGTH 11
129 #define MAX_NAME_LENGTH 256
130 #define BCAST_REQ_RETRY_COUNT 2
131 #define UCAST_REQ_RETRY_COUNT 2
132 #define BCAST_REQ_RETRY_TIMEOUT (500 * MILLISECONDS)
133 #define UCAST_REQ_RETRY_TIMEOUT (500 * MILLISECONDS)
134 #define CONFLICT_TIMER (1 * SECONDS)
135 #define INFINITE_TTL 0
136 #define DEFAULT_TTL (600 * SECONDS)
137 #define SSN_RETRY_COUNT 4
138 #define SSN_CLOSE_TIMEOUT (30 * SECONDS)
140 * K.L. The keep alive time out use to be default to
141 * 900 seconds. It is not long enough for some applications
142 * i.e. MS Access. Therefore, the timeout is increased to
143 * 5400 seconds.
145 #define SSN_KEEP_ALIVE_TIMEOUT (90 * 60) /* seconds */
146 #define FRAGMENT_TIMEOUT (2 * SECONDS)
148 /* smb_netbios_util.c */
149 extern int netbios_first_level_name_decode(char *in, char *name, char *scope);
150 extern int netbios_first_level_name_encode(unsigned char *name,
151 unsigned char *scope, unsigned char *out, int max_out);
152 extern int netbios_name_isvalid(char *in, char *out);
154 #ifdef __cplusplus
156 #endif
158 #endif /* _SMBSRV_NETBIOS_H */