Use '#if 0 ... #endif' rather than /** ... **/ to comment out
[metze/wireshark/wip.git] / epan / dissectors / packet-sasp.c
1 /* packet-sasp.c
2  * Routines for sasp packet dissection
3  * Copyright 2010, Venkateshwaran Dorai<venkateshwaran.d@gmail.com>
4  *
5  * $Id$
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License along
22  * with this program; if not, write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25
26
27 #include "config.h"
28
29 #include <glib.h>
30 #include <epan/packet.h>
31 #include <epan/expert.h>
32 #include "packet-tcp.h"
33 #include <epan/prefs.h>
34
35
36 /* forward reference */
37
38 static void dissect_sasp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
39 static void dissect_reg_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset);
40 static void dissect_dereg_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset);
41 static void dissect_reg_rep(tvbuff_t *tvb, proto_tree *tree, guint32 offset);
42 static void dissect_dereg_rep(tvbuff_t *tvb, proto_tree *tree, guint32 offset);
43 static void dissect_sendwt(tvbuff_t *tvb, proto_tree *tree, guint32 offset);
44 static void dissect_setmemstate_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset);
45 static void dissect_setmemstate_rep(tvbuff_t *tvb, proto_tree *tree, guint32 offset);
46 static void dissect_setlbstate_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset);
47 static void dissect_setlbstate_rep(tvbuff_t *tvb, proto_tree *tree, guint32 offset);
48 static void dissect_wt_req(tvbuff_t *tvb, proto_tree *tree, guint32 offset);
49 static void dissect_wt_rep(tvbuff_t *tvb, proto_tree *tree, guint32 offset);
50 static guint32 dissect_memdatacomp(tvbuff_t *tvb, proto_tree *tree, guint32 offset, proto_tree **mdct_p);
51 static guint32 dissect_grpdatacomp(tvbuff_t *tvb, proto_tree *tree, guint32 offset);
52 static guint32 dissect_grp_memdatacomp(tvbuff_t *tvb, proto_tree *tree, guint32 offset);
53 static guint32 dissect_grp_memstatedatacomp(tvbuff_t *tvb, proto_tree *tree, guint32 offset);
54 static guint32 dissect_memstatedatacomp(tvbuff_t *tvb, proto_tree *tree, guint32 offset);
55 static guint32 dissect_weight_entry_data_comp(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset);
56 static guint32 dissect_grp_wt_entry_datacomp(tvbuff_t *tvb, proto_tree *tree, guint32 offset);
57
58
59
60
61 /* Initialize the protocol and registered fields */
62
63 static int proto_sasp = -1;
64 static int hf_sasp_type = -1;
65 static int hf_sasp_length = -1;
66 static int hf_sasp_vrsn = -1;
67 static int hf_msg_len = -1;
68 static int hf_msg_id = -1;
69
70 static int hf_msg_type = -1;
71
72 /*reg reply*/
73
74 static int hf_sasp_reg_rep_rcode = -1;
75 static int hf_sasp_reg_rep_sz = -1;
76
77 /*reg req*/
78 static int hf_sasp_reg_req_sz = -1;
79 static int hf_reg_req_lbflag = -1;
80 static int hf_sasp_gmd_cnt = -1;
81
82 /*dereg req*/
83 static int hf_sasp_dereg_req_sz = -1;
84 static int hf_dereg_req_lbflag = -1;
85 /* static int hf_dereg_req_reason = -1; */
86 static int hf_dereg_req_reason_flag = -1;
87
88 /*dereg reply*/
89 static int hf_sasp_dereg_rep_rcode = -1;
90 static int hf_sasp_dereg_rep_sz = -1;
91
92 /*send wt*/
93 static int hf_sasp_sendwt_gwedcnt = -1;
94 static int hf_sasp_sendwt_sz = -1;
95
96 /*setmemstate req*/
97 static int hf_sasp_setmemstate_req_sz = -1;
98 static int hf_setmemstate_req_lbflag = -1;
99 /*static int hf_sasp_setmemstate_req_data = -1;*/
100 static int hf_sasp_setmemstate_req_gmsd_cnt = -1;
101
102 /*setmemstate reply*/
103 /* static int hf_sasp_setmemstate_rep = -1; */
104 static int hf_sasp_setmemstate_rep_rcode = -1;
105 static int hf_sasp_setmemstate_rep_sz = -1;
106
107 /*mem data comp */
108 static int hf_sasp_memdatacomp_type = -1;
109 static int hf_sasp_memdatacomp_sz = -1;
110 static int hf_sasp_memdatacomp_protocol = -1;
111 static int hf_sasp_memdatacomp_port = -1;
112 static int hf_sasp_memdatacomp_ip = -1;
113 static int hf_sasp_memdatacomp_lab_len = -1;
114 static int hf_sasp_memdatacomp_label = -1;
115
116 /*grp data comp */
117 static int hf_sasp_grpdatacomp = -1;
118 static int hf_sasp_grpdatacomp_sz = -1;
119 static int hf_sasp_grpdatacomp_LB_uid_len = -1;
120 static int hf_sasp_grpdatacomp_LB_uid = -1;
121 static int hf_sasp_grpdatacomp_grp_name_len = -1;
122 static int hf_sasp_grpdatacomp_grp_name = -1;
123
124 /*grp mem data comp */
125 static int hf_sasp_grp_memdatacomp = -1;
126 static int hf_sasp_grp_memdatacomp_sz = -1;
127 static int hf_sasp_grp_memdatacomp_cnt = -1;
128
129 /*weight req*/
130 static int hf_sasp_wt_req_sz = -1;
131 static int hf_sasp_wt_req_gd_cnt = -1;
132
133 /*weight rep*/
134 static int hf_sasp_wt_rep_sz = -1;
135 static int hf_sasp_wt_rep_rcode = -1;
136 static int hf_sasp_wt_rep_interval = -1;
137 static int hf_sasp_wt_rep_gwed_cnt = -1;
138
139 /*setlbstate req*/
140 static int hf_sasp_setlbstate_req_sz  = -1;
141 static int hf_sasp_setlbstate_req_LB_uid_len  = -1;
142 static int hf_sasp_setlbstate_req_LB_uid  = -1;
143 static int hf_sasp_setlbstate_req_LB_health  = -1;
144 /*static int hf_sasp_setlbstate_req_LB_flag = -1;*/
145 /* static int hf_lbstate_flag = -1; */
146 static int hf_sasp_pushflag = -1;
147 static int hf_sasp_trustflag = -1;
148 static int hf_sasp_nochangeflag = -1;
149
150 /*setlbstate reply*/
151 /* static int hf_sasp_setlbstate_rep = -1; */
152 static int hf_sasp_setlbstate_rep_rcode = -1;
153 static int hf_sasp_setlbstate_rep_sz = -1;
154
155 /*grp mem state data*/
156 static int hf_sasp_grp_memstatedatacomp = -1;
157 static int hf_sasp_grp_memstatedatacomp_sz = -1;
158 static int hf_sasp_grp_memstatedatacomp_cnt = -1;
159
160 /*mem state data comp*/
161 static int hf_sasp_memstatedatacomp_instance = -1;
162 static int hf_sasp_memstatedatacomp_sz = -1;
163 static int hf_sasp_memstatedatacomp_state = -1;
164 static int hf_sasp_memstatedatacomp_quiesce_flag = -1;
165
166 /*wt entry dat  comp*/
167 static int hf_sasp_weight_entry_data_comp_type = -1;
168 static int hf_sasp_weight_entry_data_comp_sz = -1;
169 static int hf_sasp_weight_entry_data_comp_state = -1;
170 /* static int hf_wtstate_flag = -1; */
171 static int hf_sasp_wed_contactsuccess_flag = -1;
172 static int hf_sasp_wed_quiesce_flag = -1;
173 static int hf_sasp_wed_registration_flag = -1;
174 static int hf_sasp_wed_confident_flag = -1;
175 static int hf_sasp_weight_entry_data_comp_weight = -1;
176
177 /*grp wt entry data comp */
178 static int hf_sasp_grp_wt_entry_datacomp_type = -1;
179 static int hf_sasp_grp_wt_entry_datacomp_sz = -1;
180 static int hf_sasp_grp_wt_entry_datacomp_cnt = -1;
181
182
183 /* Initialize the subtree pointers */
184 static gint ett_sasp_data = -1;
185 static gint ett_sasp_header = -1;
186 static gint ett_sasp_msg = -1;
187 static gint ett_sasp_payload = -1;
188 static gint ett_sasp_reg_req = -1;
189 static gint ett_sasp_reg_rep = -1;
190 static gint ett_sasp_reg_req_sz = -1;
191 static gint ett_sasp_dereg_req_sz= -1;
192 static gint ett_sasp_dereg_rep = -1;
193 static gint ett_sasp_sendwt = -1;
194 static gint ett_sasp_setmemstate_rep = -1;
195 static gint ett_sasp_memdatacomp = -1;
196 static gint ett_sasp_grpdatacomp = -1;
197 static gint ett_sasp_grp_memdatacomp = -1;
198 static gint ett_sasp_setlbstate_req = -1;
199 static gint ett_sasp_setlbstate_rep = -1;
200 static gint ett_sasp_getwt= -1;
201 static gint ett_sasp_setmemstate_req = -1;
202 static gint ett_setlbstate_req_lbflag = -1;
203 static gint ett_sasp_grp_memstatedatacomp = -1;
204 static gint ett_sasp_memstatedatacomp = -1;
205 /*static gint ett_dereg_req_reason_flag = -1;*/
206 static gint ett_sasp_grp_wt_entry_datacomp = -1;
207 static gint ett_sasp_weight_entry_data_comp = -1;
208 static gint ett_wt_entry_data_flag = -1;
209 static gint ett_sasp_wt_rep = -1;
210
211 /* desegmentation of SASP over TCP */
212 static gboolean sasp_desegment = TRUE;
213
214 static const value_string msg_table[] = {
215         { 0x1010, "Registration Request" },
216         { 0x1015, "Registration Reply"},
217         { 0x1020, "DeRegistration Request"},
218         { 0x1025, "DeRegistration Reply"},
219         { 0x1030, "Get Weights Request"},
220         { 0x1035, "Get Weights Reply" },
221         { 0x1040, "Send Weights"},
222         { 0x1050, "Set LB State Request"},
223         { 0x1055, "Set LB State Reply"},
224         { 0x1060, "Set Member State Request"},
225         { 0x1065, "Set Member State Reply"},
226         { 0x3010, "Member Data Component"},
227         { 0x3011, "Group Data Component"},
228         { 0x3012, "Weight Entry Data Component"},
229         { 0x3013, "Member State Instance"},
230         { 0x4010, "Group of Member Data"},
231         { 0x4011, "Group of Weight Entry Data" },
232         { 0x4012, "Group of Member State Data" },
233         {      0,  NULL },
234 };
235 static value_string_ext msg_table_ext = VALUE_STRING_EXT_INIT(msg_table);
236
237 static const value_string protocol_table[] = {
238         { 0x06, "TCP" },
239         { 0x11, "UDP" },
240         {    0,  NULL },
241
242 };
243
244
245 static const value_string lbstate_healthtable[] = {
246         { 0x00, "Least Healthy" },
247         { 0x7f, "Most Healthy" },
248         {    0, NULL },
249 };
250
251
252 static const value_string reg_reply_response_code[] = {
253         { 0x00, "Successful" },
254         { 0x10, "Message not understood" },
255         { 0x11, "GWM will not accept this message from the sender" },
256         { 0x40, "Member already registered" },
257         { 0x44, "Duplicate Member in Request" },
258         { 0x45, "Invalid Group (determined by the GWM)"},
259         { 0x50, "Invalid Group Name Size (size == 0)"},
260         { 0x51, "Invalid LB uid Size (size == 0 or > max)"},
261         { 0x61, "Member is registering itself, but LB hasn't yet contacted the GWM."
262                  "  This registration will not be processed."},
263         {    0, NULL },
264 };
265
266 static const value_string dereg_reply_response_code[] = {
267         { 0x00, "Successful" },
268         { 0x10, "Message not understood" },
269         { 0x11, "GWM will not accept this message from the sender" },
270         { 0x41, "Application or System not registered" },
271         { 0x42, "Unknown Group Name" },
272         { 0x43, "Unknown LB uid" },
273         { 0x44, "Duplicate Member in Request"},
274         { 0x46, "Duplicate Group in Request (for remove all members/groups requests)"},
275         { 0x51, "Invalid LB uid Size (size == 0 or > max)"},
276         { 0x61, "Member is deregistering itself, but LB hasn't yet contacted the GWM."
277                  "  This deregistration will not be processed."},
278         {    0, NULL },
279 };
280
281 static const value_string get_weights_reply_response_code[] = {
282         { 0x00, "Successful" },
283         { 0x10, "Message not understood" },
284         { 0x11, "GWM will not accept this message from the sender" },
285         { 0x42, "Unknown Group Name" },
286         { 0x43, "Unknown LB uid" },
287         { 0x46, "Duplicate Group in Request"},
288         { 0x51, "Invalid LB uid Size (size == 0 or > max)"},
289         {    0, NULL },
290 };
291
292 static const value_string set_lb_state_reply_response_code[] = {
293         { 0x00, "Successful" },
294         { 0x10, "Message not understood" },
295         { 0x11, "GWM will not accept this message from the sender" },
296         { 0x51, "Invalid LB uid Size (size == 0 or > max)"},
297         {    0, NULL },
298 };
299
300 static const value_string set_mem_state_reply_response_code[] = {
301         { 0x00, "Successful" },
302         { 0x10, "Message not understood" },
303         { 0x11, "GWM will not accept this message from the sender" },
304         { 0x41, "Application or System not registered" },
305         { 0x42, "Unknown Group Name" },
306         { 0x43, "Unknown LB uid" },
307         { 0x44, "Duplicate Member in Request"},
308         { 0x46, "Duplicate Group in Request (for remove all members/groups requests)"},
309         { 0x50, "Invalid Group Name Size (size == 0)"},
310         { 0x51, "Invalid LB uid Size (size == 0 or > max)"},
311         {    0, NULL },
312 };
313
314
315 #define SASP_GLOBAL_PORT 3860
316 #define SASP_MIN_PACKET_LEN 13
317
318 #define SASP_DEREG_REQ_REASON_LEARNED   0x01
319 #define SASP_DEREG_REQ_NOREASON_FLAG    0x00
320 #define SASP_HDR_TYPE                 0x2010
321 #define SASP_WED_CONTACT_SUCCESS_FLAG   0x01
322 #define SASP_WED_QUIESCE_FLAG           0x02
323 #define SASP_WED_REG_FLAG               0x04
324 #define SASP_WED_CONF_FLAG              0x08
325 #define SASP_PUSH_FLAG                  0x01
326 #define SASP_TRUST_FLAG                 0x02
327 #define SASP_NOCHANGE_FLAG              0x04
328 #define SASP_QUIESCE_FLAG               0x01
329
330
331
332
333 static guint
334 get_sasp_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset)
335 {
336         guint32 plen;
337
338         /*
339          * Get the length of the SASP packet.
340          */
341         plen = tvb_get_ntohl(tvb, offset + 5);
342         return plen;
343 }
344
345
346
347
348 static void
349 dissect_sasp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
350 {
351         tcp_dissect_pdus(tvb, pinfo, tree, sasp_desegment, SASP_MIN_PACKET_LEN, get_sasp_pdu_len,
352                          (dissector_t)dissect_sasp_pdu);
353
354 }
355
356
357
358 /* Called from tcp_dissect_pdus with a complete SASP pdu */
359 static void
360 dissect_sasp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
361 {
362         /* Set up structures needed to add the protocol subtree and manage it */
363         proto_item *ti;
364         proto_item *hti;
365         proto_item *mti;
366         proto_tree *sasp_tree;
367         proto_tree *msg_tree;
368         proto_tree *pay_load;
369
370         guint16 msg_type;
371         guint16 hdr_type;
372
373         guint32 offset = 0;
374
375         /*protocol is being displayed*/
376
377         col_set_str(pinfo->cinfo, COL_PROTOCOL, "SASP");
378         col_clear(pinfo->cinfo, COL_INFO);
379
380         ti = proto_tree_add_item(tree, proto_sasp, tvb, offset, -1, ENC_NA);
381         sasp_tree = proto_item_add_subtree(ti, ett_sasp_header);
382
383         hdr_type = tvb_get_ntohs(tvb, offset);
384         hti = proto_tree_add_uint_format(sasp_tree, hf_sasp_type, tvb, offset, 2, hdr_type,
385                                    "Type: %s", (hdr_type == SASP_HDR_TYPE) ? "SASP" : "[Invalid]");
386         if (hdr_type != SASP_HDR_TYPE) {
387                 expert_add_info_format(pinfo, hti, PI_MALFORMED, PI_ERROR,
388                                        "Invalid SASP Header Type [0x%04x]", hdr_type);
389                 /* XXX: The folowing should actually happen automatically ? */
390                 col_set_str(pinfo->cinfo, COL_INFO, "[Malformed: Invalid SASP Header Type]");
391                 return;
392         }
393         offset += 2;
394
395         /*length*/
396         proto_tree_add_item(sasp_tree, hf_sasp_length, tvb, offset, 2, ENC_BIG_ENDIAN);
397         offset += 2;
398
399         /*Header Version */
400         proto_tree_add_item(sasp_tree, hf_sasp_vrsn, tvb, offset, 1, ENC_BIG_ENDIAN);
401         offset += 1;
402
403         /*Message*/
404         msg_tree = proto_item_add_subtree(ti, ett_sasp_msg);
405
406         /*Message Len*/
407         proto_tree_add_item(msg_tree, hf_msg_len, tvb, offset, 4, ENC_BIG_ENDIAN);
408         offset += 4;
409
410         /*Message Id*/
411         proto_tree_add_item(msg_tree, hf_msg_id, tvb, offset, 4, ENC_BIG_ENDIAN);
412         offset += 4;
413
414         /*Message Type*/
415         msg_type = tvb_get_ntohs(tvb, offset);
416         mti = proto_tree_add_item(msg_tree, hf_msg_type, tvb, offset, 2, ENC_BIG_ENDIAN);
417         pay_load = proto_item_add_subtree(ti, ett_sasp_payload);
418         offset += 2;
419
420
421
422         switch(msg_type)
423         {
424                 case 0x1010:
425                         /* Registration  Request */
426                         col_set_str(pinfo->cinfo, COL_INFO, "Registration Request");
427                         dissect_reg_req(tvb, pay_load, offset);
428                         return;
429
430                 case 0x1015:
431
432                         /* Registration Reply */
433                         col_set_str(pinfo->cinfo, COL_INFO, "Registration Reply");
434                         dissect_reg_rep(tvb, pay_load, offset);
435                         return;
436
437                 case 0x1020:
438
439                         /* Deregistration Request */
440                         col_set_str(pinfo->cinfo, COL_INFO, "Deregistration Request");
441                         dissect_dereg_req(tvb, pay_load, offset);
442                         return;
443
444                 case 0x1025:
445
446                         /* Deregistration Reply */
447                         col_set_str(pinfo->cinfo, COL_INFO, "Deregistration Reply");
448                         dissect_dereg_rep(tvb, pay_load, offset);
449                         return;
450
451                 case 0x1030:
452
453                         /* Get Weights Request */
454                         col_set_str(pinfo->cinfo, COL_INFO, "Get Weights Request");
455                         dissect_wt_req(tvb, pay_load, offset);
456                         return;
457
458                 case 0x1035:
459
460                         /* Get Weights Response */
461                         col_set_str(pinfo->cinfo, COL_INFO, "Get Weights Response");
462                         dissect_wt_rep(tvb, pay_load, offset);
463                         return;
464
465                 case 0x1040:
466
467                         /* Send Weights Request */
468                         col_set_str(pinfo->cinfo, COL_INFO, "Send Weights Request");
469                         dissect_sendwt(tvb, pay_load, offset);
470                         return;
471
472                 case 0x1050:
473
474                         /* Set LB State Request */
475                         col_set_str(pinfo->cinfo, COL_INFO, "Set LB State Request");
476                         dissect_setlbstate_req(tvb, pay_load, offset);
477                         return;
478
479                 case 0x1055:
480
481                         /* Set LB state Reply */
482                         col_set_str(pinfo->cinfo, COL_INFO, "Set LB State Reply");
483                         dissect_setlbstate_rep(tvb, pay_load, offset);
484                         return;
485
486                 case 0x1060:
487
488                         /* Set Member State Request*/
489                         col_set_str(pinfo->cinfo, COL_INFO, "Set Member State Request");
490                         dissect_setmemstate_req(tvb, pay_load, offset);
491                         return;
492
493                 case 0x1065:
494
495                         /* Set Member State Reply */
496                         col_set_str(pinfo->cinfo, COL_INFO, "Set Member State Reply");
497                         dissect_setmemstate_rep(tvb, pay_load, offset);
498                         return;
499
500                 default:
501
502                         /* Unknown SASP Message Type */
503                         col_add_fstr(pinfo->cinfo, COL_INFO,
504                                      "[Malformed: Unknown Message Type [0x%04x]", msg_type);
505                         expert_add_info_format(pinfo, mti, PI_MALFORMED, PI_WARN,
506                                                "Unknown SASP Message Type: 0x%4x", msg_type);
507                         return;
508          }
509
510 }
511
512
513 static void dissect_reg_req(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset)
514 {
515
516          proto_item *reg_tree;
517          proto_tree *reg_req_data;
518
519          guint16 gmd_cnt, i;
520
521
522          reg_tree = proto_tree_add_text(pay_load, tvb, offset, -1, "Reg Request");
523          reg_req_data = proto_item_add_subtree(reg_tree, ett_sasp_reg_req_sz);
524
525          /* Reg Req Size */
526          proto_tree_add_item(reg_req_data, hf_sasp_reg_req_sz, tvb, offset, 2, ENC_BIG_ENDIAN);
527          offset += 2;
528
529          /* Reg Req LB Flag */
530          proto_tree_add_item(reg_req_data, hf_reg_req_lbflag, tvb, offset, 1, ENC_BIG_ENDIAN);
531          offset += 1;
532
533          gmd_cnt = tvb_get_ntohs(tvb, offset);
534
535          /* Group MEM Data Count */
536          proto_tree_add_item(reg_req_data, hf_sasp_gmd_cnt, tvb, offset, 2, ENC_BIG_ENDIAN);
537          offset += 2;
538
539          for ( i=0; i<gmd_cnt; i++)
540          {
541                  offset = dissect_grp_memdatacomp(tvb, reg_req_data, offset);
542          }
543
544 }
545
546
547
548 static void dissect_reg_rep(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset)
549 {
550
551         proto_item *reg_rep;
552         proto_tree *reg_rep_tree;
553
554         reg_rep = proto_tree_add_text(pay_load, tvb, offset, -1 , "Reg Reply");
555         reg_rep_tree = proto_item_add_subtree(reg_rep, ett_sasp_reg_rep);
556
557         /* Size */
558         proto_tree_add_item(reg_rep_tree, hf_sasp_reg_rep_sz, tvb, offset, 2, ENC_BIG_ENDIAN);
559         offset += 2;
560
561         /* Response Code */
562         proto_tree_add_item(reg_rep_tree, hf_sasp_reg_rep_rcode, tvb, offset, 1, ENC_BIG_ENDIAN);
563         offset += 1;
564
565 }
566
567
568
569 static void dissect_dereg_req(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset)
570 {
571
572         /*proto_item *dereg_req_reason_flag;*/
573         /*proto_tree *dereg_req_reason_flag_tree;*/
574
575         guint16     gmd_cnt, i;
576         proto_item *dereg_tree;
577         proto_tree *dereg_req_data;
578
579         guint8   reason_flag;
580         gboolean first_flag = TRUE;
581
582
583         emem_strbuf_t *reasonflags_strbuf = ep_strbuf_new_label("");
584         const gchar *fstr[] = {"No Reason", "Learned & Purposeful" };
585
586
587         dereg_tree = proto_tree_add_text(pay_load, tvb, offset, -1 , "DeReg Request");
588         dereg_req_data = proto_item_add_subtree(dereg_tree, ett_sasp_dereg_req_sz);
589
590         /* Size */
591         proto_tree_add_item(dereg_req_data, hf_sasp_dereg_req_sz, tvb, offset, 2, ENC_BIG_ENDIAN);
592         offset += 2;
593
594         /* LB Flag */
595         proto_tree_add_item(dereg_req_data, hf_dereg_req_lbflag, tvb, offset, 1, ENC_BIG_ENDIAN);
596         offset += 1;
597
598         /* Reason */
599         ep_strbuf_truncate(reasonflags_strbuf, 0);
600         reason_flag = tvb_get_guint8(tvb, offset);
601
602         if ((reason_flag & SASP_DEREG_REQ_REASON_LEARNED) == 0)
603         {
604                 ep_strbuf_append_printf(reasonflags_strbuf, "%s%s", first_flag ? "" : ", ", fstr[0]);
605                 first_flag = FALSE;
606         }
607         else
608         {
609                 ep_strbuf_append_printf(reasonflags_strbuf, "%s%s", first_flag ? "" : ", ", fstr[1]);
610                 first_flag = FALSE;
611         }
612
613
614         /*dereg_req_reason_flag =*/ proto_tree_add_uint_format(dereg_req_data, hf_dereg_req_reason_flag, tvb,
615                                                                offset, 1, reason_flag,
616                                                                "Reason: 0x%02x (%s)", reason_flag,
617                                                                reasonflags_strbuf->str);
618 #if 0   /* XXX: ToDo?? Flags to be displayed under a subtree ? */
619         dereg_req_reason_flag_tree = proto_item_add_subtree(dereg_req_reason_flag, ett_dereg_req_reason_flag);
620 #endif
621
622         offset += 1;
623
624
625         gmd_cnt = tvb_get_ntohs(tvb, offset);
626
627         /* Group Mem Data Count */
628         proto_tree_add_item(dereg_req_data, hf_sasp_gmd_cnt, tvb, offset, 2, ENC_BIG_ENDIAN);
629         offset += 2;
630
631         /*Group Mem Data */
632         for ( i=0; i<gmd_cnt; i++)
633         {
634                 offset = dissect_grp_memdatacomp(tvb, dereg_req_data, offset);
635         }
636
637 }
638
639
640
641 static void dissect_dereg_rep(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset)
642 {
643
644         proto_item *dereg_rep;
645         proto_tree *dereg_rep_tree;
646
647         dereg_rep = proto_tree_add_text(pay_load, tvb, offset, -1 , "Dereg Reply");
648         dereg_rep_tree = proto_item_add_subtree(dereg_rep, ett_sasp_dereg_rep);
649
650         /* Size */
651         proto_tree_add_item(dereg_rep_tree, hf_sasp_dereg_rep_sz, tvb, offset, 2, ENC_BIG_ENDIAN);
652         offset += 2;
653
654         /* Return Code */
655         proto_tree_add_item(dereg_rep_tree, hf_sasp_dereg_rep_rcode, tvb, offset, 1, ENC_BIG_ENDIAN);
656         offset += 1;
657
658 }
659
660
661 static void dissect_sendwt(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset)
662 {
663
664         proto_item *sendwt;
665         proto_tree *sendwt_tree;
666
667         guint16 gwed_cnt, i;
668
669         sendwt = proto_tree_add_text(pay_load, tvb, offset, -1 , "Send Weight");
670         sendwt_tree = proto_item_add_subtree(sendwt, ett_sasp_sendwt);
671
672         /* Size */
673         proto_tree_add_item(sendwt_tree, hf_sasp_sendwt_sz, tvb, offset, 2, ENC_BIG_ENDIAN);
674         offset += 2;
675
676         gwed_cnt = tvb_get_ntohs(tvb, offset);
677
678         /* Group Wt Entry Data Count */
679         proto_tree_add_item(sendwt_tree, hf_sasp_sendwt_gwedcnt, tvb, offset, 2, ENC_BIG_ENDIAN);
680         offset += 2;
681
682         for (i=0; i<gwed_cnt; i++)
683         {
684                 offset = dissect_grp_wt_entry_datacomp(tvb, sendwt_tree, offset);
685
686         }
687
688 }
689
690
691 static void dissect_setmemstate_req(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset)
692 {
693
694         proto_item *setmemstate;
695         proto_tree *setmemstate_req_data;
696
697         guint16 gmsd_cnt, i;
698
699         setmemstate = proto_tree_add_text(pay_load, tvb, offset, -1 , "Set Mem State Request");
700         setmemstate_req_data = proto_item_add_subtree(setmemstate, ett_sasp_setmemstate_req);
701
702         /* Size */
703         proto_tree_add_item(setmemstate_req_data, hf_sasp_setmemstate_req_sz, tvb, offset, 2, ENC_BIG_ENDIAN);
704         offset += 2;
705
706         /*LB Flag*/
707         proto_tree_add_item(setmemstate_req_data, hf_setmemstate_req_lbflag, tvb, offset, 1, ENC_BIG_ENDIAN);
708         offset += 1;
709
710         /*Group Data Count*/
711         gmsd_cnt = tvb_get_ntohs(tvb, offset);
712         proto_tree_add_item(setmemstate_req_data, hf_sasp_setmemstate_req_gmsd_cnt, tvb, offset, 2, ENC_BIG_ENDIAN);
713         offset += 2;
714
715         for ( i=0; i<gmsd_cnt; i++)
716         {
717                 offset = dissect_grp_memstatedatacomp(tvb, setmemstate_req_data, offset);
718         }
719
720
721 }
722
723 static void dissect_setmemstate_rep(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset)
724 {
725
726         proto_item *setmemstate_rep;
727         proto_tree *setmemstate_rep_tree;
728
729
730         setmemstate_rep = proto_tree_add_text(pay_load, tvb, offset, -1 , "Set Mem State Reply");
731         setmemstate_rep_tree = proto_item_add_subtree(setmemstate_rep, ett_sasp_setmemstate_rep);
732
733         /* Size */
734         proto_tree_add_item(setmemstate_rep_tree, hf_sasp_setmemstate_rep_sz, tvb, offset, 2, ENC_BIG_ENDIAN);
735         offset += 2;
736
737         /* Response Code */
738         proto_tree_add_item(setmemstate_rep_tree, hf_sasp_setmemstate_rep_rcode, tvb, offset, 1, ENC_BIG_ENDIAN);
739         offset += 1;
740 }
741
742
743 static guint32 dissect_memdatacomp(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset, proto_tree **mdct_p)
744 {
745         proto_item *memdatacomp;
746         proto_tree *memdatacomp_tree;
747
748         guint8             lab_len;
749         struct e_in6_addr  ipv6_address;
750         const gchar       *ip_str;
751
752
753         tvb_get_ipv6(tvb, offset+7, &ipv6_address);
754         ip_str = ip6_to_str(&ipv6_address);
755
756         lab_len = tvb_get_guint8(tvb, offset+23);
757
758         memdatacomp = proto_tree_add_ipv6_format(pay_load, hf_sasp_memdatacomp_ip,
759                                                  tvb, offset, 24+lab_len, (guint8*)&ipv6_address,
760                                                  "Member Data Comp (%s)", ip_str);
761
762         memdatacomp_tree = proto_item_add_subtree(memdatacomp, ett_sasp_memdatacomp);
763
764
765         /* Message Type */
766         proto_tree_add_item(memdatacomp_tree, hf_sasp_memdatacomp_type, tvb, offset, 2, ENC_BIG_ENDIAN);
767         offset += 2;
768
769         /* Size */
770         proto_tree_add_item(memdatacomp_tree, hf_sasp_memdatacomp_sz, tvb, offset, 2, ENC_BIG_ENDIAN);
771         offset += 2;
772
773         /* Protocol */
774         proto_tree_add_item(memdatacomp_tree, hf_sasp_memdatacomp_protocol, tvb, offset, 1, ENC_BIG_ENDIAN);
775         offset += 1;
776
777         /* Port */
778         proto_tree_add_item(memdatacomp_tree, hf_sasp_memdatacomp_port, tvb, offset, 2, ENC_BIG_ENDIAN);
779         offset += 2;
780
781         /*Ip*/
782         proto_tree_add_item(memdatacomp_tree, hf_sasp_memdatacomp_ip, tvb, offset, 16, ENC_NA);
783         offset += 16;
784
785
786         /*Label Len*/
787         proto_tree_add_item(memdatacomp_tree, hf_sasp_memdatacomp_lab_len, tvb, offset, 1, ENC_BIG_ENDIAN);
788         offset += 1;
789
790         /*Label*/
791         proto_tree_add_item(memdatacomp_tree, hf_sasp_memdatacomp_label, tvb, offset, lab_len, ENC_ASCII|ENC_NA);
792         offset += lab_len;
793
794         if (mdct_p != NULL)
795                 *mdct_p = memdatacomp_tree;
796
797         return offset;
798
799 }
800
801
802
803 static guint32 dissect_grpdatacomp(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset)
804 {
805
806         proto_item *grpdatacomp;
807         proto_tree *grpdatacomp_tree;
808
809         guint8 LB_uid_len;
810         guint8 grp_name_len;
811
812
813         grpdatacomp = proto_tree_add_text(pay_load, tvb, offset, -1 , "Group Data Component");
814         grpdatacomp_tree = proto_item_add_subtree(grpdatacomp, ett_sasp_grpdatacomp);
815
816         /*Type*/
817         proto_tree_add_item(grpdatacomp_tree, hf_sasp_grpdatacomp, tvb, offset, 2, ENC_BIG_ENDIAN);
818         offset += 2;
819
820         /*Size*/
821         proto_tree_add_item(grpdatacomp_tree, hf_sasp_grpdatacomp_sz, tvb, offset, 2, ENC_BIG_ENDIAN);
822         offset += 2;
823
824         LB_uid_len = tvb_get_guint8(tvb, offset);
825
826         /* LB UID Len*/
827         proto_tree_add_item(grpdatacomp_tree, hf_sasp_grpdatacomp_LB_uid_len,
828                             tvb, offset, 1, ENC_BIG_ENDIAN);
829         offset += 1;
830
831         proto_tree_add_item(grpdatacomp_tree, hf_sasp_grpdatacomp_LB_uid,
832                             tvb, offset, LB_uid_len, ENC_ASCII|ENC_NA);
833         offset += (guint8)LB_uid_len;
834
835
836         grp_name_len = tvb_get_guint8(tvb, offset);
837
838
839         /*Group Name Len */
840         proto_tree_add_item(grpdatacomp_tree, hf_sasp_grpdatacomp_grp_name_len,
841                             tvb, offset, 1, ENC_BIG_ENDIAN);
842         offset += 1;
843
844         /*Group Name*/
845         proto_tree_add_item(grpdatacomp_tree, hf_sasp_grpdatacomp_grp_name,
846                             tvb, offset, grp_name_len, ENC_ASCII|ENC_NA);
847         offset += grp_name_len;
848
849         return offset;
850
851 }
852
853
854 static guint32 dissect_grp_memdatacomp(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset)
855 {
856
857         proto_item *grp_memdatacomp;
858         proto_tree *grp_memdatacomp_tree;
859
860         guint16     mem_cnt;
861         guint16     i;
862
863         grp_memdatacomp = proto_tree_add_text(pay_load, tvb, offset, -1 , "Group Of Member Data");
864         grp_memdatacomp_tree = proto_item_add_subtree(grp_memdatacomp, ett_sasp_grp_memdatacomp);
865
866         /* Group MEM Data */
867         proto_tree_add_item(grp_memdatacomp_tree, hf_sasp_grp_memdatacomp, tvb, offset, 2, ENC_BIG_ENDIAN);
868         offset += 2;
869
870         /* Group MEM Data Size*/
871         proto_tree_add_item(grp_memdatacomp_tree, hf_sasp_grp_memdatacomp_sz, tvb, offset, 2, ENC_BIG_ENDIAN);
872         offset += 2;
873
874         mem_cnt = tvb_get_ntohs(tvb, offset);
875
876         /* Group MEM Data Count*/
877         proto_tree_add_item(grp_memdatacomp_tree, hf_sasp_grp_memdatacomp_cnt, tvb, offset, 2, ENC_BIG_ENDIAN);
878         offset += 2;
879
880         offset = dissect_grpdatacomp(tvb, grp_memdatacomp_tree, offset);
881
882         /* array of memdata */
883         for ( i=0; i<mem_cnt; i++)
884         {
885                 offset = dissect_memdatacomp(tvb, grp_memdatacomp_tree, offset, NULL);
886         }
887
888         return offset;
889
890 }
891
892
893
894 static void dissect_wt_req(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset)
895 {
896
897         proto_item *get_wt_data;
898         proto_tree *get_wt_tree;
899
900         guint16 gd_cnt, i;
901
902
903         get_wt_data = proto_tree_add_text(pay_load, tvb, offset, -1 , "Get Wt Req");
904         get_wt_tree = proto_item_add_subtree(get_wt_data, ett_sasp_getwt);
905
906         /* Size */
907         proto_tree_add_item(get_wt_tree, hf_sasp_wt_req_sz, tvb, offset, 2, ENC_BIG_ENDIAN);
908         offset += 2;
909
910         gd_cnt = tvb_get_ntohs(tvb, offset);
911
912         /* Group Data Count */
913         proto_tree_add_item(get_wt_tree, hf_sasp_wt_req_gd_cnt, tvb, offset, 2, ENC_BIG_ENDIAN);
914         offset += 2;
915
916         for (i=0; i<gd_cnt; i++)
917         {
918                 offset = dissect_grpdatacomp(tvb, get_wt_tree, offset);
919         }
920
921 }
922
923
924 static void dissect_wt_rep(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset)
925 {
926
927         proto_item *wt_rep;
928         proto_tree *wt_rep_tree;
929
930         guint16 gwed_cnt, i;
931
932         wt_rep = proto_tree_add_text(pay_load, tvb, offset, -1 , "Get Weights Reply");
933         wt_rep_tree = proto_item_add_subtree(wt_rep, ett_sasp_wt_rep);
934
935         /* Size */
936         proto_tree_add_item(wt_rep_tree, hf_sasp_wt_rep_sz, tvb, offset, 2, ENC_BIG_ENDIAN);
937         offset += 2;
938
939         /* Response Code */
940         proto_tree_add_item(wt_rep_tree, hf_sasp_wt_rep_rcode, tvb, offset, 1, ENC_BIG_ENDIAN);
941         offset += 1;
942
943         /* Interval */
944         proto_tree_add_item(wt_rep_tree, hf_sasp_wt_rep_interval, tvb, offset, 2, ENC_BIG_ENDIAN);
945         offset += 2;
946
947
948         gwed_cnt = tvb_get_ntohs(tvb, offset);
949
950         /* Count of Group of Wt Entry Data */
951         proto_tree_add_item(wt_rep_tree, hf_sasp_wt_rep_gwed_cnt, tvb, offset, 2, ENC_BIG_ENDIAN);
952         offset += 2;
953
954
955         for (i=0; i<gwed_cnt; i++)
956         {
957                 offset = dissect_grp_wt_entry_datacomp(tvb, wt_rep_tree, offset);
958         }
959 }
960
961
962
963
964 static void dissect_setlbstate_req(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset)
965 {
966
967         guint8 LB_uid_len;
968
969         static const int *lbflags[] = {
970                 &hf_sasp_pushflag,
971                 &hf_sasp_trustflag,
972                 &hf_sasp_nochangeflag,
973                 NULL
974         };
975
976
977         proto_item *setlbstate_req;
978         proto_tree *setlbstate_req_tree;
979
980         setlbstate_req = proto_tree_add_text(pay_load, tvb, offset, -1 , "Set LB State Req");
981         setlbstate_req_tree = proto_item_add_subtree(setlbstate_req, ett_sasp_setlbstate_req);
982
983         /* Size*/
984         proto_tree_add_item(setlbstate_req_tree, hf_sasp_setlbstate_req_sz,
985                             tvb, offset, 2, ENC_BIG_ENDIAN);
986         offset += 2;
987
988         LB_uid_len = tvb_get_guint8(tvb, offset);
989
990
991         /* LB UID Len */
992         proto_tree_add_item(setlbstate_req_tree, hf_sasp_setlbstate_req_LB_uid_len,
993                             tvb, offset, 1, ENC_BIG_ENDIAN);
994         offset += 1;
995
996         /*LB UID*/
997         proto_tree_add_item(setlbstate_req_tree, hf_sasp_setlbstate_req_LB_uid,
998                             tvb, offset, LB_uid_len, ENC_ASCII|ENC_NA);
999         offset += (guint8)LB_uid_len;
1000
1001         /*LB Health*/
1002         proto_tree_add_item(setlbstate_req_tree, hf_sasp_setlbstate_req_LB_health,
1003                             tvb, offset, 1, ENC_BIG_ENDIAN);
1004         offset += 1;
1005
1006
1007         proto_tree_add_bitmask_text(setlbstate_req_tree, tvb, offset, 1, "LB Flags:", NULL,
1008                     ett_setlbstate_req_lbflag, lbflags, ENC_BIG_ENDIAN, 0);
1009
1010
1011         offset += 1;
1012
1013
1014 }
1015
1016
1017
1018 static void dissect_setlbstate_rep(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset)
1019 {
1020
1021         proto_item *setlbstate_rep;
1022         proto_tree *setlbstate_rep_tree;
1023
1024         setlbstate_rep = proto_tree_add_text(pay_load, tvb, offset, -1 , "Set LB State Rep");
1025         setlbstate_rep_tree = proto_item_add_subtree(setlbstate_rep, ett_sasp_setlbstate_rep);
1026
1027
1028         /* Size */
1029         proto_tree_add_item(setlbstate_rep_tree, hf_sasp_setlbstate_rep_sz,
1030                             tvb, offset, 2, ENC_BIG_ENDIAN);
1031         offset += 2;
1032
1033         /* Response Code */
1034         proto_tree_add_item(setlbstate_rep_tree, hf_sasp_setlbstate_rep_rcode,
1035                             tvb, offset, 1, ENC_BIG_ENDIAN);
1036         offset += 1;
1037
1038 }
1039
1040
1041
1042 static guint32 dissect_grp_memstatedatacomp(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset)
1043 {
1044
1045         proto_item *grp_memstatedatacomp;
1046         proto_tree *grp_memstatedatacomp_tree;
1047
1048         guint16 mem_cnt;
1049         guint16 i;
1050
1051         grp_memstatedatacomp = proto_tree_add_text(pay_load, tvb, offset, -1 , "Group Mem State Comp");
1052         grp_memstatedatacomp_tree = proto_item_add_subtree(grp_memstatedatacomp,
1053                                                            ett_sasp_grp_memstatedatacomp);
1054
1055         /* Type */
1056         proto_tree_add_item(grp_memstatedatacomp_tree, hf_sasp_grp_memstatedatacomp,
1057                             tvb, offset, 2, ENC_BIG_ENDIAN);
1058         offset += 2;
1059
1060         /* Size */
1061         proto_tree_add_item(grp_memstatedatacomp_tree, hf_sasp_grp_memstatedatacomp_sz,
1062                             tvb, offset, 2, ENC_BIG_ENDIAN);
1063         offset += 2;
1064
1065         mem_cnt = tvb_get_ntohs(tvb, offset);
1066
1067         /* Count */
1068         proto_tree_add_item(grp_memstatedatacomp_tree, hf_sasp_grp_memstatedatacomp_cnt,
1069                             tvb, offset, 2, ENC_BIG_ENDIAN);
1070         offset += 2;
1071
1072         /* Group Data TLV */
1073         offset = dissect_grpdatacomp(tvb, grp_memstatedatacomp_tree, offset);
1074
1075         /* Array of Mem State Data */
1076         for (i=0; i<mem_cnt; i++)
1077         {
1078                 offset = dissect_memstatedatacomp(tvb, grp_memstatedatacomp_tree, offset);
1079         }
1080
1081         return offset;
1082
1083 }
1084
1085
1086 static guint32 dissect_memstatedatacomp(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset)
1087 {
1088
1089         proto_tree *memstatedatacomp_tree;
1090         proto_item *memstatedatacomp;
1091         proto_tree *memdatacomp_tree;
1092
1093         guint8      memstate_flag;
1094
1095
1096         offset = dissect_memdatacomp(tvb, pay_load, offset, &memdatacomp_tree);
1097
1098         memstatedatacomp = proto_tree_add_text(memdatacomp_tree, tvb, offset, -1 , "Member State Data");
1099         memstatedatacomp_tree = proto_item_add_subtree(memstatedatacomp, ett_sasp_memstatedatacomp);
1100
1101
1102         /* Type */
1103         proto_tree_add_item(memstatedatacomp_tree, hf_sasp_memstatedatacomp_instance,
1104                             tvb, offset, 2, ENC_BIG_ENDIAN);
1105         offset += 2;
1106
1107         /* Size */
1108         proto_tree_add_item(memstatedatacomp_tree, hf_sasp_memstatedatacomp_sz,
1109                             tvb, offset, 2, ENC_BIG_ENDIAN);
1110         offset += 2;
1111
1112         /* State */
1113         proto_tree_add_item(memstatedatacomp_tree, hf_sasp_memstatedatacomp_state,
1114                             tvb, offset, 1, ENC_BIG_ENDIAN);
1115         offset += 1;
1116
1117         /* Quiesce flag*/
1118         memstate_flag = tvb_get_guint8(tvb, offset);
1119         proto_tree_add_boolean(memstatedatacomp_tree, hf_sasp_memstatedatacomp_quiesce_flag,
1120                                tvb, offset, 1, memstate_flag);
1121         offset += 1;
1122
1123         return offset;
1124 }
1125
1126
1127
1128 static guint32 dissect_weight_entry_data_comp(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset)
1129 {
1130
1131         proto_tree *weight_entry_data_comp_tree;
1132         proto_item *weight_entry_data_comp;
1133
1134         static const int *wtflags[] = {
1135                 &hf_sasp_wed_contactsuccess_flag,
1136                 &hf_sasp_wed_quiesce_flag,
1137                 &hf_sasp_wed_registration_flag,
1138                 &hf_sasp_wed_confident_flag,
1139                 NULL
1140         };
1141
1142
1143         offset = dissect_memdatacomp(tvb, pay_load, offset, NULL);
1144
1145         weight_entry_data_comp = proto_tree_add_text(pay_load, tvb, offset, -1 , "Weight Entry Data");
1146         weight_entry_data_comp_tree = proto_item_add_subtree(weight_entry_data_comp,
1147                                                              ett_sasp_weight_entry_data_comp);
1148
1149         /* Type */
1150         proto_tree_add_item(weight_entry_data_comp_tree, hf_sasp_weight_entry_data_comp_type,
1151                             tvb, offset, 2, ENC_BIG_ENDIAN);
1152         offset += 2;
1153
1154         /* Size */
1155         proto_tree_add_item(weight_entry_data_comp_tree, hf_sasp_weight_entry_data_comp_sz,
1156                             tvb, offset, 2, ENC_BIG_ENDIAN);
1157         offset += 2;
1158
1159
1160         proto_tree_add_item(weight_entry_data_comp_tree, hf_sasp_weight_entry_data_comp_state,
1161                             tvb, offset, 1, ENC_BIG_ENDIAN);
1162         offset += 1;
1163
1164
1165         proto_tree_add_bitmask_text(weight_entry_data_comp_tree, tvb, offset, 1, "Flags:", NULL,
1166                     ett_wt_entry_data_flag, wtflags, ENC_BIG_ENDIAN, 0);
1167
1168         offset += 1;
1169
1170
1171         /* Weight */
1172         proto_tree_add_item(weight_entry_data_comp_tree, hf_sasp_weight_entry_data_comp_weight,
1173                             tvb, offset, 2, ENC_BIG_ENDIAN);
1174         offset += 2;
1175
1176         return offset;
1177
1178 }
1179
1180
1181 static guint32 dissect_grp_wt_entry_datacomp(tvbuff_t *tvb, proto_tree *pay_load, guint32 offset)
1182 {
1183
1184         proto_item *grp_wt_entry_datacomp;
1185         proto_tree *grp_wt_entry_datacomp_tree;
1186
1187         guint16     wt_entry_cnt;
1188         guint16     i;
1189
1190         grp_wt_entry_datacomp = proto_tree_add_text(pay_load, tvb, offset, -1 , "Group of Wt Entry Data");
1191         grp_wt_entry_datacomp_tree = proto_item_add_subtree(grp_wt_entry_datacomp,
1192                                                             ett_sasp_grp_wt_entry_datacomp);
1193
1194         /* Type */
1195         proto_tree_add_item(grp_wt_entry_datacomp_tree, hf_sasp_grp_wt_entry_datacomp_type,
1196                             tvb, offset, 2, ENC_BIG_ENDIAN);
1197         offset += 2;
1198
1199         /* Size */
1200         proto_tree_add_item(grp_wt_entry_datacomp_tree, hf_sasp_grp_wt_entry_datacomp_sz,
1201                             tvb, offset, 2, ENC_BIG_ENDIAN);
1202         offset += 2;
1203
1204         wt_entry_cnt = tvb_get_ntohs(tvb, offset);
1205
1206         /* Wt Entry Count*/
1207         proto_tree_add_item(grp_wt_entry_datacomp_tree, hf_sasp_grp_wt_entry_datacomp_cnt,
1208                             tvb, offset, 2, ENC_BIG_ENDIAN);
1209         offset += 2;
1210
1211         /* Group Data */
1212         offset = dissect_grpdatacomp(tvb, grp_wt_entry_datacomp_tree, offset);
1213
1214         /* Member Data */
1215         for (i=0; i<wt_entry_cnt; i++)
1216         {
1217                 offset = dissect_weight_entry_data_comp(tvb, grp_wt_entry_datacomp_tree, offset);
1218         }
1219
1220         return offset;
1221
1222 }
1223
1224
1225
1226 /* sasp protocol register */
1227 void proto_register_sasp(void)
1228 {
1229
1230         static hf_register_info hf[] = {
1231
1232                 /*SASP Header */
1233                 { &hf_sasp_type,
1234                   { "Type", "sasp.msg.type",
1235                     FT_UINT16, BASE_HEX, NULL, 0x0,
1236                     "SASP Header", HFILL }
1237                 },
1238
1239                 { &hf_sasp_length,
1240                   { "Length", "sasp.header.Len",
1241                     FT_UINT16, BASE_DEC, NULL, 0x0,
1242                     "SASP Header Length", HFILL }
1243                 },
1244
1245                 { &hf_sasp_vrsn,
1246                   { "Version", "sasp.version",
1247                     FT_UINT8, BASE_DEC, NULL, 0x0,
1248                     "SASP Version", HFILL }
1249                 },
1250
1251                 { &hf_msg_len,
1252                   { "Message Len", "sasp.msg.len",
1253                     FT_UINT32, BASE_DEC, NULL, 0x0,
1254                     "SASP Msg Len", HFILL }
1255                 },
1256
1257                 { &hf_msg_id,
1258                   { "Message Id", "sasp.msg.id",
1259                     FT_UINT32, BASE_DEC, NULL, 0x0,
1260                     "SASP Msg Id", HFILL }
1261                 },
1262
1263                 /*Message Type*/
1264                 { &hf_msg_type,
1265                   { "Message Type", "sasp.msg.type",
1266                     FT_UINT16, BASE_HEX|BASE_EXT_STRING, &msg_table_ext, 0x0,
1267                     "SASP Msg Type", HFILL }
1268                 },
1269
1270                 /*Reg Request*/
1271                 { &hf_sasp_reg_req_sz,
1272                   { "Reg Req-Size", "sasp.reg-req.size",
1273                     FT_UINT32, BASE_DEC, NULL, 0x0,
1274                     "SASP Reg Req Size", HFILL }
1275                 },
1276
1277                 { &hf_reg_req_lbflag,
1278                   { "Reg Req-LB Flag", "sasp.reg-req.lbflag",
1279                     FT_BOOLEAN, BASE_NONE, NULL, 0x0,
1280                     "SASP Reg Req LB Flag", HFILL } },
1281
1282                 { &hf_sasp_gmd_cnt,
1283                   { "Grp Mem Data-Count", "sasp.grp-mem-data.count",
1284                     FT_UINT16, BASE_DEC, NULL, 0x0,
1285                     "SASP Grp Mem Data Count", HFILL } },
1286
1287                 /* Reg Reply */
1288
1289                 { &hf_sasp_reg_rep_sz,
1290                   { "Reg Reply-Size", "sasp.reg-rep.size",
1291                     FT_UINT16, BASE_DEC, NULL, 0x0,
1292                     "SASP Reg Reply size", HFILL } },
1293
1294                 { &hf_sasp_reg_rep_rcode,
1295                   { "Reg Reply-Return Code", "sasp.reg-rep.retcode",
1296                     FT_UINT8, BASE_HEX, VALS(reg_reply_response_code), 0x0,
1297                     "SASP Reg Rep Return Code", HFILL } },
1298
1299                 /* Dereg Req */
1300                 { &hf_sasp_dereg_req_sz,
1301                   { "Dereg Req-Size", "sasp.dereg-req.size",
1302                     FT_UINT32, BASE_DEC, NULL, 0x0,
1303                     "SASP Dereg Req Size", HFILL } },
1304
1305                 { &hf_dereg_req_lbflag,
1306                   { "Dereg Req-LB Flag", "sasp.dereg-req.lbflag",
1307                     FT_BOOLEAN, BASE_NONE, NULL, 0x0,
1308                     "SASP Dereg Req LB Flag", HFILL } },
1309
1310                 { &hf_dereg_req_reason_flag,
1311                   { "Reason Flags", "sasp.flags.reason",
1312                     FT_UINT8, BASE_HEX, NULL, 0x0,
1313                     NULL, HFILL } },
1314
1315 #if 0
1316                 { &hf_dereg_req_reason,
1317                   { "Dereg Req-Reason", "sasp.dereg-req.reason",
1318                     FT_UINT8, BASE_HEX, NULL, 0x0,
1319                     "SASP Dereg Req Reason", HFILL } },
1320 #endif
1321
1322                 /* Dereg Rep */
1323                 { &hf_sasp_dereg_rep_sz,
1324                   { "Dereg Rep-Size", "sasp.dereg-rep.size",
1325                     FT_UINT16, BASE_DEC, NULL, 0x0,
1326                     "SASP Dereg Rep Size", HFILL } },
1327
1328                 { &hf_sasp_dereg_rep_rcode,
1329                   { "Dereg Rep-Return Code", "sasp.dereg-rep.retcode",
1330                     FT_UINT8, BASE_HEX, VALS(dereg_reply_response_code), 0x0,
1331                     "SASP Dereg Rep Return Code", HFILL } },
1332
1333                 /* Send weight */
1334
1335                 { &hf_sasp_sendwt_sz,
1336                   { "Sendwt-Size", "sasp.sendwt.size",
1337                     FT_UINT16, BASE_DEC, NULL, 0x0,
1338                     "SASP Sendwt-Size", HFILL } },
1339
1340                 { &hf_sasp_sendwt_gwedcnt,
1341                   { "Sendwt-Grp Wt EntryData Count", "sasp.sendwt-grp-wtentrydata.count",
1342                     FT_UINT16, BASE_DEC, NULL, 0x0,
1343                     "SASP Sendwt Grp Wt Entry Data Count", HFILL } },
1344
1345                 /*Set Mem State Req*/
1346
1347                 { &hf_sasp_setmemstate_req_sz,
1348                   { "Set Memstate Req-Size", "sasp.setmemstate-req.size",
1349                     FT_UINT16, BASE_DEC, NULL, 0x0,
1350                     "SASP Set Memstate Req Size", HFILL } },
1351
1352                 { &hf_setmemstate_req_lbflag,
1353                   { "Set Memstate Req-LB Flag", "sasp.setmemstate-req.lbflag",
1354                     FT_BOOLEAN, BASE_NONE, NULL, 0x0,
1355                     "SASP Set Memstate Req LB Flag", HFILL } },
1356
1357                 { &hf_sasp_setmemstate_req_gmsd_cnt,
1358                   { "Set Memstate Req-Gmsd Count", "sasp.group-memstate.count",
1359                     FT_UINT16, BASE_DEC, NULL, 0x0,
1360                     "Group Of Member State Data Count", HFILL } },
1361
1362                 /* Set Mem State Reply */
1363 #if 0
1364                 { &hf_sasp_setmemstate_rep,
1365                   { "Set Memstate Reply", "sasp.setmemstate-rep",
1366                     FT_UINT32, BASE_HEX, NULL, 0x0,
1367                     "SASP Set Memstate Reply", HFILL } },
1368 #endif
1369
1370                 { &hf_sasp_setmemstate_rep_sz,
1371                   { "Set Memstate Rep-Size", "sasp.setmemstate-rep.size",
1372                     FT_UINT16, BASE_DEC, NULL, 0x0,
1373                     "SASP Set Memstate Rep Size", HFILL } },
1374
1375                 { &hf_sasp_setmemstate_rep_rcode,
1376                   { "Set Memstate Rep-Return Code", "sasp.setmemstate-rep.retcode",
1377                     FT_UINT8, BASE_HEX, VALS(set_mem_state_reply_response_code), 0x0,
1378                     "SASP Set Memstate Rep Return Code", HFILL } },
1379
1380                 /*Mem Data Component*/
1381
1382                 { &hf_sasp_memdatacomp_type,
1383                   { "Message Type", "sasp.msg.type",
1384                     FT_UINT16, BASE_HEX|BASE_EXT_STRING, &msg_table_ext, 0x0,
1385                     "SASP Mem Data Comp", HFILL } },
1386
1387                 { &hf_sasp_memdatacomp_sz,
1388                   { "Mem Data Comp-Size", "sasp.memdatacomp.size",
1389                     FT_UINT16, BASE_DEC, NULL, 0x0,
1390                     "SASP Mem Data Comp Size", HFILL } },
1391
1392                 { &hf_sasp_memdatacomp_protocol,
1393                   { "Mem Data Comp-Protocol", "sasp.memdatacomp.protocol",
1394                     FT_UINT8, BASE_HEX, VALS(protocol_table), 0x0,
1395                     "SASP Mem Data Comp Protocol", HFILL } },
1396
1397                 { &hf_sasp_memdatacomp_port,
1398                   { "Mem Data Comp-Port", "sasp.memdatacomp.port",
1399                     FT_UINT16, BASE_DEC, NULL, 0x0,
1400                     "SASP Mem Data Comp Port", HFILL } },
1401
1402                 { &hf_sasp_memdatacomp_ip,
1403                   { "Mem Data Comp-Ip", "sasp.memdatacomp.ip",
1404                     FT_IPv6, BASE_NONE, NULL, 0x0,
1405                     "SASP Mem Data Comp Ip", HFILL } },
1406
1407                 { &hf_sasp_memdatacomp_lab_len,
1408                   { "Mem Data Comp-Label Len", "sasp.memdatacomp.label.len",
1409                     FT_UINT8, BASE_DEC, NULL, 0x0,
1410                     "SASP Mem Data Comp Label Length", HFILL } },
1411
1412                 { &hf_sasp_memdatacomp_label,
1413                   { "Mem Data Comp-Label", "sasp.memdatacomp.label",
1414                     FT_STRING, BASE_NONE, NULL, 0x0,
1415                     "SASP Mem Data Comp Label", HFILL } },
1416
1417                 /*Get Weight Request*/
1418
1419                 { &hf_sasp_wt_req_sz,
1420                   { "Get Wt Req-Size", "sasp.getwt.req.size",
1421                     FT_UINT16, BASE_DEC, NULL, 0x0,
1422                     "SASP Get Wt Req Size", HFILL } },
1423
1424                 { &hf_sasp_wt_req_gd_cnt,
1425                   { "Get Wt Req-Grp Data Count", "sasp.getwt-req-grpdata.count",
1426                     FT_UINT16, BASE_DEC, NULL, 0x0,
1427                     "SASP Get Wt Grp Data Count", HFILL } },
1428
1429                 /*Get Weight Reply*/
1430
1431                 { &hf_sasp_wt_rep_sz,
1432                   { "Get Wt Rep-Size", "sasp.getwt.rep.size",
1433                     FT_UINT16, BASE_DEC, NULL, 0x0,
1434                     "SASP Get Wt Rep Size", HFILL } },
1435
1436                 { &hf_sasp_wt_rep_rcode,
1437                   { "Get Wt Rep-Return Code", "sasp.getwt-rep.retcode",
1438                     FT_UINT8, BASE_HEX, VALS(get_weights_reply_response_code), 0x0,
1439                     "SASP Get Wt Rep Return Code", HFILL } },
1440
1441                 { &hf_sasp_wt_rep_interval,
1442                   { "Get Wt Rep-Interval", "sasp.getwt-rep.interval",
1443                     FT_UINT8, BASE_DEC, NULL, 0x0,
1444                     "SASP Get Wt Rep Interval", HFILL } },
1445
1446                 { &hf_sasp_wt_rep_gwed_cnt,
1447                   { "Get Wt Rep-Grp WtEntry Data Cnt", "sasp.getwt-rep-grpwtentrydata.count",
1448                     FT_UINT16, BASE_DEC, NULL, 0x0,
1449                     "SASP Get Wt Rep Grp Wt Entry Data Cnt", HFILL } },
1450
1451                 /*Set LB State Rep */
1452
1453 #if 0
1454                 { &hf_sasp_setlbstate_rep,
1455                   { "Set Lbstate Rep", "sasp.msg.type",
1456                     FT_UINT32, BASE_HEX, NULL, 0x0,
1457                     "SASP Set Lbstate Rep", HFILL } },
1458 #endif
1459
1460                 { &hf_sasp_setlbstate_rep_sz,
1461                   { "Set Lbstate Rep-Size", "sasp.setlbstate-rep.size",
1462                     FT_UINT16, BASE_DEC, NULL, 0x0,
1463                     "SASP Set Lbstate Rep Size", HFILL } },
1464
1465                 { &hf_sasp_setlbstate_rep_rcode,
1466                   { "Set Lbstate Rep-Return Code", "sasp.setlbstate-rep.retcode",
1467                     FT_UINT8, BASE_HEX, VALS(set_lb_state_reply_response_code), 0x0,
1468                     "SASP Set Lbstate Rep Return Code", HFILL } },
1469
1470
1471                 /*grp data comp */
1472
1473                 { &hf_sasp_grpdatacomp,
1474                   { "Message Type", "sasp.msg.type",
1475                     FT_UINT16, BASE_HEX|BASE_EXT_STRING, &msg_table_ext, 0x0,
1476                     "SASP Grp Data Comp", HFILL } },
1477
1478                 { &hf_sasp_grpdatacomp_sz,
1479                   { "Grp Data Comp-Size", "sasp.grpdatacomp.size",
1480                     FT_UINT16, BASE_DEC, NULL, 0x0,
1481                     "SASP Grp Data Comp size", HFILL } },
1482
1483                 { &hf_sasp_grpdatacomp_LB_uid_len,
1484                   { "Grp Data Comp-Label UID Len", "sasp.grpdatacomp.label.uid.len",
1485                     FT_UINT8, BASE_DEC, NULL, 0x0,
1486                     "SASP Grp Data Comp Label Uid Len", HFILL } },
1487
1488                 { &hf_sasp_grpdatacomp_LB_uid,
1489                   { "Grp Data Comp-Label UID", "sasp.grpdatacomp.label.uid",
1490                     FT_STRING, BASE_NONE, NULL, 0x0,
1491                     "SASP Grp Data Comp Label Uid", HFILL } },
1492
1493                 { &hf_sasp_grpdatacomp_grp_name_len,
1494                   { "Grp Data Comp-Grp Name Len", "sasp.grpdatacomp.grpname.len",
1495                     FT_UINT8, BASE_DEC, NULL, 0x0,
1496                     "SASP Grp Data Comp Grp Name Len", HFILL } },
1497
1498                 { &hf_sasp_grpdatacomp_grp_name,
1499                   { "Grp Data Comp-Grp Name", "sasp.grpdatacomp.grpname",
1500                     FT_STRING, BASE_NONE, NULL, 0x0,
1501                     "SASP Grp Data Comp Grp Name", HFILL } },
1502
1503                 /*grp mem data comp */
1504
1505                 { &hf_sasp_grp_memdatacomp,
1506                   { "Message Type", "sasp.msg.type",
1507                     FT_UINT16, BASE_HEX|BASE_EXT_STRING, &msg_table_ext, 0x0,
1508                     "SASP Grp Mem Data Comp", HFILL } },
1509
1510
1511                 { &hf_sasp_grp_memdatacomp_sz,
1512                   { "Grp Mem Data Comp-Size", "sasp.grp-memdatacomp.size",
1513                     FT_UINT16, BASE_DEC, NULL, 0x0,
1514                     "SASP Grp Mem Data Comp Size", HFILL } },
1515
1516                 { &hf_sasp_grp_memdatacomp_cnt,
1517                   { "Grp Mem Data Comp-Count", "sasp.grp.memdatacomp.count",
1518                     FT_UINT16, BASE_DEC, NULL, 0x0,
1519                     "SASP Grp Mem Data Comp Cnt", HFILL } },
1520
1521
1522                 /*set LB state req*/
1523
1524                 { &hf_sasp_setlbstate_req_sz,
1525                   { "Set LB State Req-Size", "sasp.setlbstate-req.size",
1526                     FT_UINT16, BASE_DEC, NULL, 0x0,
1527                     "SASP Set LB State Req  Size", HFILL } },
1528
1529                 { &hf_sasp_setlbstate_req_LB_uid_len,
1530                   { "Set LB State Req-LB UID Len", "sasp.setlbstate-req.lbuid.len",
1531                     FT_UINT8, BASE_DEC, NULL, 0x0,
1532                     "SASP Set LB State Req  LB Uid Len", HFILL } },
1533
1534                 { &hf_sasp_setlbstate_req_LB_uid,
1535                   { "Set LB State Req-LB UID", "sasp.setlbstate-req.lbuid",
1536                     FT_STRING, BASE_NONE, NULL, 0x0,
1537                     "SASP Set LB State Req LB UID", HFILL } },
1538
1539                 { &hf_sasp_setlbstate_req_LB_health,
1540                   { "Set LB State Req-LB Health", "sasp.setlbstate-req.lbhealth",
1541                     FT_UINT8, BASE_HEX, VALS(lbstate_healthtable), 0x0,
1542                     "SASP Set LB State Req LB Health", HFILL } },
1543
1544 #if 0
1545                 { &hf_lbstate_flag,
1546                   { "Flags", "sasp.flags.lbstate",
1547                     FT_UINT8, BASE_HEX, NULL, 0x0,
1548                     NULL, HFILL } },
1549 #endif
1550
1551                 { &hf_sasp_pushflag,
1552                   { "PUSH", "sasp.flags.push",
1553                     FT_BOOLEAN, 8, NULL, SASP_PUSH_FLAG,
1554                     "SASP Push Flag", HFILL } },
1555
1556                 { &hf_sasp_trustflag,
1557                   { "TRUST", "sasp.flags.trust",
1558                     FT_BOOLEAN, 8, NULL, SASP_TRUST_FLAG,
1559                     "SASP Trust Flag", HFILL } },
1560
1561                 { &hf_sasp_nochangeflag,
1562                   { "NOCHANGE", "sasp.flags.nochange",
1563                     FT_BOOLEAN, 8, NULL, SASP_NOCHANGE_FLAG,
1564                     "SASP Nochange Flag", HFILL } },
1565
1566                 /*grp mem state data comp */
1567
1568                 { &hf_sasp_grp_memstatedatacomp,
1569                   { "Message Type", "sasp.msg.type",
1570                     FT_UINT16, BASE_HEX|BASE_EXT_STRING, &msg_table_ext, 0x0,
1571                     "SASP Message Type", HFILL } },
1572
1573
1574                 { &hf_sasp_grp_memstatedatacomp_sz,
1575                   { "Grp Mem State-Size", "sasp.grp.memstate.size",
1576                     FT_UINT16, BASE_DEC, NULL, 0x0,
1577                     "SASP Grp Mem State Data Comp Size", HFILL } },
1578
1579                 { &hf_sasp_grp_memstatedatacomp_cnt,
1580                   { "Grp Mem State-Count", "sasp.grp.memstate.count",
1581                     FT_UINT16, BASE_DEC, NULL, 0x0,
1582                     "SASP Grp Mem State Data Comp Count", HFILL } },
1583
1584                 /*mem state instance */
1585
1586                 { &hf_sasp_memstatedatacomp_instance,
1587                   { "Message Type", "sasp.msg.type",
1588                     FT_UINT16, BASE_HEX|BASE_EXT_STRING, &msg_table_ext, 0x0,
1589                     "SASP Message Type", HFILL } },
1590
1591
1592                 { &hf_sasp_memstatedatacomp_sz,
1593                   { "Mem State-Size", "sasp.memstate.size",
1594                     FT_UINT16, BASE_DEC, NULL, 0x0,
1595                     "SASP Mem State Data Comp Size", HFILL } },
1596
1597                 { &hf_sasp_memstatedatacomp_state,
1598                   { "Mem State-State", "sasp.memstate.state",
1599                     FT_UINT8, BASE_HEX, NULL, 0x0,
1600                     "SASP Mem State Data Comp State", HFILL } },
1601
1602                 { &hf_sasp_memstatedatacomp_quiesce_flag,
1603                   { "Mem State-Quiesce Flag", "sasp.flags.quiesce",
1604                     FT_BOOLEAN, 8, NULL, SASP_QUIESCE_FLAG,
1605                     "SASP Quiesce Flag", HFILL } },
1606
1607
1608                 /*weight entry data comp*/
1609
1610                 { &hf_sasp_weight_entry_data_comp_type,
1611                   { "Wt Entry Data Comp", "sasp.msg.type",
1612                     FT_UINT16, BASE_HEX|BASE_EXT_STRING, &msg_table_ext, 0x0,
1613                     "SASP Wt Entry Data Comp", HFILL } },
1614
1615                 { &hf_sasp_weight_entry_data_comp_sz,
1616                   { "Wt Entry Data Comp-Size", "sasp.wtentry.size",
1617                     FT_UINT16, BASE_DEC, NULL, 0x0,
1618                     "SASP Wt Entry Data Comp Size", HFILL } },
1619
1620                 { &hf_sasp_weight_entry_data_comp_state,
1621                   { "Wt Entry Data Comp-state", "sasp.wtentry.state",
1622                     FT_UINT8, BASE_HEX, NULL, 0x0,
1623                     "SASP Wt Entry Data Comp State", HFILL } },
1624
1625 #if 0
1626                 { &hf_wtstate_flag,
1627                   { "Flags", "sasp.flags.wtstate",
1628                     FT_UINT8, BASE_HEX, NULL, 0x0,
1629                     NULL, HFILL } },
1630 #endif
1631
1632                 { &hf_sasp_wed_contactsuccess_flag,
1633                   { "Contact Success", "sasp.flags.contactsuccess",
1634                     FT_BOOLEAN, 8, NULL, SASP_WED_CONTACT_SUCCESS_FLAG,
1635                     "SASP Contact Success Flag", HFILL } },
1636
1637                 { &hf_sasp_wed_quiesce_flag,
1638                   { "Quiesce", "sasp.flags.quiesce",
1639                     FT_BOOLEAN, 8, NULL, SASP_WED_QUIESCE_FLAG,
1640                     "SASP Quiesce Flag", HFILL } },
1641
1642                 { &hf_sasp_wed_registration_flag,
1643                   { "Registration", "sasp.flags.registration",
1644                     FT_BOOLEAN, 8, NULL, SASP_WED_REG_FLAG,
1645                     "SASP Registration Flag", HFILL } },
1646
1647                 { &hf_sasp_wed_confident_flag,
1648                   { "Confident", "sasp.flags.confident",
1649                     FT_BOOLEAN, 8, NULL, SASP_WED_CONF_FLAG,
1650                     "SASP Confident Flag", HFILL } },
1651
1652                 { &hf_sasp_weight_entry_data_comp_weight,
1653                   { "Wt Entry Data Comp-weight", "sasp.wtentrydatacomp.weight",
1654                     FT_UINT16, BASE_DEC, NULL, 0x0,
1655                     "SASP Wt Entry Data Comp weight", HFILL } },
1656
1657
1658                 /*grp wt entry data comp */
1659
1660                 { &hf_sasp_grp_wt_entry_datacomp_type,
1661                   { "Grp Wt Entry Data Comp", "sasp.msg.type",
1662                     FT_UINT16, BASE_HEX|BASE_EXT_STRING, &msg_table_ext, 0x0,
1663                     "SASP Grp Wt Entry Data Comp", HFILL } },
1664
1665                 { &hf_sasp_grp_wt_entry_datacomp_sz,
1666                   { "Grp Wt Entry Data Comp Size", "sasp.grp-wtentrydata.size",
1667                     FT_UINT16, BASE_DEC, NULL, 0x0,
1668                     "SASP Grp Wt Entry Data Comp Size", HFILL } },
1669
1670                 { &hf_sasp_grp_wt_entry_datacomp_cnt,
1671                   { "Grp Wt Entry Data Comp Cnt", "sasp.grp-wtentrydata.count",
1672                     FT_UINT16, BASE_DEC, NULL, 0x0,
1673                     "SASP Grp Wt Entry Data Comp Cnt", HFILL } },
1674
1675         };
1676
1677         /* Setup protocol subtree array */
1678
1679         static gint *ett[] = {
1680                 &ett_sasp_data,
1681                 &ett_sasp_header,
1682                 &ett_sasp_msg,
1683                 &ett_sasp_payload,
1684                 &ett_sasp_reg_req,
1685                 &ett_sasp_reg_rep,
1686                 &ett_sasp_reg_req_sz,
1687                 &ett_sasp_dereg_req_sz,
1688                 &ett_sasp_dereg_rep,
1689                 &ett_sasp_sendwt,
1690                 &ett_sasp_setmemstate_req,
1691                 &ett_sasp_setmemstate_rep,
1692                 &ett_sasp_memdatacomp,
1693                 &ett_sasp_grpdatacomp,
1694                 &ett_sasp_grp_memdatacomp,
1695                 &ett_sasp_setlbstate_req,
1696                 &ett_sasp_setlbstate_rep,
1697                 &ett_sasp_getwt,
1698                 &ett_setlbstate_req_lbflag,
1699                 &ett_sasp_grp_memstatedatacomp,
1700                 &ett_sasp_memstatedatacomp,
1701 /*              &ett_dereg_req_reason_flag, */
1702                 &ett_sasp_grp_wt_entry_datacomp,
1703                 &ett_sasp_weight_entry_data_comp,
1704                 &ett_wt_entry_data_flag,
1705                 &ett_sasp_wt_rep,
1706         };
1707
1708         module_t *sasp_module;
1709
1710         proto_sasp = proto_register_protocol("Server/Application State Protocol", "SASP", "sasp");
1711
1712         proto_register_field_array(proto_sasp, hf, array_length(hf));
1713         proto_register_subtree_array(ett, array_length(ett));
1714
1715         sasp_module = prefs_register_protocol(proto_sasp, NULL);
1716         prefs_register_bool_preference(sasp_module, "desegment_sasp_messages",
1717                                        "Reassemble SASP messages spanning multiple TCP segments",
1718                                        "Whether the SASP dissector should reassemble messages"
1719                                         " spanning multiple TCP segments."
1720                                         " To use this option, you must also enable"
1721                                         " \"Allow subdissectors to reassemble TCP streams\""
1722                                         " in the TCP protocol settings.",
1723                                        &sasp_desegment);
1724
1725 }
1726
1727 /* Handing off to TCP */
1728 void
1729 proto_reg_handoff_sasp(void)
1730 {
1731         dissector_handle_t sasp_handle;
1732         sasp_handle = create_dissector_handle(dissect_sasp, proto_sasp);
1733         dissector_add_uint("tcp.port", SASP_GLOBAL_PORT, sasp_handle);
1734
1735 }
1736