aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorBill Meier <wmeier@newsguy.com>2010-09-23 18:48:19 +0000
committerBill Meier <wmeier@newsguy.com>2010-09-23 18:48:19 +0000
commit55620b5b7502a0da855e51338f239e68c90a17c8 (patch)
treedf13e25a6e3b56ab7c0bd4d24a199545b4631ea7 /tools
parent123347da00377f6ef9bb1b0d0bc232144928b260 (diff)
Generate the value_string array sminmpec_values[] with "gaps"
filled in (using name "(Unknown)" so that direct (indexed) access to the value_string is possible. Note that this represents a slight API change in that match_strval() on sminmpec_values will no longer return NULL for missing enterprise numbers (less than the maximum in the array) but will return the string "(Unknown)". AFAIKT this change does not materially affect existing Wireshark use of the sminmpec value_string array. svn path=/trunk/; revision=34218
Diffstat (limited to 'tools')
-rwxr-xr-xtools/make-sminmpec.pl17
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/make-sminmpec.pl b/tools/make-sminmpec.pl
index c490ce89eb..13c7c92608 100755
--- a/tools/make-sminmpec.pl
+++ b/tools/make-sminmpec.pl
@@ -79,12 +79,14 @@ open OUT, "> sminmpec.c";
my $body = '';
my $code;
+my $prev_code = -1; ## Assumption: First code in enterprise file is 0;
sub escape_non_ascii {
my $val = unpack 'C', $_[0];
return sprintf '\0%.3o',$val;
}
+
for(@in_lines) {
s/[\000-\037]//g;
s/\\/\\\\/g;
@@ -95,6 +97,15 @@ for(@in_lines) {
$code = sprintf("%5d", $1);
} if (/^ (\S.*)/ ) {
my $name = $1;
+ if ($code < $prev_code) {
+ print STDERR ("Input 'Codes' not sorted in ascending order (or duplicate codes)): $prev_code $code\n");
+ exit 1;
+ }
+ while ($code > ($prev_code+1)) {
+ $prev_code = sprintf("%5d", $prev_code+1);
+ $body .= " { $prev_code, sminmpec_unknown }, /* (Added by Wireshark) */\n";
+ }
+ $prev_code = $code;
$body .= " { $code, \"$name\" },\n";
}
}
@@ -106,6 +117,10 @@ print OUT <<"_SMINMPEC";
* THIS FILE IS AUTOGENERATED, DO NOT EDIT
* generated from http://www.iana.org/assignments/enterprise-numbers
* run "tools/make-sminmspec <infile> <outfile>" to regenerate
+ *
+ * Note: "Gaps" in the iana enterprise-numbers list have been "filled in"
+ * with "(Unknown)" as the name so that direct (indexed) access
+ * to the list is possible.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -116,6 +131,8 @@ print OUT <<"_SMINMPEC";
#include <epan/value_string.h>
#include <epan/sminmpec.h>
+static const gchar sminmpec_unknown[] = "(Unknown)";
+
static const value_string sminmpec_values[] = {
$body { 0, NULL}
};