Skip to content

Commit 6205794

Browse files
authored
fix(transaction): make flow descriptors searchable (#51)
Transaction Flow Descriptors are now searchable. The transaction flowid is added to the smf.flowid alias. Previous analysis based on flowid is displayed as generated items when displayed.
1 parent 2158ad5 commit 6205794

File tree

1 file changed

+178
-61
lines changed

1 file changed

+178
-61
lines changed

packet-assuredctrl.c

Lines changed: 178 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,15 @@ static int hf_assuredctrl_transactionflowdescriptorpubnotify_param = -1;
104104
static int hf_assuredctrl_transactionflowdescriptorpuback_param = -1;
105105
static int hf_assuredctrl_transactionflowdescriptorsuback_param = -1;
106106

107-
static int hf_assuredctrl_transactionflow_pubnotify_string = -1;
108-
static int hf_assuredctrl_transactionflow_puback_string = -1;
109-
static int hf_assuredctrl_transactionflow_suback_string = -1;
107+
static int hf_assuredctrl_transactionflow_string = -1;
108+
static int hf_assuredctrl_transactionflow_flowid_param = -1;
109+
static int hf_assuredctrl_transactionflow_msgcount_param = -1;
110+
static int hf_assuredctrl_transactionflow_lastmsgid_param = -1;
111+
static int hf_assuredctrl_transactionflow_transportwindowsz_param = -1;
112+
static int hf_assuredctrl_transactionflow_minmsgid_param = -1;
113+
static int hf_assuredctrl_transactionflow_maxmsgid_param = -1;
114+
static int hf_assuredctrl_transactionflow_msgackcount_param = -1;
115+
static int hf_assuredctrl_transactionflow_lastmsgidrcvd_param = -1;
110116

111117
static int hf_assuredctrl_transaction_xid = -1;
112118

@@ -223,8 +229,11 @@ static expert_field ei_assuredctrl_smf_expert_transport_window_zero = EI_INIT;
223229
/* Initialize the subtree pointers */
224230
static int ett_assuredctrl = -1;
225231
static int ett_FD_suback_list = -1;
232+
static int ett_FD_suback_list_item = -1;
226233
static int ett_FD_puback_list = -1;
234+
static int ett_FD_puback_list_item = -1;
227235
static int ett_FD_pubnotify_list = -1;
236+
static int ett_FD_pubnotify_list_item = -1;
228237
static int ett_EP_behaviour_list = -1;
229238
static int ett_assuredctrl_list = -1;
230239
static int ett_XA_msg_openXaSessionRequest_list = -1;
@@ -696,19 +705,6 @@ static void redelivery_delay_back_off_multiplier_format(gchar* s, uint16_t v)
696705
}
697706

698707
/* ---------- Byte Accessor Helper Functions ----------- */
699-
static int get_8_bit_value (
700-
proto_tree *tree,
701-
tvbuff_t *tvb,
702-
int offset,
703-
char const * const field_name)
704-
{
705-
uint8_t value = tvb_get_uint8(tvb, offset); /* gets value of the 8-bit field */
706-
proto_tree_add_string_format( /* adds formatted string to proto tree*/
707-
tree, hf_assuredctrl_8_bit_field, tvb, offset, 1, NULL, "%s: %d", field_name, value
708-
);
709-
return 1; /* returns the number of bytes processed */
710-
}
711-
712708
static int get_16_bit_value (
713709
proto_tree *tree,
714710
tvbuff_t *tvb,
@@ -1713,6 +1709,8 @@ static void add_FD_suback_item(
17131709
proto_tree* sub_tree;
17141710
proto_item* item;
17151711
int local_offset = offset;
1712+
int item_offset = 0;
1713+
int accumulative_item_offset = 0;
17161714
uint32_t flowid = 0;
17171715
uint64_t min = 0;
17181716
uint64_t max = 0;
@@ -1726,6 +1724,7 @@ static void add_FD_suback_item(
17261724
sub_tree = proto_item_add_subtree(item, ett_FD_suback_list);
17271725
while( local_offset < offset+size )
17281726
{
1727+
proto_tree* sub_sub_tree;
17291728
flowid = tvb_get_ntohl(tvb, local_offset); // 32 bit flowid
17301729
min = tvb_get_ntoh64(tvb, local_offset + 4);
17311730
max = tvb_get_ntoh64(tvb, local_offset + 12);
@@ -1735,17 +1734,61 @@ static void add_FD_suback_item(
17351734

17361735
if(flowid == 0xFFFFFFFF) {
17371736
if(min == 0 && max == 0 && msgCount == 1 && lastMsgIdRecved == 0 && windowSz == 0) {
1738-
proto_tree_add_string_format(sub_tree,
1739-
hf_assuredctrl_transactionflow_suback_string, tvb, offset, 36, NULL, "ROLLBACK_ONLY_CONSUMER");
1737+
item = proto_tree_add_string_format(sub_tree,
1738+
hf_assuredctrl_transactionflow_string, tvb, offset, 36, NULL, "ROLLBACK_ONLY_CONSUMER");
17401739
} else {
1741-
proto_tree_add_string_format(sub_tree,
1742-
hf_assuredctrl_transactionflow_suback_string, tvb, offset, 36, NULL, "INVALID_FLOW_ID");
1740+
item = proto_tree_add_string_format(sub_tree,
1741+
hf_assuredctrl_transactionflow_string, tvb, offset, 36, NULL, "INVALID_FLOW_ID");
17431742
}
1743+
proto_item_set_generated(item);
17441744
} else {
1745-
proto_tree_add_string_format(sub_tree,
1746-
hf_assuredctrl_transactionflow_suback_string, tvb, offset, 36, NULL,
1747-
"SubFlow:%u minAck:%" G_GINT64_MODIFIER "u maxAck:%" G_GINT64_MODIFIER "u msgCount:%u lastTpMsg:%" G_GINT64_MODIFIER "u windowSz:%u", flowid, min, max, msgCount, lastMsgIdRecved, windowSz);
1745+
item = proto_tree_add_string_format(sub_tree,
1746+
hf_assuredctrl_transactionflow_string, tvb, offset, 36, NULL,
1747+
"FlowId: %u, minAck: %" G_GUINT64_FORMAT ", maxAck: %" G_GUINT64_FORMAT
1748+
", msgCount: %u, lastTpMsg: %" G_GUINT64_FORMAT ", windowSz: %u",
1749+
flowid, min, max, msgCount, lastMsgIdRecved, windowSz);
17481750
}
1751+
sub_sub_tree = proto_item_add_subtree(item, ett_FD_suback_list_item);
1752+
1753+
item_offset = 4; // Transaction flowid is 4 bytes
1754+
proto_tree_add_item(sub_sub_tree,
1755+
hf_assuredctrl_transactionflow_flowid_param,
1756+
tvb, local_offset, item_offset, false);
1757+
item = proto_tree_add_item(sub_sub_tree, // This parameter is for easier search and filtering with flows
1758+
hf_smf_flowid_hidden_param,
1759+
tvb, local_offset, item_offset, false);
1760+
proto_item_set_hidden(item);
1761+
accumulative_item_offset += item_offset;
1762+
1763+
item_offset = 8; // message id is 8 bytes
1764+
proto_tree_add_item(sub_sub_tree,
1765+
hf_assuredctrl_transactionflow_minmsgid_param,
1766+
tvb, local_offset+accumulative_item_offset, item_offset, false);
1767+
accumulative_item_offset += item_offset;
1768+
1769+
item_offset = 8; // message id is 8 bytes
1770+
proto_tree_add_item(sub_sub_tree,
1771+
hf_assuredctrl_transactionflow_maxmsgid_param,
1772+
tvb, local_offset+accumulative_item_offset, item_offset, false);
1773+
accumulative_item_offset += item_offset;
1774+
1775+
item_offset = 4; // message ack acount is 4 bytes
1776+
proto_tree_add_item(sub_sub_tree,
1777+
hf_assuredctrl_transactionflow_msgackcount_param,
1778+
tvb, local_offset+accumulative_item_offset, item_offset, false);
1779+
accumulative_item_offset += item_offset;
1780+
1781+
item_offset = 8; // message id is 8 bytes
1782+
proto_tree_add_item(sub_sub_tree,
1783+
hf_assuredctrl_transactionflow_lastmsgidrcvd_param,
1784+
tvb, local_offset+accumulative_item_offset, item_offset, false);
1785+
accumulative_item_offset += item_offset;
1786+
1787+
item_offset = 4; // transport window is 4 bytes
1788+
proto_tree_add_item(sub_sub_tree,
1789+
hf_assuredctrl_transactionflow_transportwindowsz_param,
1790+
tvb, local_offset+accumulative_item_offset, item_offset, false);
1791+
accumulative_item_offset += item_offset;
17491792

17501793
local_offset += 36;
17511794
}
@@ -1770,23 +1813,41 @@ static void add_FD_pubnotify_item(
17701813
sub_tree = proto_item_add_subtree(item, ett_FD_pubnotify_list);
17711814
while( local_offset < offset+size )
17721815
{
1816+
proto_tree* sub_sub_tree;
17731817
flowid = tvb_get_ntohl(tvb, local_offset); // 32 bit flowid
17741818
messageCount = tvb_get_ntohl(tvb, local_offset + 4); // 32-bit count
17751819
lastMsgId = tvb_get_ntoh64(tvb, local_offset + 8);
17761820

17771821
if(flowid == 0xFFFFFFFF) {
17781822
if(messageCount == 1 && lastMsgId == 0) {
1779-
proto_tree_add_string_format(sub_tree,
1780-
hf_assuredctrl_transactionflow_pubnotify_string, tvb, offset, 16, NULL, "ROLLBACK_ONLY_PUBLISHER");
1823+
item = proto_tree_add_string_format(sub_tree, hf_assuredctrl_transactionflow_string,
1824+
tvb, offset, 16, NULL, "ROLLBACK_ONLY_PUBLISHER");
17811825
} else {
1782-
proto_tree_add_string_format(sub_tree,
1783-
hf_assuredctrl_transactionflow_pubnotify_string, tvb, offset, 16, NULL, "INVALID_FLOW_ID");
1826+
item = proto_tree_add_string_format(sub_tree, hf_assuredctrl_transactionflow_string,
1827+
tvb, offset, 16, NULL, "INVALID_FLOW_ID");
17841828
}
1829+
proto_item_set_generated(item);
17851830
} else {
1786-
proto_tree_add_string_format(sub_tree,
1787-
hf_assuredctrl_transactionflow_pubnotify_string, tvb, offset, 16, NULL,
1788-
"PubFlow:%u messageCount:%u lastMsgId:%" G_GINT64_MODIFIER "u", flowid, messageCount, lastMsgId);
1831+
item = proto_tree_add_string_format(sub_tree, hf_assuredctrl_transactionflow_string, tvb, offset, 16, NULL,
1832+
"FlowId: %u, messageCount: %u, LastMsgId: %" G_GUINT64_FORMAT, flowid, messageCount, lastMsgId);
17891833
}
1834+
sub_sub_tree = proto_item_add_subtree(item, ett_FD_pubnotify_list_item);
1835+
1836+
proto_tree_add_item(sub_sub_tree,
1837+
hf_assuredctrl_transactionflow_flowid_param,
1838+
tvb, local_offset, 4, false);
1839+
item = proto_tree_add_item(sub_sub_tree, // This parameter is for easier search and filtering with flows
1840+
hf_smf_flowid_hidden_param,
1841+
tvb, local_offset, 4, false);
1842+
proto_item_set_hidden(item);
1843+
1844+
proto_tree_add_item(sub_sub_tree,
1845+
hf_assuredctrl_transactionflow_msgcount_param,
1846+
tvb, local_offset+4, 4, false);
1847+
1848+
proto_tree_add_item(sub_sub_tree,
1849+
hf_assuredctrl_transactionflow_lastmsgid_param,
1850+
tvb, local_offset+8, 8, false);
17901851

17911852
local_offset += 16;
17921853
}
@@ -1811,14 +1872,32 @@ static void add_FD_puback_item(
18111872
sub_tree = proto_item_add_subtree(item, ett_FD_puback_list);
18121873
while( local_offset < offset+size )
18131874
{
1875+
proto_tree* sub_sub_tree;
18141876
flowid = tvb_get_ntohl(tvb, local_offset); // 32 bit flowid
18151877
lastMsgId = tvb_get_ntoh64(tvb, local_offset + 4);
18161878
windowSz = tvb_get_ntohl(tvb, local_offset + 12);
18171879

1818-
proto_tree_add_string_format(sub_tree,
1819-
hf_assuredctrl_transactionflow_puback_string, tvb, offset, 16, NULL,
1820-
"PubFlow:%u lastMsgId:%" G_GINT64_MODIFIER "u windowSize:%u", flowid, lastMsgId, windowSz
1880+
item = proto_tree_add_string_format(sub_tree,
1881+
hf_assuredctrl_transactionflow_string, tvb, offset, 16, NULL,
1882+
"FlowId:%u lastMsgId:%" G_GUINT64_FORMAT " windowSize:%u", flowid, lastMsgId, windowSz
18211883
);
1884+
sub_sub_tree = proto_item_add_subtree(item, ett_FD_puback_list_item);
1885+
1886+
proto_tree_add_item(sub_sub_tree,
1887+
hf_assuredctrl_transactionflow_flowid_param,
1888+
tvb, local_offset, 4, false);
1889+
item = proto_tree_add_item(sub_sub_tree, // This parameter is for easier search and filtering with flows
1890+
hf_smf_flowid_hidden_param,
1891+
tvb, local_offset, 4, false);
1892+
proto_item_set_hidden(item);
1893+
1894+
proto_tree_add_item(sub_sub_tree,
1895+
hf_assuredctrl_transactionflow_lastmsgid_param,
1896+
tvb, local_offset+4, 8, false);
1897+
1898+
proto_tree_add_item(sub_sub_tree,
1899+
hf_assuredctrl_transactionflow_transportwindowsz_param,
1900+
tvb, local_offset+12, 4, false);
18221901

18231902
local_offset += 16;
18241903
}
@@ -2372,12 +2451,26 @@ dissect_assuredctrl_param(
23722451
char **str_transactionctrl_msgtype)
23732452
{
23742453
int param_len;
2454+
int decode_len_param; // actual bytes used to decode the length
2455+
int len_offset_delta; // offset change to get the len param
23752456
int len_bytes; //number of bytes used for length
23762457
uint8_t param_type;
23772458
proto_item *ti;
23782459
proto_tree *assuredctrl_param_tree;
23792460

2380-
ti = proto_tree_add_item(tree, hf_assuredctrl_param, tvb, 0, -1, false);
2461+
// Calculate the length of the param
2462+
len_offset_delta = 1;
2463+
param_len = tvb_get_uint8(tvb, offset+len_offset_delta);
2464+
len_bytes = 1;
2465+
decode_len_param = 1;
2466+
if (param_len == 0) {
2467+
len_offset_delta = 2;
2468+
param_len = tvb_get_ntohl(tvb, offset+len_offset_delta); //32bit len starts after the 0
2469+
len_bytes = 5;
2470+
decode_len_param = 4;
2471+
}
2472+
2473+
ti = proto_tree_add_item(tree, hf_assuredctrl_param, tvb, offset, param_len, false);
23812474
assuredctrl_param_tree = proto_item_add_subtree(ti, ett_assuredctrl_list);
23822475

23832476
param_type = tvb_get_uint8(tvb, offset) & 0x3f;
@@ -2392,16 +2485,7 @@ dissect_assuredctrl_param(
23922485

23932486
proto_tree_add_item(assuredctrl_param_tree, hf_assuredctrl_param_uh, tvb, offset, 1, false);
23942487
proto_tree_add_item(assuredctrl_param_tree, hf_assuredctrl_param_type, tvb, offset, 1, false);
2395-
2396-
param_len = tvb_get_uint8(tvb, offset+1);
2397-
if (param_len == 0) {
2398-
param_len = tvb_get_ntohl(tvb, offset+2); //32bit len starts after the 0
2399-
len_bytes = 5;
2400-
proto_tree_add_item(assuredctrl_param_tree, hf_assuredctrl_param_len, tvb, offset+2, 4, false);
2401-
} else {
2402-
len_bytes = 1;
2403-
proto_tree_add_item(assuredctrl_param_tree, hf_assuredctrl_param_len, tvb, offset+1, 1, false);
2404-
}
2488+
proto_tree_add_item(assuredctrl_param_tree, hf_assuredctrl_param_len, tvb, offset+len_offset_delta, decode_len_param, false);
24052489

24062490
add_assuredctrl_param(tvb, pinfo, assuredctrl_param_tree, param_type, offset, param_len, len_bytes, (const char**)str_transactionctrl_msgtype);
24072491

@@ -2821,8 +2905,8 @@ proto_register_assuredctrl(void)
28212905
"", HFILL }
28222906
},
28232907
{ &hf_assuredctrl_transactionctrlmessagetype_param,
2824-
{ "XACtrl Message Type", "assuredctrl.TxnCtrl.messagetype",
2825-
FT_UINT8, BASE_HEX, VALS(transactionctrlmsgtypenames), 0xff,
2908+
{ "TxnCtrl Message Type", "assuredctrl.TxnCtrl.messagetype",
2909+
FT_UINT8, BASE_HEX, VALS(transactionctrlmsgtypenames), 0x0,
28262910
"", HFILL }
28272911
},
28282912
{ &hf_assuredctrl_xaversion_param,
@@ -2851,39 +2935,69 @@ proto_register_assuredctrl(void)
28512935
"", HFILL }
28522936
},
28532937
{ &hf_assuredctrl_transactedsessionstate_param,
2854-
{ "XACtrl TransactedSessionState", "assuredctrl.TxnCtrl.transactedsessionstate",
2938+
{ "XACtrl TransactedSessionState", "assuredctrl.TxnCtrl.transactedsessionstate",
28552939
FT_UINT8, BASE_HEX, VALS(transactedsessionstatenames), 0x0,
28562940
"", HFILL }
28572941
},
28582942
{ &hf_assuredctrl_transactionflowdescriptorpubnotify_param,
2859-
{ "XACtrl TFDPubNotify", "assuredctrl.TxnCtrl.tfdpubnotify",
2860-
FT_BYTES, BASE_NONE, NULL, 0x0,
2943+
{ "TxnCtrl TFDPubNotify", "assuredctrl.TxnCtrl.tfdpubnotify",
2944+
FT_NONE, BASE_NONE, NULL, 0x0,
28612945
"", HFILL }
28622946
},
28632947
{ &hf_assuredctrl_transactionflowdescriptorpuback_param,
2864-
{ "XACtrl TFDPubAck", "assuredctrl.TxnCtrl.tfdpuback",
2865-
FT_BYTES, BASE_NONE, NULL, 0x0,
2948+
{ "TxnCtrl TFDPubAck", "assuredctrl.TxnCtrl.tfdpuback",
2949+
FT_NONE, BASE_NONE, NULL, 0x0,
28662950
"", HFILL }
28672951
},
28682952
{ &hf_assuredctrl_transactionflowdescriptorsuback_param,
2869-
{ "XACtrl TFDSubAck", "assuredctrl.TxnCtrl.tfdsuback",
2870-
FT_BYTES, BASE_NONE, NULL, 0x0,
2953+
{ "TxnCtrl TFDSubAck", "assuredctrl.TxnCtrl.tfdsuback",
2954+
FT_NONE, BASE_NONE, NULL, 0x0,
28712955
"", HFILL }
28722956
},
28732957

2874-
{ &hf_assuredctrl_transactionflow_pubnotify_string,
2875-
{ "Field_PubNotify_Str", "assuredctrl.discard",
2958+
{ &hf_assuredctrl_transactionflow_string,
2959+
{ "Field_Transactionflow_Str", "assuredctrl.discard",
28762960
FT_STRING, BASE_NONE, NULL, 0x0,
28772961
"", HFILL }
28782962
},
2879-
{ &hf_assuredctrl_transactionflow_puback_string,
2880-
{ "Field_PubAck_Str", "assuredctrl.discard",
2881-
FT_STRING, BASE_NONE, NULL, 0x0,
2963+
{ &hf_assuredctrl_transactionflow_flowid_param,
2964+
{ "Flow ID", "assuredctrl.TxnCtrl.flowid",
2965+
FT_UINT32, BASE_DEC, NULL, 0x0,
28822966
"", HFILL }
28832967
},
2884-
{ &hf_assuredctrl_transactionflow_suback_string,
2885-
{ "Field_SubAck_Str", "assuredctrl.discard",
2886-
FT_STRING, BASE_NONE, NULL, 0x0,
2968+
{ &hf_assuredctrl_transactionflow_msgcount_param,
2969+
{ "MsgCount", "assuredctrl.TxnCtrl.msgcount",
2970+
FT_UINT32, BASE_DEC, NULL, 0x0,
2971+
"", HFILL }
2972+
},
2973+
{ &hf_assuredctrl_transactionflow_lastmsgid_param,
2974+
{ "LastMsgId", "assuredctrl.TxnCtrl.lastmsgid",
2975+
FT_UINT64, BASE_DEC, NULL, 0x0,
2976+
"", HFILL }
2977+
},
2978+
{ &hf_assuredctrl_transactionflow_transportwindowsz_param,
2979+
{ "TransportWindowSz", "assuredctrl.TxnCtrl.transportwindowsz",
2980+
FT_UINT32, BASE_DEC, NULL, 0x0,
2981+
"", HFILL }
2982+
},
2983+
{ &hf_assuredctrl_transactionflow_minmsgid_param,
2984+
{ "MinMsgId", "assuredctrl.TxnCtrl.minmsgid",
2985+
FT_UINT64, BASE_DEC, NULL, 0x0,
2986+
"", HFILL }
2987+
},
2988+
{ &hf_assuredctrl_transactionflow_maxmsgid_param,
2989+
{ "MaxMsgId", "assuredctrl.TxnCtrl.maxmsgid",
2990+
FT_UINT64, BASE_DEC, NULL, 0x0,
2991+
"", HFILL }
2992+
},
2993+
{ &hf_assuredctrl_transactionflow_msgackcount_param,
2994+
{ "MsgAckCount", "assuredctrl.TxnCtrl.msgackcount",
2995+
FT_UINT32, BASE_DEC, NULL, 0x0,
2996+
"", HFILL }
2997+
},
2998+
{ &hf_assuredctrl_transactionflow_lastmsgidrcvd_param,
2999+
{ "LastMsgIdRcvd", "assuredctrl.TxnCtrl.lastmsgidrcvd",
3000+
FT_UINT64, BASE_DEC, NULL, 0x0,
28873001
"", HFILL }
28883002
},
28893003
{ &hf_assuredctrl_transaction_xid,
@@ -3385,8 +3499,11 @@ proto_register_assuredctrl(void)
33853499
static int *ett[] = {
33863500
&ett_assuredctrl,
33873501
&ett_FD_suback_list,
3502+
&ett_FD_suback_list_item,
33883503
&ett_FD_puback_list,
3504+
&ett_FD_puback_list_item,
33893505
&ett_FD_pubnotify_list,
3506+
&ett_FD_pubnotify_list_item,
33903507
&ett_EP_behaviour_list,
33913508

33923509
&ett_assuredctrl_list,

0 commit comments

Comments
 (0)