mirror of
https://github.com/samba-team/samba.git
synced 2025-03-27 22:50:26 +03:00
librpc/rpc: add dcerpc_[extract|construct]_bind_time_features()
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Guenther Deschner <gd@samba.org>
This commit is contained in:
parent
18dce19ef9
commit
e1498ac674
@ -652,3 +652,66 @@ bool dcerpc_sec_verification_trailer_check(
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static const struct ndr_syntax_id dcerpc_bind_time_features_prefix = {
|
||||
.uuid = {
|
||||
.time_low = 0x6cb71c2c,
|
||||
.time_mid = 0x9812,
|
||||
.time_hi_and_version = 0x4540,
|
||||
.clock_seq = {0x00, 0x00},
|
||||
.node = {0x00,0x00,0x00,0x00,0x00,0x00}
|
||||
},
|
||||
.if_version = 1,
|
||||
};
|
||||
|
||||
bool dcerpc_extract_bind_time_features(struct ndr_syntax_id s, uint64_t *_features)
|
||||
{
|
||||
uint8_t values[8];
|
||||
uint64_t features = 0;
|
||||
|
||||
values[0] = s.uuid.clock_seq[0];
|
||||
values[1] = s.uuid.clock_seq[1];
|
||||
values[2] = s.uuid.node[0];
|
||||
values[3] = s.uuid.node[1];
|
||||
values[4] = s.uuid.node[2];
|
||||
values[5] = s.uuid.node[3];
|
||||
values[6] = s.uuid.node[4];
|
||||
values[7] = s.uuid.node[5];
|
||||
|
||||
ZERO_STRUCT(s.uuid.clock_seq);
|
||||
ZERO_STRUCT(s.uuid.node);
|
||||
|
||||
if (!ndr_syntax_id_equal(&s, &dcerpc_bind_time_features_prefix)) {
|
||||
if (_features != NULL) {
|
||||
*_features = 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
features = BVAL(values, 0);
|
||||
|
||||
if (_features != NULL) {
|
||||
*_features = features;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
struct ndr_syntax_id dcerpc_construct_bind_time_features(uint64_t features)
|
||||
{
|
||||
struct ndr_syntax_id s = dcerpc_bind_time_features_prefix;
|
||||
uint8_t values[8];
|
||||
|
||||
SBVAL(values, 0, features);
|
||||
|
||||
s.uuid.clock_seq[0] = values[0];
|
||||
s.uuid.clock_seq[1] = values[1];
|
||||
s.uuid.node[0] = values[2];
|
||||
s.uuid.node[1] = values[3];
|
||||
s.uuid.node[2] = values[4];
|
||||
s.uuid.node[3] = values[5];
|
||||
s.uuid.node[4] = values[6];
|
||||
s.uuid.node[5] = values[7];
|
||||
|
||||
return s;
|
||||
}
|
||||
|
@ -373,6 +373,36 @@ bool dcerpc_sec_verification_trailer_check(
|
||||
const struct dcerpc_sec_vt_pcontext *pcontext,
|
||||
const struct dcerpc_sec_vt_header2 *header2);
|
||||
|
||||
/**
|
||||
* @brief check and optionally extract the Bind Time Features from
|
||||
* the given ndr_syntax_id.
|
||||
*
|
||||
* <a href="http://msdn.microsoft.com/en-us/library/cc243715.aspx">MS-RPCE 3.3.1.5.3 Bind Time Feature Negotiation</a>.
|
||||
*
|
||||
* @param[in] s the syntax that should be checked.
|
||||
*
|
||||
* @param[out] features This is optional, it will be filled with the extracted
|
||||
* features the on success, otherwise it's filled with 0.
|
||||
*
|
||||
* @return true if the syntax matches the 6CB71C2C-9812-4540 prefix with version 1, false otherwise.
|
||||
*
|
||||
* @see dcerpc_construct_bind_time_features
|
||||
*/
|
||||
bool dcerpc_extract_bind_time_features(struct ndr_syntax_id syntax, uint64_t *features);
|
||||
|
||||
/**
|
||||
* @brief Construct a ndr_syntax_id used for Bind Time Features Negotiation.
|
||||
*
|
||||
* <a href="http://msdn.microsoft.com/en-us/library/cc243715.aspx">MS-RPCE 3.3.1.5.3 Bind Time Feature Negotiation</a>.
|
||||
*
|
||||
* @param[in] features The supported features.
|
||||
*
|
||||
* @return The ndr_syntax_id with the given features.
|
||||
*
|
||||
* @see dcerpc_extract_bind_time_features
|
||||
*/
|
||||
struct ndr_syntax_id dcerpc_construct_bind_time_features(uint64_t features);
|
||||
|
||||
#define DCERPC_AUTH_PAD_LENGTH(stub_length) (\
|
||||
(((stub_length) % DCERPC_AUTH_PAD_ALIGNMENT) > 0)?\
|
||||
(DCERPC_AUTH_PAD_ALIGNMENT - (stub_length) % DCERPC_AUTH_PAD_ALIGNMENT):\
|
||||
|
Loading…
x
Reference in New Issue
Block a user