From 7a82d352801d4d7bb439e0d6854ccaaef3895b06 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Wed, 12 Jun 2013 14:55:37 +0000 Subject: TABs -> spaces add modelines svn path=/trunk/; revision=49903 --- epan/dissectors/packet-cnip.c | 289 ++++++++++++++++++++++-------------------- 1 file changed, 151 insertions(+), 138 deletions(-) (limited to 'epan/dissectors/packet-cnip.c') diff --git a/epan/dissectors/packet-cnip.c b/epan/dissectors/packet-cnip.c index 84dba2694c..6fca2e4732 100644 --- a/epan/dissectors/packet-cnip.c +++ b/epan/dissectors/packet-cnip.c @@ -31,46 +31,46 @@ #include #include -#define DATA_PACKET 0x01 +#define DATA_PACKET 0x01 static const value_string type_tuple[]= { - {0x01, "Data Packet"}, - {0x63, "Device Configuration Request"}, - {0x03, "Device Registration"}, - {0x71, "Device Configuration"}, - {0x64, "Channel Membership Request"}, - {0x04, "Channel Membership"}, - {0x66, "Send List Request"}, - {0x06, "Send List"}, - {0x68, "Channel Routing Request"}, - {0x08, "Channel Routing"}, - {0x07, "Acknowledge"}, - {0x7F, "Segment"}, - {0x60, "Status/Health/Statistics Request"}, - {0x70, "Status/Health/Statistics Response"}, - {0, NULL} + {0x01, "Data Packet"}, + {0x63, "Device Configuration Request"}, + {0x03, "Device Registration"}, + {0x71, "Device Configuration"}, + {0x64, "Channel Membership Request"}, + {0x04, "Channel Membership"}, + {0x66, "Send List Request"}, + {0x06, "Send List"}, + {0x68, "Channel Routing Request"}, + {0x08, "Channel Routing"}, + {0x07, "Acknowledge"}, + {0x7F, "Segment"}, + {0x60, "Status/Health/Statistics Request"}, + {0x70, "Status/Health/Statistics Response"}, + {0, NULL} }; void proto_register_cnip(void); void proto_reg_handoff_cnip(void); -static gint hf_cnip_len = -1; -static gint hf_cnip_ver = -1; -static gint hf_cnip_type = -1; -static gint hf_cnip_exth = -1; -static gint hf_cnip_pf = -1; -static gint hf_cnip_pf_sec = -1; -static gint hf_cnip_pf_pcode = -1; -static gint hf_cnip_vcode = -1; -static gint hf_cnip_sessid = -1; -static gint hf_cnip_seqno = -1; -static gint hf_cnip_tstamp = -1; +static gint hf_cnip_len = -1; +static gint hf_cnip_ver = -1; +static gint hf_cnip_type = -1; +static gint hf_cnip_exth = -1; +static gint hf_cnip_pf = -1; +static gint hf_cnip_pf_sec = -1; +static gint hf_cnip_pf_pcode = -1; +static gint hf_cnip_vcode = -1; +static gint hf_cnip_sessid = -1; +static gint hf_cnip_seqno = -1; +static gint hf_cnip_tstamp = -1; -static gint proto_cnip = -1; +static gint proto_cnip = -1; -static gint ett_cnip = -1; -static gint ett_pf = -1; +static gint ett_cnip = -1; +static gint ett_pf = -1; static expert_field ei_cnip_type_unknown = EI_INIT; @@ -79,29 +79,29 @@ static dissector_handle_t data_handle; static void dissect_cnip (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - tvbuff_t *next_tvb; - gint offset; - gint type, exth_len, pf_pcode; + tvbuff_t *next_tvb; + gint offset; + gint type, exth_len, pf_pcode; - proto_tree *ti; - proto_tree *cnip_tree; + proto_tree *ti; + proto_tree *cnip_tree; static const gint *pf_fields[] = { &hf_cnip_pf_sec, &hf_cnip_pf_pcode, NULL }; - - col_set_str(pinfo->cinfo, COL_PROTOCOL, "CN/IP"); - col_clear(pinfo->cinfo, COL_INFO); - type = tvb_get_guint8(tvb, 3); - col_add_fstr(pinfo->cinfo, COL_INFO,"Priority: %s Type: %s", - (pinfo->destport == 1629 )? "urgent":"normal", - val_to_str_const(type, type_tuple, "Unknown")); + col_set_str(pinfo->cinfo, COL_PROTOCOL, "CN/IP"); + col_clear(pinfo->cinfo, COL_INFO); - exth_len = tvb_get_guint8(tvb, 4); - pf_pcode = tvb_get_guint8(tvb, 5) & 0x1F; + type = tvb_get_guint8(tvb, 3); + col_add_fstr(pinfo->cinfo, COL_INFO,"Priority: %s Type: %s", + (pinfo->destport == 1629 )? "urgent":"normal", + val_to_str_const(type, type_tuple, "Unknown")); + + exth_len = tvb_get_guint8(tvb, 4); + pf_pcode = tvb_get_guint8(tvb, 5) & 0x1F; offset = 0; @@ -148,110 +148,123 @@ static void dissect_cnip (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) val_to_str_const(type, type_tuple, "Unknown"), type); } - next_tvb = tvb_new_subset_remaining(tvb, offset); + next_tvb = tvb_new_subset_remaining(tvb, offset); - /* Try subdissectors only for data packets*/ - if (type == DATA_PACKET) { - if (dissector_try_uint(cnip_dissector_table, pf_pcode, next_tvb, pinfo, tree)) - return; - } + /* Try subdissectors only for data packets*/ + if (type == DATA_PACKET) { + if (dissector_try_uint(cnip_dissector_table, pf_pcode, next_tvb, pinfo, tree)) + return; + } - call_dissector(data_handle, next_tvb, pinfo, tree); + call_dissector(data_handle, next_tvb, pinfo, tree); } void proto_register_cnip(void) { - static hf_register_info hf[] = - { - {&hf_cnip_len, - {"Packet length", "cnip.len", - FT_UINT16, BASE_DEC, NULL, 0, - NULL, HFILL } - }, - {&hf_cnip_ver, - {"Version", "cnip.ver", - FT_UINT8, BASE_DEC, NULL, 0, - NULL, HFILL } - }, - {&hf_cnip_type, - {"Packet type", "cnip.type", - FT_UINT8, BASE_HEX, VALS(type_tuple), 0, - NULL, HFILL } - }, - {&hf_cnip_exth, - {"Ext. Header Size", "cnip.exth", - FT_UINT8, BASE_DEC, NULL, 0, - NULL, HFILL } - }, - {&hf_cnip_pf, - {"Protocol Flags", "cnip.pf", - FT_UINT8, BASE_DEC, NULL, 0, - NULL, HFILL } - }, - {&hf_cnip_pf_sec, - {"Protocol Flags", "cnip.sec", - FT_UINT8, BASE_DEC, NULL, 0x20, - NULL, HFILL } - }, - {&hf_cnip_pf_pcode, - {"Protocol Code", "cnip.protocol", - FT_UINT8, BASE_DEC, NULL, 0x1F, - NULL, HFILL } - }, - {&hf_cnip_vcode, - {"Vendor Code", "cnip.vendorcode", - FT_UINT16, BASE_DEC, NULL, 0, - NULL, HFILL } - }, - {&hf_cnip_sessid, - {"Session ID", "cnip.sessid", - FT_UINT32, BASE_DEC, NULL, 0, - NULL, HFILL } - }, - {&hf_cnip_seqno, - {"Sequence Number", "cnip.seqno", - FT_UINT32, BASE_DEC, NULL, 0, - NULL, HFILL } - }, - {&hf_cnip_tstamp, - {"Time Stamp", "cnip.tstamp", - FT_UINT32, BASE_DEC, NULL, 0, - NULL, HFILL } - } - }; - - static gint *ett[] = - { - &ett_cnip, - &ett_pf - }; - - static ei_register_info ei[] = { - { &ei_cnip_type_unknown, { "cnip.type.unknown", PI_UNDECODED, PI_WARN, "This dissector doesn't yet decode packets of type", EXPFILL }}, - }; - - expert_module_t* expert_cnip; - - proto_cnip = proto_register_protocol("Component Network over IP", - "CN/IP", "cnip"); - - proto_register_field_array(proto_cnip, hf, array_length (hf)); - proto_register_subtree_array(ett, array_length (ett)); - expert_cnip = expert_register_protocol(proto_cnip); - expert_register_field_array(expert_cnip, ei, array_length(ei)); - - /* Register table for subdissectors */ - cnip_dissector_table = register_dissector_table("cnip.protocol", - "CN/IP Protocol", FT_UINT8, BASE_DEC); + static hf_register_info hf[] = + { + {&hf_cnip_len, + {"Packet length", "cnip.len", + FT_UINT16, BASE_DEC, NULL, 0, + NULL, HFILL } + }, + {&hf_cnip_ver, + {"Version", "cnip.ver", + FT_UINT8, BASE_DEC, NULL, 0, + NULL, HFILL } + }, + {&hf_cnip_type, + {"Packet type", "cnip.type", + FT_UINT8, BASE_HEX, VALS(type_tuple), 0, + NULL, HFILL } + }, + {&hf_cnip_exth, + {"Ext. Header Size", "cnip.exth", + FT_UINT8, BASE_DEC, NULL, 0, + NULL, HFILL } + }, + {&hf_cnip_pf, + {"Protocol Flags", "cnip.pf", + FT_UINT8, BASE_DEC, NULL, 0, + NULL, HFILL } + }, + {&hf_cnip_pf_sec, + {"Protocol Flags", "cnip.sec", + FT_UINT8, BASE_DEC, NULL, 0x20, + NULL, HFILL } + }, + {&hf_cnip_pf_pcode, + {"Protocol Code", "cnip.protocol", + FT_UINT8, BASE_DEC, NULL, 0x1F, + NULL, HFILL } + }, + {&hf_cnip_vcode, + {"Vendor Code", "cnip.vendorcode", + FT_UINT16, BASE_DEC, NULL, 0, + NULL, HFILL } + }, + {&hf_cnip_sessid, + {"Session ID", "cnip.sessid", + FT_UINT32, BASE_DEC, NULL, 0, + NULL, HFILL } + }, + {&hf_cnip_seqno, + {"Sequence Number", "cnip.seqno", + FT_UINT32, BASE_DEC, NULL, 0, + NULL, HFILL } + }, + {&hf_cnip_tstamp, + {"Time Stamp", "cnip.tstamp", + FT_UINT32, BASE_DEC, NULL, 0, + NULL, HFILL } + } + }; + + static gint *ett[] = + { + &ett_cnip, + &ett_pf + }; + + static ei_register_info ei[] = { + { &ei_cnip_type_unknown, { "cnip.type.unknown", PI_UNDECODED, PI_WARN, "This dissector doesn't yet decode packets of type", EXPFILL }}, + }; + + expert_module_t* expert_cnip; + + proto_cnip = proto_register_protocol("Component Network over IP", + "CN/IP", "cnip"); + + proto_register_field_array(proto_cnip, hf, array_length (hf)); + proto_register_subtree_array(ett, array_length (ett)); + expert_cnip = expert_register_protocol(proto_cnip); + expert_register_field_array(expert_cnip, ei, array_length(ei)); + + /* Register table for subdissectors */ + cnip_dissector_table = register_dissector_table("cnip.protocol", + "CN/IP Protocol", FT_UINT8, BASE_DEC); } void proto_reg_handoff_cnip(void) { - dissector_handle_t cnip_handle; + dissector_handle_t cnip_handle; - cnip_handle = create_dissector_handle(dissect_cnip, proto_cnip); - data_handle = find_dissector("data"); + cnip_handle = create_dissector_handle(dissect_cnip, proto_cnip); + data_handle = find_dissector("data"); - dissector_add_uint ("udp.port", 1628, cnip_handle); - dissector_add_uint ("udp.port", 1629, cnip_handle); + dissector_add_uint ("udp.port", 1628, cnip_handle); + dissector_add_uint ("udp.port", 1629, cnip_handle); } + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ -- cgit v1.2.3