1141296Sdas/*- 2141296Sdas * SPDX-License-Identifier: BSD-2-Clause 32116Sjkh * 42116Sjkh * Copyright (c) 2000-2001 Boris Popov 52116Sjkh * All rights reserved. 62116Sjkh * 7141296Sdas * Redistribution and use in source and binary forms, with or without 82116Sjkh * modification, are permitted provided that the following conditions 9141296Sdas * are met: 102116Sjkh * 1. Redistributions of source code must retain the above copyright 112116Sjkh * notice, this list of conditions and the following disclaimer. 122116Sjkh * 2. Redistributions in binary form must reproduce the above copyright 132116Sjkh * notice, this list of conditions and the following disclaimer in the 14176408Sbde * documentation and/or other materials provided with the distribution. 15176408Sbde * 162116Sjkh * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 172116Sjkh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 182116Sjkh * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 192116Sjkh * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 202116Sjkh * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21141296Sdas * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 222116Sjkh * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 232116Sjkh * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 242116Sjkh * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 252116Sjkh * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 262116Sjkh * SUCH DAMAGE. 272116Sjkh */ 282116Sjkh#ifndef _NETSMB_NETBIOS_H_ 292116Sjkh#define _NETSMB_NETBIOS_H_ 302116Sjkh 31141296Sdas/* 322116Sjkh * make this file dirty... 332116Sjkh */ 34141296Sdas#ifndef _NETINET_IN_H_ 35141296Sdas#include <netinet/in.h> 36141296Sdas#endif 372116Sjkh 38151698Sbde#define NMB_TCP_PORT 137 39141296Sdas 402116Sjkh#define NBPROTO_TCPSSN 1 /* NETBIOS session over TCP */ 412116Sjkh#define NBPROTO_IPXSSN 11 /* NETBIOS over IPX */ 422116Sjkh 43151698Sbde#define NB_NAMELEN 16 44151698Sbde#define NB_ENCNAMELEN NB_NAMELEN * 2 45151698Sbde#define NB_MAXLABLEN 63 46151698Sbde 47151698Sbde#define NB_MINSALEN (sizeof(struct sockaddr_nb)) 48151698Sbde 49151698Sbde/* 50151698Sbde * name types 51151698Sbde */ 52151698Sbde#define NBT_WKSTA 0x00 53151698Sbde#define NBT_MESSENGER 0x03 542116Sjkh#define NBT_RAS_SERVER 0x06 552116Sjkh#define NBT_DOMAIN_MASTER_BROWSER 0x1B 562116Sjkh#define NBT_DOMAIN_CONTROLLER 0x1C 572116Sjkh#define NBT_MASTER_BROWSER 0x1D 582116Sjkh#define NBT_NETDDE 0x1F 598870Srgrimes#define NBT_SERVER 0x20 602116Sjkh#define NBT_RAS_CLIENT 0x21 612116Sjkh 622116Sjkh/* 632116Sjkh * Session packet types 642116Sjkh */ 652116Sjkh#define NB_SSN_MESSAGE 0x0 662116Sjkh#define NB_SSN_REQUEST 0x81 672116Sjkh#define NB_SSN_POSRESP 0x82 6897413Salfred#define NB_SSN_NEGRESP 0x83 6997413Salfred#define NB_SSN_RTGRESP 0x84 702116Sjkh#define NB_SSN_KEEPALIVE 0x85 71151698Sbde 72151698Sbde/* 732116Sjkh * resolver: Opcodes 74176408Sbde */ 75176408Sbde#define NBNS_OPCODE_QUERY 0x00 76175665Sbde#define NBNS_OPCODE_REGISTER 0x05 77151698Sbde#define NBNS_OPCODE_RELEASE 0x06 78151698Sbde#define NBNS_OPCODE_WACK 0x07 792116Sjkh#define NBNS_OPCODE_REFRESH 0x08 80#define NBNS_OPCODE_RESPONSE 0x10 /* or'ed with other opcodes */ 81 82/* 83 * resolver: NM_FLAGS 84 */ 85#define NBNS_NMFLAG_BCAST 0x01 86#define NBNS_NMFLAG_RA 0x08 /* recursion available */ 87#define NBNS_NMFLAG_RD 0x10 /* recursion desired */ 88#define NBNS_NMFLAG_TC 0x20 /* truncation occurred */ 89#define NBNS_NMFLAG_AA 0x40 /* authoritative answer */ 90 91/* 92 * resolver: Question types 93 */ 94#define NBNS_QUESTION_TYPE_NB 0x0020 95#define NBNS_QUESTION_TYPE_NBSTAT 0x0021 96 97/* 98 * resolver: Question class 99 */ 100#define NBNS_QUESTION_CLASS_IN 0x0001 101 102/* 103 * resolver: Limits 104 */ 105#define NBNS_MAXREDIRECTS 3 /* maximum number of accepted redirects */ 106#define NBDG_MAXSIZE 576 /* maximum nbns datagram size */ 107 108/* 109 * NETBIOS addressing 110 */ 111union nb_tran { 112 struct sockaddr_in x_in; 113 /* struct sockaddr_ipx was here. */ 114}; 115 116struct nb_name { 117 u_int nn_type; 118 u_char nn_name[NB_NAMELEN + 1]; 119 u_char * nn_scope; 120}; 121 122/* 123 * Socket address 124 */ 125struct sockaddr_nb { 126 u_char snb_len; 127 u_char snb_family; 128 union nb_tran snb_tran; /* transport */ 129 u_char snb_name[1 + NB_ENCNAMELEN + 1]; /* encoded */ 130}; 131 132#define snb_addrin snb_tran.x_in 133 134#endif /* !_NETSMB_NETBIOS_H_ */ 135