diff options
author | Günther Deschner <gd@samba.org> | 2015-06-25 23:12:18 +0200 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2015-07-03 02:00:27 +0200 |
commit | 185896d988a6c720f10e4ae92103c645ea97a012 (patch) | |
tree | 7ca82814921cd6b790e09db92b76fef886f20644 /source3/rpcclient/cmd_witness.c | |
parent | 92709e92507459e70ddbb152da398244866ed33b (diff) | |
download | samba-185896d988a6c720f10e4ae92103c645ea97a012.tar.gz |
s3-rpcclient: remove old extra hand marshalling from witness cmds.
Guenther
Signed-off-by: Günther Deschner <gd@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source3/rpcclient/cmd_witness.c')
-rw-r--r-- | source3/rpcclient/cmd_witness.c | 108 |
1 files changed, 31 insertions, 77 deletions
diff --git a/source3/rpcclient/cmd_witness.c b/source3/rpcclient/cmd_witness.c index bebfb4d084a..bd0372f592b 100644 --- a/source3/rpcclient/cmd_witness.c +++ b/source3/rpcclient/cmd_witness.c @@ -309,73 +309,30 @@ done: return result; } -static bool AsyncNotify_Change(TALLOC_CTX *mem_ctx, const uint8_t **ptr) +static void print_notify_response_resource_change(struct witness_ResourceChange *r) { - const uint8_t *pos = *ptr; - uint32_t length = IVAL(pos,0); - uint32_t type = IVAL(pos,4); - char *name = NULL; const char *type_str; - bool ok; - ok = convert_string_talloc(mem_ctx, CH_UTF16LE, CH_UNIX, pos + 8, - length - 8, &name, NULL); - if (!ok) { - return false; - } - if (type == WITNESS_RESOURCE_STATE_UNKNOWN) { + if (r->type == WITNESS_RESOURCE_STATE_UNKNOWN) { type_str = "Unknown"; - } else if(type == WITNESS_RESOURCE_STATE_AVAILABLE) { + } else if (r->type == WITNESS_RESOURCE_STATE_AVAILABLE) { type_str = "Available\n"; - } else if(type == WITNESS_RESOURCE_STATE_UNAVAILABLE) { + } else if (r->type == WITNESS_RESOURCE_STATE_UNAVAILABLE) { type_str = "Unavailable"; } else { - type_str = talloc_asprintf(name, "Invalid (%u)", type); + type_str = talloc_asprintf(r, "Invalid (%u)", r->type); } - d_printf("%s -> %s\n", name, type_str); - - TALLOC_FREE(name); - *ptr += length; - return true; + d_printf("%s -> %s\n", r->name, type_str); } -/* IPADDR_INFO_LIST */ -static bool AsyncNotify_Move(TALLOC_CTX *mem_ctx, const uint8_t **ptr) +static void print_notify_response_ip_addr_info_list(struct witness_IPaddrInfoList *r) { - const uint8_t *pos = *ptr; - uint32_t length = IVAL(pos,0); - /* uint32_t reserved = IVAL(pos,4); */ - uint32_t num = IVAL(pos,8); - uint32_t n; - - pos += 12; - - for (n=0; n<num; n++) { - uint32_t flags = IVAL(pos,0); - struct in_addr ipv4; - struct sockaddr_storage sas4; - char *str4, *str6; - pos += 4; - - ipv4.s_addr = *((const in_addr_t*)pos); - in_addr_to_sockaddr_storage(&sas4, ipv4); - str4 = print_canonical_sockaddr(mem_ctx, &sas4); - pos += 4; - - { -#ifdef HAVE_IPV6 - struct in6_addr ipv6; - struct sockaddr_storage sas6; - - memcpy(&ipv6.s6_addr, pos, 16); - in6_addr_to_sockaddr_storage(&sas6, ipv6); - str6 = print_canonical_sockaddr(mem_ctx, &sas6); -#else - DATA_BLOB ipv6 = data_blob(pos, 16); - str6 = data_blob_hex_string_upper(mem_ctx, &ipv6); -#endif - } - pos += 16; + int i; + + for (i=0; i < r->num; i++) { + uint32_t flags = r->addr[i].flags; + const char *str4 = r->addr[i].ipv4; + const char *str6 = r->addr[i].ipv6; d_printf("Flags 0x%08x", flags); if (flags & WITNESS_IPADDR_V4) { @@ -391,15 +348,24 @@ static bool AsyncNotify_Move(TALLOC_CTX *mem_ctx, const uint8_t **ptr) d_printf(" Offline"); } d_printf("\n"); - TALLOC_FREE(str4); - TALLOC_FREE(str6); } +} - if (pos - *ptr == length) { - *ptr = pos; - return true; +static void print_notify_response(union witness_notifyResponse_message *r, + uint32_t type) +{ + switch (type) { + case WITNESS_NOTIFY_RESOURCE_CHANGE: + print_notify_response_resource_change(&r->resource_change); + break; + case WITNESS_NOTIFY_CLIENT_MOVE: + case WITNESS_NOTIFY_SHARE_MOVE: + case WITNESS_NOTIFY_IP_CHANGE: + print_notify_response_ip_addr_info_list(&r->client_move); + break; + default: + break; } - return false; } static WERROR cmd_witness_AsyncNotify(struct rpc_pipe_client *cli, @@ -412,7 +378,7 @@ static WERROR cmd_witness_AsyncNotify(struct rpc_pipe_client *cli, struct policy_handle hnd; struct witness_notifyResponse *response = NULL; uint32_t timeout; - bool (*read_response)(TALLOC_CTX*, const uint8_t**) = NULL; + int i; use_only_one_rpc_pipe_hack(cli); @@ -443,36 +409,24 @@ static WERROR cmd_witness_AsyncNotify(struct rpc_pipe_client *cli, switch(response->type) { case WITNESS_NOTIFY_RESOURCE_CHANGE: d_printf("Resource change"); - read_response = AsyncNotify_Change; break; case WITNESS_NOTIFY_CLIENT_MOVE: d_printf("Client move"); - read_response = AsyncNotify_Move; break; case WITNESS_NOTIFY_SHARE_MOVE: d_printf("Share move"); - read_response = AsyncNotify_Move; break; case WITNESS_NOTIFY_IP_CHANGE: d_printf("IP change"); - read_response = AsyncNotify_Move; break; default: d_printf("Unknown (0x%x)", (int)response->type); } d_printf(" with %d messages\n", response->num); -#if 0 - if (read_response) { - unsigned n; - const uint8_t *pos = response->messages->data; - - for (n=0; n<response->num; n++) { - read_response(frame, &pos); - } + for (i=0; i < response->num; i++) { + print_notify_response(&response->messages[i], response->type); } -#endif - done: talloc_free(frame); return result; |