1/* 2 * Copyright (c) 2000, Boris Popov 3 * All rights reserved. 4 * 5 * Portions Copyright (C) 2001 - 2010 Apple Inc. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. All advertising materials mentioning features or use of this software 16 * must display the following acknowledgement: 17 * This product includes software developed by Boris Popov. 18 * 4. Neither the name of the author nor the names of any co-contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 */ 35#ifndef _NETSMB_NB_LIB_H_ 36#define _NETSMB_NB_LIB_H_ 37 38 39/* 40 * resource record 41 */ 42struct nbns_rr { 43 u_char * rr_name; /* compressed NETBIOS name */ 44 uint16_t rr_type; 45 uint16_t rr_class; 46 uint32_t rr_ttl; 47 uint16_t rr_rdlength; 48 u_char * rr_data; 49}; 50 51/* 52 * NetBIOS name return 53 */ 54struct nbns_nr { 55 char nr_name[NB_NAMELEN]; 56 uint16_t nr_beflags; /* Big endian, from network */ 57}; 58 59#define NBRQF_BROADCAST 0x0001 60 61#define NBNS_GROUPFLG 0x8000 62 63 64struct nb_ifdesc { 65 int id_flags; 66 struct in_addr id_addr; 67 struct in_addr id_mask; 68 char id_name[16]; /* actually IFNAMSIZ */ 69 struct nb_ifdesc * id_next; 70}; 71 72struct sockaddr; 73 74__BEGIN_DECLS 75 76/* new flag UCflag. 1=uppercase,0=don't */ 77void nb_name_encode(struct nb_name *, u_char *); 78int nb_encname_len(const char *); 79 80int nb_sockaddr(struct sockaddr *peer, const char *name, unsigned type, 81 struct sockaddr **dst); 82void convertToNetBIOSaddr(struct sockaddr_storage *storage, const char *name); 83 84int resolvehost(const char *name, CFMutableArrayRef *outAddressArray, char *netbios_name, 85 uint16_t port, int allowLocalConn, int tryBothPorts); 86int findReachableAddress(CFMutableArrayRef addressArray, uint16_t *cancel, struct connectAddress **dest); 87int nbns_resolvename(struct nb_ctx *ctx, struct smb_prefs *prefs, const char *name, 88 uint8_t nodeType, CFMutableArrayRef *outAddressArray, uint16_t port, 89 int allowLocalConn, int tryBothPorts, uint16_t *cancel); 90int nbns_getnodestatus(struct sockaddr *targethost, struct nb_ctx *ctx, 91 struct smb_prefs *prefs, uint16_t *cancel, char *nbt_server, 92 char *workgroup, CFMutableArrayRef nbrrArray); 93int isLocalIPAddress(struct sockaddr *, uint16_t port, int allowLocalConn); 94int isIPv6NumericName(const char *name); 95int nb_enum_if(struct nb_ifdesc **, int); 96int nb_error_to_errno(int error); 97 98int nb_ctx_resolve(struct nb_ctx *ctx, CFArrayRef WINSAddresses); 99__END_DECLS 100 101#endif /* !_NETSMB_NB_LIB_H_ */ 102