1/* 2 * Copyright (c) 2009-2010 Apple Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. Please obtain a copy of the License at 10 * http://www.opensource.apple.com/apsl/ and read it before using this 11 * file. 12 * 13 * The Original Code and all software distributed under the License are 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 * Please see the License for the specific language governing rights and 19 * limitations under the License. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 */ 23 24#ifndef NETBIOS_H_8C21E785_0577_44E0_8CA1_8577A1010DF0 25#define NETBIOS_H_8C21E785_0577_44E0_8CA1_8577A1010DF0 26 27#include <stdint.h> 28#include <sys/socket.h> /* sockaddr_storage */ 29#include <CoreFoundation/CoreFoundation.h> 30 31#ifdef __cplusplus 32extern "C" { 33#endif 34 35#if !defined(SMBCLIENT_EXPORT) 36#if defined(__GNUC__) 37#define SMBCLIENT_EXPORT __attribute__((visibility("default"))) 38#else 39#define SMBCLIENT_EXPORT 40#endif 41#endif /* SMBCLIENT_EXPORT */ 42 43/* 44 * All NetBIOS names are 16 characters in length. A NetBIOS suffix is the 16th 45 * character of the 16-character NetBIOS name. The NetBIOS suffix is used by 46 * Microsoft Networking software to identify functionality installed on the 47 * registered device. 48 * The following is a partial lists of NetBIOS suffixes that are used by Microsoft 49 * Windows NT. The suffixes are listed in hexadecimal format because many of 50 * them are unprintable otherwise. 51 * For a complete list please see http://support.microsoft.com/kb/163409 52 */ 53#define kNetBIOSWorkstationService 0x00 54#define kNetBIOSMSBrowseService 0x01 55#define kNetBIOSMessengerService 0x03 56#define kNetBIOSRASServerService 0x06 57#define kNetBIOSDomainMasterBrowser 0x1B 58#define kNetBIOSDomainControllers 0x1C 59#define kNetBIOSMasterBrowser 0x1D 60#define kNetBIOSBrowserServiceElections 0x1E 61#define kNetBIOSNetDDEService 0x1F 62#define kNetBIOSFileServerService 0x20 63#define kNetBIOSRASClientService 0x21 64#define kNetBIOSMSExchangeInterchange 0x22 65#define kNetBIOSMicrosoftExchangeStore 0x23 66#define kNetBIOSMicrosoftExchangeDirectory 0x24 67#define kNetBIOSModemSharingServerService 0x30 68#define kNetBIOSModemSharingClientService 0x31 69#define kNetBIOSSMSClientsRemoteControl 0x43 70#define kNetBIOSSMSAdminRemoteControlTool 0x44 71#define kNetBIOSSMSClientsRemoteChat 0x45 72#define kNetBIOSDECPathworks 0x4C 73#define kNetBIOSMicrosoftExchangeIMC 0x6A 74#define kNetBIOSMicrosoftExchangeMTA 0x87 75#define kNetBIOSNetworkMonitorAgent 0xBE 76#define kNetBIOSNetworkMonitorApplication 0xBF 77 78/*! 79 * @function SMBResolveNetBIOSNameEx 80 * @abstract Resolve the NetBIOS name to a set of sockaddr structures. 81 * @param hostname The NetBIOS name that needs to be resolved 82 * @param node_type suffix NetBIOS Name suffix 83 * @param timeout number of seconds to wait, 0 means use default value. 84 * @param winserver Optional wins server dns name to use when resolving, if 85 * null then use the system defined WINS server. 86 * @param respAddr Sockaddr of the server that responded to the request. 87 * @param count Number of sockaddr returned. 88 * @result Returns an array of sockaddrs that must be freed with free(3). 89 */ 90SMBCLIENT_EXPORT 91struct sockaddr_storage * 92SMBResolveNetBIOSNameEx( 93 const char *hostName, 94 uint8_t nodeType, 95 const char *winServer, 96 uint32_t timeout, 97 struct sockaddr_storage *respAddr, 98 int32_t *outCount) 99__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA) 100; 101/*! 102 * @function SMBResolveNetBIOSName 103 * @abstract Resolve the NetBIOS name to a set of sockaddr structures. 104 * @param hostname The NetBIOS name that needs to be resolved 105 * @param node_type suffix NetBIOS Name suffix 106 * @param timeout number of seconds to wait, 0 means use default value. 107 * @param results an array of sockaddrs that must be freed with free(3). 108 * @result Number of sockaddr returned or -1 if any error besides timed out. 109 */ 110ssize_t 111SMBResolveNetBIOSName( 112 const char * hostname, 113 uint8_t node_type, 114 uint32_t timeout, 115 struct sockaddr_storage ** results) 116__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA) 117; 118 119#define NetBIOS_NAME_LEN 16 120 121/* 122* NB_FLAGS field of the RESOURCE RECORD RDATA field for RR_TYPE of "NB": 123* 124* 1 1 1 1 1 1 125* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 126* +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 127* | G | ONT | RESERVED | 128* +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ 129* 130* Symbol Bit(s) Description: 131* 132* RESERVED 3-15 Reserved for future use. Must be zero (0). 133* ONT 1,2 Owner Node Type: 134* 00 = B node 135* 01 = P node 136* 10 = M node 137* 11 = Reserved for future use 138* For registration requests this is the claimant's type. For responses this 139* is the actual owner's type. 140* G 0 Group Name Flag. 141* If one (1) then the RR_NAME is a GROUP NetBIOS name. 142* If zero (0) then the RR_NAME is a UNIQUE NetBIOS name. 143*/ 144#define NBNS_UNIQUE_NAME 0x0000 145#define NBNS_GROUP_NAME 0x8000 146 147typedef struct NBResourceRecord { 148 char rrName[NetBIOS_NAME_LEN]; 149 uint16_t nbFlags; 150} NBResourceRecord; 151 152typedef struct NodeStatusInfo { 153 struct sockaddr_storage node_storage; 154 char node_servername[16]; 155 char node_workgroupname[16]; 156 int32_t node_errno; 157 uint32_t node_nbrrArrayCnt; 158 struct NBResourceRecord *node_nbrrArray; 159} SMBNodeStatusInfo; 160 161/*! 162 * @function SMBGetNodeStatus 163 * @abstract Find all names associated using supplied host name. 164 * @param hostname The host name of the server 165 * @param count Number of node status info returned. 166 * @result Returns an array of node status info structures that must be free. 167 */ 168SMBCLIENT_EXPORT 169struct NodeStatusInfo * 170SMBGetNodeStatus( 171 const char *hostName, 172 uint32_t *outCount) 173__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA) 174; 175 176/*! 177 * @function SMBCreateNetBIOSName 178 * @abstract Transform the proposed NetBIOS name to be a valid NetBIOS name. 179 * @param proposedName The proposed NetBIOS name. 180 * @result Returns a new CFStringRef or NULL if the name cannot be transformed. 181 */ 182SMBCLIENT_EXPORT 183CFStringRef 184SMBCreateNetBIOSName( 185 CFStringRef proposedName) 186__OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_NA) 187; 188 189#ifdef __cplusplus 190} // extern "C" 191#endif 192 193#endif /* NETBIOS_H_8C21E785_0577_44E0_8CA1_8577A1010DF0 */ 194/* vim: set sw=4 ts=4 tw=79 et: */ 195