Reindent some to improve readability
svn path=/trunk/; revision=23510
This commit is contained in:
parent
e11ec68f93
commit
be81aa150e
|
@ -79,13 +79,15 @@ static k12_handles_t* k12_handles = NULL;
|
|||
static guint nk12_handles = 0;
|
||||
|
||||
static const value_string k12_port_types[] = {
|
||||
{ K12_PORT_DS1, "Ds1" },
|
||||
{ K12_PORT_DS0S, "Ds0 Range" },
|
||||
{ K12_PORT_ATMPVC, "ATM PVC" },
|
||||
{ 0,NULL}
|
||||
{ K12_PORT_DS1, "Ds1" },
|
||||
{ K12_PORT_DS0S, "Ds0 Range" },
|
||||
{ K12_PORT_ATMPVC, "ATM PVC" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static void fill_fp_info(fp_info *p_fp_info, guchar *extra_info, guint length) {
|
||||
static void
|
||||
fill_fp_info(fp_info *p_fp_info, guchar *extra_info, guint length)
|
||||
{
|
||||
guint adj = 0;
|
||||
/* 0x11=control frame 0x30=data frame */
|
||||
guint info_type = pntohs(extra_info);
|
||||
|
@ -97,8 +99,7 @@ static void fill_fp_info(fp_info *p_fp_info, guchar *extra_info, guint length) {
|
|||
if (!p_fp_info || length < 22)
|
||||
return;
|
||||
|
||||
/* Format used by K15, later fields are
|
||||
shifted by 8 bytes. */
|
||||
/* Format used by K15, later fields are shifted by 8 bytes. */
|
||||
if (pntohs(extra_info+2) == 5)
|
||||
adj = 8;
|
||||
|
||||
|
@ -118,7 +119,7 @@ static void fill_fp_info(fp_info *p_fp_info, guchar *extra_info, guint length) {
|
|||
channel_type = extra_info[21 + adj];
|
||||
else if (info_type == 0x30) /* data frame */
|
||||
channel_type = extra_info[22 + adj];
|
||||
|
||||
|
||||
switch (channel_type) {
|
||||
case 1:
|
||||
p_fp_info->channel = CHANNEL_BCH;
|
||||
|
@ -174,7 +175,9 @@ static void fill_fp_info(fp_info *p_fp_info, guchar *extra_info, guint length) {
|
|||
}
|
||||
}
|
||||
|
||||
static void dissect_k12(tvbuff_t* tvb,packet_info* pinfo,proto_tree* tree) {
|
||||
static void
|
||||
dissect_k12(tvbuff_t* tvb,packet_info* pinfo,proto_tree* tree)
|
||||
{
|
||||
static dissector_handle_t data_handles[] = {NULL,NULL};
|
||||
proto_item* k12_item;
|
||||
proto_tree* k12_tree;
|
||||
|
@ -182,10 +185,11 @@ static void dissect_k12(tvbuff_t* tvb,packet_info* pinfo,proto_tree* tree) {
|
|||
dissector_handle_t sub_handle = NULL;
|
||||
dissector_handle_t* handles;
|
||||
guint i;
|
||||
|
||||
k12_item = proto_tree_add_protocol_format(tree, proto_k12, tvb, 0, 0, "Packet from: '%s' (0x%.8x)",
|
||||
pinfo->pseudo_header->k12.input_name,
|
||||
pinfo->pseudo_header->k12.input);
|
||||
|
||||
k12_item = proto_tree_add_protocol_format(tree, proto_k12, tvb, 0, 0,
|
||||
"Packet from: '%s' (0x%.8x)",
|
||||
pinfo->pseudo_header->k12.input_name,
|
||||
pinfo->pseudo_header->k12.input);
|
||||
|
||||
k12_tree = proto_item_add_subtree(k12_item, ett_k12);
|
||||
|
||||
|
@ -194,7 +198,7 @@ static void dissect_k12(tvbuff_t* tvb,packet_info* pinfo,proto_tree* tree) {
|
|||
stack_item = proto_tree_add_string(k12_tree, hf_k12_stack_file, tvb, 0,0,pinfo->pseudo_header->k12.stack_file);
|
||||
|
||||
k12_item = proto_tree_add_uint(k12_tree, hf_k12_port_type, tvb, 0, 0,
|
||||
pinfo->pseudo_header->k12.input_type);
|
||||
pinfo->pseudo_header->k12.input_type);
|
||||
|
||||
k12_tree = proto_item_add_subtree(k12_item, ett_port);
|
||||
|
||||
|
@ -203,24 +207,27 @@ static void dissect_k12(tvbuff_t* tvb,packet_info* pinfo,proto_tree* tree) {
|
|||
proto_tree_add_uint(k12_tree, hf_k12_ts, tvb, 0,0,pinfo->pseudo_header->k12.input_info.ds0mask);
|
||||
break;
|
||||
case K12_PORT_ATMPVC:
|
||||
{
|
||||
gchar* circuit_str = ep_strdup_printf("%u:%u:%u",
|
||||
(guint)pinfo->pseudo_header->k12.input_info.atm.vp,
|
||||
(guint)pinfo->pseudo_header->k12.input_info.atm.vc,
|
||||
(guint)pinfo->pseudo_header->k12.input_info.atm.cid);
|
||||
{
|
||||
gchar* circuit_str = ep_strdup_printf("%u:%u:%u",
|
||||
(guint)pinfo->pseudo_header->k12.input_info.atm.vp,
|
||||
(guint)pinfo->pseudo_header->k12.input_info.atm.vc,
|
||||
(guint)pinfo->pseudo_header->k12.input_info.atm.cid);
|
||||
|
||||
/*
|
||||
* XXX: this is prone to collisions!
|
||||
* we need an uniform way to manage circuits between dissectors
|
||||
*/
|
||||
pinfo->circuit_id = g_str_hash(circuit_str);
|
||||
/*
|
||||
* XXX: this is prone to collisions!
|
||||
* we need an uniform way to manage circuits between dissectors
|
||||
*/
|
||||
pinfo->circuit_id = g_str_hash(circuit_str);
|
||||
|
||||
proto_tree_add_uint(k12_tree, hf_k12_atm_vp, tvb, 0,0,pinfo->pseudo_header->k12.input_info.atm.vp);
|
||||
proto_tree_add_uint(k12_tree, hf_k12_atm_vc, tvb, 0,0,pinfo->pseudo_header->k12.input_info.atm.vc);
|
||||
if (pinfo->pseudo_header->k12.input_info.atm.cid)
|
||||
proto_tree_add_uint(k12_tree, hf_k12_atm_cid, tvb, 0,0,pinfo->pseudo_header->k12.input_info.atm.cid);
|
||||
break;
|
||||
}
|
||||
proto_tree_add_uint(k12_tree, hf_k12_atm_vp, tvb, 0, 0,
|
||||
pinfo->pseudo_header->k12.input_info.atm.vp);
|
||||
proto_tree_add_uint(k12_tree, hf_k12_atm_vc, tvb, 0, 0,
|
||||
pinfo->pseudo_header->k12.input_info.atm.vc);
|
||||
if (pinfo->pseudo_header->k12.input_info.atm.cid)
|
||||
proto_tree_add_uint(k12_tree, hf_k12_atm_cid, tvb, 0, 0,
|
||||
pinfo->pseudo_header->k12.input_info.atm.cid);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -229,7 +236,7 @@ static void dissect_k12(tvbuff_t* tvb,packet_info* pinfo,proto_tree* tree) {
|
|||
|
||||
if (! handles ) {
|
||||
for (i=0 ; i < nk12_handles; i++) {
|
||||
if ( epan_strcasestr(pinfo->pseudo_header->k12.stack_file, k12_handles[i].match)
|
||||
if ( epan_strcasestr(pinfo->pseudo_header->k12.stack_file, k12_handles[i].match)
|
||||
|| epan_strcasestr(pinfo->pseudo_header->k12.input_name, k12_handles[i].match) ) {
|
||||
handles = k12_handles[i].handles;
|
||||
break;
|
||||
|
@ -250,14 +257,14 @@ static void dissect_k12(tvbuff_t* tvb,packet_info* pinfo,proto_tree* tree) {
|
|||
proto_item* item;
|
||||
|
||||
item = proto_tree_add_text(stack_tree,tvb,0,0,
|
||||
"Warning: stk file not matched in the 'K12 Protocols' table");
|
||||
"Warning: stk file not matched in the 'K12 Protocols' table");
|
||||
PROTO_ITEM_SET_GENERATED(item);
|
||||
expert_add_info_format(pinfo, item, PI_UNDECODED, PI_WARN, "unmatched stk file");
|
||||
|
||||
item = proto_tree_add_text(stack_tree,tvb,0,0,
|
||||
"Info: You can edit the 'K12 Protocols' table from Preferences->Protocols->k12xx");
|
||||
"Info: You can edit the 'K12 Protocols' table from Preferences->Protocols->k12xx");
|
||||
PROTO_ITEM_SET_GENERATED(item);
|
||||
|
||||
|
||||
call_dissector(data_handle, tvb, pinfo, tree);
|
||||
return;
|
||||
}
|
||||
|
@ -297,14 +304,17 @@ static void dissect_k12(tvbuff_t* tvb,packet_info* pinfo,proto_tree* tree) {
|
|||
call_dissector(sub_handle, tvb, pinfo, tree);
|
||||
}
|
||||
|
||||
static void k12_update_cb(void* r, const char** err) {
|
||||
static void
|
||||
k12_update_cb(void* r, const char** err)
|
||||
{
|
||||
k12_handles_t* h = r;
|
||||
gchar** protos;
|
||||
guint num_protos, i;
|
||||
|
||||
protos = ep_strsplit(h->protos,":",0);
|
||||
|
||||
for (num_protos = 0; protos[num_protos]; num_protos++) g_strstrip(protos[num_protos]);
|
||||
for (num_protos = 0; protos[num_protos]; num_protos++)
|
||||
g_strstrip(protos[num_protos]);
|
||||
|
||||
if (h->handles) g_free(h->handles);
|
||||
|
||||
|
@ -321,13 +331,16 @@ static void k12_update_cb(void* r, const char** err) {
|
|||
*err = NULL;
|
||||
}
|
||||
|
||||
static void* k12_copy_cb(void* dest, const void* orig, unsigned len _U_) {
|
||||
static void*
|
||||
k12_copy_cb(void* dest, const void* orig, unsigned len _U_)
|
||||
{
|
||||
k12_handles_t* d = dest;
|
||||
const k12_handles_t* o = orig;
|
||||
gchar** protos = ep_strsplit(d->protos,":",0);
|
||||
guint num_protos;
|
||||
|
||||
for (num_protos = 0; protos[num_protos]; num_protos++) g_strstrip(protos[num_protos]);
|
||||
for (num_protos = 0; protos[num_protos]; num_protos++)
|
||||
g_strstrip(protos[num_protos]);
|
||||
|
||||
d->match = g_strdup(o->match);
|
||||
d->protos = g_strdup(o->protos);
|
||||
|
@ -336,7 +349,9 @@ static void* k12_copy_cb(void* dest, const void* orig, unsigned len _U_) {
|
|||
return dest;
|
||||
}
|
||||
|
||||
static void k12_free_cb(void* r) {
|
||||
static void
|
||||
k12_free_cb(void* r)
|
||||
{
|
||||
k12_handles_t* h = r;
|
||||
if (h->match) g_free(h->match);
|
||||
if (h->protos) g_free(h->protos);
|
||||
|
@ -344,7 +359,9 @@ static void k12_free_cb(void* r) {
|
|||
}
|
||||
|
||||
|
||||
static gboolean protos_chk_cb(void* r _U_, const char* p, unsigned len, void* u1 _U_, void* u2 _U_, const char** err) {
|
||||
static gboolean
|
||||
protos_chk_cb(void* r _U_, const char* p, unsigned len, void* u1 _U_, void* u2 _U_, const char** err)
|
||||
{
|
||||
gchar** protos;
|
||||
gchar* line = ep_strndup(p,len);
|
||||
guint num_protos, i;
|
||||
|
@ -354,7 +371,8 @@ static gboolean protos_chk_cb(void* r _U_, const char* p, unsigned len, void* u1
|
|||
|
||||
protos = ep_strsplit(line,":",0);
|
||||
|
||||
for (num_protos = 0; protos[num_protos]; num_protos++) g_strstrip(protos[num_protos]);
|
||||
for (num_protos = 0; protos[num_protos]; num_protos++)
|
||||
g_strstrip(protos[num_protos]);
|
||||
|
||||
if (!num_protos) {
|
||||
*err = ep_strdup_printf("No protocols given");
|
||||
|
@ -375,7 +393,9 @@ UAT_CSTRING_CB_DEF(k12,match,k12_handles_t)
|
|||
UAT_CSTRING_CB_DEF(k12,protos,k12_handles_t)
|
||||
|
||||
/* Make sure handles for various protocols are initialized */
|
||||
static void initialize_handles_once(void) {
|
||||
static void
|
||||
initialize_handles_once(void)
|
||||
{
|
||||
static gboolean initialized = FALSE;
|
||||
if (!initialized) {
|
||||
k12_handle = find_dissector("k12");
|
||||
|
@ -386,7 +406,8 @@ static void initialize_handles_once(void) {
|
|||
}
|
||||
}
|
||||
|
||||
void proto_reg_handoff_k12(void) {
|
||||
void proto_reg_handoff_k12(void)
|
||||
{
|
||||
initialize_handles_once();
|
||||
dissector_add("wtap_encap", WTAP_ENCAP_K12, k12_handle);
|
||||
}
|
||||
|
@ -394,13 +415,13 @@ void proto_reg_handoff_k12(void) {
|
|||
void
|
||||
proto_register_k12(void)
|
||||
{
|
||||
static hf_register_info hf[] = {
|
||||
{ &hf_k12_port_id, { "Port Id", "k12.port_id", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL }},
|
||||
{ &hf_k12_port_name, { "Port Name", "k12.port_name", FT_STRING, BASE_NONE, NULL, 0x0,"", HFILL }},
|
||||
{ &hf_k12_stack_file, { "Stack file used", "k12.stack_file", FT_STRING, BASE_NONE, NULL, 0x0,"", HFILL }},
|
||||
{ &hf_k12_port_type, { "Port type", "k12.input_type", FT_UINT32, BASE_HEX, VALS(k12_port_types), 0x0,"", HFILL }},
|
||||
{ &hf_k12_ts, { "Timeslot mask", "k12.ds0.ts", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL }},
|
||||
{ &hf_k12_atm_vp, { "ATM VPI", "atm.vpi", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
|
||||
static hf_register_info hf[] = {
|
||||
{ &hf_k12_port_id, { "Port Id", "k12.port_id", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL }},
|
||||
{ &hf_k12_port_name, { "Port Name", "k12.port_name", FT_STRING, BASE_NONE, NULL, 0x0,"", HFILL }},
|
||||
{ &hf_k12_stack_file, { "Stack file used", "k12.stack_file", FT_STRING, BASE_NONE, NULL, 0x0,"", HFILL }},
|
||||
{ &hf_k12_port_type, { "Port type", "k12.input_type", FT_UINT32, BASE_HEX, VALS(k12_port_types), 0x0,"", HFILL }},
|
||||
{ &hf_k12_ts, { "Timeslot mask", "k12.ds0.ts", FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL }},
|
||||
{ &hf_k12_atm_vp, { "ATM VPI", "atm.vpi", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
|
||||
{ &hf_k12_atm_vc, { "ATM VCI", "atm.vci", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
|
||||
{ &hf_k12_atm_cid, { "AAL2 CID", "aal2.cid", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }}
|
||||
};
|
||||
|
@ -412,13 +433,13 @@ proto_register_k12(void)
|
|||
};
|
||||
|
||||
static uat_field_t uat_k12_flds[] = {
|
||||
UAT_FLD_CSTRING_ISPRINT(k12,match,
|
||||
"A string that will be matched (a=A) against an .stk filename or the name of a port.\n"
|
||||
"The first match wins, the order of entries in the table is important!."),
|
||||
UAT_FLD_CSTRING_ISPRINT(k12,match,
|
||||
"A string that will be matched (a=A) against an .stk filename or the name of a port.\n"
|
||||
"The first match wins, the order of entries in the table is important!."),
|
||||
UAT_FLD_CSTRING_OTHER(k12,protos,protos_chk_cb,
|
||||
"The lowest layer protocol described by this .stk file (eg: mtp2).\n"
|
||||
"Use (sscop:sscf-nni) for sscf-nni (MTP3b) with sscop"),
|
||||
UAT_END_FIELDS
|
||||
"The lowest layer protocol described by this .stk file (eg: mtp2).\n"
|
||||
"Use (sscop:sscf-nni) for sscf-nni (MTP3b) with sscop"),
|
||||
UAT_END_FIELDS
|
||||
};
|
||||
|
||||
module_t *k12_module;
|
||||
|
@ -429,25 +450,25 @@ proto_register_k12(void)
|
|||
register_dissector("k12", dissect_k12, proto_k12);
|
||||
|
||||
k12_uat = uat_new("K12 Protocols",
|
||||
sizeof(k12_handles_t),
|
||||
"k12_protos",
|
||||
(void**) &k12_handles,
|
||||
&nk12_handles,
|
||||
UAT_CAT_FFMT,
|
||||
"ChK12ProtocolsSection",
|
||||
k12_copy_cb,
|
||||
k12_update_cb,
|
||||
k12_free_cb,
|
||||
uat_k12_flds );
|
||||
sizeof(k12_handles_t),
|
||||
"k12_protos",
|
||||
(void**) &k12_handles,
|
||||
&nk12_handles,
|
||||
UAT_CAT_FFMT,
|
||||
"ChK12ProtocolsSection",
|
||||
k12_copy_cb,
|
||||
k12_update_cb,
|
||||
k12_free_cb,
|
||||
uat_k12_flds);
|
||||
|
||||
k12_module = prefs_register_protocol(proto_k12, NULL);
|
||||
|
||||
prefs_register_obsolete_preference(k12_module, "config");
|
||||
|
||||
prefs_register_uat_preference(k12_module, "cfg",
|
||||
"K12 Protocols",
|
||||
"A table of matches vs stack filenames and relative protocols",
|
||||
k12_uat);
|
||||
"K12 Protocols",
|
||||
"A table of matches vs stack filenames and relative protocols",
|
||||
k12_uat);
|
||||
|
||||
port_handles = se_tree_create(EMEM_TREE_TYPE_RED_BLACK, "k12_port_handles");
|
||||
|
||||
|
|
Loading…
Reference in New Issue