r5145: define struct ipv4_addr in misc.idl,
authorStefan Metzmacher <metze@samba.org>
Mon, 31 Jan 2005 17:16:45 +0000 (17:16 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:09:27 +0000 (13:09 -0500)
so we can use it in nbt.idl and
get a nicer debug output

metze
(This used to be commit abacbc9192646f6f3c720758ab65889b82b9ae7b)

source4/include/includes.h
source4/libcli/nbt/namequery.c
source4/libcli/nbt/namerefresh.c
source4/libcli/nbt/nameregister.c
source4/libcli/nbt/nbtsocket.c
source4/librpc/config.mk
source4/librpc/idl/misc.idl
source4/librpc/idl/nbt.idl
source4/librpc/ndr/ndr_misc.c
source4/nbt_server/query.c
source4/nbt_server/winsserver.c

index ce24525158ef38eb6a5cdbe3fcec1180b4aff73c..a185669abd3a071dfec50290ba77423920c8647a 100644 (file)
 
 typedef int BOOL;
 
-/*
-  we use struct ipv4_addr to avoid having to include all the
-  system networking headers everywhere
-*/
-struct ipv4_addr {
-       uint32_t addr;
-};
-
 #ifndef HAVE_STRERROR
 extern char *sys_errlist[];
 #define strerror(i) sys_errlist[i]
@@ -126,7 +118,6 @@ extern int errno;
 #include "pstring.h"
 #include "smb_macros.h"
 #include "smb.h"
-#include "ads.h"
 #include "lib/socket/socket.h"
 #include "libcli/ldap/ldap.h"
 #include "byteorder.h"
@@ -142,6 +133,7 @@ extern int errno;
 #include "ntvfs/ntvfs.h"
 #include "cli_context.h"
 #include "nsswitch/winbind_client.h"
+#include "ads.h"
 
 #define malloc_p(type) (type *)malloc(sizeof(type))
 #define malloc_array_p(type, count) (type *)realloc_array(NULL, sizeof(type), count)
index 36fbfc8dd0b8b81fb73d23396d46fba11adf485f..d77482fc2bc5cdb25b73650ec33d5bcb83af5117 100644 (file)
@@ -102,7 +102,7 @@ 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);
+               in.s_addr = htonl(packet->answers[0].rdata.netbios.addresses[i].ipaddr.addr);
                addr = inet_ntoa(in);
                if (addr == NULL) {
                        talloc_free(req);
index 47fcae4f7c8ccc744164334726bff223210a8b69..c121d9c9209302e92d8789c3fb6e99d58ee5415b 100644 (file)
@@ -64,7 +64,7 @@ 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   = htonl(inet_addr(io->in.address));
+       packet->additional[0].rdata.netbios.addresses[0].ipaddr.addr   = htonl(inet_addr(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);
@@ -112,7 +112,7 @@ 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);
+       in.s_addr = htonl(packet->answers[0].rdata.netbios.addresses[0].ipaddr.addr);
        addr = inet_ntoa(in);
        if (addr == NULL) {
                talloc_free(req);
index 7e0134c28330c65cd197cb0a1a657f30290ffedb..7bed37cf78d64521c3c90aa08c1c6d87d8d88652 100644 (file)
@@ -67,7 +67,7 @@ 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   = htonl(inet_addr(io->in.address));
+       packet->additional[0].rdata.netbios.addresses[0].ipaddr.addr   = htonl(inet_addr(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);
@@ -115,7 +115,7 @@ 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);
+       in.s_addr = htonl(packet->answers[0].rdata.netbios.addresses[0].ipaddr.addr);
        addr = inet_ntoa(in);
        if (addr == NULL) {
                talloc_free(req);
index 3f16bf6921ff94d3788ff1474cee1d98029f3846..3d1397e019a9b9dd39a753a31476500bd2028796 100644 (file)
@@ -390,6 +390,10 @@ NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock,
 
        talloc_set_destructor(req, nbt_name_request_destructor);        
 
+       if (DEBUGLVL(10)) {
+               NDR_PRINT_DEBUG(nbt_name_packet, request);              
+       }
+
        status = ndr_push_struct_blob(&req->encoded, req, request, 
                                      (ndr_push_flags_fn_t)ndr_push_nbt_name_packet);
        if (!NT_STATUS_IS_OK(status)) {
index 75582c2adcc5be9a72563274be910daaa8bc06a6..3f0dea9ce1175b33b0a6649fc750a8c0e603ef4e 100644 (file)
@@ -291,7 +291,7 @@ REQUIRED_SUBSYSTEMS = LIBNDR
 INIT_OBJ_FILES = librpc/gen_ndr/ndr_nbt.o
 INIT_FUNCTION = dcerpc_nbt_init
 NOPROTO = YES
-REQUIRED_SUBSYSTEMS = LIBNDR
+REQUIRED_SUBSYSTEMS = LIBNDR NDR_MISC
 
 
 [SUBSYSTEM::NDR_ALL]
index 13306b687627637047e481e464bb36694d52dd60..4b69d1089bbd5aa2e73778bf11a71bee93e89960 100644 (file)
@@ -6,6 +6,10 @@
 
 interface misc
 {
+       typedef [public,noprint] struct {
+               uint32 addr;
+       } ipv4_addr;
+
        typedef [public,noprint,gensize] struct {
                uint32 time_low;
                uint16 time_mid;
index caca7fa336eb25653cfe8ab446670eac676eed20..9dc42fccbafc8f892d52681764be12d0f99de814 100644 (file)
@@ -102,7 +102,7 @@ interface nbt
 
        typedef struct {
                nb_flags nb_flags;
-               uint32   ipaddr;
+               ipv4_addr  ipaddr;
        } nbt_rdata_address;
 
        typedef struct {
index a538dd3033208beca59bd4c59462dc25d8c4a1ec..b9edc0ae9cc8863e8753b4d42889b4719d8c2bbd 100644 (file)
 */
 
 #include "includes.h"
+#include "system/network.h"
+
+void ndr_print_ipv4_addr(struct ndr_print *ndr, const char *name, const struct ipv4_addr *_ip)
+{
+       struct ipv4_addr ip;
+
+       ip.addr = htonl(_ip->addr);
+
+       ndr->print(ndr, "%-25s: %s", name, sys_inet_ntoa(ip));
+}
 
 /*
   build a GUID from a string
index 859a9c7f26bcd742efce860e12043a0bb16a3f33..9b9d1e29b9970af1e2481b4f1057321a9e18918a 100644 (file)
@@ -60,7 +60,7 @@ static void nbt_name_query_reply(struct nbt_name_socket *nbtsock,
                                                            struct nbt_rdata_address, 1);
        if (packet->answers[0].rdata.netbios.addresses == NULL) goto failed;
        packet->answers[0].rdata.netbios.addresses[0].nb_flags = nb_flags;
-       packet->answers[0].rdata.netbios.addresses[0].ipaddr = htonl(inet_addr(address));
+       packet->answers[0].rdata.netbios.addresses[0].ipaddr.addr = htonl(inet_addr(address));
 
        DEBUG(7,("Sending name query reply for %s<%02x> at %s to %s:%d\n", 
                 name->name, name->type, src_address, address, src_port));
index a659772cb3003fc9ab5aa5a915df3039be8e1c86..7810bebd249e5955ac6d17830801b9bdb20aa7d3 100644 (file)
@@ -32,4 +32,7 @@ void nbt_query_wins(struct nbt_name_socket *nbtsock,
                    const char *src_address, int src_port)
 {
        DEBUG(0,("WINS query from %s\n", src_address));
+       if (DEBUGLVL(10)) {
+               NDR_PRINT_DEBUG(nbt_name_packet, packet);               
+       }
 }