* Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
* Copyright (C) Paul Ashton 1997.
* Copyright (C) Jeremy Allison 1999.
+ * Copyright (C) Simo Sorce 2010
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*/
#include "includes.h"
+#include "librpc/gen_ndr/ndr_dcerpc.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_PARSE
Inits an RPC_HDR structure.
********************************************************************/
-void init_rpc_hdr(RPC_HDR *hdr, enum RPC_PKT_TYPE pkt_type, uint8 flags,
+void init_rpc_hdr(RPC_HDR *hdr, enum dcerpc_pkt_type pkt_type, uint8 flags,
uint32 call_id, int data_len, int auth_len)
{
hdr->major = 5; /* RPC version 5 */
}
/*******************************************************************
- Inits an RPC_CONTEXT structure.
- Note the transfer pointer must remain valid until this is marshalled.
+ Reads or writes a struct dcerpc_ctx_list structure.
********************************************************************/
-void init_rpc_context(RPC_CONTEXT *rpc_ctx, uint16 context_id,
- const struct ndr_syntax_id *abstract,
- const struct ndr_syntax_id *transfer)
-{
- rpc_ctx->context_id = context_id ; /* presentation context identifier (0x0) */
- rpc_ctx->num_transfer_syntaxes = 1 ; /* the number of syntaxes (has always been 1?)(0x1) */
-
- /* num and vers. of interface client is using */
- rpc_ctx->abstract = *abstract;
-
- /* vers. of interface to use for replies */
- rpc_ctx->transfer = CONST_DISCARD(struct ndr_syntax_id *, transfer);
-}
-
-/*******************************************************************
- Inits an RPC_HDR_RB structure.
- Note the context pointer must remain valid until this is marshalled.
-********************************************************************/
-
-void init_rpc_hdr_rb(RPC_HDR_RB *rpc,
- uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid,
- RPC_CONTEXT *context)
-{
- init_rpc_hdr_bba(&rpc->bba, max_tsize, max_rsize, assoc_gid);
-
- rpc->num_contexts = 1;
- rpc->rpc_context = context;
-}
-
-/*******************************************************************
- Reads or writes an RPC_CONTEXT structure.
-********************************************************************/
-
-bool smb_io_rpc_context(const char *desc, RPC_CONTEXT *rpc_ctx, prs_struct *ps, int depth)
+bool smb_io_rpc_context(const char *desc, struct dcerpc_ctx_list *rpc_ctx, prs_struct *ps, int depth)
{
int i;
if (rpc_ctx->num_transfer_syntaxes == 0)
return False;
- if(!smb_io_rpc_iface("", &rpc_ctx->abstract, ps, depth))
+ if(!smb_io_rpc_iface("", &rpc_ctx->abstract_syntax, ps, depth))
return False;
if (UNMARSHALLING(ps)) {
- if (!(rpc_ctx->transfer = PRS_ALLOC_MEM(ps, struct ndr_syntax_id, rpc_ctx->num_transfer_syntaxes))) {
+ rpc_ctx->transfer_syntaxes =
+ PRS_ALLOC_MEM(ps, struct ndr_syntax_id,
+ rpc_ctx->num_transfer_syntaxes);
+ if (!rpc_ctx->transfer_syntaxes) {
return False;
}
}
for (i = 0; i < rpc_ctx->num_transfer_syntaxes; i++ ) {
- if (!smb_io_rpc_iface("", &rpc_ctx->transfer[i], ps, depth))
+ if (!smb_io_rpc_iface("", &rpc_ctx->transfer_syntaxes[i], ps, depth))
return False;
}
return True;
}
+NTSTATUS dcerpc_pull_dcerpc_bind(TALLOC_CTX *mem_ctx,
+ const DATA_BLOB *blob,
+ struct dcerpc_bind *r)
+{
+ enum ndr_err_code ndr_err;
+
+ ndr_err = ndr_pull_struct_blob(blob, mem_ctx, r,
+ (ndr_pull_flags_fn_t)ndr_pull_dcerpc_bind);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return ndr_map_error2ntstatus(ndr_err);
+ }
+
+ return NT_STATUS_OK;
+}
+
/*******************************************************************
Reads or writes an RPC_HDR_RB structure.
********************************************************************/
return False;
if (UNMARSHALLING(ps)) {
- if (!(rpc->rpc_context = PRS_ALLOC_MEM(ps, RPC_CONTEXT, rpc->num_contexts))) {
+ if (!(rpc->rpc_context = PRS_ALLOC_MEM(ps, struct dcerpc_ctx_list, rpc->num_contexts))) {
return False;
}
}
uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid,
const char *pipe_addr,
uint8 num_results, uint16 result, uint16 reason,
- struct ndr_syntax_id *transfer)
+ const struct ndr_syntax_id *transfer)
{
init_rpc_hdr_bba (&rpc->bba, max_tsize, max_rsize, assoc_gid);
init_rpc_addr_str(&rpc->addr, pipe_addr);
return True;
}
-/*******************************************************************
- Reads or writes an RPC_HDR_FAULT structure.
-********************************************************************/
-
-bool smb_io_rpc_hdr_fault(const char *desc, RPC_HDR_FAULT *rpc, prs_struct *ps, int depth)
-{
- if (rpc == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "smb_io_rpc_hdr_fault");
- depth++;
-
- if(!prs_dcerpc_status("status ", ps, depth, &rpc->status))
- return False;
- if(!prs_uint32("reserved", ps, depth, &rpc->reserved))
- return False;
-
- return True;
-}
-
/*******************************************************************
Inits an RPC_HDR_AUTH structure.
********************************************************************/
/*******************************************************************
Reads or writes an RPC_HDR_AUTH structure.
+ NB This writes UNALIGNED. Ensure you're correctly aligned before
+ calling.
********************************************************************/
bool smb_io_rpc_hdr_auth(const char *desc, RPC_HDR_AUTH *rai, prs_struct *ps, int depth)
prs_debug(ps, depth, desc, "smb_io_rpc_hdr_auth");
depth++;
- if(!prs_align(ps))
- return False;
-
if(!prs_uint8 ("auth_type ", ps, depth, &rai->auth_type))
return False;
if(!prs_uint8 ("auth_level ", ps, depth, &rai->auth_level))
return True;
}
-
-/*******************************************************************
- Checks an RPC_AUTH_VERIFIER structure.
-********************************************************************/
-
-bool rpc_auth_verifier_chk(RPC_AUTH_VERIFIER *rav,
- const char *signature, uint32 msg_type)
-{
- return (strequal(rav->signature, signature) && rav->msg_type == msg_type);
-}
-
-/*******************************************************************
- Inits an RPC_AUTH_VERIFIER structure.
-********************************************************************/
-
-void init_rpc_auth_verifier(RPC_AUTH_VERIFIER *rav,
- const char *signature, uint32 msg_type)
-{
- fstrcpy(rav->signature, signature); /* "NTLMSSP" */
- rav->msg_type = msg_type; /* NTLMSSP_MESSAGE_TYPE */
-}
-
-/*******************************************************************
- Reads or writes an RPC_AUTH_VERIFIER structure.
-********************************************************************/
-
-bool smb_io_rpc_auth_verifier(const char *desc, RPC_AUTH_VERIFIER *rav, prs_struct *ps, int depth)
-{
- if (rav == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "smb_io_rpc_auth_verifier");
- depth++;
-
- /* "NTLMSSP" */
- if(!prs_string("signature", ps, depth, rav->signature,
- sizeof(rav->signature)))
- return False;
- if(!prs_uint32("msg_type ", ps, depth, &rav->msg_type)) /* NTLMSSP_MESSAGE_TYPE */
- return False;
-
- return True;
-}
-
-/*******************************************************************
- This parses an RPC_AUTH_VERIFIER for schannel. I think
-********************************************************************/
-
-bool smb_io_rpc_schannel_verifier(const char *desc, RPC_AUTH_VERIFIER *rav, prs_struct *ps, int depth)
-{
- if (rav == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "smb_io_rpc_schannel_verifier");
- depth++;
-
- if(!prs_string("signature", ps, depth, rav->signature, sizeof(rav->signature)))
- return False;
- if(!prs_uint32("msg_type ", ps, depth, &rav->msg_type))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-creates an RPC_AUTH_SCHANNEL_NEG structure.
-********************************************************************/
-
-void init_rpc_auth_schannel_neg(RPC_AUTH_SCHANNEL_NEG *neg,
- const char *domain, const char *myname)
-{
- neg->type1 = 0;
- neg->type2 = 0x3;
- fstrcpy(neg->domain, domain);
- fstrcpy(neg->myname, myname);
-}
-
-/*******************************************************************
- Reads or writes an RPC_AUTH_SCHANNEL_NEG structure.
-********************************************************************/
-
-bool smb_io_rpc_auth_schannel_neg(const char *desc, RPC_AUTH_SCHANNEL_NEG *neg,
- prs_struct *ps, int depth)
-{
- if (neg == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "smb_io_rpc_auth_schannel_neg");
- depth++;
-
- if(!prs_align(ps))
- return False;
-
- if(!prs_uint32("type1", ps, depth, &neg->type1))
- return False;
- if(!prs_uint32("type2", ps, depth, &neg->type2))
- return False;
- if(!prs_string("domain ", ps, depth, neg->domain, sizeof(neg->domain)))
- return False;
- if(!prs_string("myname ", ps, depth, neg->myname, sizeof(neg->myname)))
- return False;
-
- return True;
-}
-
-/*******************************************************************
-reads or writes an RPC_AUTH_SCHANNEL_CHK structure.
-********************************************************************/
-
-bool smb_io_rpc_auth_schannel_chk(const char *desc, int auth_len,
- RPC_AUTH_SCHANNEL_CHK * chk,
- prs_struct *ps, int depth)
-{
- if (chk == NULL)
- return False;
-
- prs_debug(ps, depth, desc, "smb_io_rpc_auth_schannel_chk");
- depth++;
-
- if ( !prs_uint8s(False, "sig ", ps, depth, chk->sig, sizeof(chk->sig)) )
- return False;
-
- if ( !prs_uint8s(False, "seq_num", ps, depth, chk->seq_num, sizeof(chk->seq_num)) )
- return False;
-
- if ( !prs_uint8s(False, "packet_digest", ps, depth, chk->packet_digest, sizeof(chk->packet_digest)) )
- return False;
-
- if ( auth_len == RPC_AUTH_SCHANNEL_SIGN_OR_SEAL_CHK_LEN ) {
- if ( !prs_uint8s(False, "confounder", ps, depth, chk->confounder, sizeof(chk->confounder)) )
- return False;
- }
-
- return True;
-}