9 # verify that display filter names correspond with the PROTABBREV of
10 # of the dissector. Enforces the dissector to have a source
11 # filename of format packet-PROTABBREV.c
13 # Usage: checkfiltername.pl <file or files>
16 # Copyright 2011 Michael Mann (see AUTHORS file)
18 # Wireshark - Network traffic analyzer
19 # By Gerald Combs <gerald@wireshark.org>
20 # Copyright 1998 Gerald Combs
22 # SPDX-License-Identifier: GPL-2.0-or-later
26 # ~/work/wireshark/trunk/epan/dissectors> ../../tools/checkfiltername.pl packet-3com-xns.c
27 # packet-3com-xns.c (2 (of 2) fields)
28 # 102 3comxns.type doesn't match PROTOABBREV of 3com-xns
29 # 106 3comxns.type doesn't match PROTOABBREV of 3com-xns
31 # or checkfiltername.pl packet-*.c, which will check all the dissector files.
44 my @acceptedprefixes = ("dcerpc-");
45 my @asn1automatedfilelist;
46 my @dcerpcautomatedfilelist;
47 my @idl2wrsautomatedfilelist;
48 my @filemanipulationfilelist;
53 my @noregprotocolfilelist;
54 my @periodinfilternamefilelist;
56 my $showlinenoFlag = '';
57 my $showautomatedFlag = '';
62 # "s_in_hf_register_info",
63 # "s_hf_register_info_entry",
64 # "s_header_field_info_entry",
65 # "s_header_field_info_entry_start",
66 # "s_header_field_info_entry_name",
67 # "s_header_field_info_entry_abbrev",
68 # "s_header_field_info_entry_abbrev_end",
70 # "s_in_ei_register_info",
71 # "s_ei_register_info_entry",
72 # "s_ei_register_info_entry_start",
73 # "s_ei_register_info_entry_abbrev_end",
81 my $PFNAME_value = "";
83 my $totalerrorcount = 0;
84 my $errorfilecount = 0;
88 my $noregprotocol = 1;
95 sub checkprotoabbrev
{
100 my $afterabbrev = "";
101 my $check_dup_abbrev = "";
102 my $modprotabbrev = "";
106 if (($automated == 0) || ($showall == 1)) {
107 $abbrevpos = index($_[0], ".");
108 if ($abbrevpos == -1) {
112 $abbrev = substr($_[0], 0, $abbrevpos);
113 $afterabbrev = substr($_[0], $abbrevpos+1, length($_[0])-$abbrevpos);
114 $check_dup_abbrev = $afterabbrev;
115 $afterabbrev = substr($afterabbrev, 0, length($abbrev));
118 if ($abbrev ne $protabbrev) {
121 #check if there is a supported protocol that matches the abbrev.
122 #This may be a case of filename != PROTOABBREV
123 foreach (@protocols) {
126 } elsif (index($_, ".") != -1) {
128 #compare from start of string for each period found
129 $proto_abbrevpos1 = 0;
130 while ((($proto_abbrevpos2 = index($_, ".", $proto_abbrevpos1)) != -1) &&
132 if ($abbrev eq substr($_, 0, $proto_abbrevpos2)) {
136 $proto_abbrevpos1 = $proto_abbrevpos2+1;
142 # find any underscores that preface or follow a period
143 if (((index($_[0], "._") >= 0) || (index($_[0], "_.") >= 0)) &&
144 #ASN.1 dissectors can intentionally generating this field name, so don't fault the dissector
145 (index($_[0], "_untag_item_element") < 0)) {
146 if ($showlinenoFlag) {
147 push(@elements, "$_[1] $_[0] contains an unnecessary \'_\'\n");
149 push(@elements, "$_[0] contains an unnecessary \'_\'\n");
153 if (($errorline == 1) && ($showall == 0)) {
154 #try some "accepted" variations of PROTOABBREV
156 #replace '-' with '_'
157 $modprotabbrev = $protabbrev;
158 $modprotabbrev =~ s/-/_/g;
159 if ($abbrev eq $modprotabbrev) {
164 if ($errorline == 1) {
165 $modprotabbrev = $protabbrev;
166 $modprotabbrev =~ s/-//g;
167 if ($abbrev eq $modprotabbrev) {
173 if ($errorline == 1) {
174 $modprotabbrev = $protabbrev;
175 $modprotabbrev =~ s/_//g;
176 if ($abbrev eq $modprotabbrev) {
181 if ($errorline == 1) {
182 #remove any "accepted" prefix to see if there is still a problem
183 foreach (@acceptedprefixes) {
184 if ($protabbrev =~ /^$_/) {
185 $modprotabbrev = substr($protabbrev, length($_));
186 if ($abbrev eq $modprotabbrev) {
187 push(@prefixfilelist, "$currfile\n");
194 push(@filemanipulationfilelist, "$currfile\n");
197 #now check the acceptable "fields from a different protocol"
198 if ($errorline == 1) {
199 if (is_from_other_protocol_allowed
($_[0], $currfile) == 1) {
204 #now check the acceptable "fields that include a version number"
205 if ($errorline == 1) {
206 if (is_protocol_version_allowed
($_[0], $currfile) == 1) {
212 if ($errorline == 1) {
213 $debug>1 && print "$_[1] $_[0] doesn't match PROTOABBREV of $protabbrev\n";
214 if ($showlinenoFlag) {
215 push(@elements, "$_[1] $_[0] doesn't match PROTOABBREV of $protabbrev\n");
217 push(@elements, "$_[0] doesn't match PROTOABBREV of $protabbrev\n");
221 if (($abbrev ne "") && (lc($abbrev) eq lc($afterabbrev))) {
222 # Allow ASN.1 generated files to duplicate part of proto name
223 if ((!(grep {$currfile eq $_ } @asn1automatedfilelist)) &&
225 (is_proto_dup_allowed
($abbrev, $check_dup_abbrev) == 0)) {
226 if ($showlinenoFlag) {
227 push(@elements_dup, "$_[1] $_[0] duplicates PROTOABBREV of $abbrev\n");
229 push(@elements_dup, "$_[0] duplicates PROTOABBREV of $abbrev\n");
237 my $totalfields = keys(%filters);
242 foreach (sort keys %filters) {
243 checkprotoabbrev
($filters{$_}, $_);
246 foreach (sort keys %expert_filters) {
247 checkprotoabbrev
($expert_filters{$_}, $_);
250 $count_ele = @elements;
251 $count_dup = @elements_dup;
252 $total_count = $count_ele+$count_dup;
254 if ($noregprotocol == 1) {
255 #if no protocol is registered, only worry about duplicates
256 if ($currfile ne "") {
257 push(@noregprotocolfilelist, "$currfile\n");
260 if ($count_dup > 0) {
262 $totalerrorcount += $count_dup;
265 if (($showall == 1) || ($count_dup > 0)) {
266 print "\n\n$currfile - NO PROTOCOL REGISTERED\n";
268 #everything is included, so count all errors
269 $totalerrorcount += $count_ele;
270 if (($count_ele > 0) && ($count_dup == 0)) {
274 foreach (@elements) {
278 foreach (@elements_dup) {
283 if ($total_count > 0) {
285 $totalerrorcount += $total_count;
288 if (($automated == 0) || ($showall == 1)) {
289 if ($total_count > 0) {
290 if ($automated == 1) {
292 print "\n\n$currfile - AUTOMATED ($total_count (of $totalfields) fields)\n";
295 print "\n\n$currfile ($total_count (of $totalfields) fields)\n";
298 foreach (@elements) {
301 foreach (@elements_dup) {
306 if ((($nofields) || ($totalfields == 0)) && ($currfile ne "")) {
308 print "\n\n$currfile - NO FIELDS\n";
310 push(@nofieldfilelist, "$currfile\n");
316 #--------------------------------------------------------------------
317 # This is a list of dissectors that intentionally have filter names
318 # where the second segment duplicates (at least partially) the name
319 # of the first. The most common case is in ASN.1 dissectors, but
320 # those can be dealt with by looking at the first few lines of the
321 # dissector. This list has been vetted and justification will need
322 # to be provided to add to it. Acknowledge these dissectors aren't
323 # a problem for the pre-commit script
324 #--------------------------------------------------------------------
325 sub is_proto_dup_allowed
{
326 if (($_[0] eq "amf") && (index($_[1], "amf0") >= 0)) {return 1;}
327 if (($_[0] eq "amf") && (index($_[1], "amf3") >= 0)) {return 1;}
328 if (($_[0] eq "amqp") && (index($_[1], "amqp") >= 0)) {return 1;}
329 if (($_[0] eq "bat") && (index($_[1], "batman") >= 0)) {return 1;}
330 if (($_[0] eq "browser") && (index($_[1], "browser_") >= 0)) {return 1;}
331 if (($_[0] eq "data") && (index($_[1], "data") >= 0)) {return 1;}
332 if (($_[0] eq "dlsw") && (index($_[1], "dlsw_version") >= 0)) {return 1;}
333 if (($_[0] eq "dns") && (index($_[1], "dnskey") >= 0)) {return 1;}
334 if (($_[0] eq "ecmp") && (index($_[1], "ecmp_") >= 0)) {return 1;}
335 if (($_[0] eq "exported_pdu") && (index($_[1], "exported_pdu") >= 0)) {return 1;}
336 if (($_[0] eq "fc") && (index($_[1], "fctl") >= 0)) {return 1;}
337 if (($_[0] eq "fcs") && (index($_[1], "fcsmask") >= 0)) {return 1;}
338 if (($_[0] eq "fmp") && (index($_[1], "fmp") >= 0)) {return 1;}
339 if (($_[0] eq "fr") && (index($_[1], "frame_relay") >= 0)) {return 1;}
340 if (($_[0] eq "lustre") && (index($_[1], "lustre_") >= 0)) {return 1;}
341 if (($_[0] eq "mac") && (index($_[1], "macd") >= 0)) {return 1;}
342 if (($_[0] eq "mac") && (index($_[1], "macis") >= 0)) {return 1;}
343 if (($_[0] eq "mih") && (index($_[1], "mihf") >= 0)) {return 1;}
344 if (($_[0] eq "mih") && (index($_[1], "mihcap") >= 0)) {return 1;}
345 if (($_[0] eq "ncp") && (index($_[1], "ncp") >= 0)) {return 1;}
346 if (($_[0] eq "nfs") && (index($_[1], "nfs") >= 0)) {return 1;}
347 if (($_[0] eq "oxid") && (index($_[1], "oxid") >= 0)) {return 1;}
348 if (($_[0] eq "rquota") && (index($_[1], "rquota") >= 0)) {return 1;}
349 if (($_[0] eq "pfcp") && (index($_[1], "pfcp") >= 0)) {return 1;}
350 if (($_[0] eq "sm") && (index($_[1], "sm_") >= 0)) {return 1;}
351 if (($_[0] eq "smpp") && (index($_[1], "smppplus") >= 0)) {return 1;}
352 if (($_[0] eq "spray") && (index($_[1], "sprayarr") >= 0)) {return 1;}
353 if (($_[0] eq "stat") && (index($_[1], "stat_") >= 0)) {return 1;}
354 if (($_[0] eq "stat") && (index($_[1], "state") >= 0)) {return 1;}
355 if (($_[0] eq "tds") && (index($_[1], "tds_") >= 0)) {return 1;}
356 if (($_[0] eq "time") && (index($_[1], "time") >= 0)) {return 1;}
357 if (($_[0] eq "tn3270") && (index($_[1], "tn3270e") >= 0)) {return 1;}
358 if (($_[0] eq "usb") && (index($_[1], "usb") >= 0)) {return 1;}
359 if (($_[0] eq "xml") && (index($_[1], "xml") >= 0)) {return 1;}
360 if (($_[0] eq "dns") && (index($_[1], "dnscrypt") >= 0)) {return 1;}
365 #--------------------------------------------------------------------
366 # This is a list of dissectors that intentionally have filter names
367 # shared with other dissectors. This list has been vetted and
368 # justification will need to be provided to add to it.
369 # Acknowledge these dissectors aren't a problem for the pre-commit script
370 #--------------------------------------------------------------------
371 sub is_from_other_protocol_allowed
{
373 my $dir_index = rindex($_[1], "\\");
375 #handle directory names on all platforms
376 if ($dir_index < 0) {
377 $dir_index = rindex($_[1], "/");
380 if ($dir_index < 0) {
381 $proto_filename = $_[1];
384 $proto_filename = substr($_[1], $dir_index+1);
387 # XXX - may be faster to hash this (note 1-many relationship)?
388 if (($proto_filename eq "packet-atalk.c") && (index($_[0], "llc") >= 0)) {return 1;}
389 if (($proto_filename eq "packet-awdl.c") && (index($_[0], "llc") >= 0)) {return 1;}
390 if (($proto_filename eq "packet-bpdu.c") && (index($_[0], "mstp") >= 0)) {return 1;}
391 if (($proto_filename eq "packet-bssap.c") && (index($_[0], "bsap") >= 0)) {return 1;}
392 if (($proto_filename eq "packet-caneth.c") && (index($_[0], "can") >= 0)) {return 1;}
393 if (($proto_filename eq "packet-cimetrics.c") && (index($_[0], "llc") >= 0)) {return 1;}
394 if (($proto_filename eq "packet-cipsafety.c") && (index($_[0], "cip") >= 0)) {return 1;}
395 if (($proto_filename eq "packet-cipsafety.c") && (index($_[0], "enip") >= 0)) {return 1;}
396 if (($proto_filename eq "packet-dcerpc-netlogon.c") && (index($_[0], "ntlmssp") >= 0)) {return 1;}
397 if (($proto_filename eq "packet-dcom-oxid.c") && (index($_[0], "dcom") >= 0)) {return 1;}
398 if (($proto_filename eq "packet-dvb-data-mpe.c") && (index($_[0], "mpeg_sect") >= 0)) {return 1;}
399 if (($proto_filename eq "packet-dvb-ipdc.c") && (index($_[0], "ipdc") >= 0)) {return 1;}
400 if (($proto_filename eq "packet-enip.c") && (index($_[0], "cip") >= 0)) {return 1;}
401 if (($proto_filename eq "packet-extreme.c") && (index($_[0], "llc") >= 0)) {return 1;}
402 if (($proto_filename eq "packet-fmp_notify.c") && (index($_[0], "fmp") >= 0)) {return 1;}
403 if (($proto_filename eq "packet-foundry.c") && (index($_[0], "llc") >= 0)) {return 1;}
404 if (($proto_filename eq "packet-glusterfs.c") && (index($_[0], "gluster") >= 0)) {return 1;}
405 if (($proto_filename eq "packet-h248_annex_e.c") && (index($_[0], "h248") >= 0)) {return 1;}
406 if (($proto_filename eq "packet-h248_q1950.c") && (index($_[0], "h248") >= 0)) {return 1;}
407 if (($proto_filename eq "packet-ieee1722.c") && (index($_[0], "can") >= 0)) {return 1;}
408 if (($proto_filename eq "packet-ieee80211.c") && (index($_[0], "eapol") >= 0)) {return 1;}
409 if (($proto_filename eq "packet-ieee80211-radio.c") && (index($_[0], "wlan") >= 0)) {return 1;}
410 if (($proto_filename eq "packet-ieee80211-wlancap.c") && (index($_[0], "wlan") >= 0)) {return 1;}
411 if (($proto_filename eq "packet-ieee802154.c") && (index($_[0], "wpan") >= 0)) {return 1;}
412 if (($proto_filename eq "packet-isup.c") && (index($_[0], "ansi_isup") >= 0)) {return 1;}
413 if (($proto_filename eq "packet-isup.c") && (index($_[0], "bat_ase") >= 0)) {return 1;}
414 if (($proto_filename eq "packet-isup.c") && (index($_[0], "nsap") >= 0)) {return 1;}
415 if (($proto_filename eq "packet-isup.c") && (index($_[0], "x213") >= 0)) {return 1;}
416 if (($proto_filename eq "packet-iwarp-ddp-rdmap.c") && (index($_[0], "iwarp_ddp") >= 0)) {return 1;}
417 if (($proto_filename eq "packet-iwarp-ddp-rdmap.c") && (index($_[0], "iwarp_rdma") >= 0)) {return 1;}
418 if (($proto_filename eq "packet-k12.c") && (index($_[0], "aal2") >= 0)) {return 1;}
419 if (($proto_filename eq "packet-k12.c") && (index($_[0], "atm") >= 0)) {return 1;}
420 if (($proto_filename eq "packet-m3ua.c") && (index($_[0], "mtp3") >= 0)) {return 1;}
421 if (($proto_filename eq "packet-mle.c") && (index($_[0], "wpan") >= 0)) {return 1;}
422 if (($proto_filename eq "packet-mpeg-dsmcc.c") && (index($_[0], "mpeg_sect") >= 0)) {return 1;}
423 if (($proto_filename eq "packet-mpeg-dsmcc.c") && (index($_[0], "etv.dsmcc") >= 0)) {return 1;}
424 if (($proto_filename eq "packet-mpeg1.c") && (index($_[0], "rtp.payload_mpeg_") >= 0)) {return 1;}
425 if (($proto_filename eq "packet-mysql.c") && (index($_[0], "mariadb") >= 0)) {return 1;}
426 if (($proto_filename eq "packet-ndps.c") && (index($_[0], "spx.ndps_") >= 0)) {return 1;}
427 if (($proto_filename eq "packet-pw-atm.c") && (index($_[0], "atm") >= 0)) {return 1;}
428 if (($proto_filename eq "packet-pw-atm.c") && (index($_[0], "pw") >= 0)) {return 1;}
429 if (($proto_filename eq "packet-scsi.c") && (index($_[0], "scsi_sbc") >= 0)) {return 1;}
430 if (($proto_filename eq "packet-sndcp-xid.c") && (index($_[0], "llcgprs") >= 0)) {return 1;}
431 if (($proto_filename eq "packet-wlccp.c") && (index($_[0], "llc") >= 0)) {return 1;}
432 if (($proto_filename eq "packet-wps.c") && (index($_[0], "eap") >= 0)) {return 1;}
433 if (($proto_filename eq "packet-wsp.c") && (index($_[0], "wap") >= 0)) {return 1;}
434 if (($proto_filename eq "packet-xot.c") && (index($_[0], "x25") >= 0)) {return 1;}
435 if (($proto_filename eq "packet-zbee-zcl-misc.c") && (index($_[0], "zbee_zcl_hvac") >= 0)) {return 1;}
436 if (($proto_filename eq "packet-zbee-zcl-misc.c") && (index($_[0], "zbee_zcl_ias") >= 0)) {return 1;}
438 #Understand why, but I think it could be prefixed with "dissector"
439 #prefix (which isn't necessarily "protocol")
440 if (($proto_filename eq "packet-rtcp.c") && (index($_[0], "srtcp") >= 0)) {return 1;}
441 if (($proto_filename eq "packet-rtp.c") && (index($_[0], "srtp") >= 0)) {return 1;}
442 if (($proto_filename eq "packet-dcom-cba-acco.c") && (index($_[0], "cba") >= 0)) {return 1;}
443 if (($proto_filename eq "packet-dcom-cba.c") && (index($_[0], "cba") >= 0)) {return 1;}
445 #XXX - HACK to get around nested "s in field name
446 if (($proto_filename eq "packet-gsm_sim.c") && (index($_[0], "e\\") >= 0)) {return 1;}
451 #--------------------------------------------------------------------
452 # This is a list of dissectors that use their (protocol) version number
453 # as part of the first display filter segment, which checkfiltername
454 # usually complains about. Manually allow them so that they can pass
456 #--------------------------------------------------------------------
457 sub is_protocol_version_allowed
{
459 my $dir_index = rindex($_[1], "\\");
461 #handle directory names on all platforms
462 if ($dir_index < 0) {
463 $dir_index = rindex($_[1], "/");
466 if ($dir_index < 0) {
467 $proto_filename = $_[1];
470 $proto_filename = substr($_[1], $dir_index+1);
473 # XXX - may be faster to hash this?
474 if (($proto_filename eq "packet-ehs.c") && (index($_[0], "ehs2") >= 0)) {return 1;}
475 if (($proto_filename eq "packet-hsrp.c") && (index($_[0], "hsrp2") >= 0)) {return 1;}
476 if (($proto_filename eq "packet-ipv6.c") && (index($_[0], "ip") >= 0)) {return 1;}
477 if (($proto_filename eq "packet-openflow_v1.c") && (index($_[0], "openflow") >= 0)) {return 1;}
478 if (($proto_filename eq "packet-rtnet.c") && (index($_[0], "tdma-v1") >= 0)) {return 1;}
479 if (($proto_filename eq "packet-scsi-osd.c") && (index($_[0], "scsi_osd2") >= 0)) {return 1;}
480 if (($proto_filename eq "packet-sflow.c") && (index($_[0], "sflow_5") >= 0)) {return 1;}
481 if (($proto_filename eq "packet-sflow.c") && (index($_[0], "sflow_245") >= 0)) {return 1;}
482 if (($proto_filename eq "packet-tipc.c") && (index($_[0], "tipcv2") >= 0)) {return 1;}
483 if (($proto_filename eq "packet-bluetooth.c") && (index($_[0], "llc.bluetooth_pid") >= 0)) {return 1;}
488 # ---------------------------------------------------------------------
493 'showlineno' => \
$showlinenoFlag,
494 'showautomated' => \
$showautomatedFlag,
498 if ($currfile !~ /$ARGV/) {
501 # New file - reset array and state
505 #determine PROTABBREV for dissector based on file name format of (dirs)/packet-PROTABBREV.c or (dirs)/file-PROTABBREV.c
506 $protabbrev_index = rindex($currfile, "packet-");
507 if ($protabbrev_index == -1) {
508 $protabbrev_index = rindex($currfile, "file-");
509 if ($protabbrev_index == -1) {
510 #ignore "non-dissector" files
514 $protabbrev = substr($currfile, $protabbrev_index+length("file-"));
515 $protabbrev_index = rindex($protabbrev, ".");
516 if ($protabbrev_index == -1) {
517 print "$currfile doesn't fit format of file-PROTABBREV.c\n";
521 $protabbrev = substr($currfile, $protabbrev_index+length("packet-"));
522 $protabbrev_index = rindex($protabbrev, ".");
523 if ($protabbrev_index == -1) {
524 print "$currfile doesn't fit format of packet-PROTABBREV.c\n";
528 $protabbrev = substr($protabbrev, 0, $protabbrev_index);
538 %expert_filters = ( );
542 $state = "s_unknown";
545 if (($automated == 0) && ($showautomatedFlag eq "")) {
546 #DCERPC automated files
547 if ($_ =~ "DO NOT EDIT") {
548 push(@dcerpcautomatedfilelist, "$currfile\n");
552 #ASN.1 automated files
553 elsif ($_ =~ "Generated automatically by the ASN.1 to Wireshark dissector compiler") {
554 push(@asn1automatedfilelist, "$currfile\n");
558 #idl2wrs automated files
559 elsif ($_ =~ "Autogenerated from idl2wrs") {
560 push(@idl2wrsautomatedfilelist, "$currfile\n");
566 # opening then closing comment
567 if (/(.*?)\/\
*.*\
*\
/(.*)/) {
570 # closing then opening comment
571 } elsif (/.*?\*\/(.*?
)\
/\*/) {
575 } elsif (/(.*?)\/\
*/) {
579 } elsif (/\*\/(.*?
)/) {
582 } elsif ($comment == 1) {
586 # unhandled: more than one complete comment per line
590 #proto_register_protocol state machine
594 #PFNAME is a popular #define for the proto filter name, so use it for testing
595 if ($restofline =~ /#define\s*PFNAME\s*\"([^\"]*)\"/) {
597 $debug>1 && print "PFNAME: '$1'\n";
600 until ($more_tokens == 0) {
601 if (($restofline =~ /proto_register_protocol\s*\((.*)/) ||
602 ($restofline =~ /proto_register_protocol_in_name_only\s*\((.*)/)) {
605 $state = "s_proto_start";
606 } elsif (($state eq "s_proto_start") && ($restofline =~ /^(\s*\"([^\"]*)\"\s*,)\s*(.*)/)) {
608 $state = "s_proto_long_name";
609 $debug>1 && print "proto long name: '$2'\n";
610 } elsif (($state eq "s_proto_start") && ($restofline =~ /^(\s*(([\w\d])+)\s*,)\s*(.*)/)) {
612 $state = "s_proto_long_name";
613 $debug>1 && print "proto long name: '$2'\n";
614 } elsif (($state eq "s_proto_long_name") && ($restofline =~ /^(\s*\"([^\"]*)\"\s*,)\s*(.*)/)) {
616 $state = "s_proto_short_name";
617 $debug>1 && print "proto short name: '$2'\n";
618 } elsif (($state eq "s_proto_long_name") && ($restofline =~ /^(\s*(([\w\d])+)\s*,)\s*(.*)/)) {
620 $state = "s_proto_short_name";
621 $debug>1 && print "proto short name: '$2'\n";
622 } elsif (($state eq "s_proto_short_name") && ($restofline =~ /\s*PFNAME\s*(.*)/)) {
624 $state = "s_proto_filter_name";
625 if ((index($PFNAME_value, ".") != -1) && ($noperiod == 0)) {
626 push(@periodinfilternamefilelist, "$currfile\n");
629 push(@protocols, $PFNAME_value);
630 $debug>1 && print "proto filter name: '$PFNAME_value'\n";
631 } elsif (($state eq "s_proto_short_name") && ($restofline =~ /\s*\"([^\"]*)\"\s*(.*)/)) {
633 $state = "s_proto_filter_name";
634 if ((index($1, ".") != -1) && ($noperiod == 0)) {
635 push(@periodinfilternamefilelist, "$currfile\n");
638 push(@protocols, $1);
639 $debug>1 && print "proto filter name: '$1'\n";
640 } elsif (($state eq "s_proto_short_name") && ($restofline =~ /\s*(([\w\d])+)\s*(.*)/)) {
642 $state = "s_proto_filter_name";
643 $debug>1 && print "proto filter name: '$1'\n";
649 #retrieving display filters state machine
652 until ($more_tokens == 0) {
653 if ($restofline =~ /\s*static\s*hf_register_info\s*(\w+)\[\](.*)/) {
656 $debug>1 && print "$linenumber $state\n";
657 } elsif ($restofline =~ /\s*static\s*ei_register_info\s*(\w+)\[\](.*)/) {
659 $state = "s_start_expert";
660 $debug>1 && print "$linenumber $state\n";
661 } elsif (($state eq "s_start") && ($restofline =~ /\W+{(.*)/)) {
663 $state = "s_in_hf_register_info";
664 $debug>1 && print "$linenumber $state\n";
665 } elsif (($state eq "s_in_hf_register_info") && ($restofline =~ /\W+{(.*)/)) {
667 $state = "s_hf_register_info_entry";
668 $debug>1 && print "$linenumber $state\n";
670 } elsif (($state eq "s_in_hf_register_info") && ($restofline =~ /\s*};(.*)/)) {
672 if ($onefield == 0) {
673 $debug && print "$linenumber NO FIELDS!!!\n";
675 $state = "s_nofields";
678 $state = "s_unknown";
680 } elsif (($state eq "s_hf_register_info_entry") && ($restofline =~ /\s*&\s*(hf_\w*(\[w*\])?)\s*,?(.*)/)) {
682 $debug>1 && print "$linenumber hf_register_info_entry: $1\n";
683 $state = "s_header_field_info_entry";
684 } elsif (($state eq "s_header_field_info_entry") && ($restofline =~ /\s*{(.*)/)) {
686 $state = "s_header_field_info_entry_start";
687 $debug>1 && print "$linenumber $state\n";
688 } elsif (($state eq "s_header_field_info_entry_start") && ($restofline =~ /((\"([^\"]*)\")|(\w+))\s*,(.*)/)) {
690 $debug>1 && print "$linenumber header_field_info_entry_name: $1\n";
691 $state = "s_header_field_info_entry_name";
692 } elsif (($state eq "s_header_field_info_entry_name") && ($restofline =~ /\"([^\"]*)\"\s*,?(.*)/)) {
694 $debug>1 && print "$linenumber header_field_info_entry_abbrev: $1\n";
695 $state = "s_header_field_info_entry_abbrev";
696 $filters{$linenumber} = $1;
697 } elsif (($state eq "s_header_field_info_entry_abbrev") && ($restofline =~ /[^}]*}(.*)/)) {
699 $state = "s_header_field_info_entry_abbrev_end";
700 $debug>1 && print "$linenumber $state\n";
701 } elsif (($state eq "s_header_field_info_entry_abbrev_end") && ($restofline =~ /[^}]*}(.*)/)) {
703 $state = "s_in_hf_register_info";
704 $debug>1 && print "$linenumber $state\n";
705 } elsif (($state eq "s_start_expert") && ($restofline =~ /\W+{(.*)/)) {
707 $state = "s_in_ei_register_info";
708 $debug>1 && print "$linenumber $state\n";
709 } elsif (($state eq "s_in_ei_register_info") && ($restofline =~ /\W+{(.*)/)) {
711 $state = "s_ei_register_info_entry";
712 $debug>1 && print "$linenumber $state\n";
713 } elsif (($state eq "s_in_ei_register_info") && ($restofline =~ /\s*};(.*)/)) {
715 $state = "s_unknown";
716 } elsif (($state eq "s_ei_register_info_entry") && ($restofline =~ /\s*{(.*)/)) {
718 $state = "s_ei_register_info_entry_start";
719 $debug>1 && print "$linenumber $state\n";
720 } elsif (($state eq "s_ei_register_info_entry_start") && ($restofline =~ /\"([^\"]*)\"\s*,(.*)/)) {
722 $debug>1 && print "$linenumber ei_register_info_entry_abbrev: $1\n";
723 $expert_filters{$linenumber} = $1;
724 $state = "s_ei_register_info_entry_abbrev_end";
725 } elsif (($state eq "s_ei_register_info_entry_abbrev_end") && ($restofline =~ /[^}]*}(.*)/)) {
727 $state = "s_in_ei_register_info";
728 $debug>1 && print "$linenumber $state\n";
739 if ($totalerrorcount > 0) {
740 print "\n\nTOTAL ERRORS: $totalerrorcount";
742 if ($filecount > 1) {
743 print " ($errorfilecount files)\n";
745 print "NO FIELDS: " . scalar(@nofieldfilelist) . "\n";
746 print "AUTOMATED: " . (scalar(@asn1automatedfilelist) + scalar(@dcerpcautomatedfilelist) + scalar(@idl2wrsautomatedfilelist)) . "\n";
747 print "NO PROTOCOL: " . scalar(@noregprotocolfilelist) . "\n";
749 print "\nASN.1 AUTOMATED FILE LIST\n";
750 foreach (@asn1automatedfilelist) {
753 print "\nDCE/RPC AUTOMATED FILE LIST\n";
754 foreach (@dcerpcautomatedfilelist) {
757 print "\nIDL2WRS AUTOMATED FILE LIST\n";
758 foreach (@idl2wrsautomatedfilelist) {
761 print "\n\"FILE MANIPULATION\" FILE LIST\n";
762 @uniquefilelist = grep{ not $unique{$_}++} @filemanipulationfilelist;
763 foreach (@uniquefilelist) {
766 print "\nREMOVE PREFIX FILE LIST\n";
767 @uniquefilelist = grep{ not $unique{$_}++} @prefixfilelist;
768 foreach (@uniquefilelist) {
771 print "\nNO PROTOCOL REGISTERED FILE LIST\n";
772 foreach (@noregprotocolfilelist) {
775 print "\nNO FIELDS FILE LIST\n";
776 foreach (@nofieldfilelist) {
780 print "\nPERIOD IN PROTO FILTER NAME FILE LIST\n";
781 foreach (@periodinfilternamefilelist) {
788 exit(1); # exit 1 if ERROR