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 *
1475374Sbp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1575374Sbp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1675374Sbp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1775374Sbp * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1875374Sbp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1975374Sbp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2075374Sbp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2175374Sbp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2275374Sbp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2375374Sbp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2475374Sbp * SUCH DAMAGE.
2575374Sbp *
2675374Sbp * $FreeBSD: releng/11.0/sys/netsmb/netbios.h 263140 2014-03-14 02:58:48Z glebius $
2775374Sbp */
2875374Sbp#ifndef _NETSMB_NETBIOS_H_
2975374Sbp#define	_NETSMB_NETBIOS_H_
3075374Sbp
3175374Sbp/*
3275374Sbp * make this file dirty...
3375374Sbp */
3475374Sbp#ifndef _NETINET_IN_H_
3575374Sbp#include <netinet/in.h>
3675374Sbp#endif
3775374Sbp
38150802Sbp#define	NMB_TCP_PORT	137
39150802Sbp
4075374Sbp#define	NBPROTO_TCPSSN	1		/* NETBIOS session over TCP */
4175374Sbp#define	NBPROTO_IPXSSN	11		/* NETBIOS over IPX */
4275374Sbp
4375374Sbp#define NB_NAMELEN	16
4475374Sbp#define	NB_ENCNAMELEN	NB_NAMELEN * 2
4575374Sbp#define	NB_MAXLABLEN	63
4675374Sbp
4775374Sbp#define	NB_MINSALEN	(sizeof(struct sockaddr_nb))
4875374Sbp
4975374Sbp/*
5075374Sbp * name types
5175374Sbp */
5294913Sbp#define	NBT_WKSTA		0x00
5394913Sbp#define	NBT_MESSENGER		0x03
5494913Sbp#define	NBT_RAS_SERVER		0x06
5594913Sbp#define	NBT_DOMAIN_MASTER_BROWSER	0x1B
5694913Sbp#define	NBT_DOMAIN_CONTROLLER	0x1C
5794913Sbp#define	NBT_MASTER_BROWSER	0x1D
5894913Sbp#define	NBT_NETDDE		0x1F
5994913Sbp#define	NBT_SERVER		0x20
6094913Sbp#define	NBT_RAS_CLIENT		0x21
6175374Sbp
6275374Sbp/*
6375374Sbp * Session packet types
6475374Sbp */
6575374Sbp#define	NB_SSN_MESSAGE		0x0
6675374Sbp#define	NB_SSN_REQUEST		0x81
6775374Sbp#define	NB_SSN_POSRESP		0x82
6875374Sbp#define	NB_SSN_NEGRESP		0x83
6975374Sbp#define	NB_SSN_RTGRESP		0x84
7075374Sbp#define	NB_SSN_KEEPALIVE	0x85
7175374Sbp
7275374Sbp/*
7375374Sbp * resolver: Opcodes
7475374Sbp */
7575374Sbp#define	NBNS_OPCODE_QUERY	0x00
7675374Sbp#define	NBNS_OPCODE_REGISTER	0x05
7775374Sbp#define	NBNS_OPCODE_RELEASE	0x06
7875374Sbp#define	NBNS_OPCODE_WACK	0x07
7975374Sbp#define	NBNS_OPCODE_REFRESH	0x08
8075374Sbp#define	NBNS_OPCODE_RESPONSE	0x10	/* or'ed with other opcodes */
8175374Sbp
8275374Sbp/*
8375374Sbp * resolver: NM_FLAGS
8475374Sbp */
8575374Sbp#define	NBNS_NMFLAG_BCAST	0x01
8675374Sbp#define	NBNS_NMFLAG_RA		0x08	/* recursion available */
8775374Sbp#define	NBNS_NMFLAG_RD		0x10	/* recursion desired */
8888741Sbp#define	NBNS_NMFLAG_TC		0x20	/* truncation occurred */
8975374Sbp#define	NBNS_NMFLAG_AA		0x40	/* authoritative answer */
9075374Sbp
9175374Sbp/*
9275374Sbp * resolver: Question types
9375374Sbp */
9475374Sbp#define	NBNS_QUESTION_TYPE_NB		0x0020
9575374Sbp#define NBNS_QUESTION_TYPE_NBSTAT	0x0021
9675374Sbp
9775374Sbp/*
9875374Sbp * resolver: Question class
9975374Sbp */
10075374Sbp#define NBNS_QUESTION_CLASS_IN	0x0001
10175374Sbp
10275374Sbp/*
10375374Sbp * resolver: Limits
10475374Sbp */
10575374Sbp#define	NBNS_MAXREDIRECTS	3	/* maximum number of accepted redirects */
10675374Sbp#define	NBDG_MAXSIZE		576	/* maximum nbns datagram size */
10775374Sbp
10875374Sbp/*
10975374Sbp * NETBIOS addressing
11075374Sbp */
11175374Sbpunion nb_tran {
11275374Sbp	struct sockaddr_in	x_in;
113263140Sglebius	/* struct sockaddr_ipx was here. */
11475374Sbp};
11575374Sbp
11675374Sbpstruct nb_name {
11775374Sbp	u_int		nn_type;
11875374Sbp	u_char		nn_name[NB_NAMELEN + 1];
11975374Sbp	u_char *	nn_scope;
12075374Sbp};
12175374Sbp
12275374Sbp/*
12375374Sbp * Socket address
12475374Sbp */
12575374Sbpstruct sockaddr_nb {
12675374Sbp	u_char		snb_len;
12775374Sbp	u_char		snb_family;
12875374Sbp	union nb_tran	snb_tran;		/* transport */
12975374Sbp	u_char		snb_name[1 + NB_ENCNAMELEN + 1];	/* encoded */
13075374Sbp};
13175374Sbp
13275374Sbp#define	snb_addrin	snb_tran.x_in
13375374Sbp
13475374Sbp#endif /* !_NETSMB_NETBIOS_H_ */
135