HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / epan / dissectors / packet-iuup.c
blob7843935ee894a4cd38cdb229c6532ce5a67e6a79
1 /* packet-iuup.c
2 * IuUP Protocol 3GPP TS 25.415 V6.2.0 (2005-03)
4 * (c) 2005 Luis E. Garcia Ontanon <luis@ontanon.org>
6 * $Id$
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29 Patch by Polystar (Peter Vestman, Petter Edblom):
30 Corrected rfci handling in rate control messages
31 Added crc6 and crc10 checks for header and payload
34 #include "config.h"
36 #include <glib.h>
37 #include <epan/packet.h>
38 #include <epan/prefs.h>
39 #include <epan/wmem/wmem.h>
40 #include <epan/expert.h>
41 #include <wsutil/crc10.h>
42 #include <wsutil/crc6.h>
45 typedef struct _iuup_rfci_t {
46 guint id;
47 guint sum_len;
48 guint num_of_subflows;
49 struct {
50 guint len;
51 } subflow[8];
52 struct _iuup_rfci_t* next;
53 } iuup_rfci_t;
55 typedef struct {
56 guint32 id;
57 guint num_of_subflows;
58 iuup_rfci_t* rfcis;
59 iuup_rfci_t* last_rfci;
60 } iuup_circuit_t;
62 static int proto_iuup = -1;
64 static int hf_iuup_direction = -1;
65 static int hf_iuup_circuit_id = -1;
67 static int hf_iuup_pdu_type = -1;
68 static int hf_iuup_frame_number = -1;
69 static int hf_iuup_fqc = -1;
70 static int hf_iuup_rfci = -1;
71 static int hf_iuup_hdr_crc = -1;
72 static int hf_iuup_payload_crc = -1;
74 static int hf_iuup_ack_nack = -1;
75 static int hf_iuup_frame_number_t14 = -1;
76 static int hf_iuup_mode_version = -1;
77 static int hf_iuup_procedure_indicator = -1;
78 static int hf_iuup_error_cause_val = -1;
80 static int hf_iuup_init_ti = -1;
81 static int hf_iuup_init_subflows_per_rfci = -1;
82 static int hf_iuup_init_chain_ind = -1;
84 static int hf_iuup_error_distance = -1;
85 static int hf_iuup_errorevt_cause_val = -1;
87 static int hf_iuup_time_align = -1;
88 static int hf_iuup_spare_bytes = -1;
89 static int hf_iuup_spare_03 = -1;
90 /* static int hf_iuup_spare_0f = -1; */
91 /* static int hf_iuup_spare_c0 = -1; */
92 static int hf_iuup_spare_e0 = -1;
93 static int hf_iuup_spare_ff = -1;
95 static int hf_iuup_delay = -1;
96 static int hf_iuup_advance = -1;
97 static int hf_iuup_delta = -1;
99 static int hf_iuup_mode_versions = -1;
100 static int hf_iuup_mode_versions_a[] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
103 static int hf_iuup_data_pdu_type = -1;
105 static int hf_iuup_num_rfci_ind = -1;
107 static int hf_iuup_payload = -1;
109 static int hf_iuup_init_rfci_ind = -1;
110 static int hf_iuup_init_rfci[] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
112 static int hf_iuup_init_rfci_flow_len[64][8] = {
113 {-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,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-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1,-1,-1},
133 {-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1,-1,-1},
134 {-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1,-1,-1},
135 {-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1,-1,-1},{-1,-1,-1,-1,-1,-1,-1,-1}
138 static int hf_iuup_rfci_ratectl[] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1};
141 static gint ett_iuup = -1;
142 static gint ett_rfci = -1;
143 static gint ett_ipti = -1;
144 static gint ett_support = -1;
145 static gint ett_time = -1;
146 static gint ett_rfciinds = -1;
147 static gint ett_payload = -1;
148 static gint ett_payload_subflows = -1;
150 static expert_field ei_iuup_hdr_crc_bad = EI_INIT;
151 static expert_field ei_iuup_payload_crc_bad = EI_INIT;
152 static expert_field ei_iuup_payload_undecoded = EI_INIT;
153 static expert_field ei_iuup_error_response = EI_INIT;
154 static expert_field ei_iuup_ack_nack = EI_INIT;
155 static expert_field ei_iuup_time_align = EI_INIT;
156 static expert_field ei_iuup_procedure_indicator = EI_INIT;
157 static expert_field ei_iuup_pdu_type = EI_INIT;
159 static GHashTable* circuits = NULL;
161 static dissector_handle_t data_handle = NULL;
162 static gboolean dissect_fields = FALSE;
163 static gboolean two_byte_pseudoheader = FALSE;
164 static guint global_dynamic_payload_type = 0;
167 #define PDUTYPE_DATA_WITH_CRC 0
168 #define PDUTYPE_DATA_NO_CRC 1
169 #define PDUTYPE_DATA_CONTROL_PROC 14
171 static const value_string iuup_pdu_types[] = {
172 {PDUTYPE_DATA_WITH_CRC,"Data with CRC"},
173 {PDUTYPE_DATA_NO_CRC,"Data without CRC"},
174 {PDUTYPE_DATA_CONTROL_PROC,"Control Procedure"},
175 {0,NULL}
178 static const value_string iuup_colinfo_pdu_types[] = {
179 {PDUTYPE_DATA_WITH_CRC,"Data (CRC)"},
180 {PDUTYPE_DATA_NO_CRC,"Data (no CRC)"},
181 {PDUTYPE_DATA_CONTROL_PROC,""},
182 {0,NULL}
185 #define ACKNACK_ACK 0x4
186 #define ACKNACK_NACK 0x8
187 #define ACKNACK_RESERVED 0xc
188 #define ACKNACK_PROC 0x0
190 static const value_string iuup_acknack_vals[] = {
191 {ACKNACK_PROC >> 2,"Procedure"},
192 {ACKNACK_ACK >> 2,"ACK"},
193 {ACKNACK_NACK >> 2,"NACK"},
194 {ACKNACK_RESERVED >> 2,"Reserved"},
195 {0,NULL}
198 static const value_string iuup_colinfo_acknack_vals[] = {
199 {ACKNACK_PROC,""},
200 {ACKNACK_ACK,"ACK "},
201 {ACKNACK_NACK,"NACK "},
202 {ACKNACK_RESERVED,"Reserved "},
203 {0,NULL}
206 #define PROC_INIT 0
207 #define PROC_RATE 1
208 #define PROC_TIME 2
209 #define PROC_ERROR 3
211 static const value_string iuup_procedures[] = {
212 {PROC_INIT,"Initialization"},
213 {PROC_RATE,"Rate Control"},
214 {PROC_TIME,"Time Alignment"},
215 {PROC_ERROR,"Error Event"},
216 {4,"Reserved(4)"},
217 {5,"Reserved(5)"},
218 {6,"Reserved(6)"},
219 {7,"Reserved(7)"},
220 {8,"Reserved(8)"},
221 {9,"Reserved(9)"},
222 {10,"Reserved(10)"},
223 {11,"Reserved(11)"},
224 {12,"Reserved(12)"},
225 {13,"Reserved(13)"},
226 {14,"Reserved(14)"},
227 {15,"Reserved(15)"},
228 {0,NULL}
231 static const value_string iuup_colinfo_procedures[] = {
232 {PROC_INIT,"Initialization "},
233 {PROC_RATE,"Rate Control "},
234 {PROC_TIME,"Time Alignment "},
235 {PROC_ERROR,"Error Event "},
236 {0,NULL}
240 static const value_string iuup_error_distances[] = {
241 {0, "Reporting local error"},
242 {1, "First forwarding of error event report"},
243 {2, "Second forwarding of error event report"},
244 {3, "Reserved"},
245 {0,NULL}
248 static const value_string iuup_error_causes[] = {
249 {0, "CRC error of frame header"},
250 {1, "CRC error of frame payload"},
251 {2, "Unexpected frame number"},
252 {3, "Frame loss"},
253 {4, "PDU type unknown"},
254 {5, "Unknown procedure"},
255 {6, "Unknown reserved value"},
256 {7, "Unknown field"},
257 {8, "Frame too short"},
258 {9, "Missing fields"},
259 {16, "Unexpected PDU type"},
260 {18, "Unexpected procedure"},
261 {19, "Unexpected RFCI"},
262 {20, "Unexpected value"},
263 {42, "Initialisation failure"},
264 {43, "Initialisation failure (network error, timer expiry)"},
265 {44, "Initialisation failure (Iu UP function error, repeated NACK)"},
266 {45, "Rate control failure"},
267 {46, "Error event failure"},
268 {47, "Time Alignment not supported"},
269 {48, "Requested Time Alignment not possible"},
270 {49, "Iu UP Mode version not supported"},
271 {0,NULL}
274 static const value_string iuup_rfci_indicator[] = {
275 {0, "RFCI allowed"},
276 {1, "RFCI barred"},
277 {0,NULL}
281 static const value_string iuup_ti_vals[] = {
282 {0, "IPTIs not present"},
283 {1, "IPTIs present in frame"},
284 {0,NULL}
287 static const value_string iuup_mode_version_support[] = {
288 {0, "not supported"},
289 {1, "supported"},
290 {0,NULL}
293 static const value_string iuup_init_rfci_li_vals[] = {
294 {0, "one octet used"},
295 {1, "two octets used"},
296 {0,NULL}
299 static const value_string iuup_init_chain_ind_vals[] = {
300 {0, "this frame is the last frame for the procedure"},
301 {1, "additional frames will be sent for the procedure"},
302 {0,NULL}
305 static const value_string iuup_init_lri_vals[] = {
306 {0, "Not last RFCI"},
307 {1, "Last RFCI in current frame"},
308 {0,NULL}
311 static const value_string iuup_payload_pdu_type[] = {
312 {0, "PDU type 0"},
313 {1, "PDU type 1"},
314 {0,NULL}
317 static const value_string iuup_fqcs[] = {
318 {0, "Frame Good"},
319 {1, "Frame BAD"},
320 {2, "Frame bad due to radio"},
321 {3, "spare"},
322 {0,NULL}
326 static proto_item*
327 iuup_proto_tree_add_bits(proto_tree* tree, int hf, tvbuff_t* tvb, int offset, int bit_offset, guint bits, guint8** buf) {
328 static const guint8 masks[] = {0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe};
329 int len = (bits + bit_offset)/8 + (((bits + bit_offset)%8) ? 0 : 1);
330 guint8* shifted_buffer;
331 proto_item* pi;
332 int i;
334 DISSECTOR_ASSERT(bit_offset < 8);
336 shifted_buffer = (guint8 *)tvb_memdup(wmem_packet_scope(),tvb,offset,len+1);
338 for(i = 0; i < len; i++) {
339 shifted_buffer[i] <<= bit_offset;
340 shifted_buffer[i] |= (shifted_buffer[i+1] & masks[bit_offset]) >> (8 - bit_offset);
343 shifted_buffer[len] <<= bit_offset;
344 shifted_buffer[len] &= masks[(bits + bit_offset)%8];
346 if (buf)
347 *buf = shifted_buffer;
349 pi = proto_tree_add_bytes(tree, hf, tvb, offset, len + (((bits + bit_offset)%8) ? 1 : 0) , shifted_buffer);
350 proto_item_append_text(pi, " (%i Bits)", bits);
352 return pi;
355 static void dissect_iuup_payload(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, guint rfci_id _U_, int offset) {
356 iuup_circuit_t* iuup_circuit;
357 iuup_rfci_t *rfci;
358 int last_offset = tvb_length(tvb) - 1;
359 guint bit_offset = 0;
360 proto_item* pi;
362 pi = proto_tree_add_item(tree,hf_iuup_payload,tvb,offset,-1,ENC_NA);
364 if ( ! dissect_fields ) {
365 return;
366 } else if ( ! pinfo->circuit_id
367 || ! ( iuup_circuit = (iuup_circuit_t *)g_hash_table_lookup(circuits,GUINT_TO_POINTER(pinfo->circuit_id)) ) ) {
368 expert_add_info(pinfo, pi, &ei_iuup_payload_undecoded);
369 return;
372 for(rfci = iuup_circuit->rfcis; rfci; rfci = rfci->next)
373 if ( rfci->id == rfci_id )
374 break;
376 if (!rfci) {
377 expert_add_info(pinfo, pi, &ei_iuup_payload_undecoded);
378 return;
381 tree = proto_item_add_subtree(pi,ett_payload);
384 do {
385 guint i;
386 guint subflows = rfci->num_of_subflows;
387 proto_tree* flow_tree;
389 pi = proto_tree_add_text(tree,tvb,offset,-1,"Payload Frame");
390 flow_tree = proto_item_add_subtree(pi,ett_payload_subflows);
392 bit_offset = 0;
394 for(i = 0; i < subflows; i++) {
396 if (! rfci->subflow[i].len)
397 continue;
399 iuup_proto_tree_add_bits(flow_tree, hf_iuup_rfci_subflow[rfci->id][i], tvb,
400 offset + (bit_offset/8),
401 bit_offset % 8,
402 rfci->subflow[i].len,
403 NULL);
405 bit_offset += rfci->subflow[i].len;
408 offset += (bit_offset / 8) + ((bit_offset % 8) ? 1 : 0);
410 } while (offset <= last_offset);
413 static guint dissect_rfcis(tvbuff_t* tvb, packet_info* pinfo _U_, proto_tree* tree, int* offset, iuup_circuit_t* iuup_circuit) {
414 proto_item* pi;
415 proto_tree* pt;
416 guint8 oct;
417 guint c = 0;
418 guint i;
420 do {
421 iuup_rfci_t *rfci = wmem_new0(wmem_file_scope(), iuup_rfci_t);
422 guint len = 0;
424 DISSECTOR_ASSERT(c < 64);
426 pi = proto_tree_add_item(tree,hf_iuup_init_rfci_ind,tvb,*offset,-1,ENC_NA);
427 pt = proto_item_add_subtree(pi,ett_rfci);
429 proto_tree_add_item(pt,hf_iuup_init_rfci_lri[c],tvb,*offset,1,ENC_BIG_ENDIAN);
430 proto_tree_add_item(pt,hf_iuup_init_rfci_li[c],tvb,*offset,1,ENC_BIG_ENDIAN);
431 proto_tree_add_item(pt,hf_iuup_init_rfci[c],tvb,*offset,1,ENC_BIG_ENDIAN);
433 oct = tvb_get_guint8(tvb,*offset);
434 rfci->id = oct & 0x3f;
435 rfci->num_of_subflows = iuup_circuit->num_of_subflows;
437 len = (oct & 0x40) ? 2 : 1;
438 proto_item_set_text(pi,"RFCI %i Initialization",rfci->id);
439 proto_item_set_len(pi,(len*iuup_circuit->num_of_subflows)+1);
441 (*offset)++;
443 for(i = 0; i < iuup_circuit->num_of_subflows; i++) {
444 guint subflow_len;
446 if (len == 2) {
447 subflow_len = tvb_get_ntohs(tvb,*offset);
448 } else {
449 subflow_len = tvb_get_guint8(tvb,*offset);
452 rfci->subflow[i].len = subflow_len;
453 rfci->sum_len += subflow_len;
455 proto_tree_add_uint(pt,hf_iuup_init_rfci_flow_len[c][i],tvb,*offset,len,subflow_len);
457 (*offset) += len;
461 if (iuup_circuit->last_rfci) {
462 iuup_circuit->last_rfci = iuup_circuit->last_rfci->next = rfci;
463 } else {
464 iuup_circuit->last_rfci = iuup_circuit->rfcis = rfci;
467 c++;
468 } while ( ! (oct & 0x80) );
470 return c - 1;
473 static void dissect_iuup_init(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree) {
474 int offset = 4;
475 guint8 oct = tvb_get_guint8(tvb,offset);
476 guint n = (oct & 0x0e) >> 1;
477 gboolean ti = oct & 0x10;
478 guint i;
479 guint rfcis;
480 proto_item* pi;
481 proto_tree* support_tree = NULL;
482 proto_tree* iptis_tree;
483 iuup_circuit_t* iuup_circuit = NULL;
485 if (pinfo->circuit_id) {
486 iuup_circuit = (iuup_circuit_t *)g_hash_table_lookup(circuits,GUINT_TO_POINTER(pinfo->circuit_id));
488 if (iuup_circuit) {
489 g_hash_table_remove(circuits,GUINT_TO_POINTER(pinfo->circuit_id));
492 iuup_circuit = wmem_new0(wmem_file_scope(), iuup_circuit_t);
493 } else {
494 iuup_circuit = wmem_new0(wmem_packet_scope(), iuup_circuit_t);
497 iuup_circuit->id = pinfo->circuit_id;
498 iuup_circuit->num_of_subflows = n;
499 iuup_circuit->rfcis = NULL;
500 iuup_circuit->last_rfci = NULL;
502 if (pinfo->circuit_id) {
503 g_hash_table_insert(circuits,GUINT_TO_POINTER(iuup_circuit->id),iuup_circuit);
506 if (tree) {
507 proto_tree_add_item(tree,hf_iuup_spare_e0,tvb,offset,1,ENC_BIG_ENDIAN);
508 proto_tree_add_item(tree,hf_iuup_init_ti,tvb,offset,1,ENC_BIG_ENDIAN);
509 proto_tree_add_item(tree,hf_iuup_init_subflows_per_rfci,tvb,offset,1,ENC_BIG_ENDIAN);
510 proto_tree_add_item(tree,hf_iuup_init_chain_ind,tvb,offset,1,ENC_BIG_ENDIAN);
513 offset++;
515 rfcis = dissect_rfcis(tvb, pinfo, tree, &offset, iuup_circuit);
517 if (!tree) return;
519 if (ti) {
520 pi = proto_tree_add_text(tree,tvb,offset,(rfcis/2)+(rfcis%2),"IPTIs");
521 iptis_tree = proto_item_add_subtree(pi,ett_ipti);
523 for (i = 0; i <= rfcis; i++) {
524 proto_tree_add_item(iptis_tree,hf_iuup_init_ipti[i],tvb,offset,1,ENC_BIG_ENDIAN);
525 if ((i%2)) {
526 offset++;
530 if ((i%2)) {
531 offset++;
535 if (tree) {
536 pi = proto_tree_add_item(tree,hf_iuup_mode_versions,tvb,offset,2,ENC_BIG_ENDIAN);
537 support_tree = proto_item_add_subtree(pi,ett_support);
539 for (i = 0; i < 16; i++) {
540 proto_tree_add_item(support_tree,hf_iuup_mode_versions_a[i],tvb,offset,2,ENC_BIG_ENDIAN);
545 offset += 2;
547 proto_tree_add_item(tree,hf_iuup_data_pdu_type,tvb,offset,1,ENC_BIG_ENDIAN);
551 static void dissect_iuup_ratectl(tvbuff_t* tvb, packet_info* pinfo _U_, proto_tree* tree) {
552 guint num = tvb_get_guint8(tvb,4) & 0x3f;
553 guint i;
554 proto_item* pi;
555 proto_tree* inds_tree;
556 int offset = 4;
558 pi = proto_tree_add_item(tree,hf_iuup_num_rfci_ind,tvb,4,1,ENC_BIG_ENDIAN);
559 inds_tree = proto_item_add_subtree(pi,ett_rfciinds);
561 for (i = 0; i < num; i++) {
562 if (! (i % 8) ) offset++;
563 proto_tree_add_item(inds_tree,hf_iuup_rfci_ratectl[i],tvb,offset,1,ENC_BIG_ENDIAN);
568 static void add_hdr_crc(tvbuff_t* tvb, packet_info* pinfo, proto_item* iuup_tree, guint16 crccheck)
570 proto_item *crc_item;
572 crc_item = proto_tree_add_item(iuup_tree,hf_iuup_hdr_crc,tvb,2,1,ENC_BIG_ENDIAN);
573 if (crccheck) {
574 proto_item_append_text(crc_item, "%s", " [incorrect]");
575 expert_add_info(pinfo, crc_item, &ei_iuup_hdr_crc_bad);
579 static void add_payload_crc(tvbuff_t* tvb, packet_info* pinfo, proto_item* iuup_tree)
581 proto_item *crc_item;
582 int length = tvb_length(tvb);
583 guint16 crc10 = tvb_get_ntohs(tvb, 2) & 0x3FF;
584 guint16 crccheck = update_crc10_by_bytes(crc10, tvb_get_ptr(tvb, 4, length - 4), length - 4);
586 crc_item = proto_tree_add_item(iuup_tree,hf_iuup_payload_crc,tvb,2,2,ENC_BIG_ENDIAN);
587 if (crccheck) {
588 proto_item_append_text(crc_item, "%s", " [incorrect]");
589 expert_add_info(pinfo, crc_item, &ei_iuup_payload_crc_bad);
593 #define ACKNACK_MASK 0x0c
594 #define PROCEDURE_MASK 0x0f
595 #define FQC_MASK 0xc0
596 #define PDUTYPE_MASK 0xf0
597 static void dissect_iuup(tvbuff_t* tvb_in, packet_info* pinfo, proto_tree* tree) {
598 proto_item* pi;
599 proto_item* iuup_item = NULL;
600 proto_item* pdutype_item = NULL;
601 proto_tree* iuup_tree = NULL;
602 proto_item* proc_item = NULL;
603 proto_item* ack_item = NULL;
604 guint8 first_octet;
605 guint8 second_octet;
606 guint8 pdutype;
607 guint phdr = 0;
608 guint16 hdrcrc6;
609 guint16 crccheck;
610 tvbuff_t* tvb = tvb_in;
612 col_set_str(pinfo->cinfo, COL_PROTOCOL, "IuUP");
614 if (two_byte_pseudoheader) {
615 int len = tvb_length(tvb_in) - 2;
617 phdr = tvb_get_ntohs(tvb,0);
619 proto_tree_add_item(tree,hf_iuup_direction,tvb,0,2,ENC_BIG_ENDIAN);
620 proto_tree_add_item(tree,hf_iuup_circuit_id,tvb,0,2,ENC_BIG_ENDIAN);
622 phdr &= 0x7fff;
624 pinfo->circuit_id = phdr;
626 tvb = tvb_new_subset(tvb_in,2,len,len);
629 first_octet = tvb_get_guint8(tvb,0);
630 second_octet = tvb_get_guint8(tvb,1);
631 hdrcrc6 = tvb_get_guint8(tvb, 2) >> 2;
632 crccheck = update_crc6_by_bytes(hdrcrc6, first_octet, second_octet);
634 pdutype = ( first_octet & PDUTYPE_MASK ) >> 4;
636 if (tree) {
637 iuup_item = proto_tree_add_item(tree,proto_iuup,tvb,0,-1,ENC_NA);
638 iuup_tree = proto_item_add_subtree(iuup_item,ett_iuup);
640 pdutype_item = proto_tree_add_item(iuup_tree,hf_iuup_pdu_type,tvb,0,1,ENC_BIG_ENDIAN);
643 col_add_str(pinfo->cinfo, COL_INFO, val_to_str(pdutype, iuup_colinfo_pdu_types, "Unknown PDU Type(%u) "));
645 switch(pdutype) {
646 case PDUTYPE_DATA_WITH_CRC:
647 col_append_fstr(pinfo->cinfo, COL_INFO,"FN: %x RFCI: %u", (guint)(first_octet & 0x0f) ,(guint)(second_octet & 0x3f));
649 proto_tree_add_item(iuup_tree,hf_iuup_frame_number,tvb,0,1,ENC_BIG_ENDIAN);
650 pi = proto_tree_add_item(iuup_tree,hf_iuup_fqc,tvb,1,1,ENC_BIG_ENDIAN);
652 if (first_octet & FQC_MASK) {
653 expert_add_info(pinfo, pi, &ei_iuup_error_response);
656 if (!tree) return;
657 proto_tree_add_item(iuup_tree,hf_iuup_rfci,tvb,1,1,ENC_BIG_ENDIAN);
658 add_hdr_crc(tvb, pinfo, iuup_tree, crccheck);
659 add_payload_crc(tvb, pinfo, iuup_tree);
660 dissect_iuup_payload(tvb,pinfo,iuup_tree,second_octet & 0x3f,4);
661 return;
662 case PDUTYPE_DATA_NO_CRC:
663 col_append_fstr(pinfo->cinfo, COL_INFO," RFCI %u", (guint)(second_octet & 0x3f));
665 proto_tree_add_item(iuup_tree,hf_iuup_frame_number,tvb,0,1,ENC_BIG_ENDIAN);
666 pi = proto_tree_add_item(iuup_tree,hf_iuup_fqc,tvb,1,1,ENC_BIG_ENDIAN);
668 if (first_octet & FQC_MASK) {
669 expert_add_info(pinfo, pi, &ei_iuup_error_response);
672 if (!tree)
673 return;
674 proto_tree_add_item(iuup_tree,hf_iuup_rfci,tvb,1,1,ENC_BIG_ENDIAN);
675 add_hdr_crc(tvb, pinfo, iuup_tree, crccheck);
676 dissect_iuup_payload(tvb,pinfo,iuup_tree,second_octet & 0x3f,3);
677 return;
678 case PDUTYPE_DATA_CONTROL_PROC:
679 if (tree) {
680 ack_item = proto_tree_add_item(iuup_tree,hf_iuup_ack_nack,tvb,0,1,ENC_BIG_ENDIAN);
681 proto_tree_add_item(iuup_tree,hf_iuup_frame_number_t14,tvb,0,1,ENC_BIG_ENDIAN);
682 proto_tree_add_item(iuup_tree,hf_iuup_mode_version,tvb,1,1,ENC_BIG_ENDIAN);
683 proc_item = proto_tree_add_item(iuup_tree,hf_iuup_procedure_indicator,tvb,1,1,ENC_BIG_ENDIAN);
684 add_hdr_crc(tvb, pinfo, iuup_tree, crccheck);
687 col_append_str(pinfo->cinfo, COL_INFO,
688 val_to_str(first_octet & ACKNACK_MASK,
689 iuup_colinfo_acknack_vals, "[action:%u] "));
691 col_append_str(pinfo->cinfo, COL_INFO,
692 val_to_str(second_octet & PROCEDURE_MASK,
693 iuup_colinfo_procedures, "[proc:%u] "));
695 switch ( first_octet & ACKNACK_MASK ) {
696 case ACKNACK_ACK:
697 switch(second_octet & PROCEDURE_MASK) {
698 case PROC_INIT:
699 if (!tree) return;
700 proto_tree_add_item(iuup_tree,hf_iuup_spare_03,tvb,2,1,ENC_BIG_ENDIAN);
701 proto_tree_add_item(iuup_tree,hf_iuup_spare_ff,tvb,3,1,ENC_BIG_ENDIAN);
702 return;
703 case PROC_RATE:
704 if (!tree) return;
705 dissect_iuup_ratectl(tvb,pinfo,iuup_tree);
706 return;
707 case PROC_TIME:
708 case PROC_ERROR:
709 break;
710 default:
711 expert_add_info(pinfo, proc_item, &ei_iuup_procedure_indicator);
712 return;
714 break;
715 case ACKNACK_NACK:
716 pi = proto_tree_add_item(iuup_tree,hf_iuup_error_cause_val,tvb,4,1,ENC_BIG_ENDIAN);
717 expert_add_info(pinfo, pi, &ei_iuup_error_response);
718 return;
719 case ACKNACK_RESERVED:
720 expert_add_info(pinfo, ack_item, &ei_iuup_ack_nack);
721 return;
722 case ACKNACK_PROC:
723 break;
726 switch( second_octet & PROCEDURE_MASK ) {
727 case PROC_INIT:
728 if (tree) add_payload_crc(tvb, pinfo, iuup_tree);
729 dissect_iuup_init(tvb,pinfo,iuup_tree);
730 return;
731 case PROC_RATE:
732 if (!tree) return;
733 add_payload_crc(tvb, pinfo, iuup_tree);
734 dissect_iuup_ratectl(tvb,pinfo,iuup_tree);
735 return;
736 case PROC_TIME:
738 proto_tree* time_tree;
739 guint ta;
741 ta = tvb_get_guint8(tvb,4);
743 pi = proto_tree_add_item(iuup_tree,hf_iuup_time_align,tvb,4,1,ENC_BIG_ENDIAN);
744 time_tree = proto_item_add_subtree(pi,ett_time);
746 if (ta >= 1 && ta <= 80) {
747 pi = proto_tree_add_uint(time_tree,hf_iuup_delay,tvb,4,1,ta * 500);
748 PROTO_ITEM_SET_GENERATED(pi);
749 pi = proto_tree_add_float(time_tree,hf_iuup_delta,tvb,4,1,((gfloat)((gint)(ta) * 500))/(gfloat)1000000.0);
750 PROTO_ITEM_SET_GENERATED(pi);
751 } else if (ta >= 129 && ta <= 208) {
752 pi = proto_tree_add_uint(time_tree,hf_iuup_advance,tvb,4,1,(ta-128) * 500);
753 PROTO_ITEM_SET_GENERATED(pi);
754 pi = proto_tree_add_float(time_tree,hf_iuup_delta,tvb,4,1,((gfloat)((gint)(-(((gint)ta)-128))) * 500)/(gfloat)1000000.0);
755 PROTO_ITEM_SET_GENERATED(pi);
756 } else {
757 expert_add_info(pinfo, pi, &ei_iuup_time_align);
760 proto_tree_add_item(iuup_tree,hf_iuup_spare_bytes,tvb,5,-1,ENC_NA);
761 return;
763 case PROC_ERROR:
764 col_append_str(pinfo->cinfo, COL_INFO, val_to_str(tvb_get_guint8(tvb,4) & 0x3f,iuup_error_causes,"Unknown (%u)"));
766 proto_tree_add_item(iuup_tree,hf_iuup_error_distance,tvb,4,1,ENC_BIG_ENDIAN);
767 pi = proto_tree_add_item(iuup_tree,hf_iuup_errorevt_cause_val,tvb,4,1,ENC_BIG_ENDIAN);
768 expert_add_info(pinfo, pi, &ei_iuup_error_response);
769 proto_tree_add_item(iuup_tree,hf_iuup_spare_bytes,tvb,5,-1,ENC_NA);
770 return;
771 default: /* bad */
772 expert_add_info(pinfo, proc_item, &ei_iuup_procedure_indicator);
773 return;
775 default:
776 expert_add_info(pinfo, pdutype_item, &ei_iuup_pdu_type);
777 return;
782 static gboolean dissect_iuup_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
783 int len = tvb_length(tvb);
785 guint8 first_octet = tvb_get_guint8(tvb,0);
786 guint8 second_octet = tvb_get_guint8(tvb,1);
787 guint16 hdrcrc6 = tvb_get_guint8(tvb, 2) >> 2;
789 if (update_crc6_by_bytes(hdrcrc6, first_octet, second_octet)) return FALSE;
791 switch ( first_octet & 0xf0 ) {
792 case 0x00: {
793 if (len<7) return FALSE;
794 if (update_crc10_by_bytes((guint16)(tvb_get_ntohs(tvb, 4) & 0x3FF), tvb_get_ptr(tvb, 6, len-4), len-4) ) return FALSE;
795 break;
797 case 0x10:
798 /* a FALSE positive factory */
799 if (len<5) return FALSE;
800 break;
801 case 0xe0:
802 if (len<5) return FALSE;
803 if( (second_octet & 0x0f) > 3) return FALSE;
804 break;
805 default:
806 return FALSE;
809 dissect_iuup(tvb, pinfo, tree);
810 return TRUE;
814 static void find_iuup(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
815 int len = tvb_length(tvb);
816 int offset = 0;
818 while (len > 3) {
819 if ( dissect_iuup_heur(tvb_new_subset_remaining(tvb,offset), pinfo, tree) )
820 return;
822 offset++;
823 len--;
826 call_dissector(data_handle, tvb, pinfo, tree);
829 static void init_iuup(void) {
830 if (circuits)
831 g_hash_table_destroy(circuits);
832 circuits = g_hash_table_new(g_direct_hash,g_direct_equal);
836 void proto_reg_handoff_iuup(void) {
837 static gboolean iuup_prefs_initialized = FALSE;
838 static dissector_handle_t iuup_handle;
839 static guint saved_dynamic_payload_type = 0;
841 if (!iuup_prefs_initialized) {
842 iuup_handle = find_dissector("iuup");
843 dissector_add_string("rtp_dyn_payload_type","VND.3GPP.IUFP", iuup_handle);
844 data_handle = find_dissector("data");
845 iuup_prefs_initialized = TRUE;
846 } else {
847 if ( saved_dynamic_payload_type > 95 ) {
848 dissector_delete_uint("rtp.pt", saved_dynamic_payload_type, iuup_handle);
852 saved_dynamic_payload_type = global_dynamic_payload_type;
854 if ( global_dynamic_payload_type > 95 ) {
855 dissector_add_uint("rtp.pt", global_dynamic_payload_type, iuup_handle);
860 #define HFS_RFCI(i) \
861 { &hf_iuup_rfci_ratectl[i], { "RFCI " #i, "iuup.rfci." #i, FT_UINT8, BASE_DEC, VALS(iuup_rfci_indicator),0x80>>(i%8),NULL,HFILL}}, \
862 { &hf_iuup_init_rfci[i], { "RFCI " #i, "iuup.rfci." #i, FT_UINT8, BASE_DEC, NULL,0x3f,NULL,HFILL}}, \
863 { &hf_iuup_init_rfci_flow_len[i][0], { "RFCI " #i " Flow 0 Len", "iuup.rfci."#i".flow.0.len", FT_UINT16, BASE_DEC, NULL,0x0,NULL,HFILL}}, \
864 { &hf_iuup_init_rfci_flow_len[i][1], { "RFCI " #i " Flow 1 Len", "iuup.rfci."#i".flow.1.len", FT_UINT16, BASE_DEC, NULL,0x0,NULL,HFILL}}, \
865 { &hf_iuup_init_rfci_flow_len[i][2], { "RFCI " #i " Flow 2 Len", "iuup.rfci."#i".flow.2.len", FT_UINT16, BASE_DEC, NULL,0x0,NULL,HFILL}}, \
866 { &hf_iuup_init_rfci_flow_len[i][3], { "RFCI " #i " Flow 3 Len", "iuup.rfci."#i".flow.3.len", FT_UINT16, BASE_DEC, NULL,0x0,NULL,HFILL}}, \
867 { &hf_iuup_init_rfci_flow_len[i][4], { "RFCI " #i " Flow 4 Len", "iuup.rfci."#i".flow.4.len", FT_UINT16, BASE_DEC, NULL,0x0,NULL,HFILL}}, \
868 { &hf_iuup_init_rfci_flow_len[i][5], { "RFCI " #i " Flow 5 Len", "iuup.rfci."#i".flow.5.len", FT_UINT16, BASE_DEC, NULL,0x0,NULL,HFILL}}, \
869 { &hf_iuup_init_rfci_flow_len[i][6], { "RFCI " #i " Flow 6 Len", "iuup.rfci."#i".flow.6.len", FT_UINT16, BASE_DEC, NULL,0x0,NULL,HFILL}}, \
870 { &hf_iuup_init_rfci_flow_len[i][7], { "RFCI " #i " Flow 7 Len", "iuup.rfci."#i".flow.7.len", FT_UINT16, BASE_DEC, NULL,0x0,NULL,HFILL}}, \
871 { &hf_iuup_init_rfci_li[i], { "RFCI " #i " LI", "iuup.rfci."#i".li", FT_UINT8, BASE_HEX, VALS(iuup_init_rfci_li_vals),0x40,"Length Indicator",HFILL}}, \
872 { &hf_iuup_init_rfci_lri[i], { "RFCI " #i " LRI", "iuup.rfci."#i".lri", FT_UINT8, BASE_HEX, VALS(iuup_init_lri_vals),0x80,"Last Record Indicator",HFILL}}, \
873 { &hf_iuup_rfci_subflow[i][0], { "RFCI " #i " Flow 0", "iuup.rfci."#i".flow.0", FT_BYTES, BASE_NONE, NULL,0x0,NULL,HFILL}}, \
874 { &hf_iuup_rfci_subflow[i][1], { "RFCI " #i " Flow 1", "iuup.rfci."#i".flow.1", FT_BYTES, BASE_NONE, NULL,0x0,NULL,HFILL}}, \
875 { &hf_iuup_rfci_subflow[i][2], { "RFCI " #i " Flow 2", "iuup.rfci."#i".flow.2", FT_BYTES, BASE_NONE, NULL,0x0,NULL,HFILL}}, \
876 { &hf_iuup_rfci_subflow[i][3], { "RFCI " #i " Flow 3", "iuup.rfci."#i".flow.3", FT_BYTES, BASE_NONE, NULL,0x0,NULL,HFILL}}, \
877 { &hf_iuup_rfci_subflow[i][4], { "RFCI " #i " Flow 4", "iuup.rfci."#i".flow.4", FT_BYTES, BASE_NONE, NULL,0x0,NULL,HFILL}}, \
878 { &hf_iuup_rfci_subflow[i][5], { "RFCI " #i " Flow 5", "iuup.rfci."#i".flow.5", FT_BYTES, BASE_NONE, NULL,0x0,NULL,HFILL}}, \
879 { &hf_iuup_rfci_subflow[i][6], { "RFCI " #i " Flow 6", "iuup.rfci."#i".flow.6", FT_BYTES, BASE_NONE, NULL,0x0,NULL,HFILL}}, \
880 { &hf_iuup_rfci_subflow[i][7], { "RFCI " #i " Flow 7", "iuup.rfci."#i".flow.7", FT_BYTES, BASE_NONE, NULL,0x0,NULL,HFILL}}, \
881 { &hf_iuup_init_ipti[i], { "RFCI " #i " IPTI", "iuup.rfci."#i".ipti", FT_UINT8, BASE_HEX, NULL,i%2 ? 0x0F : 0xF0,NULL,HFILL}}
885 void proto_register_iuup(void) {
886 static hf_register_info hf[] = {
887 { &hf_iuup_direction, { "Frame Direction", "iuup.direction", FT_UINT16, BASE_DEC, NULL,0x8000,NULL,HFILL}},
888 { &hf_iuup_circuit_id, { "Circuit ID", "iuup.circuit_id", FT_UINT16, BASE_DEC, NULL,0x7fff,NULL,HFILL}},
889 { &hf_iuup_pdu_type, { "PDU Type", "iuup.pdu_type", FT_UINT8, BASE_DEC, VALS(iuup_pdu_types),0xf0,NULL,HFILL}},
890 { &hf_iuup_frame_number, { "Frame Number", "iuup.framenum", FT_UINT8, BASE_DEC, NULL,0x0F,NULL,HFILL}},
891 { &hf_iuup_fqc, { "FQC", "iuup.fqc", FT_UINT8, BASE_DEC, VALS(iuup_fqcs),0xc0,"Frame Quality Classification",HFILL}},
892 { &hf_iuup_rfci, { "RFCI", "iuup.rfci", FT_UINT8, BASE_HEX, NULL, 0x3f, "RAB sub-Flow Combination Indicator",HFILL}},
893 { &hf_iuup_hdr_crc, { "Header CRC", "iuup.header_crc", FT_UINT8, BASE_HEX, NULL,0xfc,NULL,HFILL}},
894 { &hf_iuup_payload_crc, { "Payload CRC", "iuup.payload_crc", FT_UINT16, BASE_HEX, NULL,0x03FF,NULL,HFILL}},
895 { &hf_iuup_ack_nack, { "Ack/Nack", "iuup.ack", FT_UINT8, BASE_DEC, VALS(iuup_acknack_vals),0x0c,NULL,HFILL}},
896 { &hf_iuup_frame_number_t14, { "Frame Number", "iuup.framenum_t14", FT_UINT8, BASE_DEC, NULL,0x03,NULL,HFILL}},
897 { &hf_iuup_mode_version, { "Mode Version", "iuup.mode", FT_UINT8, BASE_HEX, NULL,0xf0,NULL,HFILL}},
898 { &hf_iuup_procedure_indicator, { "Procedure", "iuup.procedure", FT_UINT8, BASE_DEC, VALS(iuup_procedures),0x0f,NULL,HFILL}},
899 { &hf_iuup_error_cause_val, { "Error Cause", "iuup.error_cause", FT_UINT8, BASE_DEC, VALS(iuup_error_causes),0xfc,NULL,HFILL}},
900 { &hf_iuup_error_distance, { "Error DISTANCE", "iuup.error_distance", FT_UINT8, BASE_DEC, VALS(iuup_error_distances),0xc0,NULL,HFILL}},
901 { &hf_iuup_errorevt_cause_val, { "Error Cause", "iuup.errorevt_cause", FT_UINT8, BASE_DEC, NULL,0x3f,NULL,HFILL}},
902 { &hf_iuup_time_align, { "Time Align", "iuup.time_align", FT_UINT8, BASE_HEX, NULL,0x0,NULL,HFILL}},
903 { &hf_iuup_data_pdu_type, { "RFCI Data Pdu Type", "iuup.data_pdu_type", FT_UINT8, BASE_HEX, VALS(iuup_payload_pdu_type),0xF0,NULL,HFILL}},
905 { &hf_iuup_spare_03, { "Spare", "iuup.spare", FT_UINT8, BASE_HEX, NULL,0x03,NULL,HFILL}},
906 #if 0
907 { &hf_iuup_spare_0f, { "Spare", "iuup.spare", FT_UINT8, BASE_HEX, NULL,0x0f,NULL,HFILL}},
908 #endif
909 #if 0
910 { &hf_iuup_spare_c0, { "Spare", "iuup.spare", FT_UINT8, BASE_HEX, NULL,0xc0,NULL,HFILL}},
911 #endif
912 { &hf_iuup_spare_e0, { "Spare", "iuup.spare", FT_UINT8, BASE_HEX, NULL,0xe0,NULL,HFILL}},
913 { &hf_iuup_spare_ff, { "Spare", "iuup.spare", FT_UINT8, BASE_HEX, NULL,0xff,NULL,HFILL}},
914 { &hf_iuup_spare_bytes, { "Spare", "iuup.spare_bytes", FT_BYTES, BASE_NONE, NULL,0x0,NULL,HFILL}},
916 { &hf_iuup_delay, { "Delay", "iuup.delay", FT_UINT32, BASE_HEX, NULL,0x0,NULL,HFILL}},
917 { &hf_iuup_advance, { "Advance", "iuup.advance", FT_UINT32, BASE_HEX, NULL,0x0,NULL,HFILL}},
918 { &hf_iuup_delta, { "Delta Time", "iuup.delta", FT_FLOAT, BASE_NONE, NULL,0x0,NULL,HFILL}},
920 { &hf_iuup_init_ti, { "TI", "iuup.ti", FT_UINT8, BASE_DEC, VALS(iuup_ti_vals),0x10,"Timing Information",HFILL}},
921 { &hf_iuup_init_subflows_per_rfci, { "Subflows", "iuup.subflows", FT_UINT8, BASE_DEC, NULL,0x0e,"Number of Subflows",HFILL}},
922 { &hf_iuup_init_chain_ind, { "Chain Indicator", "iuup.chain_ind", FT_UINT8, BASE_DEC, VALS(iuup_init_chain_ind_vals),0x01,NULL,HFILL}},
923 { &hf_iuup_payload, { "Payload Data", "iuup.payload_data", FT_BYTES, BASE_NONE, NULL,0x00,NULL,HFILL}},
926 { &hf_iuup_mode_versions, { "Iu UP Mode Versions Supported", "iuup.support_mode", FT_UINT16, BASE_HEX, NULL,0x0,NULL,HFILL}},
928 { &hf_iuup_mode_versions_a[ 0], { "Version 16", "iuup.support_mode.version16", FT_UINT16, BASE_HEX, VALS(iuup_mode_version_support),0x8000,NULL,HFILL}},
929 { &hf_iuup_mode_versions_a[ 1], { "Version 15", "iuup.support_mode.version15", FT_UINT16, BASE_HEX, VALS(iuup_mode_version_support),0x4000,NULL,HFILL}},
930 { &hf_iuup_mode_versions_a[ 2], { "Version 14", "iuup.support_mode.version14", FT_UINT16, BASE_HEX, VALS(iuup_mode_version_support),0x2000,NULL,HFILL}},
931 { &hf_iuup_mode_versions_a[ 3], { "Version 13", "iuup.support_mode.version13", FT_UINT16, BASE_HEX, VALS(iuup_mode_version_support),0x1000,NULL,HFILL}},
932 { &hf_iuup_mode_versions_a[ 4], { "Version 12", "iuup.support_mode.version12", FT_UINT16, BASE_HEX, VALS(iuup_mode_version_support),0x0800,NULL,HFILL}},
933 { &hf_iuup_mode_versions_a[ 5], { "Version 11", "iuup.support_mode.version11", FT_UINT16, BASE_HEX, VALS(iuup_mode_version_support),0x0400,NULL,HFILL}},
934 { &hf_iuup_mode_versions_a[ 6], { "Version 10", "iuup.support_mode.version10", FT_UINT16, BASE_HEX, VALS(iuup_mode_version_support),0x0200,NULL,HFILL}},
935 { &hf_iuup_mode_versions_a[ 7], { "Version 9", "iuup.support_mode.version9", FT_UINT16, BASE_HEX, VALS(iuup_mode_version_support),0x0100,NULL,HFILL}},
936 { &hf_iuup_mode_versions_a[ 8], { "Version 8", "iuup.support_mode.version8", FT_UINT16, BASE_HEX, VALS(iuup_mode_version_support),0x0080,NULL,HFILL}},
937 { &hf_iuup_mode_versions_a[ 9], { "Version 7", "iuup.support_mode.version7", FT_UINT16, BASE_HEX, VALS(iuup_mode_version_support),0x0040,NULL,HFILL}},
938 { &hf_iuup_mode_versions_a[10], { "Version 6", "iuup.support_mode.version6", FT_UINT16, BASE_HEX, VALS(iuup_mode_version_support),0x0020,NULL,HFILL}},
939 { &hf_iuup_mode_versions_a[11], { "Version 5", "iuup.support_mode.version5", FT_UINT16, BASE_HEX, VALS(iuup_mode_version_support),0x0010,NULL,HFILL}},
940 { &hf_iuup_mode_versions_a[12], { "Version 4", "iuup.support_mode.version4", FT_UINT16, BASE_HEX, VALS(iuup_mode_version_support),0x0008,NULL,HFILL}},
941 { &hf_iuup_mode_versions_a[13], { "Version 3", "iuup.support_mode.version3", FT_UINT16, BASE_HEX, VALS(iuup_mode_version_support),0x0004,NULL,HFILL}},
942 { &hf_iuup_mode_versions_a[14], { "Version 2", "iuup.support_mode.version2", FT_UINT16, BASE_HEX, VALS(iuup_mode_version_support),0x0002,NULL,HFILL}},
943 { &hf_iuup_mode_versions_a[15], { "Version 1", "iuup.support_mode.version1", FT_UINT16, BASE_HEX, VALS(iuup_mode_version_support),0x0001,NULL,HFILL}},
945 { &hf_iuup_num_rfci_ind, { "Number of RFCI Indicators", "iuup.p", FT_UINT8, BASE_HEX, NULL,0x3f,NULL,HFILL}},
946 { &hf_iuup_init_rfci_ind, { "RFCI Initialization", "iuup.rfci.init", FT_BYTES, BASE_NONE, NULL,0x0,NULL,HFILL}},
948 HFS_RFCI(0),HFS_RFCI(1),HFS_RFCI(2),HFS_RFCI(3),HFS_RFCI(4),HFS_RFCI(5),HFS_RFCI(6),HFS_RFCI(7),
949 HFS_RFCI(8),HFS_RFCI(9),HFS_RFCI(10),HFS_RFCI(11),HFS_RFCI(12),HFS_RFCI(13),HFS_RFCI(14),HFS_RFCI(15),
950 HFS_RFCI(16),HFS_RFCI(17),HFS_RFCI(18),HFS_RFCI(19),HFS_RFCI(20),HFS_RFCI(21),HFS_RFCI(22),HFS_RFCI(23),
951 HFS_RFCI(24),HFS_RFCI(25),HFS_RFCI(26),HFS_RFCI(27),HFS_RFCI(28),HFS_RFCI(29),HFS_RFCI(30),HFS_RFCI(31),
952 HFS_RFCI(32),HFS_RFCI(33),HFS_RFCI(34),HFS_RFCI(35),HFS_RFCI(36),HFS_RFCI(37),HFS_RFCI(38),HFS_RFCI(39),
953 HFS_RFCI(40),HFS_RFCI(41),HFS_RFCI(42),HFS_RFCI(43),HFS_RFCI(44),HFS_RFCI(45),HFS_RFCI(46),HFS_RFCI(47),
954 HFS_RFCI(48),HFS_RFCI(49),HFS_RFCI(50),HFS_RFCI(51),HFS_RFCI(52),HFS_RFCI(53),HFS_RFCI(54),HFS_RFCI(55),
955 HFS_RFCI(56),HFS_RFCI(57),HFS_RFCI(58),HFS_RFCI(59),HFS_RFCI(60),HFS_RFCI(61),HFS_RFCI(62),HFS_RFCI(63)
960 gint* ett[] = {
961 &ett_iuup,
962 &ett_rfci,
963 &ett_ipti,
964 &ett_support,
965 &ett_time,
966 &ett_rfciinds,
967 &ett_payload,
968 &ett_payload_subflows
971 static ei_register_info ei[] = {
972 { &ei_iuup_hdr_crc_bad, { "iuup.hdr.crc.bad", PI_CHECKSUM, PI_ERROR, "Bad checksum", EXPFILL }},
973 { &ei_iuup_payload_crc_bad, { "iuup.payload.crc.bad", PI_CHECKSUM, PI_ERROR, "Bad checksum", EXPFILL }},
974 { &ei_iuup_payload_undecoded, { "iuup.payload.undecoded", PI_UNDECODED, PI_WARN, "Undecoded payload", EXPFILL }},
975 { &ei_iuup_error_response, { "iuup.error_response", PI_RESPONSE_CODE, PI_ERROR, "Error response", EXPFILL }},
976 { &ei_iuup_ack_nack, { "iuup.ack.malformed", PI_MALFORMED, PI_ERROR, "Malformed Ack/Nack", EXPFILL }},
977 { &ei_iuup_time_align, { "iuup.time_align.malformed", PI_MALFORMED, PI_ERROR, "Malformed Time Align", EXPFILL }},
978 { &ei_iuup_procedure_indicator, { "iuup.procedure.malformed", PI_MALFORMED, PI_ERROR, "Malformed Procedure", EXPFILL }},
979 { &ei_iuup_pdu_type, { "iuup.pdu_type.malformed", PI_MALFORMED, PI_ERROR, "Malformed PDU Type", EXPFILL }},
982 module_t *iuup_module;
983 expert_module_t* expert_iuup;
985 proto_iuup = proto_register_protocol("IuUP", "IuUP", "iuup");
986 proto_register_field_array(proto_iuup, hf, array_length(hf));
987 proto_register_subtree_array(ett, array_length(ett));
988 expert_iuup = expert_register_protocol(proto_iuup);
989 expert_register_field_array(expert_iuup, ei, array_length(ei));
990 register_dissector("iuup", dissect_iuup, proto_iuup);
991 register_dissector("find_iuup", find_iuup, proto_iuup);
993 register_init_routine(&init_iuup);
995 iuup_module = prefs_register_protocol(proto_iuup, proto_reg_handoff_iuup);
997 prefs_register_bool_preference(iuup_module, "dissect_payload",
998 "Dissect IuUP Payload bits",
999 "Whether IuUP Payload bits should be dissected",
1000 &dissect_fields);
1002 prefs_register_bool_preference(iuup_module, "two_byte_pseudoheader",
1003 "Two byte pseudoheader",
1004 "The payload contains a two byte pseudoheader indicating direction and circuit_id",
1005 &two_byte_pseudoheader);
1007 prefs_register_uint_preference(iuup_module, "dynamic.payload.type",
1008 "IuUP dynamic payload type",
1009 "The dynamic payload type which will be interpreted as IuUP",
1011 &global_dynamic_payload_type);