1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-02 09:47:23 +03:00

librpc: Move dcerpc_log_packet from s4 librpc to common librpc

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
Samuel Cabrero 2019-01-24 12:03:45 +01:00 committed by Andreas Schneider
parent ae9956a65e
commit 63b7889461
3 changed files with 41 additions and 39 deletions

View File

@ -1405,3 +1405,39 @@ NTSTATUS dcerpc_ncacn_push_auth(DATA_BLOB *blob,
return NT_STATUS_OK;
}
/*
log a rpc packet in a format suitable for ndrdump. This is especially useful
for sealed packets, where ethereal cannot easily see the contents
this triggers on a debug level of >= 10
*/
void dcerpc_log_packet(const char *lockdir,
const struct ndr_interface_table *ndr,
uint32_t opnum, uint32_t flags,
const DATA_BLOB *pkt)
{
const int num_examples = 20;
int i;
if (lockdir == NULL) return;
for (i=0;i<num_examples;i++) {
char *name=NULL;
int ret;
ret = asprintf(&name, "%s/rpclog/%s-%u.%d.%s",
lockdir, ndr->name, opnum, i,
(flags&NDR_IN)?"in":"out");
if (ret == -1) {
return;
}
if (!file_exist(name)) {
if (file_save(name, pkt->data, pkt->length)) {
DEBUG(10,("Logged rpc packet to %s\n", name));
}
free(name);
break;
}
free(name);
}
}

View File

@ -452,4 +452,9 @@ NTSTATUS dcerpc_ncacn_push_auth(DATA_BLOB *blob,
struct ncacn_packet *pkt,
struct dcerpc_auth *auth_info);
void dcerpc_log_packet(const char *lockdir,
const struct ndr_interface_table *ndr,
uint32_t opnum, uint32_t flags,
const DATA_BLOB *pkt);
#endif /* __DEFAULT_LIBRPC_RPCCOMMON_H__ */

View File

@ -743,45 +743,6 @@ _PUBLIC_ NTSTATUS dcerpc_fetch_session_key(struct dcerpc_pipe *p,
return NT_STATUS_OK;
}
/*
log a rpc packet in a format suitable for ndrdump. This is especially useful
for sealed packets, where ethereal cannot easily see the contents
this triggers on a debug level of >= 10
*/
_PUBLIC_ void dcerpc_log_packet(const char *lockdir,
const struct ndr_interface_table *ndr,
uint32_t opnum, uint32_t flags,
const DATA_BLOB *pkt)
{
const int num_examples = 20;
int i;
if (lockdir == NULL) return;
for (i=0;i<num_examples;i++) {
char *name=NULL;
int ret;
ret = asprintf(&name, "%s/rpclog/%s-%u.%d.%s",
lockdir, ndr->name, opnum, i,
(flags&NDR_IN)?"in":"out");
if (ret == -1) {
return;
}
if (!file_exist(name)) {
if (file_save(name, pkt->data, pkt->length)) {
DEBUG(10,("Logged rpc packet to %s\n", name));
}
free(name);
break;
}
free(name);
}
}
/*
create a secondary context from a primary connection