2N/A * Copyright (c) 2000, 2001 Boris Popov 2N/A * All rights reserved. 2N/A * Redistribution and use in source and binary forms, with or without 2N/A * modification, are permitted provided that the following conditions 2N/A * 1. Redistributions of source code must retain the above copyright 2N/A * notice, this list of conditions and the following disclaimer. 2N/A * 2. Redistributions in binary form must reproduce the above copyright 2N/A * notice, this list of conditions and the following disclaimer in the 2N/A * documentation and/or other materials provided with the distribution. 2N/A * 3. All advertising materials mentioning features or use of this software 2N/A * must display the following acknowledgement: 2N/A * This product includes software developed by Boris Popov. 2N/A * 4. Neither the name of the author nor the names of any co-contributors 2N/A * may be used to endorse or promote products derived from this software 2N/A * without specific prior written permission. 2N/A * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 2N/A * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2N/A * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2N/A * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2N/A * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2N/A * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2N/A * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2N/A * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2N/A * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2N/A * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2N/A * $Id: nb.c,v 1.1.1.2 2001/07/06 22:38:42 conrad Exp $ 2N/A * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. 2N/A * This is called by "smbutil lookup" to handle the 2N/A * "-w wins_server" option. Let the semantics of 2N/A * this option be: Use specified WINS server only. 2N/A * If specified server is the broadcast address, 2N/A * set broadcast mode (and no WINS servers). 2N/A /* Deal with explicit request for broadcast. */ 2N/A * Now get the WINS server IP addresses directly 2N/A * when reading the RC files, so no longer need to 2N/A * lookup any names here. 2N/A * For defaults, enable NetBIOS name lookup and NetBIOS lookup via broadcast. 2N/A * These settings are not configurable. 2N/A * General networking stuff, in spite of the names 2N/A * that imply they're specific to NetBIOS. 2N/A warnx(
"address for `%s' is not in the AF_INET family",
name);
2N/A "NBNS server failure",
2N/A "unsupported request",
2N/A "name already registered" 2N/A "too many redirects",
2N/A "NETBIOS name too long",
2N/A "no interface to broadcast on and no NBNS server specified" 2N/A if ((
cp[0] &
0xc0) ==
0xc0)
2N/A return (-
1);
/* first two bytes are offset to name */ 2N/A * Do the NetBIOS "first-level encoding" here. 2N/A * (RFC1002 explains this weirdness...) 2N/A * Here is what we marshall: 2N/A * uint8_t NAME_LENGTH (always 32) 2N/A * uint8_t ENCODED_NAME[32] 2N/A * uint8_t SCOPE_LENGTH 2N/A * Scope follows here, then another null. 2N/A * NetBIOS "scope" sting encoding, 2N/A * a.k.a second-level encoding. 2N/A * See RFC1002 for the details. 2N/A * Note: plen points to the length byte at the 2N/A * start of each string. This keeps a pointer 2N/A * to the location and fills it in after the 2N/A * length of the string is determined. 2N/A * One string of length zero terminates. 2N/A * With no scope string, the zero-length 2N/A * string is the only thing there.