2 Unix SMB/Netbios documentation.
4 Copyright (C) Luke Leighton Andrew Tridgell 1996
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 Document name: namework.doc
24 0.0 - 02jul96 : lkcl@pires.co.uk
27 0.1 - 22jul96 Andrew.Tridgell@anu.edu.au
28 tridge's comments on first revision
31 the module namework.c deals with NetBIOS datagram packets, primarily.
32 it deals with nmbd's workgroup browser side and the domain log in
33 side. none of the functionality here has specification documents available.
34 empirical observation of packet traces has been the order of the day,
35 along with some guess-work.
39 the receipt of datagram packets for workgroup browsing are dealt with here.
40 some of the functions listed here will call others outside of this
41 module, or will activate functionality dealt with by other modules
42 (namedb, nameannounce, nameelect, namelogon, and namebrowse).
45 /*************************************************************************
46 process_browse_packet()
47 *************************************************************************/
49 this function is responsible for further identifying which type of
50 browser datagram packet has been received, and dealing with it
51 accordingly. if the packet is not dealt with, then an error is
52 logged along with the type of packet that has been received.
54 if listening_type() was in use, then it would be used here.
56 the types of packets received and dealt with are:
58 - ANN_HostAnnouncement
59 - ANN_DomainAnnouncement
60 - ANN_LocalMasterAnnouncement
62 these are all identical in format and can all be processed by
63 process_announce(). an announcement is received from a host
64 (either a master browser telling us about itself, a server
65 telling us about itself or a master browser telling us about
68 - ANN_AnnouncementRequest
70 these are sent by master browsers or by servers. it is a
71 request to announce ourselves as appropriate by sending
72 either a ANN_HostAnnouncement datagram or both an
73 ANN_DomainAnnouncement and an ANN_LocalMasterAnnouncement
74 if we are a master browser (but not both).
78 this is an election datagram. if samba has been configured
79 as a domain master then it will also send out election
82 - ANN_GetBackupListReq
84 this is a request from another server for us to send a
85 backup list of all servers that we know about. we respond
86 by sending a datagram ANN_GetBackupListResp. the protocol
87 here is a little dicey.
89 - ANN_GetBackupListResp
91 this is a response from another server that we have sent an
92 ANN_GetBackupListReq to. the protocol is a little dicey.
96 this is a message sent by a master browser to a
97 potential master browser, indicating that it should become
98 a backup master browser for the workgroup it is a member
99 of. samba does not respond at present to such datagrams,
100 and it also sends out such datagrams for the wrong reasons
101 (this code has now been disabled until this is fixed).
103 - ANN_ResetBrowserState
105 this datagram is sent for trouble-shooting purposes.
106 it asks a browser to clear out its server lists, or to
107 stop becoming a master browser altogether. NT/AS and
108 samba do not implement this latter option.
110 - ANN_MasterAnnouncement
112 this datagram is sent by a master browser to a domain master
113 browser. it is a way to ensure that master browsers are kept in sync
114 with a domain master browser across a wide area network. on
115 receipt of an ANN_MasterAnnouncement we should sync browse lists with
118 (i never got the hang of this one when i was experimenting.
119 i forget exactly what it's for, and i never fully worked
120 out how to coax a server to send it. :-)
122 NOTE FROM TRIDGE: The reason you didn't work out how to coax a server
123 into sending it is that you can't (or shouldn't try!). Basically these
124 "master announce" datagrams are the way that separate netbios subnets
125 are linked together to form a complete browse net. The way it works is
126 that the local master decides it is going to inform the domain master
127 of its presence, then sends this master announce to the domain
128 master. The domain master then syncs with the local master using a
129 "local only" sync. The whole transaction is initiated by the local
130 master, not the domain master, so the domain master should not do any
131 of this if it does not first receive a "master announcement". The
132 local domain masters need to be configured to know the IP address of
136 /*************************************************************************
138 *************************************************************************/
141 a datagram packet is sent from one NetBIOS name of a specific type
142 to another NetBIOS name of a specific type. certain types of
143 datagrams are only expected from certain types of NetBIOS names.
145 this function is intended to catch errors in the type of datagrams
146 received from different NetBIOS names. it is currently incomplete
147 due to lack of information on the types of names and the datagrams
151 /*************************************************************************
152 process_announce_request()
153 *************************************************************************/
155 this function is responsible for dealing with announcement requests.
156 if the type of name that the request is sent to matches our current
157 status, then we should respond. otherwise, the datagram should be
160 samba only responds on its local subnets.
162 at present, just the name is checked to see if the packet is for us.
163 what should be done is that if we own the name (e.g WORGROUP(0x1d)
164 or WORKGROUP(0x1b) then we should respond, otherwise, ignore the
167 if the name is for us, and we are a member of that workgroup, then
168 samba should respond.
170 note that samba does not respond immediately. this is to ensure that
171 if the master browser for the workgroup that samba is a member of
172 sends out a broadcast request announcement, that that master browser
173 is not swamped with replies. it is therefore up to samba to reply
174 at some random interval. hence, a flag is set indicating the need
178 /*************************************************************************
179 process_reset_browser()
180 *************************************************************************/
182 this function is responsible for dealing with reset state datagrams.
183 there are three kinds of diagnostic reset requests:
185 - stop being a master browser
186 - discard browse lists, stop being a master browser, and run for re-election
187 - stop being a master browser forever.
189 samba and windows nt do not implement the latter option.
191 there appears to be a discrepancy between this description and the
192 code actually implemented.
195 /*************************************************************************
196 process_send_backup_list()
197 *************************************************************************/
199 this function is part of samba's domain master browser functionality.
201 it is responsible for giving master browsers a list of other browsers
202 that maintain backup lists of servers for that master browser's workgroup.
204 it is also responsible for giving master browsers a list of domain master
205 browsers for that local master browser's domain.
207 a correct way to think of this function is that it is a 'request to
208 send out a backup list for the requested workgroup or domain'.
210 i have some suspicions and intuitions about this function and how it
211 is to actually be used. there is no documentation on this, so it is a
212 matter of experimenting until it's right.
215 /*************************************************************************
217 *************************************************************************/
219 this function is responsible for compiling a list of either master
220 browsers and backup master browsers or domain master browsers and
221 backup domain master browsers. samba constructs this list from its
222 workgroup / server database.
224 the list is then sent to the host that requested it by sending an
225 ANN_GetBackupListResp datagram to this host.
228 NOTE FROM TRIDGE: The "backup list" stuff is only relevant to
229 local subnets. It has nothing to do with PDCs or domain masters. Its
232 1) spread the browsing load over multiple servers so one server
233 doesn't get overloaded with browse requests
234 2) make sure the database doesn't get lost completely if the master
237 To accomplish this a few things are supposed to be done:
239 - the master browser maintains a list of "backup browsers".
241 - backup browsers are are machines that are just like ordinary servers
242 but also maintain a browse list and respond to "NetServerEnum"
245 - when a server initially announces itself to the master it may set
246 its "maintain browse list" flag to auto.
248 - when a master browser sees a server announcement with "auto" set it
249 may send a "become backup" to that server telling it to become a
252 - the master has a simple algorithm to determine how many backups it wants
253 given the number of hosts on the net
255 - when a client wishes to get a browse list it asks the master for a
256 backup list. The master sends it the current list of backup browsers,
257 including itself. The client caches this list. The client then sends
258 the NetServerEnum to a random member of this list easch time it wants
259 to browse. This spreads the load.
263 /*************************************************************************
264 process_rcv_backup_list()
265 *************************************************************************/
267 this function is implemented with a slightly over-kill algorithm.
268 the correct functionality is to pick any three names at random from
269 the list that is received from this datagram, and then at intervals
270 contact _one_ of them for a list of browser, in order to update
273 samba contacts every single one of the backup browsers listed, through
274 the use of a NAME_QUERY_SRV_CHK 'state'.
277 /*************************************************************************
278 process_master_announce()
279 *************************************************************************/
281 this function is responsible for synchronising browse lists with a
282 master browser that contacts samba in its capacity as a domain master
285 the function add_browser_entry() is used to add the server that
286 contacts us to our list of browser to sync browse lists with at
287 some point in the near future.
290 /*************************************************************************
292 *************************************************************************/
294 this function is responsible for dealing with the three types of
295 announcement type datagrams that samba recognises. some appropriate
296 type-checking is done on the name that the datagram is sent to.
298 samba does not at present deal with LanManager announcements.
300 these announcements are for updating the browse entry records.
301 each browse entry has a time-to-live associated with it. each server
302 must refresh its entry with all other servers by broadcasting
303 Announcements. if it does not do so, then other servers will not
304 know about that machine, and the records on each server of that
305 other machine will die.
307 if an ANN_DomainAnnouncement is received, then this will be from
308 a master browser. only one machine on any given broadcast area (e.g
309 a subnet) should be broadcasting such announcements. the information
310 it contains tells other servers that there is a master browser for
311 this workgroup. if another server thinks that it is also a master
312 browser for the same workgroup, then it should stop being a master
313 browser and force an election.
315 if an ANN_LocalMasterAnnouncement is received, then a master browser
316 is telling us that it exists. i am uncertain that anything else
317 actually needs to be done with this, other than to shout 'hooray' and
318 'thank you for informing me of this fact'.
321 /*************************************************************************
323 *************************************************************************/
325 this function is an over-simplified way of identifying whether we
326 should be responding to a datagram that has been received.
329 /*************************************************************************
331 *************************************************************************/
333 this function helps us to identify whether we should be responding to
334 a datagram that has been received.
337 /*************************************************************************
339 *************************************************************************/
341 this function is part of samba's domain master browser capabilities.
342 it is responsible for finding appropriate servers to tell to become a
343 backup master browser for the domain that samba controls.
345 other servers that contact samba asking for a list of backup browsers
346 will then be given that server's name, and that server can expect to
347 receive NetServerEnum requests for lists of servers and workgroups.
349 this function must be updated before it is in a fit state to be used.
350 it must properly check whether a server is prepared to become a backup
351 browser before actually asking it to be one.
354 /*************************************************************************
356 *************************************************************************/
358 this function is responsible for issuing an ANN_ResetBrowserState to
359 the specified server, asking it to reset its browser information.
361 see process_reset_browser() for details on this function.