2 Unix SMB/CIFS implementation.
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.
24 #include "lib/events/events.h"
25 #include "smbd/service_task.h"
26 #include "nbt_server/nbt_server.h"
30 serve out the nbt statistics
32 static NTSTATUS nbtd_information(struct irpc_message *msg,
33 struct nbtd_information *r)
35 struct nbtd_server *server = talloc_get_type(msg->private, struct nbtd_server);
37 switch (r->in.level) {
38 case NBTD_INFO_STATISTICS:
39 r->out.info.stats = &server->stats;
51 static void nbtd_task_init(struct task_server *task)
53 struct nbtd_server *nbtsrv;
56 if (iface_count() == 0) {
57 task_server_terminate(task, "nbtd: no network interfaces configured");
61 nbtsrv = talloc(task, struct nbtd_server);
63 task_server_terminate(task, "nbtd: out of memory");
68 nbtsrv->interfaces = NULL;
69 nbtsrv->bcast_interface = NULL;
70 nbtsrv->wins_interface = NULL;
72 /* start listening on the configured network interfaces */
73 status = nbtd_startup_interfaces(nbtsrv);
74 if (!NT_STATUS_IS_OK(status)) {
75 task_server_terminate(task, "nbtd failed to setup interfaces");
79 /* start the WINS server, if appropriate */
80 status = nbtd_winsserver_init(nbtsrv);
81 if (!NT_STATUS_IS_OK(status)) {
82 task_server_terminate(task, "nbtd failed to start WINS server");
86 /* setup monitoring */
87 status = IRPC_REGISTER(task->msg_ctx, irpc, NBTD_INFORMATION,
88 nbtd_information, nbtsrv);
89 if (!NT_STATUS_IS_OK(status)) {
90 task_server_terminate(task, "nbtd failed to setup monitoring");
94 /* start the process of registering our names on all interfaces */
95 nbtd_register_names(nbtsrv);
100 initialise the nbt server
102 static NTSTATUS nbtd_init(struct event_context *event_ctx, const struct model_ops *model_ops)
104 return task_server_startup(event_ctx, model_ops, nbtd_task_init);
109 register ourselves as a available server
111 NTSTATUS server_service_nbtd_init(void)
113 return register_server_service("nbt", nbtd_init);