summaryrefslogtreecommitdiff
path: root/source4/nbt_server/register.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-02-06 08:25:53 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:09:34 -0500
commita75e9a3ee91b83af9c0fa25e407bf63cd67cd343 (patch)
tree21fde192c87ce7cab8ade46b57134cf43a037181 /source4/nbt_server/register.c
parente0caea68f5ac9f9fee1006b472bb49c2f81b21ac (diff)
downloadsamba-a75e9a3ee91b83af9c0fa25e407bf63cd67cd343.tar.gz
samba-a75e9a3ee91b83af9c0fa25e407bf63cd67cd343.tar.bz2
samba-a75e9a3ee91b83af9c0fa25e407bf63cd67cd343.zip
r5251: - renamed the nbtd server side structures to have a nbtd_ prefix, to
be consistent with the function names - added WINS client support to the NBT server. It will do initial WINS registration, and WINS refresh, automatically failing over to secondary WINS servers and handling multi-homed servers where we need to register multiple IPs. - added support for multi-homed name query replies, which are essential for multi-homed registration as the WINS server will query us to ensure we have the names when doing the secondary IPs in multi-homed registration (This used to be commit a1553fa8054dc7d33f5d77f8f95d3ffd90392b2a)
Diffstat (limited to 'source4/nbt_server/register.c')
-rw-r--r--source4/nbt_server/register.c43
1 files changed, 28 insertions, 15 deletions
diff --git a/source4/nbt_server/register.c b/source4/nbt_server/register.c
index e033797164..b65bd6d5ac 100644
--- a/source4/nbt_server/register.c
+++ b/source4/nbt_server/register.c
@@ -29,14 +29,15 @@
#include "libcli/composite/composite.h"
-static void nbtd_start_refresh_timer(struct nbt_iface_name *iname);
+static void nbtd_start_refresh_timer(struct nbtd_iface_name *iname);
/*
a name refresh request has completed
*/
static void refresh_completion_handler(struct nbt_name_request *req)
{
- struct nbt_iface_name *iname = talloc_get_type(req->async.private, struct nbt_iface_name);
+ struct nbtd_iface_name *iname = talloc_get_type(req->async.private,
+ struct nbtd_iface_name);
NTSTATUS status;
struct nbt_name_refresh io;
TALLOC_CTX *tmp_ctx = talloc_new(iname);
@@ -74,8 +75,8 @@ static void refresh_completion_handler(struct nbt_name_request *req)
static void name_refresh_handler(struct event_context *ev, struct timed_event *te,
struct timeval t, void *private)
{
- struct nbt_iface_name *iname = talloc_get_type(private, struct nbt_iface_name);
- struct nbt_interface *iface = iname->iface;
+ struct nbtd_iface_name *iname = talloc_get_type(private, struct nbtd_iface_name);
+ struct nbtd_interface *iface = iname->iface;
struct nbt_name_register io;
struct nbt_name_request *req;
@@ -92,6 +93,7 @@ static void name_refresh_handler(struct event_context *ev, struct timed_event *t
io.in.register_demand = False;
io.in.broadcast = True;
io.in.timeout = 3;
+ io.in.retries = 0;
req = nbt_name_register_send(iface->nbtsock, &io);
if (req == NULL) return;
@@ -104,7 +106,7 @@ static void name_refresh_handler(struct event_context *ev, struct timed_event *t
/*
start a timer to refresh this name
*/
-static void nbtd_start_refresh_timer(struct nbt_iface_name *iname)
+static void nbtd_start_refresh_timer(struct nbtd_iface_name *iname)
{
uint32_t refresh_time;
uint32_t max_refresh_time = lp_parm_int(-1, "nbtd", "max_refresh_time", 7200);
@@ -123,8 +125,8 @@ static void nbtd_start_refresh_timer(struct nbt_iface_name *iname)
*/
static void nbtd_register_handler(struct composite_context *req)
{
- struct nbt_iface_name *iname = talloc_get_type(req->async.private,
- struct nbt_iface_name);
+ struct nbtd_iface_name *iname = talloc_get_type(req->async.private,
+ struct nbtd_iface_name);
NTSTATUS status;
status = nbt_name_register_bcast_recv(req);
@@ -150,16 +152,16 @@ static void nbtd_register_handler(struct composite_context *req)
/*
register a name on a network interface
*/
-static void nbtd_register_name_iface(struct nbt_interface *iface,
+static void nbtd_register_name_iface(struct nbtd_interface *iface,
const char *name, enum nbt_name_type type,
uint16_t nb_flags)
{
- struct nbt_iface_name *iname;
+ struct nbtd_iface_name *iname;
const char *scope = lp_netbios_scope();
struct nbt_name_register_bcast io;
struct composite_context *req;
- iname = talloc(iface, struct nbt_iface_name);
+ iname = talloc(iface, struct nbtd_iface_name);
if (!iname) return;
iname->iface = iface;
@@ -173,8 +175,9 @@ static void nbtd_register_name_iface(struct nbt_interface *iface,
iname->nb_flags = nb_flags;
iname->ttl = lp_parm_int(-1, "nbtd", "bcast_ttl", 300000);
iname->registration_time = timeval_zero();
+ iname->wins_server = NULL;
- DLIST_ADD_END(iface->names, iname, struct nbt_iface_name *);
+ DLIST_ADD_END(iface->names, iname, struct nbtd_iface_name *);
if (nb_flags & NBT_NM_PERMANENT) {
/* permanent names are not announced and are immediately active */
@@ -183,6 +186,13 @@ static void nbtd_register_name_iface(struct nbt_interface *iface,
return;
}
+ /* if this is the wins interface, then we need to do a special
+ wins name registration */
+ if (iface == iface->nbtsrv->wins_interface) {
+ nbtd_winsclient_refresh(iname);
+ return;
+ }
+
/* setup a broadcast name registration request */
io.in.name = iname->name;
io.in.dest_addr = iface->bcast_address;
@@ -201,11 +211,11 @@ static void nbtd_register_name_iface(struct nbt_interface *iface,
/*
register one name on all our interfaces
*/
-static void nbtd_register_name(struct nbt_server *nbtsrv,
+static void nbtd_register_name(struct nbtd_server *nbtsrv,
const char *name, enum nbt_name_type type,
uint16_t nb_flags)
{
- struct nbt_interface *iface;
+ struct nbtd_interface *iface;
/* register with all the local interfaces */
for (iface=nbtsrv->interfaces;iface;iface=iface->next) {
@@ -218,14 +228,17 @@ static void nbtd_register_name(struct nbt_server *nbtsrv,
nb_flags | NBT_NM_PERMANENT);
}
- /* TODO: register with our WINS servers */
+ /* register with our WINS servers */
+ if (nbtsrv->wins_interface) {
+ nbtd_register_name_iface(nbtsrv->wins_interface, name, type, nb_flags);
+ }
}
/*
register our names on all interfaces
*/
-void nbtd_register_names(struct nbt_server *nbtsrv)
+void nbtd_register_names(struct nbtd_server *nbtsrv)
{
uint16_t nb_flags = NBT_NODE_M;
const char **aliases;