librpc: further fixes for witness.idl.
authorGregor Beck <gbeck@sernet.de>
Tue, 4 Feb 2014 14:43:39 +0000 (15:43 +0100)
committerGünther Deschner <gd@samba.org>
Mon, 13 Apr 2015 11:08:12 +0000 (13:08 +0200)
Signed-off-by: Gregor Beck <gbeck@sernet.de>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
librpc/idl/witness.idl
source3/rpcclient/cmd_witness.c

index cf605366f0a5d4d1ee008b90a8805702cfd9488a..be05cc71c6902de5ca661672ea720a635a3dd251 100644 (file)
@@ -77,11 +77,52 @@ interface witness
                WITNESS_NOTIFY_IP_CHANGE       = 4
        } witness_notifyResponse_type;
 
-       typedef struct {
-               witness_notifyResponse_type message_type;
-               uint32 length;
-               uint32 num_messages;
-               [size_is(length)] uint8 *message_buffer;
+       typedef [v1_enum] enum {
+               WITNESS_RESOURCE_STATE_UNKNOWN     = 0x00,
+               WITNESS_RESOURCE_STATE_AVAILABLE   = 0x01,
+               WITNESS_RESOURCE_STATE_UNAVAILABLE = 0xff
+       } witness_ResourceChange_type;
+
+       typedef [flag(NDR_NOALIGN|NDR_LITTLE_ENDIAN),gensize,public] struct {
+               [value(ndr_size_witness_ResourceChange(r,ndr->flags))] uint32 length;
+               witness_ResourceChange_type type;
+               nstring name;
+       } witness_ResourceChange;
+
+       typedef [bitmap32bit] bitmap {
+               WITNESS_IPADDR_V4      = 0x01,
+               WITNESS_IPADDR_V6      = 0x02,
+               WITNESS_IPADDR_ONLINE  = 0x08,
+               WITNESS_IPADDR_OFFLINE = 0x10
+       } witness_IPaddrInfo_flags;
+
+       typedef [flag(NDR_NOALIGN|NDR_LITTLE_ENDIAN),gensize] struct {
+               witness_IPaddrInfo_flags flags;
+               ipv4address ipv4;
+               ipv6address ipv6;
+       } witness_IPaddrInfo;
+
+       typedef [flag(NDR_NOALIGN|NDR_LITTLE_ENDIAN)] struct {
+               [value(r->num*ndr_size_witness_IPaddrInfo(r->addr, ndr->flags))] uint32 length;
+               [value(0)] uint32 reserved;
+               uint32 num;
+               witness_IPaddrInfo addr[num];
+       } witness_IPaddrInfoList;
+
+       typedef [public,switch_type(witness_notifyResponse_type),nodiscriminant, flag(NDR_NOALIGN|NDR_LITTLE_ENDIAN)] union {
+               [case(WITNESS_NOTIFY_RESOURCE_CHANGE)] witness_ResourceChange resource_change;
+               [case(WITNESS_NOTIFY_CLIENT_MOVE)]     witness_IPaddrInfoList client_move;
+               [case(WITNESS_NOTIFY_SHARE_MOVE)]      witness_IPaddrInfoList share_move;
+               [case(WITNESS_NOTIFY_IP_CHANGE)]       witness_IPaddrInfoList ip_change;
+       } witness_notifyResponse_message;
+
+       typedef [flag(NDR_PAHEX)] struct {
+               witness_notifyResponse_type type;
+               [value(messages->length)] uint32 length;
+               uint32 num;
+               /* [switch_is(type), size_is(num)] witness_notifyResponse_message *messages; */
+               /* [size_is(length)] uint8 *messages; */
+               [subcontext(4), subcontext_size(length), flag(NDR_REMAINING)] DATA_BLOB *messages;
        } witness_notifyResponse;
 
        WERROR witness_AsyncNotify(
index 1812449c3a01d8c54377ef301947c01198aacde2..315fa50bbe4f2523b48dab6298bdd1623bfa4f08 100644 (file)
@@ -453,7 +453,7 @@ static WERROR cmd_witness_AsyncNotify(struct rpc_pipe_client *cli,
                goto done;
        }
 
-       switch(response->message_type) {
+       switch(response->type) {
        case WITNESS_NOTIFY_RESOURCE_CHANGE:
                d_printf("Resource change");
                read_response = AsyncNotify_Change;
@@ -471,15 +471,15 @@ static WERROR cmd_witness_AsyncNotify(struct rpc_pipe_client *cli,
                read_response = AsyncNotify_Move;
                break;
        default:
-               d_printf("Unknown (0x%x)", (int)response->message_type);
+               d_printf("Unknown (0x%x)", (int)response->type);
        }
-       d_printf(" with %d messages\n", response->num_messages);
+       d_printf(" with %d messages\n", response->num);
 
        if (read_response) {
                unsigned n;
-               const uint8_t *pos = response->message_buffer;
+               const uint8_t *pos = response->messages->data;
 
-               for (n=0; n<response->num_messages; n++) {
+               for (n=0; n<response->num; n++) {
                        read_response(frame, &pos);
                }
        }