aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-cpha.c
diff options
context:
space:
mode:
authorAlexis La Goutte <alexis.lagoutte@gmail.com>2011-11-15 07:56:06 +0000
committerAlexis La Goutte <alexis.lagoutte@gmail.com>2011-11-15 07:56:06 +0000
commit9edf24f1efa53d38d3fde1a35452d134304cd7be (patch)
tree138536afa5a1acf76459ba8317c78e0f68f4cd27 /epan/dissectors/packet-cpha.c
parent47bc2af5fd98e239811c050358c52095b0530ae7 (diff)
Enhance CPHA dissector
* Remove struct and sizeof * Replace proto_tree_add_* by proto_tree_add_item * Replace CPHA function (report2str, opcode2str...) by standard Wireshark functions * and minor bug fix svn path=/trunk/; revision=39844
Diffstat (limited to 'epan/dissectors/packet-cpha.c')
-rw-r--r--epan/dissectors/packet-cpha.c514
1 files changed, 202 insertions, 312 deletions
diff --git a/epan/dissectors/packet-cpha.c b/epan/dissectors/packet-cpha.c
index f47567cb5d..99f00872c2 100644
--- a/epan/dissectors/packet-cpha.c
+++ b/epan/dissectors/packet-cpha.c
@@ -38,6 +38,7 @@ static int hf_magic_number = -1;
static int hf_cpha_protocol_ver = -1;
static int hf_cluster_number = -1;
static int hf_opcode = -1;
+static int hf_payload = -1;
static int hf_src_if_num = -1;
static int hf_random_id = -1;
static int hf_src_machine_id = -1;
@@ -48,7 +49,9 @@ static int hf_id_num = -1;
static int hf_report_code = -1;
static int hf_ha_mode = -1;
static int hf_ha_time_unit = -1;
-/*static int hf_problem = -1;*/
+static int hf_machine_states = -1;
+static int hf_state_node = -1;
+static int hf_interface_states = -1;
static int hf_num_reported_ifs = -1;
static int hf_ethernet_add = -1;
static int hf_is_if_trusted = -1;
@@ -62,93 +65,51 @@ static int hf_in_up_num = -1;
static int hf_in_assumed_up_num = -1;
static int hf_out_up_num = -1;
static int hf_out_assumed_up_num = -1;
+static int hf_cluster_last_packet = -1;
static int hf_ifn = -1;
static gint ett_cphap = -1;
-#define UDP_PORT_CPHA 8116
+#define UDP_PORT_CPHA 8116
#define CPHA_MAGIC 0x1A90
-struct cpha_hdr {
- guint16 magic_number;
- guint16 ha_protocol_ver;
- guint16 cluster_number;
- guint16 opcode;
- guint16 src_if_num;
- guint16 random_id;
- guint16 src_machine_id;
- guint16 dst_machine_id;
- guint16 policy_id;
- guint16 filler;
- guint32 data;
-};
-
-struct fwha_my_state_hdr {
- guint16 id_num;
- guint16 report_code;
- guint16 ha_mode;
- guint16 ha_time_unit;
- /*guint16 problem;*/
-};
-
-struct conf_reply_hdr {
- guint32 num_reported_ifs;
- guint8 ethernet_add[6];
- guint16 is_if_trusted;
- guint32 ip;
-};
-
-struct lb_conf_hdr {
- guint16 slot_num;
- guint16 machine_num;
- guint32 seed;
- guint32 hash_list_len;
-};
-
-struct fwhap_if_state_s {
- guint8 in_up_num;
- guint8 in_assumed_up_num;
- guint8 out_up_num;
- guint8 out_assumed_up_num;
-};
-
-#define NUM_OPCODE_TYPES 10
-
-static const char *opcode_type_str_short[NUM_OPCODE_TYPES+1] = {
- "Unknown",
- "FWHA_MY_STATE",
- "FWHA_QUERY_STATE",
- "FWHA_IF_PROBE_REQ",
- "FWHA_IF_PROBE_REPLY",
- "FWHA_IFCONF_REQ",
- "FWHA_IFCONF_REPLY",
- "FWHA_LB_CONF",
- "FWHA_LB_CONFIRM",
- "FWHA_POLICY_CHANGE",
- "FWHAP_SYNC"
+static const value_string opcode_type_short_vals[] = {
+ { 0, "Unknown" },
+ { 1, "FWHA_MY_STATE" },
+ { 2, "FWHA_QUERY_STATE" },
+ { 3, "FWHA_IF_PROBE_REQ" },
+ { 4, "FWHA_IF_PROBE_REPLY" },
+ { 5, "FWHA_IFCONF_REQ" },
+ { 6, "FWHA_IFCONF_REPLY" },
+ { 7, "FWHA_LB_CONF" },
+ { 8, "FWHA_LB_CONFIRM" },
+ { 9, "FWHA_POLICY_CHANGE" },
+ { 10, "FWHAP_SYNC" },
+ { 0, NULL }
};
-static const char *opcode_type_str_long[NUM_OPCODE_TYPES+1] = {
- "Unknown OpCode",
- "Report source machine's state",
- "Query other machine's state",
- "Interface active check request",
- "Interface active check reply",
- "Interface configuration request",
- "Interface configuration reply",
- "LB configuration report request",
- "LB configuration report reply",
- "Policy ID change request/notification",
- "New Sync packet"
+static const value_string opcode_type_vals[] = {
+ { 0, "Unknown OpCode" },
+ { 1, "FWHA_MY_STATE - Report source machine's state" },
+ { 2, "FWHA_QUERY_STATE - Query other machine's state" },
+ { 3, "FWHA_IF_PROBE_REQ - Interface active check request" },
+ { 4, "FWHA_IF_PROBE_REPLY - Interface active check reply" },
+ { 5, "FWHA_IFCONF_REQ - Interface configuration request" },
+ { 6, "FWHA_IFCONF_REPLY - Interface configuration reply" },
+ { 7, "FWHA_LB_CONF - LB configuration report request" },
+ { 8, "FWHA_LB_CONFIRM - LB configuration report reply" },
+ { 9, "FWHA_POLICY_CHANGE - Policy ID change request/notification" },
+ { 10, "FWHAP_SYNC - New Sync packet" },
+ { 0, NULL }
};
-#define NUM_STATES 5
-static const char *state_str[NUM_STATES] = {
- "Down/Dead",
- "Initializing",
- "Standby",
- "Ready",
- "Active/Active-Attention"
+static const value_string state_vals[] = {
+ { 0, "Down/Dead" },
+ { 1, "Initializing" },
+ { 2, "Standby" },
+ { 3, "Ready" },
+ { 4, "Active/Active-Attention" },
+ { 0, NULL }
};
static const value_string status_vals[] = {
@@ -158,40 +119,46 @@ static const value_string status_vals[] = {
{ 0, NULL }
};
-#define NUM_HA_MODES 4
-static const char *ha_mode_str[NUM_HA_MODES+1] = {
- "FWHA_UNDEF_MODE",
- "FWHA_NOT_ACTIVE_MODE - CPHA is not active",
- "FWHA_BALANCE_MODE - More than one machine active",
- "FWHA_PRIMARY_UP_MODE",
- "FWHA_ONE_UP_MODE"
+static const value_string ha_mode_vals[] = {
+ { 0, "FWHA_UNDEF_MODE" },
+ { 1, "FWHA_NOT_ACTIVE_MODE - CPHA is not active" },
+ { 2, "FWHA_BALANCE_MODE - More than one machine active" },
+ { 3, "FWHA_PRIMARY_UP_MODE" },
+ { 4, "FWHA_ONE_UP_MODE" },
+ { 0, NULL }
};
-static const char *ha_magic_num2str(guint16 magic);
-static const char *version2str(guint16 version);
-static const char *opcode2str_short(guint16 opcode);
-static const char *opcode2str_long(guint16 opcode);
+static const value_string ha_version_vals[] = {
+ { 1, "4.1" },
+ { 6, "NG Feature Pack 2" },
+ { 530, "NG Feature Pack 3" },
+ { 540, "NG with Application Intelligence (Early Availability)" },
+ { 514, "NG with Application Intelligence" },
+ { 0, NULL },
+};
+static const value_string report_code_vals[] = {
+ { 1, "Machine information included" },
+ { 2, "Interface information included" },
+ { 3, "Machine & Interface information included" },
+ { 0, NULL },
+};
static int dissect_my_state(tvbuff_t *, int, proto_tree *);
static int dissect_lb_conf(tvbuff_t *, int, proto_tree *);
static int dissect_policy_change(tvbuff_t *, int, proto_tree *);
static int dissect_probe(tvbuff_t *, int, proto_tree *);
static int dissect_conf_reply(tvbuff_t *, int, proto_tree *);
-static int is_report_ifs(guint16);
-static const char *report_code2str(guint16);
-static const char *ha_mode2str(guint16);
-static const char *state2str(guint8);
static int
dissect_cpha(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
- int offset = 0;
- struct cpha_hdr hdr;
- proto_item * ti;
- proto_item * nti;
- proto_tree * cpha_tree = NULL;
- proto_tree * ntree = NULL;
- guint16 opcode;
-
+ int offset = 0;
+ proto_item * ti;
+ proto_item * nti;
+ proto_tree * cpha_tree = NULL;
+ proto_tree * ntree = NULL;
+ guint16 opcode;
+ guint16 magic_number;
+ guint16 ha_version;
/*
* If the magic number or protocol version is unknown, don't treat this
* frame as a CPHA frame.
@@ -200,89 +167,75 @@ dissect_cpha(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* Not enough data for the magic number or protocol version */
return 0;
}
- hdr.magic_number = tvb_get_ntohs(tvb, 0);
- hdr.ha_protocol_ver = tvb_get_ntohs(tvb, 2);
- if (ha_magic_num2str(hdr.magic_number) == NULL) {
+ magic_number = tvb_get_ntohs(tvb, 0);
+ ha_version = tvb_get_ntohs(tvb, 2);
+ if (magic_number != CPHA_MAGIC) {
/* Bad magic number */
return 0;
}
- if (version2str(hdr.ha_protocol_ver) == NULL) {
- /* Bad version number */
- return 0;
- }
col_set_str(pinfo->cinfo, COL_PROTOCOL, "CPHA");
col_clear(pinfo->cinfo, COL_INFO);
- tvb_memcpy(tvb, (guint8 *)&hdr, offset, sizeof(hdr));
- hdr.magic_number = g_ntohs(hdr.magic_number);
- hdr.ha_protocol_ver = g_ntohs(hdr.ha_protocol_ver);
- hdr.random_id = g_ntohs(hdr.random_id);
- hdr.src_if_num = g_ntohs(hdr.src_if_num);
- hdr.src_machine_id = g_ntohs(hdr.src_machine_id);
- hdr.dst_machine_id = g_ntohs(hdr.dst_machine_id);
- hdr.policy_id = g_ntohs(hdr.policy_id);
- hdr.filler = g_ntohs(hdr.filler);
- opcode = g_ntohs(hdr.opcode);
+ opcode = tvb_get_ntohs(tvb, 6);
col_add_fstr(pinfo->cinfo, COL_INFO, "CPHAv%d: %s",
- hdr.ha_protocol_ver, opcode2str_short(opcode));
+ ha_version, val_to_str(opcode, opcode_type_vals, "Unknown %d"));
if (tree) {
ti = proto_tree_add_item(tree, proto_cphap, tvb, offset, -1, ENC_NA);
cpha_tree = proto_item_add_subtree(ti, ett_cphap);
}
if (tree) {
- proto_tree_add_uint_format(cpha_tree, hf_magic_number, tvb, offset, sizeof(hdr.magic_number), hdr.magic_number, "Magic Number: 0x%x (%s)", hdr.magic_number, ha_magic_num2str(hdr.magic_number));
- offset += sizeof(hdr.magic_number);
+ proto_tree_add_item(cpha_tree, hf_magic_number, tvb, offset, 2, ENC_BIG_ENDIAN);
+ offset += 2;
- proto_tree_add_uint_format_value(cpha_tree, hf_cpha_protocol_ver, tvb, offset, sizeof(hdr.ha_protocol_ver), hdr.ha_protocol_ver, "%d (%s)", hdr.ha_protocol_ver,version2str(hdr.ha_protocol_ver));
- offset += sizeof(hdr.ha_protocol_ver);
+ proto_tree_add_item(cpha_tree, hf_cpha_protocol_ver, tvb, offset, 2, ENC_BIG_ENDIAN);
+ offset += 2;
- proto_tree_add_uint(cpha_tree, hf_cluster_number, tvb, offset, sizeof(hdr.cluster_number), g_ntohs(hdr.cluster_number));
- offset += sizeof(hdr.cluster_number);
+ proto_tree_add_item(cpha_tree, hf_cluster_number, tvb, offset, 2, ENC_BIG_ENDIAN);
+ offset += 2;
- proto_tree_add_uint_format(cpha_tree, hf_opcode, tvb, offset, sizeof(hdr.opcode), opcode,
- "HA OpCode: %d (%s - %s)", opcode, opcode2str_short(opcode), opcode2str_long(opcode));
- offset += sizeof(hdr.opcode);
+ proto_tree_add_item(cpha_tree, hf_opcode, tvb, offset, 2, ENC_BIG_ENDIAN);
+ offset += 2;
- proto_tree_add_uint(cpha_tree, hf_src_if_num, tvb, offset, sizeof(hdr.src_if_num),
- hdr.src_if_num);
- offset += sizeof(hdr.src_if_num);
+ proto_tree_add_item(cpha_tree, hf_src_if_num, tvb, offset, 2, ENC_BIG_ENDIAN);
+ offset += 2;
- proto_tree_add_uint(cpha_tree, hf_random_id, tvb, offset, sizeof(hdr.random_id), hdr.random_id);
- offset += sizeof(hdr.random_id);
+ proto_tree_add_item(cpha_tree, hf_random_id, tvb, offset, 2, ENC_BIG_ENDIAN);
+ offset += 2;
- proto_tree_add_uint(cpha_tree, hf_src_machine_id, tvb, offset, sizeof(hdr.src_machine_id), hdr.src_machine_id);
- offset += sizeof(hdr.src_machine_id);
+ proto_tree_add_item(cpha_tree, hf_src_machine_id, tvb, offset, 2, ENC_BIG_ENDIAN);
+ offset += 2;
- proto_tree_add_uint(cpha_tree, hf_dst_machine_id, tvb, offset, sizeof(hdr.dst_machine_id), hdr.dst_machine_id);
- offset += sizeof(hdr.dst_machine_id);
- if(hdr.ha_protocol_ver != 1) {/* 4.1 - no policy_id and filler*/
- proto_tree_add_uint(cpha_tree, hf_policy_id, tvb, offset, sizeof(hdr.policy_id), hdr.policy_id);
- offset += sizeof(hdr.policy_id);
+ proto_tree_add_item(cpha_tree, hf_dst_machine_id, tvb, offset, 2, ENC_BIG_ENDIAN);
+ offset += 2;
+ if(ha_version != 1) {/* 4.1 - no policy_id and filler*/
+ proto_tree_add_item(cpha_tree, hf_policy_id, tvb, offset, 2, ENC_BIG_ENDIAN);
+ offset += 2;
- proto_tree_add_uint(cpha_tree, hf_filler, tvb, offset, sizeof(hdr.filler), g_ntohs(hdr.filler));
- offset += sizeof(hdr.filler);
+ proto_tree_add_item(cpha_tree, hf_filler, tvb, offset, 2, ENC_BIG_ENDIAN);
+ offset += 2;
}
- nti = proto_tree_add_text(cpha_tree, tvb, offset, -1, "%s", opcode2str_short(opcode));
+ nti = proto_tree_add_item(cpha_tree, hf_payload, tvb, offset, -1, ENC_NA);
+ proto_item_append_text(nti, " - %s", val_to_str(opcode, opcode_type_vals, "Unknown %d"));
ntree = proto_item_add_subtree(nti, ett_cphap);
switch(opcode) {
- case 1: dissect_my_state(tvb, offset, ntree); /* FWHAP_MY_STATE */
- break;
- case 2: break;
- case 3: /* FWHAP_IF_PROBE_REQ */
- case 4: dissect_probe(tvb, offset, ntree); /* FWHAP_IF_PROBE_RPLY */
- break;
- case 5: break;
- case 6: dissect_conf_reply(tvb, offset, ntree); /* FWHAP_IFCONF_RPLY */
- break;
- case 7: dissect_lb_conf(tvb, offset, ntree); /* FWHAP_LB_CONF */
- break;
- case 9: dissect_policy_change(tvb, offset, ntree); /* FWHAP_POLICY_CHANGE */
- break;
- default: break;
+ case 1: dissect_my_state(tvb, offset, ntree); /* FWHAP_MY_STATE */
+ break;
+ case 2: break;
+ case 3: /* FWHAP_IF_PROBE_REQ */
+ case 4: dissect_probe(tvb, offset, ntree); /* FWHAP_IF_PROBE_RPLY */
+ break;
+ case 5: break;
+ case 6: dissect_conf_reply(tvb, offset, ntree); /* FWHAP_IFCONF_RPLY */
+ break;
+ case 7: dissect_lb_conf(tvb, offset, ntree); /* FWHAP_LB_CONF */
+ break;
+ case 9: dissect_policy_change(tvb, offset, ntree); /* FWHAP_POLICY_CHANGE */
+ break;
+ default: break;
}
}
@@ -290,204 +243,121 @@ dissect_cpha(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
static int dissect_my_state(tvbuff_t * tvb, int offset, proto_tree * tree) {
- struct fwha_my_state_hdr hdr;
- struct fwhap_if_state_s if_hdr;
int i;
- proto_item * nti = NULL;
+ proto_item * nti = NULL;
proto_tree * ntree = NULL;
-
- tvb_memcpy(tvb, (guint8 *)&hdr, offset, sizeof(hdr));
- hdr.id_num = g_ntohs(hdr.id_num);
- hdr.report_code = g_ntohs(hdr.report_code);
- hdr.ha_mode = g_ntohs(hdr.ha_mode);
- hdr.ha_time_unit = g_ntohs(hdr.ha_time_unit);
-
- proto_tree_add_uint(tree, hf_id_num, tvb, offset, sizeof(hdr.id_num), hdr.id_num);
- offset += sizeof(hdr.id_num);
-
- proto_tree_add_text(tree, tvb, offset, sizeof(hdr.report_code), "Report Code: %s",report_code2str(hdr.report_code));
- offset += sizeof(hdr.report_code);
-
- proto_tree_add_uint_format_value(tree, hf_ha_mode, tvb, offset, sizeof(hdr.ha_mode), hdr.ha_mode, "%d (%s)", hdr.ha_mode, ha_mode2str(hdr.ha_mode));
- offset += sizeof(hdr.ha_mode);
-
- proto_tree_add_uint_format_value(tree, hf_ha_time_unit, tvb, offset, sizeof(hdr.ha_time_unit), hdr.ha_time_unit, "%d milliseconds", hdr.ha_time_unit);
- offset += sizeof(hdr.ha_time_unit);
-
- if (hdr.report_code & 1) {
- /* states */
- nti = proto_tree_add_text(tree, tvb, offset, hdr.id_num * sizeof(guint8), "Machine states");
- ntree = proto_item_add_subtree(nti, ett_cphap);
- for(i=0; i < hdr.id_num; i++) {
- proto_tree_add_text(ntree, tvb, offset, sizeof(guint8), "State of node %d: %d (%s)", i, tvb_get_guint8(tvb, offset), state2str(tvb_get_guint8(tvb, offset)));
- offset += sizeof(guint8);
- }
+ guint16 report_code, id_num;
+
+ proto_tree_add_item(tree, hf_id_num, tvb, offset, 2, ENC_BIG_ENDIAN);
+ id_num = tvb_get_ntohs(tvb, offset);
+ offset += 2;
+
+ proto_tree_add_item(tree, hf_report_code, tvb, offset, 2, ENC_BIG_ENDIAN);
+ report_code = tvb_get_ntohs(tvb, offset);
+ offset += 2;
+
+ proto_tree_add_item(tree, hf_ha_mode, tvb, offset, 2, ENC_BIG_ENDIAN);
+ offset += 2;
+
+ proto_tree_add_item(tree, hf_ha_time_unit, tvb, offset, 2, ENC_BIG_ENDIAN);
+ offset += 2;
+
+ if (report_code & 1) {
+ /* states */
+ nti = proto_tree_add_item(tree, hf_machine_states, tvb, offset, id_num, ENC_NA);
+ ntree = proto_item_add_subtree(nti, ett_cphap);
+ for(i=0; i < id_num; i++) {
+ nti = proto_tree_add_item(ntree, hf_state_node, tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_item_append_text(nti, " (Nodes %d)", i);
+ offset += 1;
+ }
}
- if (hdr.report_code & 2) {
- /* interface information */
- nti = proto_tree_add_text(tree, tvb, offset, sizeof(struct fwhap_if_state_s), "Interface states");
- ntree = proto_item_add_subtree(nti, ett_cphap);
- tvb_memcpy(tvb, (guint8 *)&if_hdr, offset, sizeof(if_hdr));
- proto_tree_add_int(ntree, hf_in_up_num, tvb, offset, sizeof(if_hdr.in_up_num), if_hdr.in_up_num);
- offset += sizeof(if_hdr.in_up_num);
- proto_tree_add_int(ntree, hf_in_assumed_up_num, tvb, offset, sizeof(if_hdr.in_assumed_up_num), if_hdr.in_assumed_up_num);
- offset += sizeof(if_hdr.in_assumed_up_num);
- proto_tree_add_int(ntree, hf_out_up_num, tvb, offset, sizeof(if_hdr.out_up_num), if_hdr.out_up_num);
- offset += sizeof(if_hdr.out_up_num);
- proto_tree_add_int(ntree, hf_out_assumed_up_num, tvb, offset, sizeof(if_hdr.out_assumed_up_num), if_hdr.out_assumed_up_num);
- offset += sizeof(if_hdr.out_assumed_up_num);
-
- for(i=0; i < hdr.id_num; i++) {
- proto_tree_add_text(tree, tvb, offset, sizeof(guint8), "Cluster %d: last packet seen %d time units ago", i, tvb_get_guint8(tvb, offset));
- offset += sizeof(guint8);
- }
+ if (report_code & 2) {
+ /* interface information */
+ nti = proto_tree_add_item(tree, hf_interface_states, tvb, offset, 4, ENC_NA);
+ ntree = proto_item_add_subtree(nti, ett_cphap);
+ proto_tree_add_item(ntree, hf_in_up_num, tvb, offset, 1, ENC_BIG_ENDIAN);
+ offset += 1;
+ proto_tree_add_item(ntree, hf_in_assumed_up_num, tvb, offset, 1, ENC_BIG_ENDIAN);
+ offset += 1;
+ proto_tree_add_item(ntree, hf_out_up_num, tvb, offset, 1, ENC_BIG_ENDIAN);
+ offset += 1;
+ proto_tree_add_item(ntree, hf_out_assumed_up_num, tvb, offset, 1, ENC_BIG_ENDIAN);
+ offset += 1;
+
+ for(i=0; i < id_num; i++) {
+ proto_tree_add_item(tree, hf_cluster_last_packet, tvb, offset, 1, ENC_BIG_ENDIAN);
+ proto_item_append_text(nti, " (Cluster %d)", i);
+ offset += 1;
+ }
}
-return offset;
+ return offset;
}
static int dissect_lb_conf(tvbuff_t * tvb, int offset, proto_tree * tree) {
- struct lb_conf_hdr hdr;
-
- tvb_memcpy(tvb, (guint8 *)&hdr, offset, sizeof(hdr));
- hdr.slot_num = g_ntohs(hdr.slot_num);
- hdr.machine_num = g_ntohs(hdr.machine_num);
- hdr.seed = g_ntohs(hdr.seed);
- hdr.hash_list_len = g_ntohs(hdr.hash_list_len);
- proto_tree_add_uint(tree, hf_slot_num, tvb, offset, sizeof(hdr.slot_num), hdr.slot_num);
- offset += sizeof(hdr.slot_num);
+ proto_tree_add_item(tree, hf_slot_num, tvb, offset, 2, ENC_BIG_ENDIAN);
+ offset += 2;
- proto_tree_add_int(tree, hf_machine_num, tvb, offset, sizeof(hdr.machine_num), hdr.machine_num);
- offset += sizeof(hdr.machine_num);
+ proto_tree_add_item(tree, hf_machine_num, tvb, offset, 2, ENC_BIG_ENDIAN);
+ offset += 2;
- proto_tree_add_uint(tree, hf_seed, tvb, offset, sizeof(hdr.seed), hdr.seed);
- offset += sizeof(hdr.seed);
+ proto_tree_add_item(tree, hf_seed, tvb, offset, 4, ENC_BIG_ENDIAN);
+ offset += 4;
- proto_tree_add_uint(tree, hf_hash_len, tvb, offset, sizeof(hdr.hash_list_len), hdr.hash_list_len);
- offset += sizeof(hdr.hash_list_len);
+ proto_tree_add_item(tree, hf_hash_len, tvb, offset, 4, ENC_BIG_ENDIAN);
+ offset += 4;
return offset;
}
static int dissect_policy_change(tvbuff_t * tvb, int offset, proto_tree * tree) {
- guint32 status;
- status = tvb_get_ntohl(tvb, offset);
-
- proto_tree_add_uint(tree, hf_status, tvb, offset, sizeof(status), status);
- offset += sizeof(guint32);
+ proto_tree_add_item(tree, hf_status, tvb, offset, 4, ENC_BIG_ENDIAN);
+ offset += 4;
return offset;
}
static int dissect_probe(tvbuff_t * tvb, int offset, proto_tree * tree) {
- guint32 ifn;
- ifn = tvb_get_ntohl(tvb, offset);
+ proto_tree_add_item(tree, hf_ifn, tvb, offset, 4, ENC_BIG_ENDIAN);
+ offset += 4;
- proto_tree_add_uint(tree, hf_ifn, tvb, offset, sizeof(ifn), ifn);
- offset += sizeof(guint32);
-return offset;
+ return offset;
}
static int dissect_conf_reply(tvbuff_t * tvb, int offset, proto_tree * tree) {
- struct conf_reply_hdr hdr;
- tvb_memcpy(tvb, (guint8 *)&hdr, offset, sizeof(hdr));
- hdr.num_reported_ifs = g_ntohl(hdr.num_reported_ifs);
- hdr.is_if_trusted = g_ntohs(hdr.is_if_trusted);
+ proto_tree_add_item(tree, hf_num_reported_ifs, tvb, offset, 4, ENC_BIG_ENDIAN);
+ offset += 4;
- proto_tree_add_uint(tree, hf_num_reported_ifs, tvb, offset, sizeof(hdr.num_reported_ifs), hdr.num_reported_ifs);
- offset += sizeof(hdr.num_reported_ifs);
- proto_tree_add_ether(tree, hf_ethernet_add, tvb, offset, 6, hdr.ethernet_add);
+ proto_tree_add_item(tree, hf_ethernet_add, tvb, offset, 6, ENC_NA);
offset += 6;
- proto_tree_add_boolean(tree, hf_is_if_trusted, tvb, offset, sizeof(hdr.is_if_trusted), hdr.is_if_trusted);
- offset += sizeof(hdr.is_if_trusted);
+ proto_tree_add_item(tree, hf_is_if_trusted, tvb, offset, 2, ENC_BIG_ENDIAN);
+ offset += 2;
- proto_tree_add_ipv4(tree, hf_ip, tvb, offset, sizeof(hdr.ip), hdr.ip);
+ proto_tree_add_item(tree, hf_ip, tvb, offset, 4, ENC_NA);
offset += 4;
return offset;
}
-static int
-is_report_ifs(guint16 report_code) {
- if(report_code & 2)
- return 1;
- return 0;
-}
-
-static const char *
-report_code2str(guint16 report_code) {
- int ret;
- ret = is_report_ifs(report_code);
- if(!(report_code & 1))
- return "Machine information NOT present";
- if(ret == 1)
- return "Interface information included";
- return "Unknown report code!";
-}
-static const char *
-ha_magic_num2str(guint16 magic) {
- if(magic == CPHA_MAGIC)
- return "correct";
- return NULL;
-}
-
-static const char *
-version2str(guint16 version) {
- switch(version) {
- case 1: return "4.1";
- case 6: return "NG Feature Pack 2";
- case 530: return "NG Feature Pack 3";
- case 540: return "NG with Application Intelligence (Early Availability)";
- case 541: return "NG with Application Intelligence";
- default: break;
- }
- return "Unknown Version";
-}
-static const char *
-opcode2str_short(guint16 opcode) {
- if(opcode <= NUM_OPCODE_TYPES)
- return opcode_type_str_short[opcode];
- return opcode_type_str_short[0];
-}
-
-static const char *
-ha_mode2str(guint16 hamode) {
- if(hamode <= NUM_HA_MODES)
- return ha_mode_str[hamode];
- return "Unknown HA mode";
-}
-
-static const char *
-state2str(guint8 state) {
- if(state < NUM_STATES)
- return state_str[state];
- return "Unknown";
-}
-
-
-static const char *
-opcode2str_long(guint16 opcode) {
- if(opcode <= NUM_OPCODE_TYPES)
- return opcode_type_str_long[opcode];
- return opcode_type_str_long[0];
-}
-
void
proto_register_cpha(void)
{
static hf_register_info hf[] = {
{ &hf_magic_number,
- { "CPHAP Magic Number", "cpha.magic_number", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}},
+ { "Magic Number", "cpha.magic_number", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL}},
{ &hf_cpha_protocol_ver,
- { "Protocol Version", "cpha.version", FT_UINT16, BASE_DEC, NULL, 0x0, "CPHAP Version", HFILL}},
+ { "Protocol Version", "cpha.version", FT_UINT16, BASE_DEC, VALS(ha_version_vals), 0x0, "CPHAP Version", HFILL}},
{ &hf_cluster_number,
{ "Cluster Number", "cpha.cluster_number", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}},
{ &hf_opcode,
- { "OpCode", "cpha.opcode", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}},
+ { "HA OpCode", "cpha.opcode", FT_UINT16, BASE_DEC, VALS(opcode_type_vals), 0x0, NULL, HFILL}},
+ { &hf_payload,
+ { "Payload", "cpha.payload", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL}},
{ &hf_src_if_num,
{ "Source Interface", "cpha.src_if", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}},
{ &hf_random_id,
@@ -503,11 +373,17 @@ proto_register_cpha(void)
{ &hf_id_num,
{ "Number of IDs reported", "cpha.id_num", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}},
{ &hf_report_code,
- { "Report code", "cpha.id_num", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}},
+ { "Report code", "cpha.id_num", FT_UINT16, BASE_DEC, VALS(report_code_vals), 0x0, NULL, HFILL}},
{ &hf_ha_mode,
- { "HA mode", "cpha.ha_mode", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL}},
+ { "HA mode", "cpha.ha_mode", FT_UINT16, BASE_DEC, VALS(ha_mode_vals), 0x0, NULL, HFILL}},
{ &hf_ha_time_unit,
{ "HA Time unit", "cpha.ha_time_unit", FT_UINT16, BASE_DEC, NULL, 0x0, "HA Time unit (ms)", HFILL}},
+ { &hf_machine_states,
+ { "Machines States", "cpha.machine_states", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL}},
+ { &hf_state_node,
+ { "State node", "cpha.state_node", FT_UINT8, BASE_DEC, VALS(state_vals), 0x0, NULL, HFILL}},
+ { &hf_interface_states,
+ { "Interface States", "cpha.interface_states", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL}},
{ &hf_num_reported_ifs,
{ "Reported Interfaces", "cpha.reported_ifs", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL}},
{ &hf_ethernet_add,
@@ -532,6 +408,8 @@ proto_register_cpha(void)
{ "Interfaces up in the Outbound", "cpha.out_up", FT_INT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
{ &hf_out_assumed_up_num,
{ "Interfaces assumed up in the Outbound", "cpha.out_assume_up", FT_INT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
+ { &hf_cluster_last_packet,
+ { "Last packet seen", "cpha.cluster_last_packet", FT_INT8, BASE_DEC, NULL, 0x0, "Time units ago", HFILL}},
{ &hf_status,
{ "Status", "cpha.status", FT_UINT32, BASE_DEC, VALS(status_vals), 0x0, NULL, HFILL}},
{ &hf_ifn,
@@ -542,7 +420,7 @@ proto_register_cpha(void)
};
proto_cphap = proto_register_protocol("Check Point High Availability Protocol",
- "CPHA", "cpha");
+ "CPHA", "cpha");
proto_register_field_array(proto_cphap, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
}
@@ -555,3 +433,15 @@ proto_reg_handoff_cpha(void)
cpha_handle = new_create_dissector_handle(dissect_cpha, proto_cphap);
dissector_add_uint("udp.port", UDP_PORT_CPHA, cpha_handle);
}
+/*
+ * Editor modelines
+ *
+ * Local Variables:
+ * c-basic-offset: 2
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * ex: set shiftwidth=2 tabstop=8 expandtab:
+ * :indentSize=2:tabSize=8:noTabs=true:
+ */