summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/Makefile.in2
-rw-r--r--source3/include/proto.h1
-rw-r--r--source3/lib/util.c73
-rw-r--r--source3/librpc/ndr/libndr.h5
-rw-r--r--source3/librpc/ndr/util.c6
5 files changed, 79 insertions, 8 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index d6c5486528..1685bf141d 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -968,7 +968,7 @@ REPLACETORT_OBJ = @libreplacedir@/test/testsuite.o \
@libreplacedir@/test/main.o \
$(LIBREPLACE_OBJ)
-NDRDUMP_OBJ = librpc/tools/ndrdump.o \
+NDRDUMP_OBJ = ../librpc/tools/ndrdump.o \
$(PARAM_OBJ) $(LIBNDR_GEN_OBJ) \
$(LIBSAMBA_OBJ) $(LIB_NONSMBD_OBJ) $(POPT_LIB_OBJ) \
librpc/gen_ndr/ndr_svcctl.o
diff --git a/source3/include/proto.h b/source3/include/proto.h
index fb6d45befd..7dc0319e7d 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1291,6 +1291,7 @@ enum remote_arch_types get_remote_arch(void);
void print_asc(int level, const unsigned char *buf,int len);
void dump_data(int level, const unsigned char *buf1,int len);
void dump_data_pw(const char *msg, const uchar * data, size_t len);
+void dump_data_skip_zeros(int level, const uint8_t *buf, int len);
const char *tab_depth(int level, int depth);
int str_checksum(const char *s);
void zero_free(void *p, size_t size);
diff --git a/source3/lib/util.c b/source3/lib/util.c
index ec43ea7037..418ae41392 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -2217,25 +2217,60 @@ void print_asc(int level, const unsigned char *buf,int len)
DEBUG(level,("%c", isprint(buf[i])?buf[i]:'.'));
}
-void dump_data(int level, const unsigned char *buf1,int len)
+/**
+ * Write dump of binary data to the log file.
+ *
+ * The data is only written if the log level is at least level.
+ */
+static void _dump_data(int level, const uint8_t *buf, int len,
+ bool omit_zero_bytes)
{
- const unsigned char *buf = (const unsigned char *)buf1;
int i=0;
+ const uint8_t empty[16];
+ bool skipped = false;
+
if (len<=0) return;
if (!DEBUGLVL(level)) return;
-
- DEBUGADD(level,("[%03X] ",i));
+
+ memset(&empty, '\0', 16);
+
for (i=0;i<len;) {
+
+ if (i%16 == 0) {
+ if ((omit_zero_bytes == true) &&
+ (i > 0) &&
+ (len > i+16) &&
+ (memcmp(&buf[i], &empty, 16) == 0))
+ {
+ i +=16;
+ continue;
+ }
+
+ if (i<len) {
+ DEBUGADD(level,("[%04X] ",i));
+ }
+ }
+
DEBUGADD(level,("%02X ",(int)buf[i]));
i++;
- if (i%8 == 0) DEBUGADD(level,(" "));
- if (i%16 == 0) {
+ if (i%8 == 0) DEBUGADD(level,(" "));
+ if (i%16 == 0) {
+
print_asc(level,&buf[i-16],8); DEBUGADD(level,(" "));
print_asc(level,&buf[i-8],8); DEBUGADD(level,("\n"));
- if (i<len) DEBUGADD(level,("[%03X] ",i));
+
+ if ((omit_zero_bytes == true) &&
+ (len > i+16) &&
+ (memcmp(&buf[i], &empty, 16) == 0)) {
+ if (!skipped) {
+ DEBUGADD(level,("skipping zero buffer bytes\n"));
+ skipped = true;
+ }
+ }
}
}
+
if (i%16) {
int n;
n = 16 - (i%16);
@@ -2248,8 +2283,32 @@ void dump_data(int level, const unsigned char *buf1,int len)
if (n>0) print_asc(level,&buf[i-n],n);
DEBUGADD(level,("\n"));
}
+
+}
+
+/**
+ * Write dump of binary data to the log file.
+ *
+ * The data is only written if the log level is at least level.
+ */
+_PUBLIC_ void dump_data(int level, const uint8_t *buf, int len)
+{
+ _dump_data(level, buf, len, false);
}
+/**
+ * Write dump of binary data to the log file.
+ *
+ * The data is only written if the log level is at least level.
+ * 16 zero bytes in a row are ommited
+ */
+_PUBLIC_ void dump_data_skip_zeros(int level, const uint8_t *buf, int len)
+{
+ _dump_data(level, buf, len, true);
+}
+
+
+
void dump_data_pw(const char *msg, const uchar * data, size_t len)
{
#ifdef DEBUG_PASSWORD
diff --git a/source3/librpc/ndr/libndr.h b/source3/librpc/ndr/libndr.h
index a860f35998..e25a7b8abd 100644
--- a/source3/librpc/ndr/libndr.h
+++ b/source3/librpc/ndr/libndr.h
@@ -26,6 +26,11 @@
#include "librpc/gen_ndr/misc.h"
#include "librpc/gen_ndr/security.h"
+/* Samba 3 doesn't use iconv_convenience: */
+extern void *global_loadparm;
+extern void *cmdline_lp_ctx;
+struct smb_iconv_convenience *lp_iconv_convenience(void *lp_ctx);
+
/*
this provides definitions for the libcli/rpc/ MSRPC library
*/
diff --git a/source3/librpc/ndr/util.c b/source3/librpc/ndr/util.c
index b85739df69..427292ac70 100644
--- a/source3/librpc/ndr/util.c
+++ b/source3/librpc/ndr/util.c
@@ -180,3 +180,9 @@ _PUBLIC_ void ndr_print_sockaddr_storage(struct ndr_print *ndr, const char *name
ndr->print(ndr, "%-25s: %s", name, print_sockaddr(addr, sizeof(addr), ss));
}
+void *global_loadparm;
+void *cmdline_lp_ctx;
+struct smb_iconv_convenience *lp_iconv_convenience(void *lp_ctx)
+{
+ return NULL;
+}