annotate usr/src/lib/smbsrv/libsmbns/common/smbns_browser.c @ 10717:fe0545fc3cdd

6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API 6877755 smbd should not route stderr, stdout to /dev/null 6882701 Wrong error message for attempt to map local user to Windows group, or vice versa 6885105 Potential for deadlock in smb_node_set_delete_on_close() 6881928 smbd core generated when running a script to join domain, set abe properties 6885538 Reduce dependencies on libsmbrdr 6820325 cifs service can't start on multi vlan+ipmp configuration
author Alan Wright <amw@Sun.COM>
date Mon, 05 Oct 2009 11:03:34 -0700
parents 3569b6c7f56c
children 37e5dcdf36d3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
2 * CDDL HEADER START
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
3 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
4 * The contents of this file are subject to the terms of the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
5 * Common Development and Distribution License (the "License").
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
6 * You may not use this file except in compliance with the License.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
7 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
9 * or http://www.opensolaris.org/os/licensing.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
10 * See the License for the specific language governing permissions
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
11 * and limitations under the License.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
12 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
13 * When distributing Covered Code, include this CDDL HEADER in each
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
15 * If applicable, add the following below this CDDL HEADER, with the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
16 * fields enclosed by brackets "[]" replaced with your own identifying
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
17 * information: Portions Copyright [yyyy] [name of copyright owner]
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
18 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
19 * CDDL HEADER END
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
20 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
21 /*
8670
6da349c3f817 6792084 smb_node_lookup should not take ownership of the hold on vnode passed as a parameter
jose borrego <Jose.Borrego@Sun.COM>
parents: 8334
diff changeset
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
23 * Use is subject to license terms.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
24 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
25
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
26 #include <sys/tzfile.h>
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
27 #include <errno.h>
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
28 #include <stdlib.h>
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
29 #include <stdio.h>
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
30 #include <unistd.h>
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
31 #include <syslog.h>
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
32 #include <string.h>
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
33 #include <strings.h>
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
34 #include <time.h>
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
35 #include <synch.h>
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
36 #include <netdb.h>
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
37 #include <sys/socket.h>
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
38 #include <arpa/inet.h>
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
39
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5331
diff changeset
40 #include <smbsrv/libsmb.h>
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
41 #include <smbsrv/libsmbns.h>
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
42 #include <smbsrv/cifs.h>
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
43 #include <smbsrv/mailslot.h>
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
44 #include <smbns_browser.h>
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
45 #include <smbns_netbios.h>
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
46
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
47 /*
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
48 * ntdomain_info
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
49 * Temporary. It should be removed once NBTD is integrated.
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
50 */
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
51 smb_ntdomain_t ntdomain_info;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
52 mutex_t ntdomain_mtx;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
53 cond_t ntdomain_cv;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
54
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
55 #define SMB_SERVER_SIGNATURE 0xaa550415
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
56
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
57 typedef struct smb_hostinfo {
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
58 list_node_t hi_lnd;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
59 smb_nic_t hi_nic;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
60 char hi_nbname[NETBIOS_NAME_SZ];
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
61 name_entry_t hi_netname;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
62 uint32_t hi_nextannouce;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
63 int hi_reps;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
64 int hi_interval;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
65 uint8_t hi_updatecnt;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
66 uint32_t hi_type;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
67 } smb_hostinfo_t;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
68
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
69 typedef struct smb_browserinfo {
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
70 list_t bi_hlist;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
71 int bi_hcnt;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
72 rwlock_t bi_hlist_rwl;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
73 boolean_t bi_changed;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
74 mutex_t bi_mtx;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
75 } smb_browserinfo_t;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
76
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
77 static smb_browserinfo_t smb_binfo;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
78
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
79 static int smb_browser_init(void);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
80 static void smb_browser_infoinit(void);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
81 static void smb_browser_infoterm(void);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
82 static void smb_browser_infofree(void);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
83
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
84
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
85 void
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
86 smb_browser_reconfig(void)
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
87 {
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
88 (void) mutex_lock(&smb_binfo.bi_mtx);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
89 smb_binfo.bi_changed = B_TRUE;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
90 (void) mutex_unlock(&smb_binfo.bi_mtx);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
91 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
92
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
93 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
94 * 3. Browser Overview
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
95 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
96 * Hosts involved in the browsing process can be separated into two
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
97 * distinct groups, browser clients and browser servers (often referred to
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
98 * simply as "browsers").
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
99 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
100 * A browser is a server which maintains information about servers -
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
101 * primarily the domain they are in and the services that they are running
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
102 * -- and about domains. Browsers may assume several different roles in
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
103 * their lifetimes, and dynamically switch between them.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
104 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
105 * Browser clients are of two types: workstations and (non-browser)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
106 * servers. In the context of browsing, workstations query browsers for the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
107 * information they contain; servers supply browsers the information by
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
108 * registering with them. Note that, at times, browsers may themselves
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
109 * behave as browser clients and query other browsers.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
110 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
111 * For the purposes of this specification, a domain is simply a name with
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
112 * which to associate a group of resources such as computers, servers and
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
113 * users. Domains allow a convenient means for browser clients to restrict
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
114 * the scope of a search when they query browser servers. Every domain has
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
115 * a "master" server called the Primary Domain Controller (PDC) that
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
116 * manages various activities within the domain.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
117 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
118 * One browser for each domain on a subnet is designated the Local Master
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
119 * Browser for that domain. Servers in its domain on the subnet register
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
120 * with it, as do the Local Master Browsers for other domains on the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
121 * subnet. It uses these registrations to maintain authoritative
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
122 * information about its domain on its subnet. If there are other subnets
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
123 * in the network, it also knows the name of the server running the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
124 * domain's Domain Master Browser; it registers with it, and uses it to
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
125 * obtain information about the rest of the network (see below).
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
126 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
127 * Clients on a subnet query browsers designated as the Backup Browsers for
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
128 * the subnet (not the Master Browser). Backup Browsers maintain a copy of
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
129 * the information on the Local Master Browser; they get it by periodically
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
130 * querying the Local Master Browser for all of its information. Clients
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
131 * find the Backup Browsers by asking the Local Master Browser. Clients are
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
132 * expected to spread their queries evenly across Backup Browsers to
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
133 * balance the load.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
134 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
135 * The Local Master Browser is dynamically elected automatically. Multiple
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
136 * Backup Browser Servers may exist per subnet; they are selected from
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
137 * among the potential browser servers by the Local Master Browser, which
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
138 * is configured to select enough to handle the expected query load.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
139 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
140 * When there are multiple subnets, a Domain Master Browser is assigned
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
141 * the task of keeping the multiple subnets in synchronization. The Primary
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
142 * Domain Controller (PDC) always acts as the Domain Master Browser. The
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
143 * Domain Master Browser periodically acts as a client and queries all the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
144 * Local Master Browsers for its domain, asking them for a list containing
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
145 * all the domains and all the servers in their domain known within their
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
146 * subnets; it merges all the replies into a single master list. This
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
147 * allows a Domain Master Browser server to act as a collection point for
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
148 * inter-subnet browsing information. Local Master Browsers periodically
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
149 * query the Domain Master Browser to retrieve the network-wide information
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
150 * it maintains.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
151 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
152 * When a domain spans only a single subnet, there will not be any distinct
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
153 * Local Master Browser; this role will be handled by the Domain Master
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
154 * Browser. Similarly, the Domain Master Browser is always the Local Master
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
155 * Browser for the subnet it is on.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
156 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
157 * When a browser client suspects that the Local Master Browser has failed,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
158 * the client will instigate an election in which the browser servers
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
159 * participate, and some browser servers may change roles.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
160 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
161 * Some characteristics of a good browsing mechanism include:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
162 * . minimal network traffic
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
163 * . minimum server discovery time
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
164 * . minimum change discovery latency
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
165 * . immunity to machine failures
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
166 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
167 * Historically, Browser implementations had been very closely tied to
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
168 * NETBIOS and datagrams. The early implementations caused a lot of
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
169 * broadcast traffic. See Appendix D for an overview that presents how the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
170 * Browser specification evolved.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
171 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
172 * 4. Browsing Protocol Architecture
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
173 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
174 * This section first describes the how the browsing protocol is layered,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
175 * then describes the roles of clients, servers, and browsers in the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
176 * browsing subsystem.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
177 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
178 * 4.1 Layering of Browsing Protocol Requests
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
179 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
180 * Most of the browser functionality is implemented using mailslots.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
181 * Mailslots provide a mechanism for fast, unreliable unidirectional data
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
182 * transfer; they are named via ASCII "mailslot (path) name". Mailslots are
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
183 * implemented using the CIFS Transact SMB which is encapsulated in a
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
184 * NETBIOS datagram. Browser protocol requests are sent to browser specific
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
185 * mailslots using some browser-specific NETBIOS names. These datagrams can
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
186 * either be unicast or broadcast, depending on whether the NETBIOS name is
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
187 * a "unique name" or a "group name". Various data structures, which are
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
188 * detailed subsequently within this document, flow as the data portion of
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
189 * the Transact SMB.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
190 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
191 * Here is an example of a generic browser SMB, showing how a browser
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
192 * request is encapsulated in a TRANSACT SMB request. Note that the PID,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
193 * TID, MID, UID, and Flags are all 0 in mailslot requests.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
194 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
195 * SMB: C transact, File = \MAILSLOT\BROWSE
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
196 * SMB: SMB Status = Error Success
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
197 * SMB: Error class = No Error
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
198 * SMB: Error code = No Error
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
199 * SMB: Header: PID = 0x0000 TID = 0x0000 MID = 0x0000 UID = 0x0000
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
200 * SMB: Tree ID (TID) = 0 (0x0)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
201 * SMB: Process ID (PID) = 0 (0x0)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
202 * SMB: User ID (UID) = 0 (0x0)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
203 * SMB: Multiplex ID (MID) = 0 (0x0)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
204 * SMB: Flags Summary = 0 (0x0)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
205 * SMB: Command = C transact
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
206 * SMB: Word count = 17
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
207 * SMB: Word parameters
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
208 * SMB: Total parm bytes = 0
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
209 * SMB: Total data bytes = 33
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
210 * SMB: Max parm bytes = 0
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
211 * SMB: Max data bytes = 0
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
212 * SMB: Max setup words = 0
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
213 * SMB: Transact Flags Summary = 0 (0x0)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
214 * SMB: ...............0 = Leave session intact
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
215 * SMB: ..............0. = Response required
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
216 * SMB: Transact timeout = 0 (0x0)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
217 * SMB: Parameter bytes = 0 (0x0)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
218 * SMB: Parameter offset = 0 (0x0)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
219 * SMB: Data bytes = 33 (0x21)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
220 * SMB: Data offset = 86 (0x56)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
221 * SMB: Setup word count = 3
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
222 * SMB: Setup words
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
223 * SMB: Mailslot opcode = Write mailslot
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
224 * SMB: Transaction priority = 1
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
225 * SMB: Mailslot class = Unreliable (broadcast)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
226 * SMB: Byte count = 50
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
227 * SMB: Byte parameters
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
228 * SMB: Path name = \MAILSLOT\BROWSE
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
229 * SMB: Transaction data
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
230 * SMB: Data: Number of data bytes remaining = 33 (0x0021)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
231 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
232 * Note the SMB command is Transact, the opcode within the Transact SMB is
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
233 * Mailslot Write, and the browser data structure is carried as the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
234 * Transact data.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
235 * The Transaction data begins with an opcode, that signifies the operation
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
236 * and determines the size and structure of data that follows. This opcode
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
237 * is named as per one of the below:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
238 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
239 * HostAnnouncement 1
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
240 * AnnouncementRequest 2
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
241 * RequestElection 8
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
242 * GetBackupListReq 9
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
243 * GetBackupListResp 10
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
244 * BecomeBackup 11
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
245 * DomainAnnouncment 12
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
246 * MasterAnnouncement 13
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
247 * LocalMasterAnnouncement 15
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
248 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
249 * Browser datagrams are often referred to as simply browser frames. The
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
250 * frames are in particular, referred to by the name of the opcode within
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
251 * the Transaction data e.g. a GetBackupListReq browser frame, a
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
252 * RequestElection browser frame, etc.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
253 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
254 * The structures that are sent as the data portion of the Transact SMB are
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
255 * described in section(s) 6.2 through 6.12 in this document. These
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
256 * structures are tightly packed, i.e. there are no intervening pad bytes
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
257 * in the structure, unless they are explicitly described as being there.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
258 * All quantities are sent in native Intel format and multi-byte values are
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
259 * transmitted least significant byte first.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
260 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
261 * Besides mailslots and Transaction SMBs, the other important piece of the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
262 * browser architecture is the NetServerEnum2 request. This request that
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
263 * allows an application to interrogate a Browser Server and obtain a
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
264 * complete list of resources (servers, domains, etc) known to that Browser
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
265 * server. Details of the NetServerEnum2 request are presented in section
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
266 * 6.4. Some examples of the NetServerEnum2 request being used are when a
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
267 * Local Master Browser sends a NetServerEnum2 request to the Domain Master
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
268 * Browser and vice versa. Another example is when a browser client sends a
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
269 * NetServerEnum2 request to a Backup Browser server.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
270 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
271 * 4.3 Non-Browser Server
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
272 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
273 * A non-browser server is a server that has some resource(s) or service(s)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
274 * it wishes to advertise as being available using the browsing protocol.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
275 * Examples of non-browser servers would be an SQL server, print server,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
276 * etc.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
277 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
278 * A non-browser server MUST periodically send a HostAnnouncement browser
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
279 * frame, specifying the type of resources or services it is advertising.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
280 * Details are in section 6.5.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
281 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
282 * A non-browser server SHOULD announce itself relatively frequently when
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
283 * it first starts up in order to make its presence quickly known to the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
284 * browsers and thence to potential clients. The frequency of the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
285 * announcements SHOULD then be gradually stretched, so as to minimize
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
286 * network traffic. Typically, non-browser servers announce themselves
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
287 * once every minute upon start up and then gradually adjust the frequency
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
288 * of the announcements to once every 12 minutes.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
289 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
290 * A non-browser server SHOULD send a HostAnnouncement browser frame
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
291 * specifying a type of 0 just prior to shutting down, to allow it to
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
292 * quickly be removed from the list of available servers.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
293 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
294 * A non-browser server MUST receive and process AnnouncementRequest frames
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
295 * from the Local Master Browser, and MUST respond with a HostAnnouncement
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
296 * frame, after a delay chosen randomly from the interval [0,30] seconds.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
297 * AnnouncementRequests typically happen when a Local Master Browser starts
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
298 * up with an empty list of servers for the domain, and wants to fill it
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
299 * quickly. The 30 second range for responses prevents the Master Browser
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
300 * from becoming overloaded and losing replies, as well as preventing the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
301 * network from being flooded with responses.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
302 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
303 * 4.4 Browser Servers
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
304 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
305 * The following sections describe the roles of the various types of
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
306 * browser servers.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
307 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
308 * 4.4.1 Potential Browser Server
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
309 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
310 * A Potential Browser server is a browser server that is capable of being
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
311 * a Backup Browser server or Master Browser server, but is not currently
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
312 * fulfilling either of those roles.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
313 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
314 * A Potential Browser MUST set type SV_TYPE_POTENTIAL_BROWSER (see section
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
315 * 6.4.1) in its HostAnnouncement until it is ready to shut down. In its
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
316 * last HostAnnouncement frame before it shuts down, it SHOULD specify a
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
317 * type of 0.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
318 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
319 * A Potential Browser server MUST receive and process BecomeBackup frames
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
320 * (see section 6.9) and become a backup browser upon their receipt.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
321 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
322 * A Potential Browser MUST participate in browser elections (see section
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
323 * 6.8).
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
324 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
325 * 4.4.2 Backup Browser
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
326 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
327 * Backup Browser servers are a subset of the Potential Browsers that have
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
328 * been chosen by the Master Browser on their subnet to be the Backup
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
329 * Browsers for the subnet.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
330 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
331 * A Backup Browser MUST set type SV_TYPE_BACKUP_BROWSER (see section
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
332 * 6.4.1) in its HostAnnouncement until it is ready to shut down. In its
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
333 * last HostAnnouncement frame before it shuts down, it SHOULD specify a
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
334 * type of 0.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
335 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
336 * A Backup Browser MUST listen for a LocalMasterAnnouncement frame (see
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
337 * section 6.10) from the Local Master Browser, and use it to set the name
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
338 * of the Master Browser it queries for the server and domain lists.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
339 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
340 * A Backup Browsers MUST periodically make a NetServerEnum2 request of
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
341 * the Master Browser on its subnet for its domain to get a list of servers
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
342 * in that domain, as well as a list of domains. The period is a
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
343 * configuration option balancing currency of the information with network
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
344 * traffic costs - a typical value is 15 minutes.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
345 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
346 * A Backup Browser SHOULD force an election by sending a RequestElection
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
347 * frame (see section 6.7) if it does not get a response to its periodic
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
348 * NetServeEnum2 request to the Master Browser.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
349 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
350 * A Backup Browser MUST receive and process NetServerEnum2 requests from
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
351 * browser clients, for its own domain and others. If the request is for a
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
352 * list of servers in its domain, or for a list of domains, it can answer
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
353 * from its internal lists. If the request is for a list of servers in a
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
354 * domain different than the one it serves, it sends a NetServerEnum2
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
355 * request to the Domain Master Browser for that domain (which it can in
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
356 * find in its list of domains and their Domain Master Browsers).
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
357 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
358 * A Backup Browser MUST participate in browser elections (see section
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
359 * 6.8).
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
360 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
361 * 4.4.3 Master Browser
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
362 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
363 * Master Browsers are responsible for:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
364 * . indicating it is a Master Browser
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
365 * . receiving server announcements and building a list of such servers
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
366 * and keeping it reasonably up-to-date.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
367 * . returning lists of Backup Browsers to browser clients.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
368 * . ensuring an appropriate number of Backup Browsers are available.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
369 * . announcing their existence to other Master Browsers on their subnet,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
370 * to the Domain Master Browser for their domain, and to all browsers in
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
371 * their domain on their subnet
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
372 * . forwarding requests for lists of servers on other domains to the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
373 * Master Browser for that domain
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
374 * . keeping a list of domains in its subnet
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
375 * . synchronizing with the Domain Master Browser (if any) for its domain
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
376 * . participating in browser elections
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
377 * . ensuring that there is only one Master Browser on its subnet
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
378 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
379 * A Master Browser MUST set type SV_TYPE_MASTER_BROWSER (see section
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
380 * 6.4.1) in its HostAnnouncement until it is ready to shut down. In its
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
381 * last HostAnnouncement frame before it shuts down, it SHOULD specify a
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
382 * type of 0.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
383 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
384 * A Master Browser MUST receive and process HostAnnouncement frames from
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
385 * servers, adding the server name and other information to its servers
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
386 * list; it must mark them as "local" entries. Periodically, it MUST check
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
387 * all local server entries to see if a server's HostAnnouncement has timed
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
388 * out (no HostAnnouncement received for three times the periodicity the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
389 * server gave in the last received HostAnnouncement) and remove timed-out
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
390 * servers from its list.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
391 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
392 * A Master Browser MUST receive and process DomainAnnouncement frames (see
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
393 * section 6.12) and maintain the domain names and their associated (Local)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
394 * Master Browsers in its internal domain list until they time out; it must
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
395 * mark these as "local" entries. Periodically, it MUST check all local
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
396 * domain entries to see if a server's DomainAnnouncement has timed out (no
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
397 * DomainAnnouncement received for three times the periodicity the server
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
398 * gave in the last received DomainAnnouncement) and remove timed-out
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
399 * servers from its list.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
400 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
401 * A Master Browser MUST receive and process GetBackupListRequest frames
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
402 * from clients, returning GetBackupListResponse frames containing a list
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
403 * of the Backup Servers for its domain.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
404 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
405 * A Master Browser MUST eventually send BecomeBackup frames (see section
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
406 * 6.9) to one or more Potential Browser servers to increase the number of
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
407 * Backup Browsers if there are not enough Backup Browsers to handle the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
408 * anticipated query load. Note: possible good times for checking for
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
409 * sufficient backup browsers are after being elected, when timing out
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
410 * server HostAnnouncements, and when receiving a server's HostAnnouncement
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
411 * for the first time.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
412 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
413 * A Master Browser MUST periodically announce itself and the domain it
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
414 * serves to other (Local) Master Browsers on its subnet, by sending a
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
415 * DomainAnnouncement frame (see section 6.12) to its subnet.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
416 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
417 * A Master Browser MUST send a MasterAnnouncement frame (see section 6.11)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
418 * to the Domain Master Browser after it is first elected, and periodically
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
419 * thereafter. This informs the Domain Master Browser of the presence of
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
420 * all the Master Browsers.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
421 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
422 * A Master Browser MUST periodically announce itself to all browsers for
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
423 * its domain on its subnet by sending a LocalMasterAnnouncement frame (see
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
424 * section 6.10).
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
425 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
426 * A Master Browser MUST receive and process NetServerEnum2 requests from
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
427 * browser clients, for its own domain and others. If the request is for a
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
428 * list of servers in its domain, or for a list of domains, it can answer
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
429 * from its internal lists. Entries in its list marked "local" MUST have
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
430 * the SV_TYPE_LOCAL_LIST_ONLY bit set in the returned results; it must be
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
431 * clear for all other entries. If the request is for a list of servers in
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
432 * a domain different than the one it serves, it sends a NetServerEnum2
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
433 * request to the Domain Master Browser for that domain (which it can in
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
434 * find in its list of domains and their Domain Master Browsers).
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
435 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
436 * Note: The list of servers that the Master Browser maintains and
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
437 * returns to the Backup Browsers, is limited in size to 64K of
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
438 * data. This will limit the number of systems that can be in a
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
439 * browse list in a single workgroup or domain to approximately two
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
440 * thousand systems.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
441 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
442 * A Master Browser SHOULD request all servers to register with it by
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
443 * sending an AnnouncementRequest frame, if, on becoming the Master Browser
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
444 * by winning an election, its server list is empty. Otherwise, clients
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
445 * might get an incomplete list of servers until the servers' periodic
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
446 * registrations fill the server list.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
447 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
448 * If the Master Browser on a subnet is not the Primary Domain Controller
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
449 * (PDC), then it is a Local Master Browser.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
450 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
451 * A Local Master Browser MUST periodically synchronize with the Domain
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
452 * Master Browser (which is the PDC). This synchronization is performed by
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
453 * making a NetServerEnum2 request to the Domain Master Browser and merging
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
454 * the results with its list of servers and domains. An entry from the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
455 * Domain Master Browser should be marked "non-local", and must not
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
456 * overwrite an entry with the same name marked "local". The Domain Master
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
457 * Browser is located as specified in Appendix B.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
458 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
459 * A Master Browser MUST participate in browser elections (see section
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
460 * 6.8).
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
461 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
462 * A Master Browser MUST, if it receives a HostAnnouncement,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
463 * DomainAnnouncement, or LocalMasterAnnouncement frame another system that
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
464 * claims to be the Master Browser for its domain, demote itself from
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
465 * Master Browser and force an election. This ensures that there is only
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
466 * ever one Master Browser in each workgroup or domain.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
467 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
468 * A Master Browser SHOULD, if it loses an election, become a Backup
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
469 * Browser (without being told to do so by the new Master Browser). Since
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
470 * it has more up-to-date information in its lists than a Potential
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
471 * Browser, it is more efficient to have it be a Backup Browser than to
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
472 * promote a Potential Browser.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
473 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
474 * 4.4.3.1 Preferred Master Browser
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
475 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
476 * A Preferred Master Browser supports exactly the same protocol elements
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
477 * as a Potential Browser, except as follows.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
478 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
479 * A Preferred Master Browser MUST always force an election when it starts
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
480 * up.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
481 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
482 * A Preferred Master Browser MUST participate in browser elections (see
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
483 * section 6.8).
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
484 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
485 * A Preferred Master Browser MUST set the Preferred Master bit in the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
486 * RequestElection frame (see section 6.7) to bias the election in its
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
487 * favor.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
488 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
489 * A Preferred Master Browser SHOULD, if it loses an election,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
490 * automatically become a Backup Browser, without being told to do so by
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
491 * the Master Browser.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
492 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
493 * 4.4.4 Domain Master Browser
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
494 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
495 * Since the Domain Master Browser always runs on the PDC, it must
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
496 * implement all the protocols required of a PDC in addition to the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
497 * browsing protocol, and that is way beyond the scope of this
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
498 * specification.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
499 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
500 * 5. Mailslot Protocol Specification
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
501 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
502 * The only transaction allowed to a mailslot is a mailslot write. Mailslot
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
503 * writes requests are encapsulated in TRANSACT SMBs. The following table
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
504 * shows the interpretation of the TRANSACT SMB parameters for a mailslot
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
505 * transaction:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
506 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
507 * Name Value Description
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
508 * Command SMB_COM_TRANSACTION
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
509 * Name <name> STRING name of mail slot to write;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
510 * must start with "\\MAILSLOT\\"
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
511 * SetupCount 3 Always 3 for mailslot writes
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
512 * Setup[0] 1 Command code == write mailslot
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
513 * Setup[1] Ignored
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
514 * Setup[2] Ignored
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
515 * TotalDataCount n Size of data in bytes to write to
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
516 * the mailslot
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
517 * Data[ n ] The data to write to the mailslot
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
518 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
519 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
520
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
521 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
522 * SMB: C transact, File = \MAILSLOT\BROWSE
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
523 * SMB: SMB Status = Error Success
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
524 * SMB: Error class = No Error
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
525 * SMB: Error code = No Error
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
526 * SMB: Header: PID = 0x0000 TID = 0x0000 MID = 0x0000 UID = 0x0000
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
527 * SMB: Tree ID (TID) = 0 (0x0)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
528 * SMB: Process ID (PID) = 0 (0x0)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
529 * SMB: User ID (UID) = 0 (0x0)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
530 * SMB: Multiplex ID (MID) = 0 (0x0)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
531 * SMB: Flags Summary = 0 (0x0)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
532 * SMB: Command = C transact
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
533 * SMB: Word count = 17
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
534 * SMB: Word parameters
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
535 * SMB: Total parm bytes = 0
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
536 * SMB: Total data bytes = 33
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
537 * SMB: Max parm bytes = 0
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
538 * SMB: Max data bytes = 0
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
539 * SMB: Max setup words = 0
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
540 * SMB: Transact Flags Summary = 0 (0x0)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
541 * SMB: ...............0 = Leave session intact
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
542 * SMB: ..............0. = Response required
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
543 * SMB: Transact timeout = 0 (0x0)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
544 * SMB: Parameter bytes = 0 (0x0)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
545 * SMB: Parameter offset = 0 (0x0)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
546 * SMB: Data bytes = 33 (0x21)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
547 * SMB: Data offset = 86 (0x56)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
548 * SMB: Setup word count = 3
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
549 * SMB: Setup words
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
550 * SMB: Mailslot opcode = Write mailslot
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
551 * SMB: Transaction priority = 1
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
552 * SMB: Mailslot class = Unreliable (broadcast)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
553 * SMB: Byte count = 50
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
554 * SMB: Byte parameters
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
555 * SMB: Path name = \MAILSLOT\BROWSE
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
556 * SMB: Transaction data
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
557 * SMB: Data: Number of data bytes remaining = 33 (0x0021)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
558 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
559 * 5. Mailslot Protocol Specification
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
560 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
561 * The only transaction allowed to a mailslot is a mailslot write. Mailslot
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
562 * writes requests are encapsulated in TRANSACT SMBs. The following table
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
563 * shows the interpretation of the TRANSACT SMB parameters for a mailslot
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
564 * transaction:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
565 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
566 * Name Value Description
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
567 * Command SMB_COM_TRANSACTION
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
568 * Name <name> STRING name of mail slot to write;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
569 * must start with "\MAILSLOT\"
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
570 * SetupCount 3 Always 3 for mailslot writes
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
571 * Setup[0] 1 Command code == write mailslot
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
572 * Setup[1] Ignored
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
573 * Setup[2] Ignored
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
574 * TotalDataCount n Size of data in bytes to write to
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
575 * the mailslot
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
576 * Data[ n ] The data to write to the mailslot
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
577 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
578 * Magic 0xFF 'S' 'M' 'B'
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
579 * smb_com a byte, the "first" command
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
580 * Error a 4-byte union, ignored in a request
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
581 * smb_flg a one byte set of eight flags
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
582 * smb_flg2 a two byte set of 16 flags
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
583 * . twelve reserved bytes, have a role
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
584 * in connectionless transports (IPX, UDP?)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
585 * smb_tid a 16-bit tree ID, a mount point sorta,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
586 * 0xFFFF is this command does not have
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
587 * or require a tree context
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
588 * smb_pid a 16-bit process ID
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
589 * smb_uid a 16-bit user ID, specific to this "session"
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
590 * and mapped to a system (bona-fide) UID
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
591 * smb_mid a 16-bit multiplex ID, used to differentiate
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
592 * multiple simultaneous requests from the same
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
593 * process (pid) (ref RPC "xid")
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
594 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
595
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
596 int
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
597 smb_browser_load_transact_header(unsigned char *buffer, int maxcnt,
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
598 int data_count, int reply, char *mailbox)
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
599 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
600 smb_msgbuf_t mb;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
601 int mailboxlen;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
602 char *fmt;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
603 int result;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
604 short class = (reply == ONE_WAY_TRANSACTION) ? 2 : 0;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
605
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
606 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
607 * If the mailboxlen is an even number we need to pad the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
608 * header so that the data starts on a word boundary.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
609 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
610 fmt = "Mb4.bw20.bwwwwb.wl2.wwwwb.wwwws";
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
611 mailboxlen = strlen(mailbox) + 1;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
612
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
613 if ((mailboxlen & 0x01) == 0) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
614 ++mailboxlen;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
615 fmt = "Mb4.bw20.bwwwwb.wl2.wwwwb.wwwws.";
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
616 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
617
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
618 bzero(buffer, maxcnt);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
619 smb_msgbuf_init(&mb, buffer, maxcnt, 0);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
620
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
621 result = smb_msgbuf_encode(&mb, fmt,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
622 SMB_COM_TRANSACTION, /* Command */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
623 0x18,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
624 0x3,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
625 17, /* Count of parameter words */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
626 0, /* Total Parameter words sent */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
627 data_count, /* Total Data bytes sent */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
628 2, /* Max Parameters to return */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
629 0, /* Max data bytes to return */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
630 0, /* Max setup bytes to return */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
631 reply, /* No reply */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
632 0xffffffff, /* Timeout */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
633 0, /* Parameter bytes sent */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
634 0, /* Parameter offset */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
635 data_count, /* Data bytes sent */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
636 69 + mailboxlen, /* Data offset */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
637 3, /* Setup word count */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
638 1, /* Setup word[0] */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
639 0, /* Setup word[1] */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
640 class, /* Setup word[2] */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
641 mailboxlen + data_count, /* Total request bytes */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
642 mailbox); /* Mailbox address */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
643
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
644 smb_msgbuf_term(&mb);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
645 return (result);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
646 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
647
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
648 static int
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
649 smb_browser_addr_of_subnet(struct name_entry *name, smb_hostinfo_t *hinfo,
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
650 struct name_entry *result)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
651 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
652 uint32_t ipaddr, mask, saddr;
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
653 addr_entry_t *addr;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
654
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
655 if (name == NULL)
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
656 return (-1);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
657
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
658 if (hinfo->hi_nic.nic_smbflags & SMB_NICF_ALIAS)
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
659 return (-1);
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
660
8670
6da349c3f817 6792084 smb_node_lookup should not take ownership of the hold on vnode passed as a parameter
jose borrego <Jose.Borrego@Sun.COM>
parents: 8334
diff changeset
661 ipaddr = hinfo->hi_nic.nic_ip.a_ipv4;
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
662 mask = hinfo->hi_nic.nic_mask;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
663
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
664 *result = *name;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
665 addr = &name->addr_list;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
666 do {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
667 saddr = addr->sin.sin_addr.s_addr;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
668 if ((saddr & mask) == (ipaddr & mask)) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
669 *result = *name;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
670 result->addr_list = *addr;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
671 result->addr_list.forw = result->addr_list.back =
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
672 &result->addr_list;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
673 return (0);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
674 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
675 addr = addr->forw;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
676 } while (addr != &name->addr_list);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
677
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
678 return (-1);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
679 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
680
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
681
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
682 static int
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
683 smb_browser_bcast_addr_of_subnet(struct name_entry *name, uint32_t bcast,
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
684 struct name_entry *result)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
685 {
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
686 if (name != NULL && name != result)
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
687 *result = *name;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
688
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
689 result->addr_list.sin.sin_family = AF_INET;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
690 result->addr_list.sinlen = sizeof (result->addr_list.sin);
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
691 result->addr_list.sin.sin_addr.s_addr = bcast;
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
692 result->addr_list.sin.sin_port = htons(IPPORT_NETBIOS_DGM);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
693 result->addr_list.forw = result->addr_list.back = &result->addr_list;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
694 return (0);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
695 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
696
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
697 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
698 * 6.5 HostAnnouncement Browser Frame
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
699 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
700 * To advertise its presence, i.e. to publish itself as being available, a
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
701 * non-browser server sends a HostAnnouncement browser frame. If the server
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
702 * is a member of domain "D", this frame is sent to the NETBIOS unique name
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
703 * D(1d) and mailslot "\\MAILSLOT\\BROWSE". The definition of the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
704 * HostAnnouncement frame is:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
705 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
706 * struct {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
707 * unsigned short Opcode;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
708 * unsigned char UpdateCount;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
709 * uint32_t Periodicity;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
710 * unsigned char ServerName[];
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
711 * unsigned char VersionMajor;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
712 * unsigned char VersionMinor;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
713 * uint32_t Type;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
714 * uint32_t Signature;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
715 * unsigned char Comment[];
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
716 * }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
717 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
718 * where:
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
719 * Opcode - Identifies this structure as a browser server
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
720 * announcement and is defined as HostAnnouncement with a
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
721 * value of decimal 1.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
722 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
723 * UpdateCount - must be sent as zero and ignored on receipt.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
724 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
725 * Periodicity - The announcement frequency of the server (in
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
726 * seconds). The server will be removed from the browse list
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
727 * if it has not been heard from in 3X its announcement
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
728 * frequency. In no case will the server be removed from the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
729 * browse list before the period 3X has elapsed. Actual
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
730 * implementations may take more than 3X to actually remove
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
731 * the server from the browse list.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
732 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
733 * ServerName - Null terminated ASCII server name (up to 16 bytes
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
734 * in length).
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
735 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
736 * VersionMajor - The major version number of the OS the server
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
737 * is running. it will be returned by NetServerEnum2.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
738 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
739 * VersionMinor - The minor version number of the OS the server
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
740 * is running. This is entirely informational and does not
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
741 * have any significance for the browsing protocol.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
742 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
743 * Type - Specifies the type of the server. The server type bits
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
744 * are specified in the NetServerEnum2 section.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
745 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
746 * Signature - The browser protocol minor version number in the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
747 * low 8 bits, the browser protocol major version number in
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
748 * the next higher 8 bits and the signature 0xaa55 in the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
749 * high 16 bits of this field. Thus, for this version of the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
750 * browser protocol (1.15) this field has the value
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
751 * 0xaa55010f. This may used to isolate browser servers that
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
752 * are running out of revision browser software; otherwise,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
753 * it is ignored.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
754 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
755 * Comment - Null terminated ASCII comment for the server.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
756 * Limited to 43 bytes.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
757 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
758 * When a non-browser server starts up, it announces itself in the manner
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
759 * described once every minute. The frequency of these statements is
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
760 * gradually stretched to once every 12 minutes.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
761 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
762 * Note: older non-browser servers in a domain "D" sent HostAnnouncement
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
763 * frames to the NETBIOS group name D(00). Non-Browser servers supporting
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
764 * version 1.15 of the browsing protocol SHOULD NOT use this NETBIOS name,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
765 * but for backwards compatibility Master Browsers MAY receive and process
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
766 * HostAnnouncement frames on this name as described above for D(1d).
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
767 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
768
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
769 static void
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
770 smb_browser_send_HostAnnouncement(smb_hostinfo_t *hinfo,
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
771 uint32_t next_announcement, boolean_t remove,
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
772 addr_entry_t *addr, char suffix)
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
773 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
774 smb_msgbuf_t mb;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
775 int offset, announce_len, data_length;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
776 struct name_entry dest_name;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
777 unsigned char *buffer;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
778 uint32_t type;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
779 char resource_domain[SMB_PI_MAX_DOMAIN];
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
780
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5331
diff changeset
781 if (smb_getdomainname(resource_domain, SMB_PI_MAX_DOMAIN) != 0)
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5331
diff changeset
782 return;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
783 (void) utf8_strupr(resource_domain);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
784
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
785 if (addr == NULL) {
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
786 /* Local master Browser */
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
787 smb_init_name_struct((unsigned char *)resource_domain, suffix,
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
788 0, 0, 0, 0, 0, &dest_name);
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
789 if (smb_browser_bcast_addr_of_subnet(0, hinfo->hi_nic.nic_bcast,
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
790 &dest_name) < 0)
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
791 return;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
792 } else {
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
793 smb_init_name_struct((unsigned char *)resource_domain, suffix,
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
794 0, 0, 0, 0, 0, &dest_name);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
795 dest_name.addr_list = *addr;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
796 dest_name.addr_list.forw = dest_name.addr_list.back =
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
797 &dest_name.addr_list;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
798 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
799
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
800 /* give some extra room */
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
801 buffer = malloc(MAX_DATAGRAM_LENGTH * 2);
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
802 if (buffer == NULL) {
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
803 syslog(LOG_DEBUG, "smb browser: HostAnnouncement: %m");
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
804 return;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
805 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
806
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
807 data_length = 1 + 1 + 4 + 16 + 1 + 1 + 4 + 4 +
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
808 strlen(hinfo->hi_nic.nic_cmnt) + 1;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
809
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
810 offset = smb_browser_load_transact_header(buffer,
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
811 MAX_DATAGRAM_LENGTH, data_length, ONE_WAY_TRANSACTION,
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
812 MAILSLOT_BROWSE);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
813
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
814 if (offset < 0) {
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
815 free(buffer);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
816 return;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
817 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
818
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
819 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
820 * A non-browser server SHOULD send a HostAnnouncement browser frame
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
821 * specifying a type of 0 just prior to shutting down, to allow it to
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
822 * quickly be removed from the list of available servers.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
823 */
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
824 if (remove || (!smb_netbios_running()))
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
825 type = 0;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
826 else
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
827 type = hinfo->hi_type;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
828
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
829 smb_msgbuf_init(&mb, buffer + offset, MAX_DATAGRAM_LENGTH - offset, 0);
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
830
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
831 announce_len = smb_msgbuf_encode(&mb, "bbl16cbblls",
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
832 HOST_ANNOUNCEMENT,
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
833 ++hinfo->hi_updatecnt,
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
834 next_announcement * 60000, /* Periodicity in MilliSeconds */
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
835 hinfo->hi_nbname,
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
836 SMB_VERSION_MAJOR,
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
837 SMB_VERSION_MINOR,
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
838 type,
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
839 SMB_SERVER_SIGNATURE,
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
840 hinfo->hi_nic.nic_cmnt);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
841
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
842 if (announce_len > 0)
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
843 (void) smb_netbios_datagram_send(&hinfo->hi_netname, &dest_name,
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
844 buffer, offset + announce_len);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
845
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
846 free(buffer);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
847 smb_msgbuf_term(&mb);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
848 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
849
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
850 static void
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
851 smb_browser_process_AnnouncementRequest(struct datagram *datagram,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
852 char *mailbox)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
853 {
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
854 smb_hostinfo_t *hinfo;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
855 uint32_t next_announcement;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
856 uint32_t delay = random() % 29; /* in seconds */
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
857 boolean_t h_found = B_FALSE;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
858
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
859 if (strcmp(mailbox, MAILSLOT_LANMAN) != 0) {
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
860 syslog(LOG_DEBUG, "smb browser: wrong mailbox (%s)", mailbox);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
861 return;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
862 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
863
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
864 smb_netbios_sleep(delay);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
865
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
866 (void) rw_rdlock(&smb_binfo.bi_hlist_rwl);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
867 hinfo = list_head(&smb_binfo.bi_hlist);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
868 while (hinfo) {
8670
6da349c3f817 6792084 smb_node_lookup should not take ownership of the hold on vnode passed as a parameter
jose borrego <Jose.Borrego@Sun.COM>
parents: 8334
diff changeset
869 if ((hinfo->hi_nic.nic_ip.a_ipv4 &
6da349c3f817 6792084 smb_node_lookup should not take ownership of the hold on vnode passed as a parameter
jose borrego <Jose.Borrego@Sun.COM>
parents: 8334
diff changeset
870 hinfo->hi_nic.nic_mask) ==
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
871 (datagram->src.addr_list.sin.sin_addr.s_addr &
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
872 hinfo->hi_nic.nic_mask)) {
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
873 h_found = B_TRUE;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
874 break;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
875 }
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
876 hinfo = list_next(&smb_binfo.bi_hlist, hinfo);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
877 }
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
878
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
879 if (h_found) {
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
880 next_announcement = hinfo->hi_nextannouce * 60 * 1000;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
881 smb_browser_send_HostAnnouncement(hinfo, next_announcement,
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
882 B_FALSE, &datagram->src.addr_list, NBT_MB);
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
883 }
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
884 (void) rw_unlock(&smb_binfo.bi_hlist_rwl);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
885 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
886
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
887 void *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
888 smb_browser_dispatch(void *arg)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
889 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
890 struct datagram *datagram = (struct datagram *)arg;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
891 smb_msgbuf_t mb;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
892 int rc;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
893 unsigned char command;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
894 unsigned char parameter_words;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
895 unsigned short total_parameter_words;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
896 unsigned short total_data_count;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
897 unsigned short max_parameters_to_return;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
898 unsigned short max_data_to_return;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
899 unsigned char max_setup_bytes_to_return;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
900 unsigned short reply;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
901 unsigned short parameter_bytes_sent;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
902 unsigned short parameter_offset;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
903 unsigned short data_bytes_sent;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
904 unsigned short data_offset;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
905 unsigned char setup_word_count;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
906 unsigned short setup_word_0;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
907 unsigned short setup_word_1;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
908 unsigned short setup_word_2;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
909 unsigned short total_request_bytes;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
910 char *mailbox;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
911 unsigned char message_type;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
912 unsigned char *data;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
913 int datalen;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
914
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
915 syslog(LOG_DEBUG, "smb browser: packet received");
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
916
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
917 smb_msgbuf_init(&mb, datagram->data, datagram->data_length, 0);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
918 rc = smb_msgbuf_decode(&mb, "Mb27.bwwwwb.w6.wwwwb.wwwws",
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
919 &command, /* Command */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
920 &parameter_words, /* Count of parameter words */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
921 &total_parameter_words, /* Total Parameter words sent */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
922 &total_data_count, /* Total Data bytes sent */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
923 &max_parameters_to_return, /* Max Parameters to return */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
924 &max_data_to_return, /* Max data bytes to return */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
925 &max_setup_bytes_to_return, /* Max setup bytes to return */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
926 &reply, /* No reply */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
927 &parameter_bytes_sent, /* Parameter bytes sent */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
928 &parameter_offset, /* Parameter offset */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
929 &data_bytes_sent, /* Data bytes sent */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
930 &data_offset, /* Data offset */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
931 &setup_word_count, /* Setup word count */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
932 &setup_word_0, /* Setup word[0] */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
933 &setup_word_1, /* Setup word[1] */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
934 &setup_word_2, /* Setup word[2] */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
935 &total_request_bytes, /* Total request bytes */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
936 &mailbox); /* Mailbox address */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
937
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
938 if (rc < 0) {
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
939 syslog(LOG_ERR, "smb browser: decode error");
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
940 smb_msgbuf_term(&mb);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
941 free(datagram);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
942 return (0);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
943 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
944
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
945 data = &datagram->data[data_offset];
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
946 datalen = datagram->data_length - data_offset;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
947
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
948 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
949 * The PDC location protocol, i.e. anything on the \\NET
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
950 * mailslot, is handled by the smb_netlogon module.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
951 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
952 if (strncasecmp("\\MAILSLOT\\NET\\", mailbox, 14) == 0) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
953 smb_netlogon_receive(datagram, mailbox, data, datalen);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
954 smb_msgbuf_term(&mb);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
955 free(datagram);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
956 return (0);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
957 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
958
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
959 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
960 * If it's not a netlogon message, assume it's a browser request.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
961 * This is not the most elegant way to extract the command byte
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
962 * but at least we no longer use it to get the netlogon opcode.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
963 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
964 message_type = datagram->data[data_offset];
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
965
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
966 switch (message_type) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
967 case ANNOUNCEMENT_REQUEST :
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
968 smb_browser_process_AnnouncementRequest(datagram, mailbox);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
969 break;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
970
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
971 default:
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
972 syslog(LOG_DEBUG, "smb browser: invalid message type(%d, %x)",
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
973 message_type, message_type);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
974 break;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
975 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
976
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
977 smb_msgbuf_term(&mb);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
978 free(datagram);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
979 return (0);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
980 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
981
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
982
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
983 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
984 * 11.1 Registered unique names
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
985 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
986 * <COMPUTER>(00)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
987 * This name is used by all servers and clients to receive second
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
988 * class mailslot messages. A system must add this name in order to
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
989 * receive mailslot messages. The only browser requests that should
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
990 * appear on this name are BecomeBackup, GetBackupListResp,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
991 * MasterAnnouncement, and LocalMasterAnnouncement frames. All other
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
992 * datagrams (other than the expected non-browser datagrams) may be
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
993 * ignored and an error logged.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
994 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
995 * <DOMAIN>(1d)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
996 * This name is used to identify a master browser server for domain
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
997 * "DOMAIN" on a subnet. A master browser server adds this name as a
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
998 * unique NETBIOS name when it becomes master browser. If the attempt
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
999 * to add the name fails, the master browser server assumes that there
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1000 * is another master in the domain and will fail to come up. It may
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1001 * log an error if the failure occurs more than 3 times in a row (this
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1002 * either indicates some form of network misconfiguration or a
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1003 * software error). The only requests that should appear on this name
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1004 * are GetBackupListRequest and HostAnnouncement requests. All other
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1005 * datagrams on this name may be ignored (and an error logged). If
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1006 * running a NETBIOS name service (NBNS, such as WINS), this name
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1007 * should not be registered with the NBNS.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1008 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1009 * <DOMAIN>(1b)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1010 * This name is used to identify the Domain Master Browser for domain
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1011 * "DOMAIN" (which is also the primary domain controller). It is a
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1012 * unique name added only by the primary domain controller. The
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1013 * primary domain controller will respond to GetBackupListRequest on
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1014 * this name just as it responds to these requests on the <DOMAIN>(1d)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1015 * name.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1016 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1017 * 11.2 Registered group names
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1018 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1019 * (01)(02)__MSBROWSE__(02)(01)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1020 * This name is used by Master Browsers to announce themselves to the
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1021 * other Master Browsers on a subnet. It is added as a group name by
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1022 * all Master Browser servers. The only broadcasts that should appear
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1023 * on this name is DomainAnnouncement requests. All other datagrams
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1024 * can be ignored.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1025 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1026 * <DOMAIN>(00)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1027 * This name is used by clients and servers in domain "DOMAIN" to
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1028 * process server announcements. The only requests that should appear
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1029 * on this name that the browser is interested in are
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1030 * AnnouncementRequest and NETLOGON_QUERY (to locate the PDC) packets.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1031 * All other unidentifiable requests may be ignored (and an error
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1032 * logged).
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1033 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1034 * <DOMAIN>(1E)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1035 * This name is used for announcements to browsers for domain "DOMAIN"
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1036 * on a subnet. This name is registered by all the browser servers in
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1037 * the domain. The only requests that should appear on this name are
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1038 * RequestElection and AnnouncementRequest packets. All other
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1039 * datagrams may be ignored (and an error logged).
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1040 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1041 * <DOMAIN>(1C)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1042 * This name is registered by Primary Domain Controllers.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1043 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1044
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1045 static void
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1046 smb_browser_config(void)
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1047 {
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1048 smb_hostinfo_t *hinfo;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1049 struct name_entry name;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1050 struct name_entry master;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1051 struct name_entry dest;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1052 struct name_entry *entry;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1053 char resource_domain[SMB_PI_MAX_DOMAIN];
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1054 int rc;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1055
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1056 if (smb_browser_init() != 0)
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1057 return;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1058
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5331
diff changeset
1059 if (smb_getdomainname(resource_domain, SMB_PI_MAX_DOMAIN) != 0)
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5331
diff changeset
1060 return;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1061 (void) utf8_strupr(resource_domain);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1062
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1063 /* domain<00> */
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1064 smb_init_name_struct((unsigned char *)resource_domain, NBT_WKSTA,
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1065 0, 0, 0, 0, 0, &name);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1066 entry = smb_name_find_name(&name);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1067 smb_name_unlock_name(entry);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1068
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1069 (void) rw_rdlock(&smb_binfo.bi_hlist_rwl);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1070 hinfo = list_head(&smb_binfo.bi_hlist);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1071 while (hinfo) {
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1072 smb_init_name_struct((unsigned char *)resource_domain,
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1073 NBT_WKSTA, 0, hinfo->hi_nic.nic_ip.a_ipv4,
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1074 htons(IPPORT_NETBIOS_DGM), NAME_ATTR_GROUP,
8670
6da349c3f817 6792084 smb_node_lookup should not take ownership of the hold on vnode passed as a parameter
jose borrego <Jose.Borrego@Sun.COM>
parents: 8334
diff changeset
1075 NAME_ATTR_LOCAL, &name);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1076 (void) smb_name_add_name(&name);
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1077
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1078 hinfo = list_next(&smb_binfo.bi_hlist, hinfo);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1079 }
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1080 (void) rw_unlock(&smb_binfo.bi_hlist_rwl);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1081
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1082 /* All our local master browsers */
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1083 smb_init_name_struct((unsigned char *)resource_domain, NBT_MB,
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1084 0, 0, 0, 0, 0, &dest);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1085 entry = smb_name_find_name(&dest);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1086
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1087 if (entry) {
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1088 (void) rw_rdlock(&smb_binfo.bi_hlist_rwl);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1089 hinfo = list_head(&smb_binfo.bi_hlist);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1090 while (hinfo) {
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1091 rc = smb_browser_addr_of_subnet(entry, hinfo, &master);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1092 if (rc == 0) {
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1093 syslog(LOG_DEBUG,
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1094 "smb browser: master browser found at %s",
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1095 inet_ntoa(master.addr_list.sin.sin_addr));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1096 }
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1097 hinfo = list_next(&smb_binfo.bi_hlist, hinfo);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1098 }
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1099 (void) rw_unlock(&smb_binfo.bi_hlist_rwl);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1100
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1101 smb_name_unlock_name(entry);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1102 }
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1103
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1104 /* Domain master browser */
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1105 smb_init_name_struct((unsigned char *)resource_domain,
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1106 NBT_DMB, 0, 0, 0, 0, 0, &dest);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1107
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1108 if ((entry = smb_name_find_name(&dest)) != 0) {
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1109 syslog(LOG_DEBUG,
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1110 "smb browser: domain master browser for %s is %s",
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1111 resource_domain,
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1112 inet_ntoa(entry->addr_list.sin.sin_addr));
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1113 smb_name_unlock_name(entry);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1114 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1115 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1116
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1117 static int
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1118 smb_browser_init(void)
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1119 {
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1120 smb_hostinfo_t *hinfo;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1121 smb_niciter_t ni;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1122 uint32_t type;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1123
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1124 (void) rw_wrlock(&smb_binfo.bi_hlist_rwl);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1125 smb_browser_infofree();
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1126
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1127 if (smb_nic_getfirst(&ni) != 0) {
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1128 (void) rw_unlock(&smb_binfo.bi_hlist_rwl);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1129 return (-1);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1130 }
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1131
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1132 type = MY_SERVER_TYPE;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1133 if (smb_config_get_secmode() == SMB_SECMODE_DOMAIN)
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1134 type |= SV_DOMAIN_MEMBER;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1135
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1136 do {
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1137 if ((ni.ni_nic.nic_smbflags & SMB_NICF_NBEXCL) ||
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1138 (ni.ni_nic.nic_smbflags & SMB_NICF_ALIAS))
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1139 continue;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1140
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1141 hinfo = malloc(sizeof (smb_hostinfo_t));
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1142 if (hinfo == NULL) {
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1143 smb_browser_infofree();
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1144 (void) rw_unlock(&smb_binfo.bi_hlist_rwl);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1145 return (-1);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1146 }
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1147
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1148 hinfo->hi_nic = ni.ni_nic;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1149 /* One Minute announcements for first five */
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1150 hinfo->hi_nextannouce = 1;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1151 hinfo->hi_interval = 1;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1152 hinfo->hi_reps = 5;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1153 hinfo->hi_updatecnt = 0;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1154 hinfo->hi_type = type;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1155
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1156 /* This is the name used for HostAnnouncement */
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1157 (void) strlcpy(hinfo->hi_nbname, hinfo->hi_nic.nic_host,
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1158 NETBIOS_NAME_SZ);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1159 (void) utf8_strupr(hinfo->hi_nbname);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1160 /* 0x20: file server service */
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1161 smb_init_name_struct((unsigned char *)hinfo->hi_nbname,
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1162 NBT_SERVER, 0, hinfo->hi_nic.nic_ip.a_ipv4,
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1163 htons(IPPORT_NETBIOS_DGM),
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1164 NAME_ATTR_UNIQUE, NAME_ATTR_LOCAL,
8670
6da349c3f817 6792084 smb_node_lookup should not take ownership of the hold on vnode passed as a parameter
jose borrego <Jose.Borrego@Sun.COM>
parents: 8334
diff changeset
1165 &hinfo->hi_netname);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1166
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1167 list_insert_tail(&smb_binfo.bi_hlist, hinfo);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1168 smb_binfo.bi_hcnt++;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1169 } while (smb_nic_getnext(&ni) == 0);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1170
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1171 (void) rw_unlock(&smb_binfo.bi_hlist_rwl);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1172 return (0);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1173 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1174
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1175 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1176 * smb_browser_non_master_duties
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1177 *
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1178 * To advertise its presence, i.e. to publish itself as being available, a
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1179 * non-browser server sends a HostAnnouncement browser frame. If the server
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1180 * is a member of domain "D", this frame is sent to the NETBIOS unique name
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1181 * D(1d) and mailslot "\\MAILSLOT\\BROWSE".
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1182 */
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1183 static void
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1184 smb_browser_non_master_duties(smb_hostinfo_t *hinfo, boolean_t remove)
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1185 {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1186 struct name_entry name;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1187 struct name_entry *dest;
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1188 addr_entry_t addr;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1189 char resource_domain[SMB_PI_MAX_DOMAIN];
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1190
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1191 smb_browser_send_HostAnnouncement(hinfo, hinfo->hi_interval,
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1192 remove, 0, NBT_MB);
5772
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5331
diff changeset
1193 if (smb_getdomainname(resource_domain, SMB_PI_MAX_DOMAIN) != 0)
237ac22142fe 6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents: 5331
diff changeset
1194 return;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1195
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1196 (void) utf8_strupr(resource_domain);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1197
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1198 smb_init_name_struct((unsigned char *)resource_domain, NBT_MB,
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1199 0, 0, 0, 0, 0, &name);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1200
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1201 if ((dest = smb_name_find_name(&name))) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1202 addr = dest->addr_list;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1203 addr.forw = addr.back = &addr;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1204 smb_name_unlock_name(dest);
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1205 smb_browser_send_HostAnnouncement(hinfo, hinfo->hi_interval,
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1206 remove, &addr, NBT_MB);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1207 } else {
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1208 smb_init_name_struct((unsigned char *)resource_domain,
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1209 NBT_DMB, 0, 0, 0, 0, 0, &name);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1210 if ((dest = smb_name_find_name(&name))) {
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1211 addr = dest->addr_list;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1212 addr.forw = addr.back = &addr;
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1213 smb_name_unlock_name(dest);
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1214 smb_browser_send_HostAnnouncement(hinfo,
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1215 remove, hinfo->hi_interval, &addr, NBT_DMB);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1216 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1217 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1218
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1219 /*
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1220 * One Minute announcements for first five
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1221 * minutes, one minute longer each round
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1222 * until 12 minutes and every 12 minutes
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1223 * thereafter.
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1224 */
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1225 if (--hinfo->hi_reps == 0) {
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1226 if (hinfo->hi_interval < 12)
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1227 hinfo->hi_interval++;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1228
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1229 hinfo->hi_reps = 1;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1230 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1231
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1232 hinfo->hi_nextannouce = hinfo->hi_interval;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1233 }
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1234
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1235
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1236 /*
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1237 * SMB NetBIOS Browser Service
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1238 */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1239 /*ARGSUSED*/
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1240 void *
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1241 smb_browser_service(void *arg)
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1242 {
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1243 smb_hostinfo_t *hinfo;
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1244
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1245 smb_browser_infoinit();
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1246 smb_browser_config();
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1247
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1248 smb_netbios_event(NETBIOS_EVENT_BROWSER_START);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1249
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1250 restart:
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1251 do {
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1252 (void) rw_rdlock(&smb_binfo.bi_hlist_rwl);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1253 hinfo = list_head(&smb_binfo.bi_hlist);
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1254
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1255 while (hinfo) {
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1256 if (--hinfo->hi_nextannouce > 0 ||
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1257 hinfo->hi_nic.nic_bcast == 0) {
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1258 hinfo = list_next(&smb_binfo.bi_hlist, hinfo);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1259 continue;
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1260 }
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1261
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1262 smb_browser_non_master_duties(hinfo, B_FALSE);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1263
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1264 /* Check to see whether reconfig is needed */
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1265 (void) mutex_lock(&smb_binfo.bi_mtx);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1266 if (smb_binfo.bi_changed) {
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1267 smb_binfo.bi_changed = B_FALSE;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1268 (void) mutex_unlock(&smb_binfo.bi_mtx);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1269 (void) rw_unlock(&smb_binfo.bi_hlist_rwl);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1270 smb_browser_config();
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1271 goto restart;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1272 }
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1273 (void) mutex_unlock(&smb_binfo.bi_mtx);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1274
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1275 hinfo = list_next(&smb_binfo.bi_hlist, hinfo);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1276 }
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1277
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1278 (void) rw_unlock(&smb_binfo.bi_hlist_rwl);
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1279 smb_netbios_sleep(SECSPERMIN); /* 1 minute */
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1280 } while (smb_netbios_running());
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1281
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1282 smb_browser_infoterm();
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1283 smb_netbios_event(NETBIOS_EVENT_BROWSER_STOP);
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1284 return (0);
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents:
diff changeset
1285 }
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1286
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1287 /*
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1288 * smb_browser_netlogon
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1289 *
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1290 * Sends SAMLOGON/NETLOGON request for all host/ips, except
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1291 * aliases, to find a domain controller.
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1292 *
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1293 * The dc argument will be set if a DC is found.
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1294 */
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1295 boolean_t
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1296 smb_browser_netlogon(char *domain, char *dc, uint32_t dc_len)
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1297 {
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1298 smb_hostinfo_t *hinfo;
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1299 boolean_t found = B_FALSE;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1300 timestruc_t to;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1301 int err;
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1302
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1303 (void) rw_rdlock(&smb_binfo.bi_hlist_rwl);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1304 hinfo = list_head(&smb_binfo.bi_hlist);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1305 while (hinfo) {
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1306 if ((hinfo->hi_nic.nic_smbflags & SMB_NICF_ALIAS) == 0)
9832
3569b6c7f56c 6803042 AUXILIARY tags in libsmb mapfile produce ELF noise and bloated binary
Alan Wright <amw@Sun.COM>
parents: 8670
diff changeset
1307 smb_netlogon_request(&hinfo->hi_netname, domain);
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1308 hinfo = list_next(&smb_binfo.bi_hlist, hinfo);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1309 }
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1310 (void) rw_unlock(&smb_binfo.bi_hlist_rwl);
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1311
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1312 bzero(dc, dc_len);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1313 to.tv_sec = 30;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1314 to.tv_nsec = 0;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1315 (void) mutex_lock(&ntdomain_mtx);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1316 while (ntdomain_info.n_ipaddr == 0) {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1317 err = cond_reltimedwait(&ntdomain_cv, &ntdomain_mtx, &to);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1318 if (err == ETIME)
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1319 break;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1320 }
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1321
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1322 if (ntdomain_info.n_ipaddr != 0) {
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1323 (void) strlcpy(dc, ntdomain_info.n_name, dc_len);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1324 found = B_TRUE;
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1325 }
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1326 (void) mutex_unlock(&ntdomain_mtx);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1327
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1328 return (found);
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1329 }
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1330
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1331 /*
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1332 * smb_browser_infoinit
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1333 *
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1334 * This function is called only once when the browser starts
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1335 * to initialize the global smb_binfo structure.
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1336 */
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1337 static void
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1338 smb_browser_infoinit(void)
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1339 {
8334
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1340 (void) mutex_lock(&ntdomain_mtx);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1341 bzero(&ntdomain_info, sizeof (ntdomain_info));
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1342 (void) mutex_unlock(&ntdomain_mtx);
5f1c6a3b0fad 6762162 $DATA appended to streams when stream type != $DATA
jose borrego <Jose.Borrego@Sun.COM>
parents: 6030
diff changeset
1343
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1344 (void) rw_wrlock(&smb_binfo.bi_hlist_rwl);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1345 list_create(&smb_binfo.bi_hlist, sizeof (smb_hostinfo_t),
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1346 offsetof(smb_hostinfo_t, hi_lnd));
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1347 smb_binfo.bi_hcnt = 0;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1348 (void) rw_unlock(&smb_binfo.bi_hlist_rwl);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1349
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1350 (void) mutex_lock(&smb_binfo.bi_mtx);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1351 smb_binfo.bi_changed = B_FALSE;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1352 (void) mutex_unlock(&smb_binfo.bi_mtx);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1353 }
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1354
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1355 /*
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1356 * smb_browser_infoterm
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1357 *
10717
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1358 * This function is called only once when the browser stops
fe0545fc3cdd 6612607 CIFS ADS client should use ldap_sasl_interactive_bind_s API
Alan Wright <amw@Sun.COM>
parents: 9832
diff changeset
1359 * to destroy the smb_binfo structure.
6030
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1360 */
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1361 static void
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1362 smb_browser_infoterm(void)
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1363 {
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1364 (void) rw_wrlock(&smb_binfo.bi_hlist_rwl);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1365 smb_browser_infofree();
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1366 list_destroy(&smb_binfo.bi_hlist);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1367 (void) rw_unlock(&smb_binfo.bi_hlist_rwl);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1368 }
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1369
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1370 /*
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1371 * smb_browser_infofree
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1372 *
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1373 * Removes all the hostinfo structures from the browser list
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1374 * and frees the allocated memory
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1375 */
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1376 static void
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1377 smb_browser_infofree(void)
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1378 {
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1379 smb_hostinfo_t *hinfo;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1380
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1381 while ((hinfo = list_head(&smb_binfo.bi_hlist)) != NULL) {
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1382 list_remove(&smb_binfo.bi_hlist, hinfo);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1383 free(hinfo);
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1384 }
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1385
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1386 smb_binfo.bi_hcnt = 0;
6bebab7d43d5 6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents: 5772
diff changeset
1387 }