[SCM] Samba Shared Repository - branch master updated
Kai Blin
kai at samba.org
Sat May 18 04:49:01 MDT 2013
The branch, master has been updated
via a3a3086 dns: Also print packet information for DBGC_DNS
via 0f5e9d2 librpc: Add NDR_PRINT_DEBUGC to ndr print to a debug class
via 30cba0d debug: Add ability to dump_data per debug class
from 1c9ef67 smbd: Fix a ISO C90 forbids mixed declarations and code warning
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit a3a3086a2a35021bcf4dd4d3bcaeb51eb1b44a19
Author: Kai Blin <kai at samba.org>
Date: Fri Jan 18 18:36:45 2013 +0100
dns: Also print packet information for DBGC_DNS
Signed-off-by: Kai Blin <kai at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
Autobuild-User(master): Kai Blin <kai at samba.org>
Autobuild-Date(master): Sat May 18 12:48:15 CEST 2013 on sn-devel-104
commit 0f5e9d29f607f9d910641632dfcd20ef800b0bc4
Author: Kai Blin <kai at samba.org>
Date: Fri Jan 18 18:35:15 2013 +0100
librpc: Add NDR_PRINT_DEBUGC to ndr print to a debug class
Signed-off-by: Kai Blin <kai at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 30cba0d201fc91cff30b6ea2bd11979930650169
Author: Kai Blin <kai at samba.org>
Date: Fri Jan 18 09:44:02 2013 +0100
debug: Add ability to dump_data per debug class
Signed-off-by: Kai Blin <kai at samba.org>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
-----------------------------------------------------------------------
Summary of changes:
lib/util/debug.h | 7 +++
lib/util/samba_util.h | 8 ++++
lib/util/util.c | 30 ++++++++++++++
librpc/ABI/{ndr-0.0.1.sigs => ndr-0.0.2.sigs} | 2 +
librpc/ndr/libndr.h | 3 +
librpc/ndr/ndr.c | 51 +++++++++++++++++++++++++
librpc/wscript_build | 2 +-
source4/dns_server/dns_server.c | 10 ++--
8 files changed, 107 insertions(+), 6 deletions(-)
copy librpc/ABI/{ndr-0.0.1.sigs => ndr-0.0.2.sigs} (99%)
Changeset truncated at 500 lines:
diff --git a/lib/util/debug.h b/lib/util/debug.h
index feea0a8..30df787 100644
--- a/lib/util/debug.h
+++ b/lib/util/debug.h
@@ -161,10 +161,17 @@ extern int *DEBUGLEVEL_CLASS;
( ((level) <= MAX_DEBUG_LEVEL) && \
unlikely(DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level)))
+#define CHECK_DEBUGLVLC( dbgc_class, level ) \
+ ( ((level) <= MAX_DEBUG_LEVEL) && \
+ unlikely(DEBUGLEVEL_CLASS[ dbgc_class ] >= (level)))
+
#define DEBUGLVL( level ) \
( CHECK_DEBUGLVL(level) \
&& dbghdrclass( level, DBGC_CLASS, __location__, __FUNCTION__ ) )
+#define DEBUGLVLC( dbgc_class, level ) \
+ ( CHECK_DEBUGLVLC( dbgc_class, level ) \
+ && dbghdrclass( level, dbgc_class, __location__, __FUNCTION__ ) )
#define DEBUG( level, body ) \
(void)( ((level) <= MAX_DEBUG_LEVEL) && \
diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h
index 6a4373e..89aa9aa 100644
--- a/lib/util/samba_util.h
+++ b/lib/util/samba_util.h
@@ -693,6 +693,14 @@ _PUBLIC_ void dump_data(int level, const uint8_t *buf,int len);
/**
* Write dump of binary data to the log file.
*
+ * The data is only written if the log level is at least level for
+ * debug class dbgc_class.
+ */
+_PUBLIC_ void dump_data_dbgc(int dbgc_class, int level, const uint8_t *buf, int len);
+
+/**
+ * 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 omitted
*/
diff --git a/lib/util/util.c b/lib/util/util.c
index 7962c1e..7c669fb 100644
--- a/lib/util/util.c
+++ b/lib/util/util.c
@@ -384,6 +384,19 @@ _PUBLIC_ bool fcntl_lock(int fd, int op, off_t offset, off_t count, int type)
return true;
}
+struct debug_channel_level {
+ int channel;
+ int level;
+};
+
+static void debugadd_channel_cb(const char *buf, void *private_data)
+{
+ struct debug_channel_level *dcl =
+ (struct debug_channel_level *)private_data;
+
+ DEBUGADDC(dcl->channel, dcl->level,("%s", buf));
+}
+
static void debugadd_cb(const char *buf, void *private_data)
{
int *plevel = (int *)private_data;
@@ -505,6 +518,23 @@ _PUBLIC_ void dump_data(int level, const uint8_t *buf, int len)
/**
* Write dump of binary data to the log file.
*
+ * The data is only written if the log level is at least level for
+ * debug class dbgc_class.
+ */
+_PUBLIC_ void dump_data_dbgc(int dbgc_class, int level, const uint8_t *buf, int len)
+{
+ struct debug_channel_level dcl = { dbgc_class, level };
+
+ if (!DEBUGLVLC(dbgc_class, level)) {
+ DEBUG(0, ("dbgc_class is %d\n", dbgc_class));
+ return;
+ }
+ dump_data_cb(buf, len, false, debugadd_channel_cb, &dcl);
+}
+
+/**
+ * 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 omitted
*/
diff --git a/librpc/ABI/ndr-0.0.1.sigs b/librpc/ABI/ndr-0.0.2.sigs
similarity index 99%
copy from librpc/ABI/ndr-0.0.1.sigs
copy to librpc/ABI/ndr-0.0.2.sigs
index 904be70..66be5ba 100644
--- a/librpc/ABI/ndr-0.0.1.sigs
+++ b/librpc/ABI/ndr-0.0.2.sigs
@@ -38,6 +38,8 @@ ndr_print_bitmap_flag: void (struct ndr_print *, size_t, const char *, uint32_t,
ndr_print_bool: void (struct ndr_print *, const char *, const bool)
ndr_print_debug: void (ndr_print_fn_t, const char *, void *)
ndr_print_debug_helper: void (struct ndr_print *, const char *, ...)
+ndr_print_debugc: void (int, ndr_print_fn_t, const char *, void *)
+ndr_print_debugc_helper: void (struct ndr_print *, const char *, ...)
ndr_print_dlong: void (struct ndr_print *, const char *, int64_t)
ndr_print_double: void (struct ndr_print *, const char *, double)
ndr_print_enum: void (struct ndr_print *, const char *, const char *, const char *, uint32_t)
diff --git a/librpc/ndr/libndr.h b/librpc/ndr/libndr.h
index 1bd284f..a950519 100644
--- a/librpc/ndr/libndr.h
+++ b/librpc/ndr/libndr.h
@@ -162,6 +162,7 @@ struct ndr_print {
/* useful macro for debugging */
#define NDR_PRINT_DEBUG(type, p) ndr_print_debug((ndr_print_fn_t)ndr_print_ ##type, #p, p)
+#define NDR_PRINT_DEBUGC(dbgc_class, type, p) ndr_print_debugc(dbgc_class, (ndr_print_fn_t)ndr_print_ ##type, #p, p)
#define NDR_PRINT_UNION_DEBUG(type, level, p) ndr_print_union_debug((ndr_print_fn_t)ndr_print_ ##type, #p, level, p)
#define NDR_PRINT_FUNCTION_DEBUG(type, flags, p) ndr_print_function_debug((ndr_print_function_t)ndr_print_ ##type, #type, flags, p)
#define NDR_PRINT_BOTH_DEBUG(type, p) NDR_PRINT_FUNCTION_DEBUG(type, NDR_BOTH, p)
@@ -460,9 +461,11 @@ struct ndr_push *ndr_push_init_ctx(TALLOC_CTX *mem_ctx);
DATA_BLOB ndr_push_blob(struct ndr_push *ndr);
enum ndr_err_code ndr_push_expand(struct ndr_push *ndr, uint32_t extra_size);
void ndr_print_debug_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
+void ndr_print_debugc_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
void ndr_print_printf_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
void ndr_print_string_helper(struct ndr_print *ndr, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
void ndr_print_debug(ndr_print_fn_t fn, const char *name, void *ptr);
+void ndr_print_debugc(int dbgc_class, ndr_print_fn_t fn, const char *name, void *ptr);
void ndr_print_union_debug(ndr_print_fn_t fn, const char *name, uint32_t level, void *ptr);
void ndr_print_function_debug(ndr_print_function_t fn, const char *name, int flags, void *ptr);
char *ndr_print_struct_string(TALLOC_CTX *mem_ctx, ndr_print_fn_t fn, const char *name, void *ptr);
diff --git a/librpc/ndr/ndr.c b/librpc/ndr/ndr.c
index b77bfae..e86cf2f 100644
--- a/librpc/ndr/ndr.c
+++ b/librpc/ndr/ndr.c
@@ -165,6 +165,38 @@ _PUBLIC_ enum ndr_err_code ndr_push_expand(struct ndr_push *ndr, uint32_t extra_
return NDR_ERR_SUCCESS;
}
+_PUBLIC_ void ndr_print_debugc_helper(struct ndr_print *ndr, const char *format, ...)
+{
+ va_list ap;
+ char *s = NULL;
+ uint32_t i;
+ int ret;
+ int dbgc_class;
+
+ va_start(ap, format);
+ ret = vasprintf(&s, format, ap);
+ va_end(ap);
+
+ if (ret == -1) {
+ return;
+ }
+
+ dbgc_class = *(int *)ndr->private_data;
+
+ if (ndr->no_newline) {
+ DEBUGADDC(dbgc_class, 1,("%s", s));
+ free(s);
+ return;
+ }
+
+ for (i=0;i<ndr->depth;i++) {
+ DEBUGADDC(dbgc_class, 1,(" "));
+ }
+
+ DEBUGADDC(dbgc_class, 1,("%s\n", s));
+ free(s);
+}
+
_PUBLIC_ void ndr_print_debug_helper(struct ndr_print *ndr, const char *format, ...)
{
va_list ap;
@@ -236,6 +268,25 @@ _PUBLIC_ void ndr_print_string_helper(struct ndr_print *ndr, const char *format,
}
/*
+ a useful helper function for printing idl structures via DEBUGC()
+*/
+_PUBLIC_ void ndr_print_debugc(int dbgc_class, ndr_print_fn_t fn, const char *name, void *ptr)
+{
+ struct ndr_print *ndr;
+
+ DEBUGC(dbgc_class, 1,(" "));
+
+ ndr = talloc_zero(NULL, struct ndr_print);
+ if (!ndr) return;
+ ndr->private_data = &dbgc_class;
+ ndr->print = ndr_print_debugc_helper;
+ ndr->depth = 1;
+ ndr->flags = 0;
+ fn(ndr, name, ptr);
+ talloc_free(ndr);
+}
+
+/*
a useful helper function for printing idl structures via DEBUG()
*/
_PUBLIC_ void ndr_print_debug(ndr_print_fn_t fn, const char *name, void *ptr)
diff --git a/librpc/wscript_build b/librpc/wscript_build
index cc5d617..2017a29 100644
--- a/librpc/wscript_build
+++ b/librpc/wscript_build
@@ -642,7 +642,7 @@ bld.SAMBA_LIBRARY('ndr',
public_deps='errors talloc samba-util',
public_headers='gen_ndr/misc.h gen_ndr/ndr_misc.h ndr/libndr.h:ndr.h',
header_path= [('*gen_ndr*', 'gen_ndr')],
- vnum='0.0.1',
+ vnum='0.0.2',
abi_directory='ABI',
abi_match='ndr_* GUID_*',
)
diff --git a/source4/dns_server/dns_server.c b/source4/dns_server/dns_server.c
index 70020f4..bb4605f 100644
--- a/source4/dns_server/dns_server.c
+++ b/source4/dns_server/dns_server.c
@@ -133,7 +133,7 @@ static struct tevent_req *dns_process_send(TALLOC_CTX *mem_ctx,
tevent_req_werror(req, WERR_INVALID_PARAM);
return tevent_req_post(req, ev);
}
- dump_data(8, in->data, in->length);
+ dump_data_dbgc(DBGC_DNS, 8, in->data, in->length);
ndr_err = ndr_pull_struct_blob(
in, state, &state->in_packet,
@@ -144,8 +144,8 @@ static struct tevent_req *dns_process_send(TALLOC_CTX *mem_ctx,
tevent_req_done(req);
return tevent_req_post(req, ev);
}
- if (DEBUGLVL(8)) {
- NDR_PRINT_DEBUG(dns_name_packet, &state->in_packet);
+ if (DEBUGLVLC(DBGC_DNS, 8)) {
+ NDR_PRINT_DEBUGC(DBGC_DNS, dns_name_packet, &state->in_packet);
}
ret = dns_verify_tsig(dns, state, &state->state, &state->in_packet, in);
@@ -239,8 +239,8 @@ static WERROR dns_process_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
}
}
- if (DEBUGLVL(8)) {
- NDR_PRINT_DEBUG(dns_name_packet, &state->out_packet);
+ if (DEBUGLVLC(DBGC_DNS, 8)) {
+ NDR_PRINT_DEBUGC(DBGC_DNS, dns_name_packet, &state->out_packet);
}
ndr_err = ndr_push_struct_blob(
--
Samba Shared Repository
More information about the samba-cvs
mailing list