s4:lib/tevent: rename structs
[samba.git] / source4 / nbt_server / register.c
index d22903d5199c10cc0c29fb3fa9ed94aaf3cb1f7f..a2840ab5c03c4ba9b17ee479ffb2254299f92340 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "includes.h"
 #include "lib/events/events.h"
-#include "lib/util/dlinklist.h"
+#include "../lib/util/dlinklist.h"
 #include "nbt_server/nbt_server.h"
 #include "smbd/service_task.h"
 #include "libcli/composite/composite.h"
@@ -31,7 +31,6 @@
 #include "dsdb/samdb/samdb.h"
 #include "param/param.h"
 
-
 static void nbtd_start_refresh_timer(struct nbtd_iface_name *iname);
 
 /*
@@ -39,7 +38,7 @@ static void nbtd_start_refresh_timer(struct nbtd_iface_name *iname);
 */
 static void refresh_completion_handler(struct nbt_name_request *req)
 {
-       struct nbtd_iface_name *iname = talloc_get_type(req->async.private
+       struct nbtd_iface_name *iname = talloc_get_type(req->async.private_data,
                                                        struct nbtd_iface_name);
        NTSTATUS status;
        struct nbt_name_refresh io;
@@ -78,7 +77,7 @@ static void refresh_completion_handler(struct nbt_name_request *req)
 /*
   handle name refresh timer events
 */
-static void name_refresh_handler(struct event_context *ev, struct timed_event *te, 
+static void name_refresh_handler(struct tevent_context *ev, struct tevent_timer *te, 
                                 struct timeval t, void *private_data)
 {
        struct nbtd_iface_name *iname = talloc_get_type(private_data, struct nbtd_iface_name);
@@ -94,12 +93,13 @@ static void name_refresh_handler(struct event_context *ev, struct timed_event *t
           registration packets */
        io.in.name            = iname->name;
        io.in.dest_addr       = iface->bcast_address;
+       io.in.dest_port       = lp_nbt_port(iface->nbtsrv->task->lp_ctx);
        io.in.address         = iface->ip_address;
        io.in.nb_flags        = iname->nb_flags;
        io.in.ttl             = iname->ttl;
-       io.in.register_demand = False;
-       io.in.broadcast       = True;
-       io.in.multi_homed     = False;
+       io.in.register_demand = false;
+       io.in.broadcast       = true;
+       io.in.multi_homed     = false;
        io.in.timeout         = 3;
        io.in.retries         = 0;
 
@@ -108,7 +108,7 @@ static void name_refresh_handler(struct event_context *ev, struct timed_event *t
        if (req == NULL) return;
 
        req->async.fn = refresh_completion_handler;
-       req->async.private = iname;
+       req->async.private_data = iname;
 }
 
 
@@ -118,7 +118,7 @@ static void name_refresh_handler(struct event_context *ev, struct timed_event *t
 static void nbtd_start_refresh_timer(struct nbtd_iface_name *iname)
 {
        uint32_t refresh_time;
-       uint32_t max_refresh_time = lp_parm_int(NULL, "nbtd", "max_refresh_time", 7200);
+       uint32_t max_refresh_time = lp_parm_int(iname->iface->nbtsrv->task->lp_ctx, NULL, "nbtd", "max_refresh_time", 7200);
 
        refresh_time = MIN(max_refresh_time, iname->ttl/2);
        
@@ -171,7 +171,7 @@ static void nbtd_register_name_iface(struct nbtd_interface *iface,
                                     uint16_t nb_flags)
 {
        struct nbtd_iface_name *iname;
-       const char *scope = lp_netbios_scope();
+       const char *scope = lp_netbios_scope(iface->nbtsrv->task->lp_ctx);
        struct nbt_name_register_bcast io;
        struct composite_context *creq;
        struct nbtd_server *nbtsrv = iface->nbtsrv;
@@ -188,7 +188,7 @@ static void nbtd_register_name_iface(struct nbtd_interface *iface,
                iname->name.scope = NULL;
        }
        iname->nb_flags          = nb_flags;
-       iname->ttl               = lp_parm_int(NULL, "nbtd", "bcast_ttl", 300000);
+       iname->ttl               = lp_parm_int(iface->nbtsrv->task->lp_ctx, NULL, "nbtd", "bcast_ttl", 300000);
        iname->registration_time = timeval_zero();
        iname->wins_server       = NULL;
 
@@ -211,6 +211,7 @@ static void nbtd_register_name_iface(struct nbtd_interface *iface,
        /* setup a broadcast name registration request */
        io.in.name            = iname->name;
        io.in.dest_addr       = iface->bcast_address;
+       io.in.dest_port       = lp_nbt_port(iface->nbtsrv->task->lp_ctx);
        io.in.address         = iface->ip_address;
        io.in.nb_flags        = nb_flags;
        io.in.ttl             = iname->ttl;
@@ -227,9 +228,9 @@ static void nbtd_register_name_iface(struct nbtd_interface *iface,
 /*
   register one name on all our interfaces
 */
-static void nbtd_register_name(struct nbtd_server *nbtsrv, 
-                              const char *name, enum nbt_name_type type,
-                              uint16_t nb_flags)
+void nbtd_register_name(struct nbtd_server *nbtsrv, 
+                       const char *name, enum nbt_name_type type,
+                       uint16_t nb_flags)
 {
        struct nbtd_interface *iface;
        
@@ -261,29 +262,29 @@ void nbtd_register_names(struct nbtd_server *nbtsrv)
 
        /* note that we don't initially mark the names "ACTIVE". They are 
           marked active once registration is successful */
-       nbtd_register_name(nbtsrv, lp_netbios_name(), NBT_NAME_CLIENT, nb_flags);
-       nbtd_register_name(nbtsrv, lp_netbios_name(), NBT_NAME_USER,   nb_flags);
-       nbtd_register_name(nbtsrv, lp_netbios_name(), NBT_NAME_SERVER, nb_flags);
+       nbtd_register_name(nbtsrv, lp_netbios_name(nbtsrv->task->lp_ctx), NBT_NAME_CLIENT, nb_flags);
+       nbtd_register_name(nbtsrv, lp_netbios_name(nbtsrv->task->lp_ctx), NBT_NAME_USER,   nb_flags);
+       nbtd_register_name(nbtsrv, lp_netbios_name(nbtsrv->task->lp_ctx), NBT_NAME_SERVER, nb_flags);
 
-       aliases = lp_netbios_aliases();
+       aliases = lp_netbios_aliases(nbtsrv->task->lp_ctx);
        while (aliases && aliases[0]) {
                nbtd_register_name(nbtsrv, aliases[0], NBT_NAME_CLIENT, nb_flags);
                nbtd_register_name(nbtsrv, aliases[0], NBT_NAME_SERVER, nb_flags);
                aliases++;
        }
 
-       if (lp_server_role() == ROLE_DOMAIN_CONTROLLER) {
-               BOOL is_pdc = samdb_is_pdc(nbtsrv->sam_ctx);
+       if (lp_server_role(nbtsrv->task->lp_ctx) == ROLE_DOMAIN_CONTROLLER)     {
+               bool is_pdc = samdb_is_pdc(nbtsrv->sam_ctx);
                if (is_pdc) {
-                       nbtd_register_name(nbtsrv, lp_workgroup(),
+                       nbtd_register_name(nbtsrv, lp_workgroup(nbtsrv->task->lp_ctx),
                                           NBT_NAME_PDC, nb_flags);
                }
-               nbtd_register_name(nbtsrv, lp_workgroup(),
+               nbtd_register_name(nbtsrv, lp_workgroup(nbtsrv->task->lp_ctx),
                                   NBT_NAME_LOGON, nb_flags | NBT_NM_GROUP);
        }
 
        nb_flags |= NBT_NM_GROUP;
-       nbtd_register_name(nbtsrv, lp_workgroup(),    NBT_NAME_CLIENT, nb_flags);
+       nbtd_register_name(nbtsrv, lp_workgroup(nbtsrv->task->lp_ctx), NBT_NAME_CLIENT, nb_flags);
 
        nb_flags |= NBT_NM_PERMANENT;
        nbtd_register_name(nbtsrv, "__SAMBA__",       NBT_NAME_CLIENT, nb_flags);