netbios.h revision 75374
175374Sbp/* 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 75374 2001-04-10 07:59:06Z 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 4875374Sbp#define AF_NETBIOS AF_NS /* XXX: should go to socket.h */ 4975374Sbp#define PF_NETBIOS AF_NETBIOS 5075374Sbp 5175374Sbp#define NBPROTO_TCPSSN 1 /* NETBIOS session over TCP */ 5275374Sbp#define NBPROTO_IPXSSN 11 /* NETBIOS over IPX */ 5375374Sbp 5475374Sbp#define NB_NAMELEN 16 5575374Sbp#define NB_ENCNAMELEN NB_NAMELEN * 2 5675374Sbp#define NB_MAXLABLEN 63 5775374Sbp 5875374Sbp#define NB_MINSALEN (sizeof(struct sockaddr_nb)) 5975374Sbp 6075374Sbp/* 6175374Sbp * name types 6275374Sbp */ 6375374Sbp#define NBT_WKSTA 0x00 6475374Sbp#define NBT_SERVER 0x20 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 */ 9275374Sbp#define NBNS_NMFLAG_TC 0x20 /* truncation occured */ 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