r11965: Try to fix some 64-bit warnings.
[Samba/gebeck_regimport.git] / source4 / nbt_server / nbt_server.c
blob3ba06c7df9d7c87425ff502b568fbd5ac8df7891
1 /*
2 Unix SMB/CIFS implementation.
4 NBT server task
6 Copyright (C) Andrew Tridgell 2005
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.
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.
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.
23 #include "includes.h"
24 #include "lib/events/events.h"
25 #include "smbd/service_task.h"
26 #include "nbt_server/nbt_server.h"
30 startup the nbtd task
32 static void nbtd_task_init(struct task_server *task)
34 struct nbtd_server *nbtsrv;
35 NTSTATUS status;
37 if (iface_count() == 0) {
38 task_server_terminate(task, "nbtd: no network interfaces configured");
39 return;
42 nbtsrv = talloc(task, struct nbtd_server);
43 if (nbtsrv == NULL) {
44 task_server_terminate(task, "nbtd: out of memory");
45 return;
48 nbtsrv->task = task;
49 nbtsrv->interfaces = NULL;
50 nbtsrv->bcast_interface = NULL;
51 nbtsrv->wins_interface = NULL;
53 /* start listening on the configured network interfaces */
54 status = nbtd_startup_interfaces(nbtsrv);
55 if (!NT_STATUS_IS_OK(status)) {
56 task_server_terminate(task, "nbtd failed to setup interfaces");
57 return;
60 /* start the WINS server, if appropriate */
61 status = nbtd_winsserver_init(nbtsrv);
62 if (!NT_STATUS_IS_OK(status)) {
63 task_server_terminate(task, "nbtd failed to start WINS server");
64 return;
67 nbtd_register_irpc(nbtsrv);
69 /* start the process of registering our names on all interfaces */
70 nbtd_register_names(nbtsrv);
72 irpc_add_name(task->msg_ctx, "nbt_server");
77 initialise the nbt server
79 static NTSTATUS nbtd_init(struct event_context *event_ctx, const struct model_ops *model_ops)
81 return task_server_startup(event_ctx, model_ops, nbtd_task_init);
86 register ourselves as a available server
88 NTSTATUS server_service_nbtd_init(void)
90 return register_server_service("nbt", nbtd_init);