summaryrefslogtreecommitdiff
path: root/source4/libcli/nbt
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-02-01 04:12:44 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:09:28 -0500
commit9b9c23b19be5a90821e1075a76f8b94fdb2424e2 (patch)
treef968db44bf97befaa4d19136e83c508cd3932b35 /source4/libcli/nbt
parentc4f115aa1b0029f716d495fa8fa3052d1a833439 (diff)
downloadsamba-9b9c23b19be5a90821e1075a76f8b94fdb2424e2.tar.gz
samba-9b9c23b19be5a90821e1075a76f8b94fdb2424e2.tar.bz2
samba-9b9c23b19be5a90821e1075a76f8b94fdb2424e2.zip
r5155: define ipv4address as a based IDL type, mapped to a "const char *" in
the header, and defined on the wire as a 4 byte network byte order IP. This means the calling code doesn't have to worry about network byte order conversions. (This used to be commit 72048e37179dd5b9ada0c5280d2f0d8c23d1a17d)
Diffstat (limited to 'source4/libcli/nbt')
-rw-r--r--source4/libcli/nbt/namequery.c11
-rw-r--r--source4/libcli/nbt/namerefresh.c14
-rw-r--r--source4/libcli/nbt/nameregister.c15
3 files changed, 11 insertions, 29 deletions
diff --git a/source4/libcli/nbt/namequery.c b/source4/libcli/nbt/namequery.c
index d77482fc2b..072b1e459a 100644
--- a/source4/libcli/nbt/namequery.c
+++ b/source4/libcli/nbt/namequery.c
@@ -72,8 +72,6 @@ NTSTATUS nbt_name_query_recv(struct nbt_name_request *req,
{
NTSTATUS status;
struct nbt_name_packet *packet;
- const char *addr;
- struct in_addr in;
int i;
status = nbt_name_request_recv(req);
@@ -102,13 +100,8 @@ NTSTATUS nbt_name_query_recv(struct nbt_name_request *req,
}
for (i=0;i<io->out.num_addrs;i++) {
- in.s_addr = htonl(packet->answers[0].rdata.netbios.addresses[i].ipaddr.addr);
- addr = inet_ntoa(in);
- if (addr == NULL) {
- talloc_free(req);
- return NT_STATUS_NO_MEMORY;
- }
- io->out.reply_addrs[i] = talloc_strdup(mem_ctx, addr);
+ io->out.reply_addrs[i] = talloc_steal(mem_ctx,
+ packet->answers[0].rdata.netbios.addresses[i].ipaddr);
}
talloc_steal(mem_ctx, io->out.name.name);
diff --git a/source4/libcli/nbt/namerefresh.c b/source4/libcli/nbt/namerefresh.c
index c121d9c920..0d0576d764 100644
--- a/source4/libcli/nbt/namerefresh.c
+++ b/source4/libcli/nbt/namerefresh.c
@@ -64,7 +64,8 @@ struct nbt_name_request *nbt_name_refresh_send(struct nbt_name_socket *nbtsock,
struct nbt_rdata_address, 1);
if (packet->additional[0].rdata.netbios.addresses == NULL) goto failed;
packet->additional[0].rdata.netbios.addresses[0].nb_flags = io->in.nb_flags;
- packet->additional[0].rdata.netbios.addresses[0].ipaddr.addr = htonl(inet_addr(io->in.address));
+ packet->additional[0].rdata.netbios.addresses[0].ipaddr =
+ talloc_strdup(packet->additional, io->in.address);
req = nbt_name_request_send(nbtsock, io->in.dest_addr, lp_nbt_port(), packet,
timeval_current_ofs(io->in.timeout, 0), False);
@@ -86,8 +87,6 @@ NTSTATUS nbt_name_refresh_recv(struct nbt_name_request *req,
{
NTSTATUS status;
struct nbt_name_packet *packet;
- const char *addr;
- struct in_addr in;
status = nbt_name_request_recv(req);
if (!NT_STATUS_IS_OK(status) ||
@@ -112,13 +111,8 @@ NTSTATUS nbt_name_refresh_recv(struct nbt_name_request *req,
talloc_free(req);
return NT_STATUS_INVALID_NETWORK_RESPONSE;
}
- in.s_addr = htonl(packet->answers[0].rdata.netbios.addresses[0].ipaddr.addr);
- addr = inet_ntoa(in);
- if (addr == NULL) {
- talloc_free(req);
- return NT_STATUS_NO_MEMORY;
- }
- io->out.reply_addr = talloc_strdup(mem_ctx, addr);
+ io->out.reply_addr = talloc_steal(mem_ctx,
+ packet->answers[0].rdata.netbios.addresses[0].ipaddr);
talloc_steal(mem_ctx, io->out.name.name);
talloc_steal(mem_ctx, io->out.name.scope);
diff --git a/source4/libcli/nbt/nameregister.c b/source4/libcli/nbt/nameregister.c
index 7bed37cf78..4701d0c1bc 100644
--- a/source4/libcli/nbt/nameregister.c
+++ b/source4/libcli/nbt/nameregister.c
@@ -67,7 +67,9 @@ struct nbt_name_request *nbt_name_register_send(struct nbt_name_socket *nbtsock,
struct nbt_rdata_address, 1);
if (packet->additional[0].rdata.netbios.addresses == NULL) goto failed;
packet->additional[0].rdata.netbios.addresses[0].nb_flags = io->in.nb_flags;
- packet->additional[0].rdata.netbios.addresses[0].ipaddr.addr = htonl(inet_addr(io->in.address));
+ packet->additional[0].rdata.netbios.addresses[0].ipaddr =
+ talloc_strdup(packet->additional, io->in.address);
+ if (packet->additional[0].rdata.netbios.addresses[0].ipaddr == NULL) goto failed;
req = nbt_name_request_send(nbtsock, io->in.dest_addr, lp_nbt_port(), packet,
timeval_current_ofs(io->in.timeout, 0), False);
@@ -89,8 +91,6 @@ NTSTATUS nbt_name_register_recv(struct nbt_name_request *req,
{
NTSTATUS status;
struct nbt_name_packet *packet;
- const char *addr;
- struct in_addr in;
status = nbt_name_request_recv(req);
if (!NT_STATUS_IS_OK(status) ||
@@ -115,13 +115,8 @@ NTSTATUS nbt_name_register_recv(struct nbt_name_request *req,
talloc_free(req);
return NT_STATUS_INVALID_NETWORK_RESPONSE;
}
- in.s_addr = htonl(packet->answers[0].rdata.netbios.addresses[0].ipaddr.addr);
- addr = inet_ntoa(in);
- if (addr == NULL) {
- talloc_free(req);
- return NT_STATUS_NO_MEMORY;
- }
- io->out.reply_addr = talloc_strdup(mem_ctx, addr);
+ io->out.reply_addr = talloc_steal(mem_ctx,
+ packet->answers[0].rdata.netbios.addresses[0].ipaddr);
talloc_steal(mem_ctx, io->out.name.name);
talloc_steal(mem_ctx, io->out.name.scope);