epan/dissectors/pidl/witness/witness.cnf nicer + regen ws-metze/20231214
authorStefan Metzmacher <metze@samba.org>
Wed, 13 Dec 2023 10:44:40 +0000 (11:44 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 14 Dec 2023 14:26:50 +0000 (15:26 +0100)
epan/dissectors/packet-dcerpc-witness.c
epan/dissectors/pidl/witness/witness.cnf

index 2079554eaf3e53c04c7d09a3fe2e4c8a838943be..23c0d451c87b204cdbeb931fdb01d14cdfe8bcbe 100644 (file)
@@ -213,6 +213,43 @@ static int witness_dissect_element_RegisterEx_client_computer_name_(tvbuff_t *tv
 static int witness_dissect_element_RegisterEx_flags(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_);
 static int witness_dissect_element_RegisterEx_timeout(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_);
  #include "to_str.h"
+ #include "wsutil/str_util.h"
+static int
+witness_dissect_element_ResourceChange_type(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
+{
+       proto_item *item = NULL;
+       const char *s = NULL;
+       int levels = 2;
+       guint32 type = 0;
+       static const value_string type_vals[] = {
+               { WITNESS_RESOURCE_STATE_UNKNOWN, "RESOURCE_STATE_UNKNOWN" },
+               { WITNESS_RESOURCE_STATE_AVAILABLE, "RESOURCE_AVAILABLE" },
+               { WITNESS_RESOURCE_STATE_UNAVAILABLE, "RESOURCE_UNAVAILABLE" },
+               { 0, NULL }
+       };
+       offset = witness_dissect_enum_ResourceChange_type(tvb, offset, pinfo, tree, di, drep, hf_witness_witness_ResourceChange_type, &type);
+       s = val_to_str_wmem(pinfo->pool, type, VALS(type_vals), "unknown type: 0x%x");
+       if (di->conformant_run == 0) {
+               col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", s);
+       }
+       if (tree != NULL) {
+               item = tree->last_child;
+       }
+       item = proto_item_get_parent(item);
+       while (item && levels > 0) {
+               proto_item_append_text(item, " %s", s);
+               item = proto_item_get_parent(item);
+               levels--;
+       }
+       return offset;
+}
+static int
+witness_dissect_element_ResourceChange_name(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
+{
+       gint options = CB_STR_COL_INFO | CB_STR_ITEM_LEVELS(2);
+       offset = dissect_null_term_wstring(tvb, offset, pinfo, tree, drep, hf_witness_witness_ResourceChange_name, options);
+       return offset;
+}
 static int
 witness_dissect_notifyResponse_message(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *parent_tree _U_, dcerpc_info* di _U_, guint8 *drep _U_, int hf_index _U_, guint32 param _U_);
 struct witness_dissect_notifyResponse_message_state {
@@ -273,6 +310,7 @@ witness_dissect_struct_notifyResponse(tvbuff_t *tvb _U_, int offset _U_, packet_
        proto_tree *tree = NULL;
        int old_offset;
        struct witness_dissect_notifyResponse_message_state *state = NULL;
+       const char *type_name = "UNKNOWN";
        ALIGN_TO_4_BYTES;
        old_offset = offset;
        if (parent_tree) {
@@ -285,6 +323,49 @@ witness_dissect_struct_notifyResponse(tvbuff_t *tvb _U_, int offset _U_, packet_
        offset = witness_dissect_element_notifyResponse_type(tvb, offset, pinfo, tree, di, drep, &state->type);
        offset = witness_dissect_element_notifyResponse_length(tvb, offset, pinfo, tree, di, drep);
        offset = witness_dissect_element_notifyResponse_num(tvb, offset, pinfo, tree, di, drep, &state->num);
+       switch(state->type) {
+       case WITNESS_NOTIFY_RESOURCE_CHANGE:
+               type_name = "RESOURCE_CHANGE";
+               break;
+       case WITNESS_NOTIFY_CLIENT_MOVE:
+               type_name = "CLIENT_MOVE";
+               break;
+       case WITNESS_NOTIFY_SHARE_MOVE:
+               type_name = "SHARE_MOVE";
+               break;
+       case WITNESS_NOTIFY_IP_CHANGE:
+               type_name = "IP_CHANGE";
+               break;
+       }
+       if (item) {
+               proto_item_append_text(item,
+                                      " %s (%u message%s)",
+                                      type_name,
+                                      state->num,
+                                      plurality(state->num, "", "s"));
+               proto_item_append_text(proto_item_get_parent_nth(item, 1),
+                                      " %s (%u message%s)",
+                                      type_name,
+                                      state->num,
+                                      plurality(state->num, "", "s"));
+               proto_item_append_text(proto_item_get_parent_nth(item, 2),
+                                      " %s (%u message%s)",
+                                      type_name,
+                                      state->num,
+                                      plurality(state->num, "", "s"));
+               proto_item_append_text(proto_item_get_parent_nth(item, 3),
+                                      " %s (%u message%s)",
+                                      type_name,
+                                      state->num,
+                                      plurality(state->num, "", "s"));
+       }
+       if (di->conformant_run == 0) {
+               col_append_fstr(pinfo->cinfo, COL_INFO,
+                               " %s (%u message%s)",
+                               type_name,
+                               state->num,
+                               plurality(state->num, "", "s"));
+       }
        di->private_data = state;
        offset = dissect_ndr_embedded_pointer(tvb, offset, pinfo, tree, di, drep,
                                              witness_dissect_element_notifyResponse_messages,
@@ -402,8 +483,10 @@ PIDL_dissect_ipv4address(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tr
        if (param & PIDL_SET_COL_INFO) {
                const char *ip = tvb_ip_to_str(pinfo->pool, tvb, offset);
                header_field_info *hf_info = proto_registrar_get_nth(hfindex);
-               proto_item_append_text(proto_tree_get_parent(tree), " %s:%s", hf_info->name, ip);
-               col_append_fstr(pinfo->cinfo, COL_INFO," %s:%s", hf_info->name, ip);
+               if (strcmp(ip, "0.0.0.0") != 0) {
+                       proto_item_append_text(proto_tree_get_parent(tree), " %s:%s", hf_info->name, ip);
+                       col_append_fstr(pinfo->cinfo, COL_INFO," %s:%s", hf_info->name, ip);
+               }
        }
        return offset + 4;
 }
@@ -421,43 +504,28 @@ PIDL_dissect_ipv6address(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tr
        if (param & PIDL_SET_COL_INFO) {
                const char *ip = tvb_ip6_to_str(pinfo->pool, tvb, offset);
                header_field_info *hf_info = proto_registrar_get_nth(hfindex);
-               proto_item_append_text(proto_tree_get_parent(tree), " %s:%s", hf_info->name, ip);
-               col_append_fstr(pinfo->cinfo, COL_INFO," %s:%s", hf_info->name, ip);
+               if (strcmp(ip, "::") != 0) {
+                       proto_item_append_text(proto_tree_get_parent(tree), " %s:%s", hf_info->name, ip);
+                       col_append_fstr(pinfo->cinfo, COL_INFO," %s:%s", hf_info->name, ip);
+               }
        }
        return offset + 16;
 }
-
-
-/* IDL: enum { */
-/* IDL:        WITNESS_V1=0x00010001, */
-/* IDL:        WITNESS_V2=0x00020000, */
-/* IDL:        WITNESS_UNSPECIFIED_VERSION=0xFFFFFFFF, */
-/* IDL: } */
-
-int
-witness_dissect_enum_version(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_, int hf_index _U_, guint32 *param _U_)
-{
-       guint32 parameter=0;
-       if (param) {
-               parameter = *param;
-       }
-       offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep, hf_index, &parameter);
-       if (param) {
-               *param = parameter;
-       }
-       return offset;
-}
-
-
 /* IDL: enum { */
 /* IDL:        WITNESS_STATE_UNKNOWN=0x00, */
 /* IDL:        WITNESS_STATE_AVAILABLE=0x01, */
 /* IDL:        WITNESS_STATE_UNAVAILABLE=0xff, */
 /* IDL: } */
-
 int
 witness_dissect_enum_interfaceInfo_state(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_, int hf_index _U_, guint16 *param _U_)
 {
+       static const value_string state_vals[] = {
+               { WITNESS_STATE_UNKNOWN, "STATE_UNKNOWN" },
+               { WITNESS_STATE_AVAILABLE, "AVAILABLE" },
+               { WITNESS_STATE_UNAVAILABLE, "UNAVAILABLE" },
+               { 0, NULL }
+       };
+       const char *s = NULL;
        guint16 parameter=0;
        if (param) {
                parameter = *param;
@@ -466,16 +534,18 @@ witness_dissect_enum_interfaceInfo_state(tvbuff_t *tvb _U_, int offset _U_, pack
        if (param) {
                *param = parameter;
        }
+       s = val_to_str_wmem(pinfo->pool, parameter, VALS(state_vals), "unknown state: 0x%x");
+       proto_item_append_text(proto_tree_get_parent(tree), " %s:", s);
+       if (di->conformant_run == 0) {
+               col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", s);
+       }
        return offset;
 }
-
-
 /* IDL: bitmap { */
 /* IDL:        WITNESS_INFO_IPv4_VALID =  0x01 , */
 /* IDL:        WITNESS_INFO_IPv6_VALID =  0x02 , */
 /* IDL:        WITNESS_INFO_WITNESS_IF =  0x04 , */
 /* IDL: } */
-
 int
 witness_dissect_bitmap_interfaceInfo_flags(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *parent_tree _U_, dcerpc_info* di _U_, guint8 *drep _U_, int hf_index _U_, guint32 param _U_)
 {
@@ -488,24 +558,128 @@ witness_dissect_bitmap_interfaceInfo_flags(tvbuff_t *tvb _U_, int offset _U_, pa
        };
        guint32 flags;
        ALIGN_TO_4_BYTES;
-
        item = proto_tree_add_bitmask_with_flags(parent_tree, tvb, offset, hf_index,
                                ett_witness_witness_interfaceInfo_flags, witness_witness_interfaceInfo_flags_fields, DREP_ENC_INTEGER(drep), BMT_NO_FALSE);
-
        offset = dissect_ndr_uint32(tvb, offset, pinfo, parent_tree, di, drep, -1, &flags);
-
        if (!flags)
                proto_item_append_text(item, ": (No values set)");
-
        if (flags & (~0x00000007)) {
                flags &= (~0x00000007);
                proto_item_append_text(item, "Unknown bitmap value 0x%x", flags);
        }
+       if (flags & 0x4) {
+               proto_item_append_text(proto_tree_get_parent(parent_tree), " WITNESS_IF");
+               col_append_fstr(pinfo->cinfo, COL_INFO," WITNESS_IF");
+       }
+       return offset;
+}
+static int
+witness_dissect_element_Register_net_name_(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
+{
+       char *data = NULL;
+       struct ndr_generic_array nga = { .is_conformant = FALSE, };
+       offset = dissect_ndr_conformant_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
+       offset = dissect_ndr_varying_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
+       offset = dissect_ndr_generic_array_string(tvb, offset, pinfo, tree, di, drep, sizeof(guint16), hf_witness_witness_Register_net_name, FALSE, &nga, &data);
+       proto_item_append_text(tree, ": %s", data);
+       if (di->conformant_run == 0) {
+               col_append_fstr(pinfo->cinfo, COL_INFO, " NetName[%s]", data);
+       }
+       return offset;
+}
+static int
+witness_dissect_element_Register_ip_address_(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
+{
+       char *data = NULL;
+       struct ndr_generic_array nga = { .is_conformant = FALSE, };
+       offset = dissect_ndr_conformant_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
+       offset = dissect_ndr_varying_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
+       offset = dissect_ndr_generic_array_string(tvb, offset, pinfo, tree, di, drep, sizeof(guint16), hf_witness_witness_Register_ip_address, FALSE, &nga, &data);
+       proto_item_append_text(tree, ": %s", data);
+       if (di->conformant_run == 0) {
+               col_append_fstr(pinfo->cinfo, COL_INFO, " IpAddress[%s]", data);
+       }
+       return offset;
+}
+static int
+witness_dissect_element_RegisterEx_net_name_(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
+{
+       char *data = NULL;
+       struct ndr_generic_array nga = { .is_conformant = FALSE, };
+       offset = dissect_ndr_conformant_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
+       offset = dissect_ndr_varying_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
+       offset = dissect_ndr_generic_array_string(tvb, offset, pinfo, tree, di, drep, sizeof(guint16), hf_witness_witness_RegisterEx_net_name, FALSE, &nga, &data);
+       proto_item_append_text(tree, ": %s", data);
+       if (di->conformant_run == 0) {
+               col_append_fstr(pinfo->cinfo, COL_INFO, " NetName[%s]", data);
+       }
+       return offset;
+}
+static int
+witness_dissect_element_RegisterEx_share_name_(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
+{
+       char *data = NULL;
+       struct ndr_generic_array nga = { .is_conformant = FALSE, };
+       offset = dissect_ndr_conformant_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
+       offset = dissect_ndr_varying_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
+       offset = dissect_ndr_generic_array_string(tvb, offset, pinfo, tree, di, drep, sizeof(guint16), hf_witness_witness_RegisterEx_share_name, FALSE, &nga, &data);
+       proto_item_append_text(tree, ": %s", data);
+       if (di->conformant_run == 0) {
+               col_append_fstr(pinfo->cinfo, COL_INFO, " ShareName[%s]", data);
+       }
+       return offset;
+}
+static int
+witness_dissect_element_RegisterEx_ip_address_(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
+{
+       char *data = NULL;
+       struct ndr_generic_array nga = { .is_conformant = FALSE, };
+       offset = dissect_ndr_conformant_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
+       offset = dissect_ndr_varying_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
+       offset = dissect_ndr_generic_array_string(tvb, offset, pinfo, tree, di, drep, sizeof(guint16), hf_witness_witness_RegisterEx_ip_address, FALSE, &nga, &data);
+       proto_item_append_text(tree, ": %s", data);
+       if (di->conformant_run == 0) {
+               col_append_fstr(pinfo->cinfo, COL_INFO, " IpAddress[%s]", data);
+       }
+       return offset;
+}
+
+
+/* IDL: enum { */
+/* IDL:        WITNESS_V1=0x00010001, */
+/* IDL:        WITNESS_V2=0x00020000, */
+/* IDL:        WITNESS_UNSPECIFIED_VERSION=0xFFFFFFFF, */
+/* IDL: } */
 
+int
+witness_dissect_enum_version(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_, int hf_index _U_, guint32 *param _U_)
+{
+       guint32 parameter=0;
+       if (param) {
+               parameter = *param;
+       }
+       offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep, hf_index, &parameter);
+       if (param) {
+               *param = parameter;
+       }
        return offset;
 }
 
 
+/* IDL: enum { */
+/* IDL:        WITNESS_STATE_UNKNOWN=0x00, */
+/* IDL:        WITNESS_STATE_AVAILABLE=0x01, */
+/* IDL:        WITNESS_STATE_UNAVAILABLE=0xff, */
+/* IDL: } */
+
+
+/* IDL: bitmap { */
+/* IDL:        WITNESS_INFO_IPv4_VALID =  0x01 , */
+/* IDL:        WITNESS_INFO_IPv6_VALID =  0x02 , */
+/* IDL:        WITNESS_INFO_WITNESS_IF =  0x04 , */
+/* IDL: } */
+
+
 /* IDL: struct { */
 /* IDL:        [charset(UTF16)] [to_null(1)] uint16 group_name[260]; */
 /* IDL:        witness_version version; */
@@ -725,22 +899,6 @@ witness_dissect_element_ResourceChange_length(tvbuff_t *tvb _U_, int offset _U_,
        return offset;
 }
 
-static int
-witness_dissect_element_ResourceChange_type(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
-{
-       offset = witness_dissect_enum_ResourceChange_type(tvb, offset, pinfo, tree, di, drep, hf_witness_witness_ResourceChange_type, 0);
-
-       return offset;
-}
-
-static int
-witness_dissect_element_ResourceChange_name(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
-{
-       offset = dissect_null_term_wstring(tvb, offset, pinfo, tree, drep, hf_witness_witness_ResourceChange_name , 0);
-
-       return offset;
-}
-
 int
 witness_dissect_struct_ResourceChange(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *parent_tree _U_, dcerpc_info* di _U_, guint8 *drep _U_, int hf_index _U_, guint32 param _U_)
 {
@@ -1121,22 +1279,6 @@ witness_dissect_element_Register_net_name(tvbuff_t *tvb _U_, int offset _U_, pac
        return offset;
 }
 
-static int
-witness_dissect_element_Register_net_name_(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
-{
-       char *data = NULL;
-       struct ndr_generic_array nga = { .is_conformant = FALSE, };
-
-       offset = dissect_ndr_conformant_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
-
-       offset = dissect_ndr_varying_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
-
-       offset = dissect_ndr_generic_array_string(tvb, offset, pinfo, tree, di, drep, sizeof(guint16), hf_witness_witness_Register_net_name, FALSE, &nga, &data);
-       proto_item_append_text(tree, ": %s", data);
-
-       return offset;
-}
-
 static int
 witness_dissect_element_Register_ip_address(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
 {
@@ -1145,22 +1287,6 @@ witness_dissect_element_Register_ip_address(tvbuff_t *tvb _U_, int offset _U_, p
        return offset;
 }
 
-static int
-witness_dissect_element_Register_ip_address_(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
-{
-       char *data = NULL;
-       struct ndr_generic_array nga = { .is_conformant = FALSE, };
-
-       offset = dissect_ndr_conformant_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
-
-       offset = dissect_ndr_varying_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
-
-       offset = dissect_ndr_generic_array_string(tvb, offset, pinfo, tree, di, drep, sizeof(guint16), hf_witness_witness_Register_ip_address, FALSE, &nga, &data);
-       proto_item_append_text(tree, ": %s", data);
-
-       return offset;
-}
-
 static int
 witness_dissect_element_Register_client_computer_name(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
 {
@@ -1355,22 +1481,6 @@ witness_dissect_element_RegisterEx_net_name(tvbuff_t *tvb _U_, int offset _U_, p
        return offset;
 }
 
-static int
-witness_dissect_element_RegisterEx_net_name_(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
-{
-       char *data = NULL;
-       struct ndr_generic_array nga = { .is_conformant = FALSE, };
-
-       offset = dissect_ndr_conformant_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
-
-       offset = dissect_ndr_varying_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
-
-       offset = dissect_ndr_generic_array_string(tvb, offset, pinfo, tree, di, drep, sizeof(guint16), hf_witness_witness_RegisterEx_net_name, FALSE, &nga, &data);
-       proto_item_append_text(tree, ": %s", data);
-
-       return offset;
-}
-
 static int
 witness_dissect_element_RegisterEx_share_name(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
 {
@@ -1379,22 +1489,6 @@ witness_dissect_element_RegisterEx_share_name(tvbuff_t *tvb _U_, int offset _U_,
        return offset;
 }
 
-static int
-witness_dissect_element_RegisterEx_share_name_(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
-{
-       char *data = NULL;
-       struct ndr_generic_array nga = { .is_conformant = FALSE, };
-
-       offset = dissect_ndr_conformant_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
-
-       offset = dissect_ndr_varying_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
-
-       offset = dissect_ndr_generic_array_string(tvb, offset, pinfo, tree, di, drep, sizeof(guint16), hf_witness_witness_RegisterEx_share_name, FALSE, &nga, &data);
-       proto_item_append_text(tree, ": %s", data);
-
-       return offset;
-}
-
 static int
 witness_dissect_element_RegisterEx_ip_address(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
 {
@@ -1403,22 +1497,6 @@ witness_dissect_element_RegisterEx_ip_address(tvbuff_t *tvb _U_, int offset _U_,
        return offset;
 }
 
-static int
-witness_dissect_element_RegisterEx_ip_address_(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
-{
-       char *data = NULL;
-       struct ndr_generic_array nga = { .is_conformant = FALSE, };
-
-       offset = dissect_ndr_conformant_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
-
-       offset = dissect_ndr_varying_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
-
-       offset = dissect_ndr_generic_array_string(tvb, offset, pinfo, tree, di, drep, sizeof(guint16), hf_witness_witness_RegisterEx_ip_address, FALSE, &nga, &data);
-       proto_item_append_text(tree, ": %s", data);
-
-       return offset;
-}
-
 static int
 witness_dissect_element_RegisterEx_client_computer_name(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
 {
index afc555bdfb1ad72f5f9b3ada13c468b219b48d7d..6d818bed34aeee27b82627073bcb8b4db5deb438 100644 (file)
@@ -1,4 +1,6 @@
 NOEMIT witness_dissect_element_interfaceInfo_group_name
+MANUAL witness_dissect_element_ResourceChange_type
+MANUAL witness_dissect_element_ResourceChange_name
 MANUAL witness_dissect_struct_notifyResponse
 NOEMIT witness_dissect_element_notifyResponse_messages
 MANUAL witness_dissect_struct_IPaddrInfoList
@@ -6,9 +8,19 @@ NOEMIT witness_dissect_struct_IPaddrInfoList
 NOEMIT witness_dissect_element_IPaddrInfoList_num
 NOEMIT witness_dissect_element_IPaddrInfoList_addr
 
+MANUAL witness_dissect_enum_interfaceInfo_state
+MANUAL witness_dissect_bitmap_interfaceInfo_flags
+
 NOEMIT witness_dissect_element_notifyResponse_type
 NOEMIT witness_dissect_element_notifyResponse_num
 
+MANUAL witness_dissect_element_Register_net_name_
+MANUAL witness_dissect_element_Register_ip_address_
+
+MANUAL witness_dissect_element_RegisterEx_net_name_
+MANUAL witness_dissect_element_RegisterEx_share_name_
+MANUAL witness_dissect_element_RegisterEx_ip_address_
+
 HF_FIELD hf_witness_witness_notifyResponse_messages_ "Messages" "witness.witness_notifyResponse.messages_" FT_NONE BASE_NONE NULL 0 "" "" ""
 
 TYPE ipv4address "offset=PIDL_dissect_ipv4address(tvb, offset, pinfo, tree, di, drep, @HF@, PIDL_SET_COL_INFO);" FT_IPv4 BASE_NONE 0 NULL 4
@@ -18,6 +30,53 @@ TYPE ipv6address "offset=PIDL_dissect_ipv6address(tvb, offset, pinfo, tree, di,
 CODE START
 
  #include "to_str.h"
+ #include "wsutil/str_util.h"
+
+static int
+witness_dissect_element_ResourceChange_type(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
+{
+       proto_item *item = NULL;
+       const char *s = NULL;
+       int levels = 2;
+       guint32 type = 0;
+       static const value_string type_vals[] = {
+               { WITNESS_RESOURCE_STATE_UNKNOWN, "RESOURCE_STATE_UNKNOWN" },
+               { WITNESS_RESOURCE_STATE_AVAILABLE, "RESOURCE_AVAILABLE" },
+               { WITNESS_RESOURCE_STATE_UNAVAILABLE, "RESOURCE_UNAVAILABLE" },
+               { 0, NULL }
+       };
+
+       offset = witness_dissect_enum_ResourceChange_type(tvb, offset, pinfo, tree, di, drep, hf_witness_witness_ResourceChange_type, &type);
+
+       s = val_to_str_wmem(pinfo->pool, type, VALS(type_vals), "unknown type: 0x%x");
+
+       if (di->conformant_run == 0) {
+               col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", s);
+       }
+
+       if (tree != NULL) {
+               item = tree->last_child;
+       }
+
+       item = proto_item_get_parent(item);
+       while (item && levels > 0) {
+               proto_item_append_text(item, " %s", s);
+               item = proto_item_get_parent(item);
+               levels--;
+       }
+
+       return offset;
+}
+
+static int
+witness_dissect_element_ResourceChange_name(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
+{
+       gint options = CB_STR_COL_INFO | CB_STR_ITEM_LEVELS(2);
+
+       offset = dissect_null_term_wstring(tvb, offset, pinfo, tree, drep, hf_witness_witness_ResourceChange_name, options);
+
+       return offset;
+}
 
 static int
 witness_dissect_notifyResponse_message(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *parent_tree _U_, dcerpc_info* di _U_, guint8 *drep _U_, int hf_index _U_, guint32 param _U_);
@@ -93,6 +152,7 @@ witness_dissect_struct_notifyResponse(tvbuff_t *tvb _U_, int offset _U_, packet_
        proto_tree *tree = NULL;
        int old_offset;
        struct witness_dissect_notifyResponse_message_state *state = NULL;
+       const char *type_name = "UNKNOWN";
 
        ALIGN_TO_4_BYTES;
 
@@ -112,6 +172,54 @@ witness_dissect_struct_notifyResponse(tvbuff_t *tvb _U_, int offset _U_, packet_
 
        offset = witness_dissect_element_notifyResponse_num(tvb, offset, pinfo, tree, di, drep, &state->num);
 
+       switch(state->type) {
+       case WITNESS_NOTIFY_RESOURCE_CHANGE:
+               type_name = "RESOURCE_CHANGE";
+               break;
+
+       case WITNESS_NOTIFY_CLIENT_MOVE:
+               type_name = "CLIENT_MOVE";
+               break;
+
+       case WITNESS_NOTIFY_SHARE_MOVE:
+               type_name = "SHARE_MOVE";
+               break;
+
+       case WITNESS_NOTIFY_IP_CHANGE:
+               type_name = "IP_CHANGE";
+               break;
+       }
+
+       if (item) {
+               proto_item_append_text(item,
+                                      " %s (%u message%s)",
+                                      type_name,
+                                      state->num,
+                                      plurality(state->num, "", "s"));
+               proto_item_append_text(proto_item_get_parent_nth(item, 1),
+                                      " %s (%u message%s)",
+                                      type_name,
+                                      state->num,
+                                      plurality(state->num, "", "s"));
+               proto_item_append_text(proto_item_get_parent_nth(item, 2),
+                                      " %s (%u message%s)",
+                                      type_name,
+                                      state->num,
+                                      plurality(state->num, "", "s"));
+               proto_item_append_text(proto_item_get_parent_nth(item, 3),
+                                      " %s (%u message%s)",
+                                      type_name,
+                                      state->num,
+                                      plurality(state->num, "", "s"));
+       }
+       if (di->conformant_run == 0) {
+               col_append_fstr(pinfo->cinfo, COL_INFO,
+                               " %s (%u message%s)",
+                               type_name,
+                               state->num,
+                               plurality(state->num, "", "s"));
+       }
+
        di->private_data = state;
        offset = dissect_ndr_embedded_pointer(tvb, offset, pinfo, tree, di, drep,
                                              witness_dissect_element_notifyResponse_messages,
@@ -256,9 +364,11 @@ PIDL_dissect_ipv4address(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tr
                const char *ip = tvb_ip_to_str(pinfo->pool, tvb, offset);
                header_field_info *hf_info = proto_registrar_get_nth(hfindex);
 
-               proto_item_append_text(proto_tree_get_parent(tree), " %s:%s", hf_info->name, ip);
+               if (strcmp(ip, "0.0.0.0") != 0) {
+                       proto_item_append_text(proto_tree_get_parent(tree), " %s:%s", hf_info->name, ip);
 
-               col_append_fstr(pinfo->cinfo, COL_INFO," %s:%s", hf_info->name, ip);
+                       col_append_fstr(pinfo->cinfo, COL_INFO," %s:%s", hf_info->name, ip);
+               }
        }
        return offset + 4;
 }
@@ -282,12 +392,185 @@ PIDL_dissect_ipv6address(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tr
                const char *ip = tvb_ip6_to_str(pinfo->pool, tvb, offset);
                header_field_info *hf_info = proto_registrar_get_nth(hfindex);
 
-               proto_item_append_text(proto_tree_get_parent(tree), " %s:%s", hf_info->name, ip);
+               if (strcmp(ip, "::") != 0) {
+                       proto_item_append_text(proto_tree_get_parent(tree), " %s:%s", hf_info->name, ip);
 
-               col_append_fstr(pinfo->cinfo, COL_INFO," %s:%s", hf_info->name, ip);
+                       col_append_fstr(pinfo->cinfo, COL_INFO," %s:%s", hf_info->name, ip);
+               }
        }
 
        return offset + 16;
 }
 
+/* IDL: enum { */
+/* IDL:        WITNESS_STATE_UNKNOWN=0x00, */
+/* IDL:        WITNESS_STATE_AVAILABLE=0x01, */
+/* IDL:        WITNESS_STATE_UNAVAILABLE=0xff, */
+/* IDL: } */
+
+int
+witness_dissect_enum_interfaceInfo_state(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_, int hf_index _U_, guint16 *param _U_)
+{
+       static const value_string state_vals[] = {
+               { WITNESS_STATE_UNKNOWN, "STATE_UNKNOWN" },
+               { WITNESS_STATE_AVAILABLE, "AVAILABLE" },
+               { WITNESS_STATE_UNAVAILABLE, "UNAVAILABLE" },
+               { 0, NULL }
+       };
+       const char *s = NULL;
+       guint16 parameter=0;
+       if (param) {
+               parameter = *param;
+       }
+       offset = dissect_ndr_uint16(tvb, offset, pinfo, tree, di, drep, hf_index, &parameter);
+       if (param) {
+               *param = parameter;
+       }
+
+       s = val_to_str_wmem(pinfo->pool, parameter, VALS(state_vals), "unknown state: 0x%x");
+
+       proto_item_append_text(proto_tree_get_parent(tree), " %s:", s);
+       if (di->conformant_run == 0) {
+               col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", s);
+       }
+
+       return offset;
+}
+
+
+/* IDL: bitmap { */
+/* IDL:        WITNESS_INFO_IPv4_VALID =  0x01 , */
+/* IDL:        WITNESS_INFO_IPv6_VALID =  0x02 , */
+/* IDL:        WITNESS_INFO_WITNESS_IF =  0x04 , */
+/* IDL: } */
+
+int
+witness_dissect_bitmap_interfaceInfo_flags(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *parent_tree _U_, dcerpc_info* di _U_, guint8 *drep _U_, int hf_index _U_, guint32 param _U_)
+{
+       proto_item *item;
+       static int * const witness_witness_interfaceInfo_flags_fields[] = {
+               &hf_witness_witness_interfaceInfo_flags_WITNESS_INFO_IPv4_VALID,
+               &hf_witness_witness_interfaceInfo_flags_WITNESS_INFO_IPv6_VALID,
+               &hf_witness_witness_interfaceInfo_flags_WITNESS_INFO_WITNESS_IF,
+               NULL
+       };
+       guint32 flags;
+       ALIGN_TO_4_BYTES;
+
+       item = proto_tree_add_bitmask_with_flags(parent_tree, tvb, offset, hf_index,
+                               ett_witness_witness_interfaceInfo_flags, witness_witness_interfaceInfo_flags_fields, DREP_ENC_INTEGER(drep), BMT_NO_FALSE);
+
+       offset = dissect_ndr_uint32(tvb, offset, pinfo, parent_tree, di, drep, -1, &flags);
+
+       if (!flags)
+               proto_item_append_text(item, ": (No values set)");
+
+       if (flags & (~0x00000007)) {
+               flags &= (~0x00000007);
+               proto_item_append_text(item, "Unknown bitmap value 0x%x", flags);
+       }
+
+       if (flags & 0x4) {
+               proto_item_append_text(proto_tree_get_parent(parent_tree), " WITNESS_IF");
+               col_append_fstr(pinfo->cinfo, COL_INFO," WITNESS_IF");
+       }
+
+       return offset;
+}
+
+static int
+witness_dissect_element_Register_net_name_(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
+{
+       char *data = NULL;
+       struct ndr_generic_array nga = { .is_conformant = FALSE, };
+
+       offset = dissect_ndr_conformant_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
+
+       offset = dissect_ndr_varying_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
+
+       offset = dissect_ndr_generic_array_string(tvb, offset, pinfo, tree, di, drep, sizeof(guint16), hf_witness_witness_Register_net_name, FALSE, &nga, &data);
+       proto_item_append_text(tree, ": %s", data);
+       if (di->conformant_run == 0) {
+               col_append_fstr(pinfo->cinfo, COL_INFO, " NetName[%s]", data);
+       }
+
+       return offset;
+}
+
+static int
+witness_dissect_element_Register_ip_address_(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
+{
+       char *data = NULL;
+       struct ndr_generic_array nga = { .is_conformant = FALSE, };
+
+       offset = dissect_ndr_conformant_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
+
+       offset = dissect_ndr_varying_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
+
+       offset = dissect_ndr_generic_array_string(tvb, offset, pinfo, tree, di, drep, sizeof(guint16), hf_witness_witness_Register_ip_address, FALSE, &nga, &data);
+       proto_item_append_text(tree, ": %s", data);
+       if (di->conformant_run == 0) {
+               col_append_fstr(pinfo->cinfo, COL_INFO, " IpAddress[%s]", data);
+       }
+
+       return offset;
+}
+
+static int
+witness_dissect_element_RegisterEx_net_name_(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
+{
+       char *data = NULL;
+       struct ndr_generic_array nga = { .is_conformant = FALSE, };
+
+       offset = dissect_ndr_conformant_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
+
+       offset = dissect_ndr_varying_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
+
+       offset = dissect_ndr_generic_array_string(tvb, offset, pinfo, tree, di, drep, sizeof(guint16), hf_witness_witness_RegisterEx_net_name, FALSE, &nga, &data);
+       proto_item_append_text(tree, ": %s", data);
+       if (di->conformant_run == 0) {
+               col_append_fstr(pinfo->cinfo, COL_INFO, " NetName[%s]", data);
+       }
+
+       return offset;
+}
+
+static int
+witness_dissect_element_RegisterEx_share_name_(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
+{
+       char *data = NULL;
+       struct ndr_generic_array nga = { .is_conformant = FALSE, };
+
+       offset = dissect_ndr_conformant_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
+
+       offset = dissect_ndr_varying_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
+
+       offset = dissect_ndr_generic_array_string(tvb, offset, pinfo, tree, di, drep, sizeof(guint16), hf_witness_witness_RegisterEx_share_name, FALSE, &nga, &data);
+       proto_item_append_text(tree, ": %s", data);
+       if (di->conformant_run == 0) {
+               col_append_fstr(pinfo->cinfo, COL_INFO, " ShareName[%s]", data);
+       }
+
+       return offset;
+}
+
+static int
+witness_dissect_element_RegisterEx_ip_address_(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)
+{
+       char *data = NULL;
+       struct ndr_generic_array nga = { .is_conformant = FALSE, };
+
+       offset = dissect_ndr_conformant_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
+
+       offset = dissect_ndr_varying_array_hdr(tvb, offset, pinfo, tree, di, drep, &nga);
+
+       offset = dissect_ndr_generic_array_string(tvb, offset, pinfo, tree, di, drep, sizeof(guint16), hf_witness_witness_RegisterEx_ip_address, FALSE, &nga, &data);
+       proto_item_append_text(tree, ": %s", data);
+       if (di->conformant_run == 0) {
+               col_append_fstr(pinfo->cinfo, COL_INFO, " IpAddress[%s]", data);
+       }
+
+       return offset;
+}
+
 CODE END