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