summaryrefslogtreecommitdiff
path: root/source4/nbt_server
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-02-12 01:00:15 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:09:45 -0500
commit7b8f58c37c7a975b93e20bd40b5195960fe22c6f (patch)
tree2fdb8f527feb2498dbb3551706ec9d17d3b41b89 /source4/nbt_server
parent49568fab37d3a8fc3727ec5972cecdaf35e904b5 (diff)
downloadsamba-7b8f58c37c7a975b93e20bd40b5195960fe22c6f.tar.gz
samba-7b8f58c37c7a975b93e20bd40b5195960fe22c6f.tar.bz2
samba-7b8f58c37c7a975b93e20bd40b5195960fe22c6f.zip
r5352: added a function nbt_name_string() that formats a nbt_name structure
as a human readable string. The format is designed to be able to be used as the DN for the WINS database as well, while coping with arbitrary bytes in the name (except nul bytes) (This used to be commit aac3090e3504ba07124a9d480322a98efb97175e)
Diffstat (limited to 'source4/nbt_server')
-rw-r--r--source4/nbt_server/defense.c5
-rw-r--r--source4/nbt_server/nodestatus.c8
-rw-r--r--source4/nbt_server/packet.c13
-rw-r--r--source4/nbt_server/query.c4
-rw-r--r--source4/nbt_server/register.c26
-rw-r--r--source4/nbt_server/winsclient.c29
-rw-r--r--source4/nbt_server/winsserver.c1
7 files changed, 47 insertions, 39 deletions
diff --git a/source4/nbt_server/defense.c b/source4/nbt_server/defense.c
index bce72d805f..00e0e740af 100644
--- a/source4/nbt_server/defense.c
+++ b/source4/nbt_server/defense.c
@@ -57,8 +57,9 @@ void nbtd_request_defense(struct nbt_name_socket *nbtsock,
iname = nbtd_find_iname(iface, name, NBT_NM_ACTIVE);
if (iname != NULL && !(iname->nb_flags & NBT_NM_GROUP)) {
- DEBUG(2,("Defending name %s<%02x> on %s against %s\n",
- name->name, name->type, iface->bcast_address, src_address));
+ DEBUG(2,("Defending name %s on %s against %s\n",
+ nbt_name_string(packet, name),
+ iface->bcast_address, src_address));
nbtd_negative_name_registration_reply(nbtsock, packet,
src_address, src_port);
} else {
diff --git a/source4/nbt_server/nodestatus.c b/source4/nbt_server/nodestatus.c
index 5b79bf315f..7f8e6d4a24 100644
--- a/source4/nbt_server/nodestatus.c
+++ b/source4/nbt_server/nodestatus.c
@@ -82,8 +82,8 @@ static void nbtd_node_status_reply(struct nbt_name_socket *nbtsock,
it could lead to giving attackers too much information */
ZERO_STRUCT(packet->answers[0].rdata.status.statistics);
- DEBUG(7,("Sending node status reply for %s<%02x> to %s:%d\n",
- name->name, name->type, src_address, src_port));
+ DEBUG(7,("Sending node status reply for %s to %s:%d\n",
+ nbt_name_string(packet, name), src_address, src_port));
nbt_name_reply_send(nbtsock, src_address, src_port, packet);
@@ -113,8 +113,8 @@ void nbtd_query_status(struct nbt_name_socket *nbtsock,
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));
+ DEBUG(7,("Node status query for %s from %s - not found on %s\n",
+ nbt_name_string(packet, name), src_address, iface->ip_address));
return;
}
diff --git a/source4/nbt_server/packet.c b/source4/nbt_server/packet.c
index edca4ecb00..e6eec27fdc 100644
--- a/source4/nbt_server/packet.c
+++ b/source4/nbt_server/packet.c
@@ -128,8 +128,8 @@ void nbtd_name_query_reply(struct nbt_name_socket *nbtsock,
if (addr->ipaddr == NULL) goto failed;
}
- DEBUG(7,("Sending name query reply for %s<%02x> at %s to %s:%d\n",
- name->name, name->type, addresses[0], src_address, src_port));
+ DEBUG(7,("Sending name query reply for %s at %s to %s:%d\n",
+ nbt_name_string(packet, name), addresses[0], src_address, src_port));
nbt_name_reply_send(nbtsock, src_address, src_port, packet);
@@ -168,8 +168,8 @@ void nbtd_negative_name_query_reply(struct nbt_name_socket *nbtsock,
packet->answers[0].ttl = 0;
ZERO_STRUCT(packet->answers[0].rdata);
- DEBUG(7,("Sending negative name query reply for %s<%02x> to %s:%d\n",
- name->name, name->type, src_address, src_port));
+ DEBUG(7,("Sending negative name query reply for %s to %s:%d\n",
+ nbt_name_string(packet, name), src_address, src_port));
nbt_name_reply_send(nbtsock, src_address, src_port, packet);
@@ -209,12 +209,11 @@ void nbtd_negative_name_registration_reply(struct nbt_name_socket *nbtsock,
packet->answers[0].ttl = 0;
packet->answers[0].rdata = request_packet->additional[0].rdata;
- DEBUG(7,("Sending negative name registration reply for %s<%02x> to %s:%d\n",
- name->name, name->type, src_address, src_port));
+ DEBUG(7,("Sending negative name registration reply for %s to %s:%d\n",
+ nbt_name_string(packet, name), src_address, src_port));
nbt_name_reply_send(nbtsock, src_address, src_port, packet);
failed:
talloc_free(packet);
}
-
diff --git a/source4/nbt_server/query.c b/source4/nbt_server/query.c
index cc14a762da..c51a146adf 100644
--- a/source4/nbt_server/query.c
+++ b/source4/nbt_server/query.c
@@ -79,8 +79,8 @@ void nbtd_request_query(struct nbt_name_socket *nbtsock,
ignore it for now */
if (!(iname->nb_flags & NBT_NM_ACTIVE) &&
(packet->operation & NBT_FLAG_BROADCAST)) {
- DEBUG(7,("Query for %s<%02x> from %s - name not active yet on %s\n",
- name->name, name->type, src_address, iface->ip_address));
+ DEBUG(7,("Query for %s from %s - name not active yet on %s\n",
+ nbt_name_string(packet, name), src_address, iface->ip_address));
return;
}
diff --git a/source4/nbt_server/register.c b/source4/nbt_server/register.c
index c28ba0764c..bec316cdea 100644
--- a/source4/nbt_server/register.c
+++ b/source4/nbt_server/register.c
@@ -44,8 +44,9 @@ static void refresh_completion_handler(struct nbt_name_request *req)
status = nbt_name_refresh_recv(req, tmp_ctx, &io);
if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
- DEBUG(4,("Refreshed name %s<%02x> on %s\n",
- iname->name.name, iname->name.type, iname->iface->ip_address));
+ DEBUG(4,("Refreshed name %s on %s\n",
+ nbt_name_string(tmp_ctx, &iname->name),
+ iname->iface->ip_address));
iname->registration_time = timeval_current();
nbtd_start_refresh_timer(iname);
talloc_free(tmp_ctx);
@@ -56,13 +57,14 @@ static void refresh_completion_handler(struct nbt_name_request *req)
iname->nb_flags &= ~NBT_NM_ACTIVE;
if (NT_STATUS_IS_OK(status)) {
- DEBUG(1,("Name conflict from %s refreshing name %s<%02x> on %s - %s\n",
- io.out.reply_addr, iname->name.name, iname->name.type,
+ DEBUG(1,("Name conflict from %s refreshing name %s on %s - %s\n",
+ io.out.reply_addr, nbt_name_string(tmp_ctx, &iname->name),
iname->iface->ip_address,
nt_errstr(nbt_rcode_to_ntstatus(io.out.rcode))));
} else {
- DEBUG(1,("Error refreshing name %s<%02x> on %s - %s\n",
- iname->name.name, iname->name.type, iname->iface->ip_address,
+ DEBUG(1,("Error refreshing name %s on %s - %s\n",
+ nbt_name_string(tmp_ctx, &iname->name),
+ iname->iface->ip_address,
nt_errstr(status)));
}
@@ -130,14 +132,17 @@ static void nbtd_register_handler(struct composite_context *req)
struct nbtd_iface_name *iname = talloc_get_type(req->async.private,
struct nbtd_iface_name);
NTSTATUS status;
+ TALLOC_CTX *tmp_ctx = talloc_new(iname);
status = nbt_name_register_bcast_recv(req);
if (NT_STATUS_IS_OK(status)) {
/* good - nobody complained about our registration */
iname->nb_flags |= NBT_NM_ACTIVE;
- DEBUG(3,("Registered %s<%02x> on interface %s\n",
- iname->name.name, iname->name.type, iname->iface->bcast_address));
+ DEBUG(3,("Registered %s on interface %s\n",
+ nbt_name_string(tmp_ctx, &iname->name),
+ iname->iface->bcast_address));
iname->registration_time = timeval_current();
+ talloc_free(tmp_ctx);
nbtd_start_refresh_timer(iname);
return;
}
@@ -145,9 +150,10 @@ static void nbtd_register_handler(struct composite_context *req)
/* someone must have replied with an objection! */
iname->nb_flags |= NBT_NM_CONFLICT;
- DEBUG(1,("Error registering %s<%02x> on interface %s - %s\n",
- iname->name.name, iname->name.type, iname->iface->bcast_address,
+ DEBUG(1,("Error registering %s on interface %s - %s\n",
+ nbt_name_string(tmp_ctx, &iname->name), iname->iface->bcast_address,
nt_errstr(status)));
+ talloc_free(tmp_ctx);
}
diff --git a/source4/nbt_server/winsclient.c b/source4/nbt_server/winsclient.c
index e941d77e28..cfb68a3aaf 100644
--- a/source4/nbt_server/winsclient.c
+++ b/source4/nbt_server/winsclient.c
@@ -66,30 +66,31 @@ static void nbtd_wins_refresh_handler(struct composite_context *c)
if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
/* our WINS server is dead - start registration over
from scratch */
- DEBUG(2,("Failed to refresh %s<%02x> with WINS server %s\n",
- iname->name.name, iname->name.type, iname->wins_server));
+ DEBUG(2,("Failed to refresh %s with WINS server %s\n",
+ nbt_name_string(tmp_ctx, &iname->name), iname->wins_server));
+ talloc_free(tmp_ctx);
nbtd_winsclient_register(iname);
return;
}
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(1,("Name refresh failure with WINS for %s<%02x> - %s\n",
- iname->name.name, iname->name.type, nt_errstr(status)));
+ DEBUG(1,("Name refresh failure with WINS for %s - %s\n",
+ nbt_name_string(tmp_ctx, &iname->name), nt_errstr(status)));
talloc_free(tmp_ctx);
return;
}
if (io.out.rcode != 0) {
- DEBUG(1,("WINS server %s rejected name refresh of %s<%02x> - %s\n",
- io.out.wins_server, iname->name.name, iname->name.type,
+ DEBUG(1,("WINS server %s rejected name refresh of %s - %s\n",
+ io.out.wins_server, nbt_name_string(tmp_ctx, &iname->name),
nt_errstr(nbt_rcode_to_ntstatus(io.out.rcode))));
iname->nb_flags |= NBT_NM_CONFLICT;
talloc_free(tmp_ctx);
return;
}
- DEBUG(4,("Refreshed name %s<%02x> with WINS server %s\n",
- iname->name.name, iname->name.type, iname->wins_server));
+ DEBUG(4,("Refreshed name %s with WINS server %s\n",
+ nbt_name_string(tmp_ctx, &iname->name), iname->wins_server));
/* success - start a periodic name refresh */
iname->nb_flags |= NBT_NM_ACTIVE;
if (iname->wins_server) {
@@ -167,15 +168,15 @@ static void nbtd_wins_register_handler(struct composite_context *c)
}
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(1,("Name register failure with WINS for %s<%02x> - %s\n",
- iname->name.name, iname->name.type, nt_errstr(status)));
+ DEBUG(1,("Name register failure with WINS for %s - %s\n",
+ nbt_name_string(tmp_ctx, &iname->name), nt_errstr(status)));
talloc_free(tmp_ctx);
return;
}
if (io.out.rcode != 0) {
- DEBUG(1,("WINS server %s rejected name register of %s<%02x> - %s\n",
- io.out.wins_server, iname->name.name, iname->name.type,
+ DEBUG(1,("WINS server %s rejected name register of %s - %s\n",
+ io.out.wins_server, nbt_name_string(tmp_ctx, &iname->name),
nt_errstr(nbt_rcode_to_ntstatus(io.out.rcode))));
iname->nb_flags |= NBT_NM_CONFLICT;
talloc_free(tmp_ctx);
@@ -196,8 +197,8 @@ static void nbtd_wins_register_handler(struct composite_context *c)
nbtd_wins_refresh,
iname);
- DEBUG(3,("Registered %s<%02x> with WINS server %s\n",
- iname->name.name, iname->name.type, iname->wins_server));
+ DEBUG(3,("Registered %s with WINS server %s\n",
+ nbt_name_string(tmp_ctx, &iname->name), iname->wins_server));
talloc_free(tmp_ctx);
}
diff --git a/source4/nbt_server/winsserver.c b/source4/nbt_server/winsserver.c
index c7720b6ec7..22cfee415c 100644
--- a/source4/nbt_server/winsserver.c
+++ b/source4/nbt_server/winsserver.c
@@ -24,6 +24,7 @@
#include "nbt_server/nbt_server.h"
+
static void nbtd_winsserver_query(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
const char *src_address, int src_port)