r12619: make sure we don't return more than 25 addresses, as w2k3 crashes in that...
[kai/samba-autobuild/.git] / source4 / nbt_server / nbt_server.h
1 /* 
2    Unix SMB/CIFS implementation.
3
4    NBT server structures
5
6    Copyright (C) Andrew Tridgell        2005
7    
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 2 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 #include "libcli/nbt/libnbt.h"
24 #include "libcli/wrepl/winsrepl.h"
25 #include "libcli/dgram/libdgram.h"
26 #include "librpc/gen_ndr/ndr_irpc.h"
27 #include "lib/messaging/irpc.h"
28
29 /* 
30    a list of our registered names on each interface
31 */
32 struct nbtd_iface_name {
33         struct nbtd_iface_name *next, *prev;
34         struct nbtd_interface *iface;
35         struct nbt_name name;
36         uint16_t nb_flags;
37         struct timeval registration_time;
38         uint32_t ttl;
39
40         /* if registered with a wins server, then this lists the server being
41            used */
42         char *wins_server;
43 };
44
45
46 /* a list of network interfaces we are listening on */
47 struct nbtd_interface {
48         struct nbtd_interface *next, *prev;
49         struct nbtd_server *nbtsrv;
50         const char *ip_address;
51         const char *bcast_address;
52         const char *netmask;
53         struct nbt_name_socket *nbtsock;
54         struct nbt_dgram_socket *dgmsock;
55         struct nbtd_iface_name *names;
56 };
57
58
59 /*
60   top level context structure for the nbt server
61 */
62 struct nbtd_server {
63         struct task_server *task;
64
65         /* the list of local network interfaces */
66         struct nbtd_interface *interfaces;
67
68         /* broadcast interface used for receiving packets only */
69         struct nbtd_interface *bcast_interface;
70
71         /* wins client interface - used for registering and refreshing
72            our names with a WINS server */
73         struct nbtd_interface *wins_interface;
74
75         struct wins_server *winssrv;
76
77         struct nbtd_statistics stats;
78 };
79
80
81
82 /* check a condition on an incoming packet */
83 #define NBTD_ASSERT_PACKET(packet, src, test) do { \
84         if (!(test)) { \
85                 nbtd_bad_packet(packet, src, #test); \
86                 return; \
87         } \
88 } while (0)
89
90 #include "nbt_server/nbt_server_proto.h"