1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

r5210: changed server side nbt functions to be prefixed with nbtd_ instead of

nbt_, so as to more clearly separate them from the client code in
libcli/nbt/
(This used to be commit b07a7e35f2)
This commit is contained in:
Andrew Tridgell 2005-02-04 01:39:10 +00:00 committed by Gerald (Jerry) Carter
parent 60d9b40ba4
commit bd22848ad8
8 changed files with 79 additions and 76 deletions

View File

@ -29,13 +29,13 @@
/*
receive an incoming request and dispatch it to the right place
*/
static void nbt_request_handler(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
const char *src_address, int src_port)
static void nbtd_request_handler(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
const char *src_address, int src_port)
{
switch (packet->operation & NBT_OPCODE) {
case NBT_OPCODE_QUERY:
nbt_request_query(nbtsock, packet, src_address, src_port);
nbtd_request_query(nbtsock, packet, src_address, src_port);
break;
}
}
@ -45,8 +45,9 @@ static void nbt_request_handler(struct nbt_name_socket *nbtsock,
/*
find a registered name on an interface
*/
struct nbt_iface_name *nbt_find_iname(struct nbt_interface *iface, struct nbt_name *name,
uint16_t nb_flags)
struct nbt_iface_name *nbtd_find_iname(struct nbt_interface *iface,
struct nbt_name *name,
uint16_t nb_flags)
{
struct nbt_iface_name *iname;
for (iname=iface->names;iname;iname=iname->next) {
@ -62,11 +63,11 @@ struct nbt_iface_name *nbt_find_iname(struct nbt_interface *iface, struct nbt_na
/*
start listening on the given address
*/
static NTSTATUS nbt_add_socket(struct nbt_server *nbtsrv,
const char *bind_address,
const char *address,
const char *bcast,
const char *netmask)
static NTSTATUS nbtd_add_socket(struct nbt_server *nbtsrv,
const char *bind_address,
const char *address,
const char *bcast,
const char *netmask)
{
struct nbt_interface *iface;
NTSTATUS status;
@ -101,7 +102,7 @@ static NTSTATUS nbt_add_socket(struct nbt_server *nbtsrv,
return status;
}
nbt_set_incoming_handler(bcast_nbtsock, nbt_request_handler, iface);
nbt_set_incoming_handler(bcast_nbtsock, nbtd_request_handler, iface);
}
iface->nbtsock = nbt_name_socket_init(iface, nbtsrv->task->event_ctx);
@ -118,7 +119,7 @@ static NTSTATUS nbt_add_socket(struct nbt_server *nbtsrv,
/* we need to be able to send broadcasts out */
socket_set_option(iface->nbtsock->sock, "SO_BROADCAST", "1");
nbt_set_incoming_handler(iface->nbtsock, nbt_request_handler, iface);
nbt_set_incoming_handler(iface->nbtsock, nbtd_request_handler, iface);
if (strcmp(netmask, "0.0.0.0") == 0) {
DLIST_ADD(nbtsrv->bcast_interface, iface);
@ -133,7 +134,7 @@ static NTSTATUS nbt_add_socket(struct nbt_server *nbtsrv,
/*
setup our listening sockets on the configured network interfaces
*/
NTSTATUS nbt_startup_interfaces(struct nbt_server *nbtsrv)
NTSTATUS nbtd_startup_interfaces(struct nbt_server *nbtsrv)
{
int num_interfaces = iface_count();
int i;
@ -157,11 +158,11 @@ NTSTATUS nbt_startup_interfaces(struct nbt_server *nbtsrv)
primary_address = talloc_strdup(tmp_ctx, primary_address);
NT_STATUS_HAVE_NO_MEMORY(primary_address);
status = nbt_add_socket(nbtsrv,
"0.0.0.0",
primary_address,
talloc_strdup(tmp_ctx, "255.255.255.255"),
talloc_strdup(tmp_ctx, "0.0.0.0"));
status = nbtd_add_socket(nbtsrv,
"0.0.0.0",
primary_address,
talloc_strdup(tmp_ctx, "255.255.255.255"),
talloc_strdup(tmp_ctx, "0.0.0.0"));
NT_STATUS_NOT_OK_RETURN(status);
}
@ -170,7 +171,7 @@ NTSTATUS nbt_startup_interfaces(struct nbt_server *nbtsrv)
const char *bcast = talloc_strdup(tmp_ctx, sys_inet_ntoa(*iface_n_bcast(i)));
const char *netmask = talloc_strdup(tmp_ctx, sys_inet_ntoa(*iface_n_netmask(i)));
status = nbt_add_socket(nbtsrv, address, address, bcast, netmask);
status = nbtd_add_socket(nbtsrv, address, address, bcast, netmask);
NT_STATUS_NOT_OK_RETURN(status);
}

View File

@ -45,14 +45,14 @@ static void nbtd_task_init(struct task_server *task)
nbtsrv->bcast_interface = NULL;
/* start listening on the configured network interfaces */
status = nbt_startup_interfaces(nbtsrv);
status = nbtd_startup_interfaces(nbtsrv);
if (!NT_STATUS_IS_OK(status)) {
task_terminate(task, "nbtd failed to setup interfaces");
return;
}
/* start the process of registering our names on all interfaces */
nbt_register_names(nbtsrv);
nbtd_register_names(nbtsrv);
}

View File

@ -65,7 +65,7 @@ struct nbt_server {
/* check a condition on an incoming packet */
#define NBT_ASSERT_PACKET(packet, src_address, test) do { \
if (!(test)) { \
nbt_bad_packet(packet, src_address, #test); \
nbtd_bad_packet(packet, src_address, #test); \
return; \
} \
} while (0)

View File

@ -28,11 +28,11 @@
/*
send a name status reply
*/
static void nbt_node_status_reply(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *request_packet,
const char *src_address, int src_port,
struct nbt_name *name,
struct nbt_interface *iface)
static void nbtd_node_status_reply(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *request_packet,
const char *src_address, int src_port,
struct nbt_name *name,
struct nbt_interface *iface)
{
struct nbt_name_packet *packet;
uint32_t name_count;
@ -95,9 +95,9 @@ failed:
/*
answer a node status query
*/
void nbt_query_status(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
const char *src_address, int src_port)
void nbtd_query_status(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
const char *src_address, int src_port)
{
struct nbt_name *name;
struct nbt_iface_name *iname;
@ -111,12 +111,13 @@ void nbt_query_status(struct nbt_name_socket *nbtsock,
/* see if we have the requested name on this interface */
name = &packet->questions[0].name;
iname = nbt_find_iname(iface, name, NBT_NM_ACTIVE);
iname = nbtd_find_iname(iface, name, NBT_NM_ACTIVE);
if (iname == NULL) {
DEBUG(7,("Node status query for %s<%02x> from %s - not found on %s\n",
name->name, name->type, src_address, iface->ip_address));
return;
}
nbt_node_status_reply(nbtsock, packet, src_address, src_port, &iname->name, iface);
nbtd_node_status_reply(nbtsock, packet, src_address, src_port,
&iname->name, iface);
}

View File

@ -27,8 +27,8 @@
/*
we received a badly formed packet - log it
*/
void nbt_bad_packet(struct nbt_name_packet *packet,
const char *src_address, const char *reason)
void nbtd_bad_packet(struct nbt_name_packet *packet,
const char *src_address, const char *reason)
{
DEBUG(2,("nbtd: bad packet '%s' from %s\n", reason, src_address));
if (DEBUGLVL(5)) {

View File

@ -28,11 +28,11 @@
/*
send a name query reply
*/
static void nbt_name_query_reply(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *request_packet,
const char *src_address, int src_port,
struct nbt_name *name, uint32_t ttl,
uint16_t nb_flags, const char *address)
static void nbtd_name_query_reply(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *request_packet,
const char *src_address, int src_port,
struct nbt_name *name, uint32_t ttl,
uint16_t nb_flags, const char *address)
{
struct nbt_name_packet *packet;
@ -77,9 +77,9 @@ failed:
/*
answer a name query
*/
void nbt_request_query(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
const char *src_address, int src_port)
void nbtd_request_query(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
const char *src_address, int src_port)
{
struct nbt_iface_name *iname;
struct nbt_name *name;
@ -89,14 +89,14 @@ void nbt_request_query(struct nbt_name_socket *nbtsock,
/* see if its a node status query */
if (packet->qdcount == 1 &&
packet->questions[0].question_type == NBT_QTYPE_STATUS) {
nbt_query_status(nbtsock, packet, src_address, src_port);
nbtd_query_status(nbtsock, packet, src_address, src_port);
return;
}
/* if its a WINS query then direct to our WINS server */
if ((packet->operation & NBT_FLAG_RECURSION_DESIRED) &&
!(packet->operation & NBT_FLAG_BROADCAST)) {
nbt_query_wins(nbtsock, packet, src_address, src_port);
nbtd_query_wins(nbtsock, packet, src_address, src_port);
return;
}
@ -107,14 +107,14 @@ void nbt_request_query(struct nbt_name_socket *nbtsock,
/* see if we have the requested name on this interface */
name = &packet->questions[0].name;
iname = nbt_find_iname(iface, name, NBT_NM_ACTIVE);
iname = nbtd_find_iname(iface, name, NBT_NM_ACTIVE);
if (iname == NULL) {
DEBUG(7,("Query for %s<%02x> from %s - not found on %s\n",
name->name, name->type, src_address, iface->ip_address));
return;
}
nbt_name_query_reply(nbtsock, packet, src_address, src_port,
&iname->name, iname->ttl, iname->nb_flags,
iface->ip_address);
nbtd_name_query_reply(nbtsock, packet, src_address, src_port,
&iname->name, iname->ttl, iname->nb_flags,
iface->ip_address);
}

View File

@ -29,7 +29,7 @@
#include "libcli/composite/composite.h"
static void nbt_start_refresh_timer(struct nbt_iface_name *iname);
static void nbtd_start_refresh_timer(struct nbt_iface_name *iname);
/*
a name refresh request has completed
@ -46,7 +46,7 @@ static void refresh_completion_handler(struct nbt_name_request *req)
DEBUG(4,("Refreshed name %s<%02x> on %s\n",
iname->name.name, iname->name.type, iname->iface->ip_address));
iname->registration_time = timeval_current();
nbt_start_refresh_timer(iname);
nbtd_start_refresh_timer(iname);
talloc_free(tmp_ctx);
return;
}
@ -99,7 +99,7 @@ static void name_refresh_handler(struct event_context *ev, struct timed_event *t
/*
start a timer to refresh this name
*/
static void nbt_start_refresh_timer(struct nbt_iface_name *iname)
static void nbtd_start_refresh_timer(struct nbt_iface_name *iname)
{
uint32_t refresh_time;
uint32_t max_refresh_time = lp_parm_int(-1, "nbtd", "max_refresh_time", 7200);
@ -116,9 +116,10 @@ static void nbt_start_refresh_timer(struct nbt_iface_name *iname)
/*
a name registration has completed
*/
static void nbt_register_handler(struct composite_context *req)
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 nbt_iface_name *iname = talloc_get_type(req->async.private,
struct nbt_iface_name);
NTSTATUS status;
status = nbt_name_register_bcast_recv(req);
@ -128,7 +129,7 @@ static void nbt_register_handler(struct composite_context *req)
DEBUG(3,("Registered %s<%02x> on interface %s\n",
iname->name.name, iname->name.type, iname->iface->bcast_address));
iname->registration_time = timeval_current();
nbt_start_refresh_timer(iname);
nbtd_start_refresh_timer(iname);
return;
}
@ -144,9 +145,9 @@ static void nbt_register_handler(struct composite_context *req)
/*
register a name on a network interface
*/
static void nbt_register_name_iface(struct nbt_interface *iface,
const char *name, enum nbt_name_type type,
uint16_t nb_flags)
static void nbtd_register_name_iface(struct nbt_interface *iface,
const char *name, enum nbt_name_type type,
uint16_t nb_flags)
{
struct nbt_iface_name *iname;
const char *scope = lp_netbios_scope();
@ -187,7 +188,7 @@ static void nbt_register_name_iface(struct nbt_interface *iface,
req = nbt_name_register_bcast_send(iface->nbtsock, &io);
if (req == NULL) return;
req->async.fn = nbt_register_handler;
req->async.fn = nbtd_register_handler;
req->async.private = iname;
}
@ -195,21 +196,21 @@ static void nbt_register_name_iface(struct nbt_interface *iface,
/*
register one name on all our interfaces
*/
static void nbt_register_name(struct nbt_server *nbtsrv,
const char *name, enum nbt_name_type type,
uint16_t nb_flags)
static void nbtd_register_name(struct nbt_server *nbtsrv,
const char *name, enum nbt_name_type type,
uint16_t nb_flags)
{
struct nbt_interface *iface;
/* register with all the local interfaces */
for (iface=nbtsrv->interfaces;iface;iface=iface->next) {
nbt_register_name_iface(iface, name, type, nb_flags);
nbtd_register_name_iface(iface, name, type, nb_flags);
}
/* register on our general broadcast interface as a permanent name */
if (nbtsrv->bcast_interface) {
nbt_register_name_iface(nbtsrv->bcast_interface, name, type,
nb_flags | NBT_NM_PERMANENT);
nbtd_register_name_iface(nbtsrv->bcast_interface, name, type,
nb_flags | NBT_NM_PERMANENT);
}
/* TODO: register with our WINS servers */
@ -219,21 +220,21 @@ static void nbt_register_name(struct nbt_server *nbtsrv,
/*
register our names on all interfaces
*/
void nbt_register_names(struct nbt_server *nbtsrv)
void nbtd_register_names(struct nbt_server *nbtsrv)
{
uint16_t nb_flags = NBT_NODE_M;
/* note that we don't initially mark the names "ACTIVE". They are
marked active once registration is successful */
nbt_register_name(nbtsrv, lp_netbios_name(), NBT_NAME_CLIENT, nb_flags);
nbt_register_name(nbtsrv, lp_netbios_name(), NBT_NAME_USER, nb_flags);
nbt_register_name(nbtsrv, lp_netbios_name(), NBT_NAME_SERVER, nb_flags);
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);
nb_flags |= NBT_NM_GROUP;
nbt_register_name(nbtsrv, lp_workgroup(), NBT_NAME_CLIENT, nb_flags);
nbtd_register_name(nbtsrv, lp_workgroup(), NBT_NAME_CLIENT, nb_flags);
nb_flags |= NBT_NM_PERMANENT;
nbt_register_name(nbtsrv, "__SAMBA__", NBT_NAME_CLIENT, nb_flags);
nbt_register_name(nbtsrv, "__SAMBA__", NBT_NAME_SERVER, nb_flags);
nbt_register_name(nbtsrv, "*", NBT_NAME_CLIENT, nb_flags);
nbtd_register_name(nbtsrv, "__SAMBA__", NBT_NAME_CLIENT, nb_flags);
nbtd_register_name(nbtsrv, "__SAMBA__", NBT_NAME_SERVER, nb_flags);
nbtd_register_name(nbtsrv, "*", NBT_NAME_CLIENT, nb_flags);
}

View File

@ -27,9 +27,9 @@
/*
answer a name query
*/
void nbt_query_wins(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
const char *src_address, int src_port)
void nbtd_query_wins(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
const char *src_address, int src_port)
{
DEBUG(0,("WINS query from %s\n", src_address));
if (DEBUGLVL(10)) {