1c398230bSWarner Losh /*- 2681a5bbeSBoris Popov * Copyright (c) 2000-2001 Boris Popov 3681a5bbeSBoris Popov * All rights reserved. 4681a5bbeSBoris Popov * 5681a5bbeSBoris Popov * Redistribution and use in source and binary forms, with or without 6681a5bbeSBoris Popov * modification, are permitted provided that the following conditions 7681a5bbeSBoris Popov * are met: 8681a5bbeSBoris Popov * 1. Redistributions of source code must retain the above copyright 9681a5bbeSBoris Popov * notice, this list of conditions and the following disclaimer. 10681a5bbeSBoris Popov * 2. Redistributions in binary form must reproduce the above copyright 11681a5bbeSBoris Popov * notice, this list of conditions and the following disclaimer in the 12681a5bbeSBoris Popov * documentation and/or other materials provided with the distribution. 13681a5bbeSBoris Popov * 3. All advertising materials mentioning features or use of this software 14681a5bbeSBoris Popov * must display the following acknowledgement: 15681a5bbeSBoris Popov * This product includes software developed by Boris Popov. 16681a5bbeSBoris Popov * 4. Neither the name of the author nor the names of any co-contributors 17681a5bbeSBoris Popov * may be used to endorse or promote products derived from this software 18681a5bbeSBoris Popov * without specific prior written permission. 19681a5bbeSBoris Popov * 20681a5bbeSBoris Popov * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 21681a5bbeSBoris Popov * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22681a5bbeSBoris Popov * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23681a5bbeSBoris Popov * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 24681a5bbeSBoris Popov * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25681a5bbeSBoris Popov * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26681a5bbeSBoris Popov * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27681a5bbeSBoris Popov * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28681a5bbeSBoris Popov * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29681a5bbeSBoris Popov * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30681a5bbeSBoris Popov * SUCH DAMAGE. 31681a5bbeSBoris Popov * 32681a5bbeSBoris Popov * $FreeBSD$ 33681a5bbeSBoris Popov */ 34681a5bbeSBoris Popov #ifndef _NETSMB_NETBIOS_H_ 35681a5bbeSBoris Popov #define _NETSMB_NETBIOS_H_ 36681a5bbeSBoris Popov 37681a5bbeSBoris Popov /* 38681a5bbeSBoris Popov * make this file dirty... 39681a5bbeSBoris Popov */ 40681a5bbeSBoris Popov #ifndef _NETINET_IN_H_ 41681a5bbeSBoris Popov #include <netinet/in.h> 42681a5bbeSBoris Popov #endif 43681a5bbeSBoris Popov 44681a5bbeSBoris Popov #ifndef _NETIPX_IPX_H_ 45681a5bbeSBoris Popov #include <netipx/ipx.h> 46681a5bbeSBoris Popov #endif 47681a5bbeSBoris Popov 48681a5bbeSBoris Popov #define NBPROTO_TCPSSN 1 /* NETBIOS session over TCP */ 49681a5bbeSBoris Popov #define NBPROTO_IPXSSN 11 /* NETBIOS over IPX */ 50681a5bbeSBoris Popov 51681a5bbeSBoris Popov #define NB_NAMELEN 16 52681a5bbeSBoris Popov #define NB_ENCNAMELEN NB_NAMELEN * 2 53681a5bbeSBoris Popov #define NB_MAXLABLEN 63 54681a5bbeSBoris Popov 55681a5bbeSBoris Popov #define NB_MINSALEN (sizeof(struct sockaddr_nb)) 56681a5bbeSBoris Popov 57681a5bbeSBoris Popov /* 58681a5bbeSBoris Popov * name types 59681a5bbeSBoris Popov */ 60681a5bbeSBoris Popov #define NBT_WKSTA 0x00 610904a0d3SBoris Popov #define NBT_MESSENGER 0x03 620904a0d3SBoris Popov #define NBT_RAS_SERVER 0x06 630904a0d3SBoris Popov #define NBT_DOMAIN_MASTER_BROWSER 0x1B 640904a0d3SBoris Popov #define NBT_DOMAIN_CONTROLLER 0x1C 650904a0d3SBoris Popov #define NBT_MASTER_BROWSER 0x1D 660904a0d3SBoris Popov #define NBT_NETDDE 0x1F 67681a5bbeSBoris Popov #define NBT_SERVER 0x20 680904a0d3SBoris Popov #define NBT_RAS_CLIENT 0x21 69681a5bbeSBoris Popov 70681a5bbeSBoris Popov /* 71681a5bbeSBoris Popov * Session packet types 72681a5bbeSBoris Popov */ 73681a5bbeSBoris Popov #define NB_SSN_MESSAGE 0x0 74681a5bbeSBoris Popov #define NB_SSN_REQUEST 0x81 75681a5bbeSBoris Popov #define NB_SSN_POSRESP 0x82 76681a5bbeSBoris Popov #define NB_SSN_NEGRESP 0x83 77681a5bbeSBoris Popov #define NB_SSN_RTGRESP 0x84 78681a5bbeSBoris Popov #define NB_SSN_KEEPALIVE 0x85 79681a5bbeSBoris Popov 80681a5bbeSBoris Popov /* 81681a5bbeSBoris Popov * resolver: Opcodes 82681a5bbeSBoris Popov */ 83681a5bbeSBoris Popov #define NBNS_OPCODE_QUERY 0x00 84681a5bbeSBoris Popov #define NBNS_OPCODE_REGISTER 0x05 85681a5bbeSBoris Popov #define NBNS_OPCODE_RELEASE 0x06 86681a5bbeSBoris Popov #define NBNS_OPCODE_WACK 0x07 87681a5bbeSBoris Popov #define NBNS_OPCODE_REFRESH 0x08 88681a5bbeSBoris Popov #define NBNS_OPCODE_RESPONSE 0x10 /* or'ed with other opcodes */ 89681a5bbeSBoris Popov 90681a5bbeSBoris Popov /* 91681a5bbeSBoris Popov * resolver: NM_FLAGS 92681a5bbeSBoris Popov */ 93681a5bbeSBoris Popov #define NBNS_NMFLAG_BCAST 0x01 94681a5bbeSBoris Popov #define NBNS_NMFLAG_RA 0x08 /* recursion available */ 95681a5bbeSBoris Popov #define NBNS_NMFLAG_RD 0x10 /* recursion desired */ 96fc75194cSBoris Popov #define NBNS_NMFLAG_TC 0x20 /* truncation occurred */ 97681a5bbeSBoris Popov #define NBNS_NMFLAG_AA 0x40 /* authoritative answer */ 98681a5bbeSBoris Popov 99681a5bbeSBoris Popov /* 100681a5bbeSBoris Popov * resolver: Question types 101681a5bbeSBoris Popov */ 102681a5bbeSBoris Popov #define NBNS_QUESTION_TYPE_NB 0x0020 103681a5bbeSBoris Popov #define NBNS_QUESTION_TYPE_NBSTAT 0x0021 104681a5bbeSBoris Popov 105681a5bbeSBoris Popov /* 106681a5bbeSBoris Popov * resolver: Question class 107681a5bbeSBoris Popov */ 108681a5bbeSBoris Popov #define NBNS_QUESTION_CLASS_IN 0x0001 109681a5bbeSBoris Popov 110681a5bbeSBoris Popov /* 111681a5bbeSBoris Popov * resolver: Limits 112681a5bbeSBoris Popov */ 113681a5bbeSBoris Popov #define NBNS_MAXREDIRECTS 3 /* maximum number of accepted redirects */ 114681a5bbeSBoris Popov #define NBDG_MAXSIZE 576 /* maximum nbns datagram size */ 115681a5bbeSBoris Popov 116681a5bbeSBoris Popov /* 117681a5bbeSBoris Popov * NETBIOS addressing 118681a5bbeSBoris Popov */ 119681a5bbeSBoris Popov union nb_tran { 120681a5bbeSBoris Popov struct sockaddr_in x_in; 121681a5bbeSBoris Popov struct sockaddr_ipx x_ipx; 122681a5bbeSBoris Popov }; 123681a5bbeSBoris Popov 124681a5bbeSBoris Popov struct nb_name { 125681a5bbeSBoris Popov u_int nn_type; 126681a5bbeSBoris Popov u_char nn_name[NB_NAMELEN + 1]; 127681a5bbeSBoris Popov u_char * nn_scope; 128681a5bbeSBoris Popov }; 129681a5bbeSBoris Popov 130681a5bbeSBoris Popov /* 131681a5bbeSBoris Popov * Socket address 132681a5bbeSBoris Popov */ 133681a5bbeSBoris Popov struct sockaddr_nb { 134681a5bbeSBoris Popov u_char snb_len; 135681a5bbeSBoris Popov u_char snb_family; 136681a5bbeSBoris Popov union nb_tran snb_tran; /* transport */ 137681a5bbeSBoris Popov u_char snb_name[1 + NB_ENCNAMELEN + 1]; /* encoded */ 138681a5bbeSBoris Popov }; 139681a5bbeSBoris Popov 140681a5bbeSBoris Popov #define snb_addrin snb_tran.x_in 141681a5bbeSBoris Popov 142681a5bbeSBoris Popov #endif /* !_NETSMB_NETBIOS_H_ */ 143