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 48ef29b0f6SBoris Popov #define NMB_TCP_PORT 137 49ef29b0f6SBoris Popov 50681a5bbeSBoris Popov #define NBPROTO_TCPSSN 1 /* NETBIOS session over TCP */ 51681a5bbeSBoris Popov #define NBPROTO_IPXSSN 11 /* NETBIOS over IPX */ 52681a5bbeSBoris Popov 53681a5bbeSBoris Popov #define NB_NAMELEN 16 54681a5bbeSBoris Popov #define NB_ENCNAMELEN NB_NAMELEN * 2 55681a5bbeSBoris Popov #define NB_MAXLABLEN 63 56681a5bbeSBoris Popov 57681a5bbeSBoris Popov #define NB_MINSALEN (sizeof(struct sockaddr_nb)) 58681a5bbeSBoris Popov 59681a5bbeSBoris Popov /* 60681a5bbeSBoris Popov * name types 61681a5bbeSBoris Popov */ 62681a5bbeSBoris Popov #define NBT_WKSTA 0x00 630904a0d3SBoris Popov #define NBT_MESSENGER 0x03 640904a0d3SBoris Popov #define NBT_RAS_SERVER 0x06 650904a0d3SBoris Popov #define NBT_DOMAIN_MASTER_BROWSER 0x1B 660904a0d3SBoris Popov #define NBT_DOMAIN_CONTROLLER 0x1C 670904a0d3SBoris Popov #define NBT_MASTER_BROWSER 0x1D 680904a0d3SBoris Popov #define NBT_NETDDE 0x1F 69681a5bbeSBoris Popov #define NBT_SERVER 0x20 700904a0d3SBoris Popov #define NBT_RAS_CLIENT 0x21 71681a5bbeSBoris Popov 72681a5bbeSBoris Popov /* 73681a5bbeSBoris Popov * Session packet types 74681a5bbeSBoris Popov */ 75681a5bbeSBoris Popov #define NB_SSN_MESSAGE 0x0 76681a5bbeSBoris Popov #define NB_SSN_REQUEST 0x81 77681a5bbeSBoris Popov #define NB_SSN_POSRESP 0x82 78681a5bbeSBoris Popov #define NB_SSN_NEGRESP 0x83 79681a5bbeSBoris Popov #define NB_SSN_RTGRESP 0x84 80681a5bbeSBoris Popov #define NB_SSN_KEEPALIVE 0x85 81681a5bbeSBoris Popov 82681a5bbeSBoris Popov /* 83681a5bbeSBoris Popov * resolver: Opcodes 84681a5bbeSBoris Popov */ 85681a5bbeSBoris Popov #define NBNS_OPCODE_QUERY 0x00 86681a5bbeSBoris Popov #define NBNS_OPCODE_REGISTER 0x05 87681a5bbeSBoris Popov #define NBNS_OPCODE_RELEASE 0x06 88681a5bbeSBoris Popov #define NBNS_OPCODE_WACK 0x07 89681a5bbeSBoris Popov #define NBNS_OPCODE_REFRESH 0x08 90681a5bbeSBoris Popov #define NBNS_OPCODE_RESPONSE 0x10 /* or'ed with other opcodes */ 91681a5bbeSBoris Popov 92681a5bbeSBoris Popov /* 93681a5bbeSBoris Popov * resolver: NM_FLAGS 94681a5bbeSBoris Popov */ 95681a5bbeSBoris Popov #define NBNS_NMFLAG_BCAST 0x01 96681a5bbeSBoris Popov #define NBNS_NMFLAG_RA 0x08 /* recursion available */ 97681a5bbeSBoris Popov #define NBNS_NMFLAG_RD 0x10 /* recursion desired */ 98fc75194cSBoris Popov #define NBNS_NMFLAG_TC 0x20 /* truncation occurred */ 99681a5bbeSBoris Popov #define NBNS_NMFLAG_AA 0x40 /* authoritative answer */ 100681a5bbeSBoris Popov 101681a5bbeSBoris Popov /* 102681a5bbeSBoris Popov * resolver: Question types 103681a5bbeSBoris Popov */ 104681a5bbeSBoris Popov #define NBNS_QUESTION_TYPE_NB 0x0020 105681a5bbeSBoris Popov #define NBNS_QUESTION_TYPE_NBSTAT 0x0021 106681a5bbeSBoris Popov 107681a5bbeSBoris Popov /* 108681a5bbeSBoris Popov * resolver: Question class 109681a5bbeSBoris Popov */ 110681a5bbeSBoris Popov #define NBNS_QUESTION_CLASS_IN 0x0001 111681a5bbeSBoris Popov 112681a5bbeSBoris Popov /* 113681a5bbeSBoris Popov * resolver: Limits 114681a5bbeSBoris Popov */ 115681a5bbeSBoris Popov #define NBNS_MAXREDIRECTS 3 /* maximum number of accepted redirects */ 116681a5bbeSBoris Popov #define NBDG_MAXSIZE 576 /* maximum nbns datagram size */ 117681a5bbeSBoris Popov 118681a5bbeSBoris Popov /* 119681a5bbeSBoris Popov * NETBIOS addressing 120681a5bbeSBoris Popov */ 121681a5bbeSBoris Popov union nb_tran { 122681a5bbeSBoris Popov struct sockaddr_in x_in; 123681a5bbeSBoris Popov struct sockaddr_ipx x_ipx; 124681a5bbeSBoris Popov }; 125681a5bbeSBoris Popov 126681a5bbeSBoris Popov struct nb_name { 127681a5bbeSBoris Popov u_int nn_type; 128681a5bbeSBoris Popov u_char nn_name[NB_NAMELEN + 1]; 129681a5bbeSBoris Popov u_char * nn_scope; 130681a5bbeSBoris Popov }; 131681a5bbeSBoris Popov 132681a5bbeSBoris Popov /* 133681a5bbeSBoris Popov * Socket address 134681a5bbeSBoris Popov */ 135681a5bbeSBoris Popov struct sockaddr_nb { 136681a5bbeSBoris Popov u_char snb_len; 137681a5bbeSBoris Popov u_char snb_family; 138681a5bbeSBoris Popov union nb_tran snb_tran; /* transport */ 139681a5bbeSBoris Popov u_char snb_name[1 + NB_ENCNAMELEN + 1]; /* encoded */ 140681a5bbeSBoris Popov }; 141681a5bbeSBoris Popov 142681a5bbeSBoris Popov #define snb_addrin snb_tran.x_in 143681a5bbeSBoris Popov 144681a5bbeSBoris Popov #endif /* !_NETSMB_NETBIOS_H_ */ 145