#!/usr/bin/perl -w # SPDX-License-Identifier: GPL-2.0-or-later
java.lang.NullPointerException # Build a static ASN.1 Object Identified (OID) registry
java.lang.NullPointerException # Copyright (C) 2012 Red Hat, Inc. All Rights Reserved. # Written by David Howells (dhowells@redhat.com)
java.lang.NullPointerException
java.lang.NullPointerException # Open the file to read from
java.lang.NullPointerException
open IN_FILE, "<$ARGV[0]" || die; while (<IN_FILE>) {
chomp; if (m!\s+OID_([a-zA-z][a-zA-Z0-9_]+),\s+/[*]\s+([012][.0-9]*)\s+[*]/!) {
push @names, $1;
push @oids, $2;
}
}
close IN_FILE || die;
java.lang.NullPointerException # Open the files to write into
java.lang.NullPointerException
open C_FILE, ">$ARGV[1]"or die;
print C_FILE "/*\n";
my $scriptname = $0;
$scriptname =~ s#^\Q$abs_srctree/\E##;
print C_FILE " * Automatically generated by ", $scriptname, ". Do not edit\n";
print C_FILE " */\n";
java.lang.NullPointerException # Split the data up into separate lists and also determine the lengths of the # encoded data arrays.
java.lang.NullPointerException
my @indices = ();
my @lengths = ();
my $total_length = 0;
for (my $i = 0; $i <= $#names; $i++) {
my $name = $names[$i];
my $oid = $oids[$i];
my @components = split(/[.]/, $oid);
# Determine the encoded length of this OID
my $size = $#components; for (my $loop = 2; $loop <= $#components; $loop++) {
my $c = $components[$loop];
# We will base128 encode the number
my $tmp = ($c == 0) ? 0 : int(log($c)/log(2));
$tmp = int($tmp / 7);
$size += $tmp;
}
push @lengths, $size;
push @indices, $total_length;
$total_length += $size;
}
java.lang.NullPointerException # Create a hash value for each OID
java.lang.NullPointerException
my @hash_values = (); for (my $i = 0; $i <= $#names; $i++) {
my @octets = @{$encoded_oids[$i]};
java.lang.NullPointerException # Build the search index table (ordered by length then hash then content)
java.lang.NullPointerException
my @index_table = ( 0 .. $#names );
@index_table = sort {
my @octets_a = @{$encoded_oids[$a]};
my @octets_b = @{$encoded_oids[$b]};
return $hash_values[$a] <=> $hash_values[$b] if ($hash_values[$a] != $hash_values[$b]); return $#octets_a <=> $#octets_b if ($#octets_a != $#octets_b); for (my $i = $#octets_a; $i >= 0; $i--) { return $octets_a[$i] <=> $octets_b[$i] if ($octets_a[$i] != $octets_b[$i]);
} return 0;
} @index_table;
java.lang.NullPointerException # Emit the search index and hash value table
java.lang.NullPointerException
print C_FILE "\n";
print C_FILE "static const struct {\n";
print C_FILE "\tunsigned char hash;\n"; if ($#names <= 255) {
print C_FILE "\tenum OID oid : 8;\n";
} else {
print C_FILE "\tenum OID oid : 16;\n";
}
print C_FILE "} oid_search_table[OID__NR] = {\n"; for (my $i = 0; $i <= $#names; $i++) {
my @octets = @{$encoded_oids[$index_table[$i]]};
printf(C_FILE "\t[%3u] = { %3u, OID_%-35s }, // ",
$i,
$hash_values[$index_table[$i]],
$names[$index_table[$i]]);
printf C_FILE "%02x", $_ foreach (@octets);
print C_FILE "\n";
}
print C_FILE "};\n";
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.