netbios.h revision 150802
1139823Simp/*- 275374Sbp * Copyright (c) 2000-2001 Boris Popov 375374Sbp * All rights reserved. 475374Sbp * 575374Sbp * Redistribution and use in source and binary forms, with or without 675374Sbp * modification, are permitted provided that the following conditions 775374Sbp * are met: 875374Sbp * 1. Redistributions of source code must retain the above copyright 975374Sbp * notice, this list of conditions and the following disclaimer. 1075374Sbp * 2. Redistributions in binary form must reproduce the above copyright 1175374Sbp * notice, this list of conditions and the following disclaimer in the 1275374Sbp * documentation and/or other materials provided with the distribution. 1375374Sbp * 3. All advertising materials mentioning features or use of this software 1475374Sbp * must display the following acknowledgement: 1575374Sbp * This product includes software developed by Boris Popov. 1675374Sbp * 4. Neither the name of the author nor the names of any co-contributors 1775374Sbp * may be used to endorse or promote products derived from this software 1875374Sbp * without specific prior written permission. 1975374Sbp * 2075374Sbp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 2175374Sbp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2275374Sbp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2375374Sbp * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2475374Sbp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2575374Sbp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2675374Sbp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2775374Sbp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2875374Sbp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2975374Sbp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3075374Sbp * SUCH DAMAGE. 3175374Sbp * 3275374Sbp * $FreeBSD: head/sys/netsmb/netbios.h 150802 2005-10-02 08:32:49Z bp $ 3375374Sbp */ 3475374Sbp#ifndef _NETSMB_NETBIOS_H_ 3575374Sbp#define _NETSMB_NETBIOS_H_ 3675374Sbp 3775374Sbp/* 3875374Sbp * make this file dirty... 3975374Sbp */ 4075374Sbp#ifndef _NETINET_IN_H_ 4175374Sbp#include <netinet/in.h> 4275374Sbp#endif 4375374Sbp 4475374Sbp#ifndef _NETIPX_IPX_H_ 4575374Sbp#include <netipx/ipx.h> 4675374Sbp#endif 4775374Sbp 48150802Sbp#define NMB_TCP_PORT 137 49150802Sbp 5075374Sbp#define NBPROTO_TCPSSN 1 /* NETBIOS session over TCP */ 5175374Sbp#define NBPROTO_IPXSSN 11 /* NETBIOS over IPX */ 5275374Sbp 5375374Sbp#define NB_NAMELEN 16 5475374Sbp#define NB_ENCNAMELEN NB_NAMELEN * 2 5575374Sbp#define NB_MAXLABLEN 63 5675374Sbp 5775374Sbp#define NB_MINSALEN (sizeof(struct sockaddr_nb)) 5875374Sbp 5975374Sbp/* 6075374Sbp * name types 6175374Sbp */ 6294913Sbp#define NBT_WKSTA 0x00 6394913Sbp#define NBT_MESSENGER 0x03 6494913Sbp#define NBT_RAS_SERVER 0x06 6594913Sbp#define NBT_DOMAIN_MASTER_BROWSER 0x1B 6694913Sbp#define NBT_DOMAIN_CONTROLLER 0x1C 6794913Sbp#define NBT_MASTER_BROWSER 0x1D 6894913Sbp#define NBT_NETDDE 0x1F 6994913Sbp#define NBT_SERVER 0x20 7094913Sbp#define NBT_RAS_CLIENT 0x21 7175374Sbp 7275374Sbp/* 7375374Sbp * Session packet types 7475374Sbp */ 7575374Sbp#define NB_SSN_MESSAGE 0x0 7675374Sbp#define NB_SSN_REQUEST 0x81 7775374Sbp#define NB_SSN_POSRESP 0x82 7875374Sbp#define NB_SSN_NEGRESP 0x83 7975374Sbp#define NB_SSN_RTGRESP 0x84 8075374Sbp#define NB_SSN_KEEPALIVE 0x85 8175374Sbp 8275374Sbp/* 8375374Sbp * resolver: Opcodes 8475374Sbp */ 8575374Sbp#define NBNS_OPCODE_QUERY 0x00 8675374Sbp#define NBNS_OPCODE_REGISTER 0x05 8775374Sbp#define NBNS_OPCODE_RELEASE 0x06 8875374Sbp#define NBNS_OPCODE_WACK 0x07 8975374Sbp#define NBNS_OPCODE_REFRESH 0x08 9075374Sbp#define NBNS_OPCODE_RESPONSE 0x10 /* or'ed with other opcodes */ 9175374Sbp 9275374Sbp/* 9375374Sbp * resolver: NM_FLAGS 9475374Sbp */ 9575374Sbp#define NBNS_NMFLAG_BCAST 0x01 9675374Sbp#define NBNS_NMFLAG_RA 0x08 /* recursion available */ 9775374Sbp#define NBNS_NMFLAG_RD 0x10 /* recursion desired */ 9888741Sbp#define NBNS_NMFLAG_TC 0x20 /* truncation occurred */ 9975374Sbp#define NBNS_NMFLAG_AA 0x40 /* authoritative answer */ 10075374Sbp 10175374Sbp/* 10275374Sbp * resolver: Question types 10375374Sbp */ 10475374Sbp#define NBNS_QUESTION_TYPE_NB 0x0020 10575374Sbp#define NBNS_QUESTION_TYPE_NBSTAT 0x0021 10675374Sbp 10775374Sbp/* 10875374Sbp * resolver: Question class 10975374Sbp */ 11075374Sbp#define NBNS_QUESTION_CLASS_IN 0x0001 11175374Sbp 11275374Sbp/* 11375374Sbp * resolver: Limits 11475374Sbp */ 11575374Sbp#define NBNS_MAXREDIRECTS 3 /* maximum number of accepted redirects */ 11675374Sbp#define NBDG_MAXSIZE 576 /* maximum nbns datagram size */ 11775374Sbp 11875374Sbp/* 11975374Sbp * NETBIOS addressing 12075374Sbp */ 12175374Sbpunion nb_tran { 12275374Sbp struct sockaddr_in x_in; 12375374Sbp struct sockaddr_ipx x_ipx; 12475374Sbp}; 12575374Sbp 12675374Sbpstruct nb_name { 12775374Sbp u_int nn_type; 12875374Sbp u_char nn_name[NB_NAMELEN + 1]; 12975374Sbp u_char * nn_scope; 13075374Sbp}; 13175374Sbp 13275374Sbp/* 13375374Sbp * Socket address 13475374Sbp */ 13575374Sbpstruct sockaddr_nb { 13675374Sbp u_char snb_len; 13775374Sbp u_char snb_family; 13875374Sbp union nb_tran snb_tran; /* transport */ 13975374Sbp u_char snb_name[1 + NB_ENCNAMELEN + 1]; /* encoded */ 14075374Sbp}; 14175374Sbp 14275374Sbp#define snb_addrin snb_tran.x_in 14375374Sbp 14475374Sbp#endif /* !_NETSMB_NETBIOS_H_ */ 145