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$
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
3875374Sbp#ifndef _NETIPX_IPX_H_
3975374Sbp#include <netipx/ipx.h>
4075374Sbp#endif
4175374Sbp
42150802Sbp#define	NMB_TCP_PORT	137
43150802Sbp
4475374Sbp#define	NBPROTO_TCPSSN	1		/* NETBIOS session over TCP */
4575374Sbp#define	NBPROTO_IPXSSN	11		/* NETBIOS over IPX */
4675374Sbp
4775374Sbp#define NB_NAMELEN	16
4875374Sbp#define	NB_ENCNAMELEN	NB_NAMELEN * 2
4975374Sbp#define	NB_MAXLABLEN	63
5075374Sbp
5175374Sbp#define	NB_MINSALEN	(sizeof(struct sockaddr_nb))
5275374Sbp
5375374Sbp/*
5475374Sbp * name types
5575374Sbp */
5694913Sbp#define	NBT_WKSTA		0x00
5794913Sbp#define	NBT_MESSENGER		0x03
5894913Sbp#define	NBT_RAS_SERVER		0x06
5994913Sbp#define	NBT_DOMAIN_MASTER_BROWSER	0x1B
6094913Sbp#define	NBT_DOMAIN_CONTROLLER	0x1C
6194913Sbp#define	NBT_MASTER_BROWSER	0x1D
6294913Sbp#define	NBT_NETDDE		0x1F
6394913Sbp#define	NBT_SERVER		0x20
6494913Sbp#define	NBT_RAS_CLIENT		0x21
6575374Sbp
6675374Sbp/*
6775374Sbp * Session packet types
6875374Sbp */
6975374Sbp#define	NB_SSN_MESSAGE		0x0
7075374Sbp#define	NB_SSN_REQUEST		0x81
7175374Sbp#define	NB_SSN_POSRESP		0x82
7275374Sbp#define	NB_SSN_NEGRESP		0x83
7375374Sbp#define	NB_SSN_RTGRESP		0x84
7475374Sbp#define	NB_SSN_KEEPALIVE	0x85
7575374Sbp
7675374Sbp/*
7775374Sbp * resolver: Opcodes
7875374Sbp */
7975374Sbp#define	NBNS_OPCODE_QUERY	0x00
8075374Sbp#define	NBNS_OPCODE_REGISTER	0x05
8175374Sbp#define	NBNS_OPCODE_RELEASE	0x06
8275374Sbp#define	NBNS_OPCODE_WACK	0x07
8375374Sbp#define	NBNS_OPCODE_REFRESH	0x08
8475374Sbp#define	NBNS_OPCODE_RESPONSE	0x10	/* or'ed with other opcodes */
8575374Sbp
8675374Sbp/*
8775374Sbp * resolver: NM_FLAGS
8875374Sbp */
8975374Sbp#define	NBNS_NMFLAG_BCAST	0x01
9075374Sbp#define	NBNS_NMFLAG_RA		0x08	/* recursion available */
9175374Sbp#define	NBNS_NMFLAG_RD		0x10	/* recursion desired */
9288741Sbp#define	NBNS_NMFLAG_TC		0x20	/* truncation occurred */
9375374Sbp#define	NBNS_NMFLAG_AA		0x40	/* authoritative answer */
9475374Sbp
9575374Sbp/*
9675374Sbp * resolver: Question types
9775374Sbp */
9875374Sbp#define	NBNS_QUESTION_TYPE_NB		0x0020
9975374Sbp#define NBNS_QUESTION_TYPE_NBSTAT	0x0021
10075374Sbp
10175374Sbp/*
10275374Sbp * resolver: Question class
10375374Sbp */
10475374Sbp#define NBNS_QUESTION_CLASS_IN	0x0001
10575374Sbp
10675374Sbp/*
10775374Sbp * resolver: Limits
10875374Sbp */
10975374Sbp#define	NBNS_MAXREDIRECTS	3	/* maximum number of accepted redirects */
11075374Sbp#define	NBDG_MAXSIZE		576	/* maximum nbns datagram size */
11175374Sbp
11275374Sbp/*
11375374Sbp * NETBIOS addressing
11475374Sbp */
11575374Sbpunion nb_tran {
11675374Sbp	struct sockaddr_in	x_in;
11775374Sbp	struct sockaddr_ipx	x_ipx;
11875374Sbp};
11975374Sbp
12075374Sbpstruct nb_name {
12175374Sbp	u_int		nn_type;
12275374Sbp	u_char		nn_name[NB_NAMELEN + 1];
12375374Sbp	u_char *	nn_scope;
12475374Sbp};
12575374Sbp
12675374Sbp/*
12775374Sbp * Socket address
12875374Sbp */
12975374Sbpstruct sockaddr_nb {
13075374Sbp	u_char		snb_len;
13175374Sbp	u_char		snb_family;
13275374Sbp	union nb_tran	snb_tran;		/* transport */
13375374Sbp	u_char		snb_name[1 + NB_ENCNAMELEN + 1];	/* encoded */
13475374Sbp};
13575374Sbp
13675374Sbp#define	snb_addrin	snb_tran.x_in
13775374Sbp
13875374Sbp#endif /* !_NETSMB_NETBIOS_H_ */
139