14bff34e3Sthurlow /* 24bff34e3Sthurlow * Copyright (c) 2000-2001 Boris Popov 34bff34e3Sthurlow * All rights reserved. 44bff34e3Sthurlow * 54bff34e3Sthurlow * Redistribution and use in source and binary forms, with or without 64bff34e3Sthurlow * modification, are permitted provided that the following conditions 74bff34e3Sthurlow * are met: 84bff34e3Sthurlow * 1. Redistributions of source code must retain the above copyright 94bff34e3Sthurlow * notice, this list of conditions and the following disclaimer. 104bff34e3Sthurlow * 2. Redistributions in binary form must reproduce the above copyright 114bff34e3Sthurlow * notice, this list of conditions and the following disclaimer in the 124bff34e3Sthurlow * documentation and/or other materials provided with the distribution. 134bff34e3Sthurlow * 3. All advertising materials mentioning features or use of this software 144bff34e3Sthurlow * must display the following acknowledgement: 154bff34e3Sthurlow * This product includes software developed by Boris Popov. 164bff34e3Sthurlow * 4. Neither the name of the author nor the names of any co-contributors 174bff34e3Sthurlow * may be used to endorse or promote products derived from this software 184bff34e3Sthurlow * without specific prior written permission. 194bff34e3Sthurlow * 204bff34e3Sthurlow * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 214bff34e3Sthurlow * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 224bff34e3Sthurlow * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 234bff34e3Sthurlow * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 244bff34e3Sthurlow * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 254bff34e3Sthurlow * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 264bff34e3Sthurlow * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 274bff34e3Sthurlow * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 284bff34e3Sthurlow * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 294bff34e3Sthurlow * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 304bff34e3Sthurlow * SUCH DAMAGE. 314bff34e3Sthurlow * 324bff34e3Sthurlow * $Id: netbios.h,v 1.5 2004/03/19 01:49:45 lindak Exp $ 334bff34e3Sthurlow */ 344bff34e3Sthurlow 35*613a2f6bSGordon Ross /* 36*613a2f6bSGordon Ross * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 37*613a2f6bSGordon Ross * Use is subject to license terms. 38*613a2f6bSGordon Ross */ 39*613a2f6bSGordon Ross 404bff34e3Sthurlow #ifndef _NETSMB_NETBIOS_H_ 414bff34e3Sthurlow #define _NETSMB_NETBIOS_H_ 424bff34e3Sthurlow 434bff34e3Sthurlow #ifndef _NETINET_IN_H_ 444bff34e3Sthurlow #include <netinet/in.h> 454bff34e3Sthurlow #endif 464bff34e3Sthurlow 474bff34e3Sthurlow /* 484bff34e3Sthurlow * This is a fake address family number, used to 494bff34e3Sthurlow * recognize our fake sockaddr_nb objects. 504bff34e3Sthurlow * This is never handed to bind or connect. 514bff34e3Sthurlow */ 524bff34e3Sthurlow #ifndef AF_NETBIOS 534bff34e3Sthurlow #define AF_NETBIOS (AF_MAX+2) 544bff34e3Sthurlow #endif 554bff34e3Sthurlow 564bff34e3Sthurlow #define PF_NETBIOS AF_NETBIOS 574bff34e3Sthurlow 584bff34e3Sthurlow /* 594bff34e3Sthurlow * NetBIOS port numbers by the names used in the Darwin code. 604bff34e3Sthurlow * XXX: Change the code to use IPPORT_xxx from in.h directly. 614bff34e3Sthurlow * XXX: Add IPPORT_SMB_OVER_TCP or some such (port 445) 624bff34e3Sthurlow */ 634bff34e3Sthurlow #define NBNS_UDP_PORT IPPORT_NETBIOS_NS /* 137 */ 644bff34e3Sthurlow #define SMB_TCP_PORT IPPORT_NETBIOS_SSN /* 139 */ 654bff34e3Sthurlow 664bff34e3Sthurlow #define NBPROTO_TCPSSN 1 /* NETBIOS session over TCP */ 674bff34e3Sthurlow 684bff34e3Sthurlow #define NB_NAMELEN 16 694bff34e3Sthurlow #define NB_ENCNAMELEN NB_NAMELEN * 2 704bff34e3Sthurlow #define NB_MAXLABLEN 63 714bff34e3Sthurlow 72*613a2f6bSGordon Ross #define NB_MAXPKTLEN 0x1FFFF 73*613a2f6bSGordon Ross 744bff34e3Sthurlow #define NB_MINSALEN (sizeof (struct sockaddr_nb)) 754bff34e3Sthurlow 764bff34e3Sthurlow /* 774bff34e3Sthurlow * name types 784bff34e3Sthurlow */ 794bff34e3Sthurlow #define NBT_WKSTA 0x00 804bff34e3Sthurlow #define NBT_CLIENT 0x03 814bff34e3Sthurlow #define NBT_RASSRVR 0x06 824bff34e3Sthurlow #define NBT_DMB 0x1B 834bff34e3Sthurlow #define NBT_IP 0x1C 844bff34e3Sthurlow #define NBT_MB 0x1D 854bff34e3Sthurlow #define NBT_BS 0x1E 864bff34e3Sthurlow #define NBT_NETDDE 0x1F 874bff34e3Sthurlow #define NBT_SERVER 0x20 884bff34e3Sthurlow #define NBT_RASCLNT 0x21 894bff34e3Sthurlow #define NBT_NMAGENT 0xBE 904bff34e3Sthurlow #define NBT_NMUTIL 0xBF 914bff34e3Sthurlow 924bff34e3Sthurlow /* 934bff34e3Sthurlow * Session packet types 944bff34e3Sthurlow */ 954bff34e3Sthurlow #define NB_SSN_MESSAGE 0x0 964bff34e3Sthurlow #define NB_SSN_REQUEST 0x81 974bff34e3Sthurlow #define NB_SSN_POSRESP 0x82 984bff34e3Sthurlow #define NB_SSN_NEGRESP 0x83 994bff34e3Sthurlow #define NB_SSN_RTGRESP 0x84 1004bff34e3Sthurlow #define NB_SSN_KEEPALIVE 0x85 1014bff34e3Sthurlow 1024bff34e3Sthurlow /* 1034bff34e3Sthurlow * resolver: Opcodes 1044bff34e3Sthurlow */ 1054bff34e3Sthurlow #define NBNS_OPCODE_QUERY 0x00 1064bff34e3Sthurlow #define NBNS_OPCODE_REGISTER 0x05 1074bff34e3Sthurlow #define NBNS_OPCODE_RELEASE 0x06 1084bff34e3Sthurlow #define NBNS_OPCODE_WACK 0x07 1094bff34e3Sthurlow #define NBNS_OPCODE_REFRESH 0x08 1104bff34e3Sthurlow #define NBNS_OPCODE_RESPONSE 0x10 /* or'ed with other opcodes */ 1114bff34e3Sthurlow 1124bff34e3Sthurlow /* 1134bff34e3Sthurlow * resolver: NM_FLAGS 1144bff34e3Sthurlow */ 1154bff34e3Sthurlow #define NBNS_NMFLAG_BCAST 0x01 1164bff34e3Sthurlow #define NBNS_NMFLAG_RA 0x08 /* recursion available */ 1174bff34e3Sthurlow #define NBNS_NMFLAG_RD 0x10 /* recursion desired */ 1184bff34e3Sthurlow #define NBNS_NMFLAG_TC 0x20 /* truncation occured */ 1194bff34e3Sthurlow #define NBNS_NMFLAG_AA 0x40 /* authoritative answer */ 1204bff34e3Sthurlow 1214bff34e3Sthurlow /* 1224bff34e3Sthurlow * resolver: Question types 1234bff34e3Sthurlow */ 1244bff34e3Sthurlow #define NBNS_QUESTION_TYPE_NB 0x0020 1254bff34e3Sthurlow #define NBNS_QUESTION_TYPE_NBSTAT 0x0021 1264bff34e3Sthurlow 1274bff34e3Sthurlow /* 1284bff34e3Sthurlow * resolver: Question class 1294bff34e3Sthurlow */ 1304bff34e3Sthurlow #define NBNS_QUESTION_CLASS_IN 0x0001 1314bff34e3Sthurlow 1324bff34e3Sthurlow /* 1334bff34e3Sthurlow * resolver: Limits 1344bff34e3Sthurlow */ 1354bff34e3Sthurlow #define NBNS_MAXREDIRECTS 3 /* max number of accepted redirects */ 1364bff34e3Sthurlow #define NBDG_MAXSIZE 576 /* maximum nbns datagram size */ 1374bff34e3Sthurlow 1384bff34e3Sthurlow /* 1394bff34e3Sthurlow * NETBIOS addressing 1404bff34e3Sthurlow */ 1414bff34e3Sthurlow 1424bff34e3Sthurlow struct nb_name { 1434bff34e3Sthurlow uint_t nn_type; 1444bff34e3Sthurlow char nn_name[NB_NAMELEN]; 1454bff34e3Sthurlow char *nn_scope; 1464bff34e3Sthurlow }; 1474bff34e3Sthurlow typedef struct nb_name nb_name_t; 1484bff34e3Sthurlow 1494bff34e3Sthurlow /* 1504bff34e3Sthurlow * Our private NetBIOS socket address format. 1514bff34e3Sthurlow * Note that it's LARGER than sockaddr. 1524bff34e3Sthurlow * 1534bff34e3Sthurlow * XXX: Also note that the library code is sloppy about 1544bff34e3Sthurlow * casting this to sockaddr_in so let's keep snb_ipaddr 1554bff34e3Sthurlow * at the same offset, at least until that's fixed. 1564bff34e3Sthurlow */ 1574bff34e3Sthurlow struct sockaddr_nb { 1584bff34e3Sthurlow sa_family_t snb_family; /* address family */ 1594bff34e3Sthurlow uint16_t snb_flags; /* NBNS_GROUPFLG, etc. */ 1604bff34e3Sthurlow uint32_t snb_ipaddr; /* always IPv4 */ 1614bff34e3Sthurlow char snb_name[NB_NAMELEN]; /* NOT encoded */ 1624bff34e3Sthurlow }; 1634bff34e3Sthurlow typedef struct sockaddr_nb sockaddr_nb_t; 1644bff34e3Sthurlow 1654bff34e3Sthurlow #endif /* !_NETSMB_NETBIOS_H_ */ 166