1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-26 21:57:41 +03:00

librpc/rpc: remove dcerpc_binding->localaddress and store it in the options array

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
This commit is contained in:
Stefan Metzmacher 2014-01-23 09:45:47 +01:00 committed by Günther Deschner
parent c327a60a02
commit afcd5506c9
3 changed files with 5 additions and 52 deletions

View File

@ -90,7 +90,6 @@ static const struct {
{"bigendian", DCERPC_PUSH_BIGENDIAN},
{"smb2", DCERPC_SMB2},
{"ndr64", DCERPC_NDR64},
{"localaddress", DCERPC_LOCALADDRESS}
};
const char *epm_floor_string(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor)
@ -244,12 +243,7 @@ _PUBLIC_ char *dcerpc_binding_string(TALLOC_CTX *mem_ctx, const struct dcerpc_bi
}
o = s;
if (ncacn_options[i].flag == DCERPC_LOCALADDRESS && b->localaddress) {
s = talloc_asprintf_append_buffer(s, ",%s=%s", ncacn_options[i].name,
b->localaddress);
} else {
s = talloc_asprintf_append_buffer(s, ",%s", ncacn_options[i].name);
}
s = talloc_asprintf_append_buffer(s, ",%s", ncacn_options[i].name);
if (s == NULL) {
talloc_free(o);
return NULL;
@ -358,7 +352,6 @@ _PUBLIC_ NTSTATUS dcerpc_parse_binding(TALLOC_CTX *mem_ctx, const char *s, struc
b->flags = 0;
b->assoc_group_id = 0;
b->endpoint = NULL;
b->localaddress = NULL;
if (!options) {
*b_out = b;
@ -396,9 +389,7 @@ _PUBLIC_ NTSTATUS dcerpc_parse_binding(TALLOC_CTX *mem_ctx, const char *s, struc
int k;
char c = b->options[i][opt_len];
if (ncacn_options[j].flag == DCERPC_LOCALADDRESS && c == '=') {
b->localaddress = talloc_strdup(b, &b->options[i][opt_len+1]);
} else if (c != 0) {
if (c != 0) {
continue;
}
@ -441,11 +432,6 @@ _PUBLIC_ const char *dcerpc_binding_get_string_option(const struct dcerpc_bindin
size_t i;
int ret;
ret = strcmp(name, "localaddress");
if (ret == 0) {
return b->localaddress;
}
if (b->options == NULL) {
return NULL;
}
@ -508,28 +494,6 @@ _PUBLIC_ NTSTATUS dcerpc_binding_set_string_option(struct dcerpc_binding *b,
* value != NULL means add or reset.
*/
ret = strcmp(name, "localaddress");
if (ret == 0) {
tmp = discard_const_p(char, b->localaddress);
if (value == NULL) {
talloc_free(tmp);
b->localaddress = NULL;
b->flags &= ~DCERPC_LOCALADDRESS;
return NT_STATUS_OK;
}
b->localaddress = talloc_strdup(b, value);
if (b->localaddress == NULL) {
b->localaddress = tmp;
return NT_STATUS_NO_MEMORY;
}
talloc_free(tmp);
b->flags |= DCERPC_LOCALADDRESS;
return NT_STATUS_OK;
}
for (i=0; b->options && b->options[i]; i++) {
const char *o = b->options[i];
@ -1001,14 +965,6 @@ _PUBLIC_ struct dcerpc_binding *dcerpc_binding_dup(TALLOC_CTX *mem_ctx,
}
}
if (b->localaddress != NULL) {
n->localaddress = talloc_strdup(n, b->localaddress);
if (n->localaddress == NULL) {
talloc_free(n);
return NULL;
}
}
if (b->endpoint != NULL) {
n->endpoint = talloc_strdup(n, b->endpoint);
if (n->endpoint == NULL) {

View File

@ -48,7 +48,6 @@ struct dcerpc_binding {
const char *target_principal;
const char *endpoint;
const char **options;
const char *localaddress;
uint32_t flags;
uint32_t assoc_group_id;
};
@ -104,9 +103,6 @@ struct dcerpc_binding {
/* use NDR64 transport */
#define DCERPC_NDR64 (1<<21)
/* specify binding interface */
#define DCERPC_LOCALADDRESS (1<<22)
/* handle upgrades or downgrades automatically */
#define DCERPC_SCHANNEL_AUTO (1<<23)

View File

@ -131,8 +131,9 @@ static bool test_parse_check_results(struct torture_context *tctx)
"308FB580-1EB2-11CA-923B-08002B1075A7@ncacn_ip_tcp:$SERVER", &b), "parse");
torture_assert_ntstatus_ok(tctx, dcerpc_parse_binding(tctx, "ncacn_ip_tcp:$SERVER[,sign,localaddress=192.168.1.1]", &b), "parse");
torture_assert(tctx, b->transport == NCACN_IP_TCP, "ncacn_ip_tcp expected");
torture_assert(tctx, b->flags == (DCERPC_SIGN | DCERPC_LOCALADDRESS), "sign flag");
torture_assert_str_equal(tctx, b->localaddress, "192.168.1.1", "localaddress");
torture_assert(tctx, b->flags == DCERPC_SIGN, "sign flag");
torture_assert_str_equal(tctx, dcerpc_binding_get_string_option(b, "localaddress"),
"192.168.1.1", "localaddress");
torture_assert_str_equal(tctx, "ncacn_ip_tcp:$SERVER[,sign,localaddress=192.168.1.1]",
dcerpc_binding_string(tctx, b), "back to string");