1*5331Samw /* 2*5331Samw * CDDL HEADER START 3*5331Samw * 4*5331Samw * The contents of this file are subject to the terms of the 5*5331Samw * Common Development and Distribution License (the "License"). 6*5331Samw * You may not use this file except in compliance with the License. 7*5331Samw * 8*5331Samw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*5331Samw * or http://www.opensolaris.org/os/licensing. 10*5331Samw * See the License for the specific language governing permissions 11*5331Samw * and limitations under the License. 12*5331Samw * 13*5331Samw * When distributing Covered Code, include this CDDL HEADER in each 14*5331Samw * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*5331Samw * If applicable, add the following below this CDDL HEADER, with the 16*5331Samw * fields enclosed by brackets "[]" replaced with your own identifying 17*5331Samw * information: Portions Copyright [yyyy] [name of copyright owner] 18*5331Samw * 19*5331Samw * CDDL HEADER END 20*5331Samw */ 21*5331Samw /* 22*5331Samw * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23*5331Samw * Use is subject to license terms. 24*5331Samw */ 25*5331Samw 26*5331Samw #ifndef _SMBSRV_NETBIOS_H 27*5331Samw #define _SMBSRV_NETBIOS_H 28*5331Samw 29*5331Samw #pragma ident "%Z%%M% %I% %E% SMI" 30*5331Samw 31*5331Samw /* 32*5331Samw * NetBIOS over TCP/IP interface definitions. NetBIOS over TCP/IP is 33*5331Samw * documented in the following RFC documents: 34*5331Samw * 35*5331Samw * RFC 1001: Protocol Standard for a NetBIOS Service on a TCP/UDP 36*5331Samw * Transport: Concepts and Methods 37*5331Samw * 38*5331Samw * RFC 1002: Protocol Standard for a NetBIOS Service on a TCP/UDP 39*5331Samw * Transport: Detailed Specifications 40*5331Samw * 41*5331Samw * These documents reference RCF883. 42*5331Samw * RFC 883: Domain Names - Implementation and Specification 43*5331Samw */ 44*5331Samw 45*5331Samw #ifdef __cplusplus 46*5331Samw extern "C" { 47*5331Samw #endif 48*5331Samw 49*5331Samw 50*5331Samw /* 51*5331Samw * NetBIOS names in NetBIOS packets are valid domain names as defined in 52*5331Samw * RFC 883. Each label is limited to 63 bytes with an overall length of 53*5331Samw * 255 bytes as described in RFC 1002 section 4.1. This is known as 54*5331Samw * second-level encoding. In first-level encoding the label lengths are 55*5331Samw * represented as dots (.). 56*5331Samw * 57*5331Samw * RFC 1001 section 14.1 describes first-level encoding of the NetBIOS 58*5331Samw * name (hostname) and scope. The ASCII name is padded to 15 bytes using 59*5331Samw * spaces and a one byte type or suffix is written to the 16th byte. 60*5331Samw * This is then encoded as a 32 byte string. 61*5331Samw * 62*5331Samw * NetBIOS Name: NetBIOS 63*5331Samw * NetBIOS Scope: PROCOM.COM 64*5331Samw * First Level: EOGFHEECEJEPFDCACACACACACACACACA.PROCOM.COM 65*5331Samw * Second Level: <32>EOGFHEECEJEPFDCACACACACACACACACA<6>PROCOM<3>COM<0> 66*5331Samw */ 67*5331Samw #define NETBIOS_NAME_SZ 16 68*5331Samw #define NETBIOS_ENCODED_NAME_SZ 32 69*5331Samw #define NETBIOS_LABEL_MAX 63 70*5331Samw #define NETBIOS_DOMAIN_NAME_MAX 255 71*5331Samw #define NETBIOS_DOMAIN_NAME_BUFLEN (NETBIOS_DOMAIN_NAME_MAX + 1) 72*5331Samw #define NETBIOS_SESSION_REQUEST_DATA_LENGTH \ 73*5331Samw ((NETBIOS_ENCODED_NAME_SZ + 2) * 2) 74*5331Samw 75*5331Samw #define NETBIOS_HDR_SZ 4 /* bytes */ 76*5331Samw /* 77*5331Samw * Session Packet Types (RFC 1002 4.3.1). 78*5331Samw */ 79*5331Samw #define SESSION_MESSAGE 0x00 80*5331Samw #define SESSION_REQUEST 0x81 81*5331Samw #define POSITIVE_SESSION_RESPONSE 0x82 82*5331Samw #define NEGATIVE_SESSION_RESPONSE 0x83 83*5331Samw #define RETARGET_SESSION_RESPONSE 0x84 84*5331Samw #define SESSION_KEEP_ALIVE 0x85 85*5331Samw 86*5331Samw /* 87*5331Samw * NEGATIVE SESSION RESPONSE packet error code values (RFC 1002 4.3.4). 88*5331Samw */ 89*5331Samw #define SESSION_NOT_LISTENING_ON_CALLED_NAME 0x80 90*5331Samw #define SESSION_NOT_LISTENING_FOR_CALLING_NAME 0x81 91*5331Samw #define SESSION_CALLED_NAME_NOT_PRESENT 0x82 92*5331Samw #define SESSION_INSUFFICIENT_RESOURCES 0x83 93*5331Samw #define SESSION_UNSPECIFIED_ERROR 0x8F 94*5331Samw 95*5331Samw /* 96*5331Samw * Time conversions 97*5331Samw */ 98*5331Samw #define MILLISECONDS 1 99*5331Samw #define SECONDS (1000 * MILLISECONDS) 100*5331Samw #define MINUTES (60 * SECONDS) 101*5331Samw #define HOURS (60 * MINUTES) 102*5331Samw #define TO_SECONDS(x) ((x) / 1000) 103*5331Samw #define TO_MILLISECONDS(x) ((x) * 1000) 104*5331Samw 105*5331Samw /* 106*5331Samw * DATAGRAM service definitions 107*5331Samw */ 108*5331Samw #define DATAGRAM_DESTINATION_NAME_NOT_PRESENT 0x82 109*5331Samw #define DATAGRAM_INVALID_SOURCE_NAME_FORMAT 0x83 110*5331Samw #define DATAGRAM_INVALID_DESTINATION_NAME_FORMAT 0x84 111*5331Samw 112*5331Samw #define NAME_SERVICE_TCP_PORT 137 113*5331Samw #define NAME_SERVICE_UDP_PORT 137 114*5331Samw #define DGM_SRVC_UDP_PORT 138 115*5331Samw #define SSN_SRVC_TCP_PORT 139 116*5331Samw #define MAX_DATAGRAM_LENGTH 576 117*5331Samw #define DATAGRAM_HEADER_LENGTH 14 118*5331Samw #define MAX_NAME_LENGTH 256 119*5331Samw #define BCAST_REQ_RETRY_COUNT 2 120*5331Samw #define UCAST_REQ_RETRY_COUNT 2 121*5331Samw #define BCAST_REQ_RETRY_TIMEOUT (500 * MILLISECONDS) 122*5331Samw #define UCAST_REQ_RETRY_TIMEOUT (500 * MILLISECONDS) 123*5331Samw #define CONFLICT_TIMER (1 * SECONDS) 124*5331Samw #define INFINITE_TTL 0 125*5331Samw #define DEFAULT_TTL (600 * SECONDS) 126*5331Samw #define SSN_RETRY_COUNT 4 127*5331Samw #define SSN_CLOSE_TIMEOUT (30 * SECONDS) 128*5331Samw /* 129*5331Samw * K.L. The keep alive time out use to be default to 130*5331Samw * 900 seconds. It is not long enough for some applications 131*5331Samw * i.e. MS Access. Therefore, the timeout is increased to 132*5331Samw * 5400 seconds. 133*5331Samw */ 134*5331Samw #define SSN_KEEP_ALIVE_TIMEOUT (90 * 60) /* seconds */ 135*5331Samw #define FRAGMENT_TIMEOUT (2 * SECONDS) 136*5331Samw 137*5331Samw /* smb_netbios_util.c */ 138*5331Samw extern int netbios_first_level_name_decode(char *in, char *name, char *scope); 139*5331Samw extern int netbios_first_level_name_encode(unsigned char *name, 140*5331Samw unsigned char *scope, unsigned char *out, int max_out); 141*5331Samw extern int netbios_name_isvalid(char *in, char *out); 142*5331Samw 143*5331Samw #ifdef __cplusplus 144*5331Samw } 145*5331Samw #endif 146*5331Samw 147*5331Samw #endif /* _SMBSRV_NETBIOS_H */ 148