added lots of comments to the docs that Luke wrote on the internals of
[samba.git] / source3 / namedbresp.doc
1 module namedbresp deals with the maintenance of the list of expected
2 responses - creating, finding and removal.
3
4 module nameresp deals with the initial transmission, re-transmission
5 and time-out of netbios response records.
6
7
8 /*************************************************************************
9   find_response_record()
10   *************************************************************************/
11
12 this function is responsible for matching the unique response transaction
13 id with an expected response record. as a side-effect of this search,
14 it will find the subnet (or the WINS pseudo-subnet) that samba expected
15 the response to come from.
16
17
18 /*************************************************************************
19   make_response_queue_record()
20   *************************************************************************/
21
22 this function is responsible for creating a response record, which will
23 be queued awaiting a response.
24
25 the number of retries is set to 3, and the retry period set to 1 second.
26 if no response is received, then the packet is re-transmitted, which is
27 why so much information is stored in the response record.
28
29 the number of expected responses queued is kept, so listen_for_packets()
30 knows it must time-out after 1 second if one or more responses are
31 expected.
32
33
34 /*************************************************************************
35   remove_response_record()
36   *************************************************************************/
37
38 this function is responsible for removing a response record from the
39 expected response queue. the number of expected responses is decreased.
40
41
42 /*************************************************************************
43   add_response_record()
44   *************************************************************************/
45
46 this function is responsible for adding the response record created by
47 make_response_queue_record() into the appropriate response record queue.
48
49
50 -----------------
51 NOTE FROM TRIDGE:
52
53 namedbresp.c is interesting because it implements a novel way of
54 getting most of the advantages of a multi-threaded nmbd daemon without
55 the portability problems. 
56
57 The NBT specs (rfc1001/1002) talk about the 16 bit IDs in the packets
58 as being used to ensure that packets are unique, and to stop packets
59 from being confused. It suggests incrementing the ID by 1 each time.
60
61 Instead Luke uses these IDs to identify individual threads of control
62 in nmbd. So when nmbd sends out a NBT packet as part of some complex
63 processing, it adds to a linked list the information required to
64 continue the processing when the reply comes in (or it times
65 out). When a reply arrives this list can be searched to find the
66 matching query and the next step in the processing can be carried out.
67
68 This is really good stuff, and allows for much more complex behaviour
69 than was possible with the old nmbd.
70 ----------------