Subversion Repositories oidplus

Rev

Rev 1425 | Blame | Compare with Previous | Last modification | View Log | RSS feed

#!/usr/bin/env php
-- This file (wellknown_other_sqlite.sql) contains ASN.1 and IRI names of OIDs which are either
-- a) Root OIDs
-- b) Unicode labels which are long arcs
-- c) Standardized ASN.1 identifiers
-- d) OIDs where potential users of this software can register OIDs in these arcs (e.g. an "identified organization" arc)
-- Use the tool dev/generate_wellknown_other_sqlite to generate this file

<?php

/*
 * OIDplus 2.0
 * Copyright 2019 - 2021 Daniel Marschall, ViaThinkSoft
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

use ViaThinkSoft\OIDplus\OIDplus;

require_once __DIR__ . '/../includes/oidplus.inc.php';
require_once __DIR__ . '/ft_get_oid_data.inc.php';

OIDplus::init(false);
if (!OIDplus::baseConfig()->exists('OIDINFO_API_URL')) {
        die("OIDINFO_API_URL not available (API is currently not public)\n");
}

$output = array();

function _is_standardized($oid, $asn1id) {
        $std = asn1_get_standardized_array();
        $x = oid_up($oid) == $oid ? '' : oid_up($oid).".";
        return isset( $std[$x.$asn1id]) && ($std[$x.$asn1id] == $oid);
}

function _is_long($oid) {
        $oid = '/'.str_replace('.', '/', $oid);
        return in_array($oid, iri_get_long_arcs());
}

function _process_oid($oid) {
        global $output;

        if (!isset($output[$oid])) {
                if ($oid == '0.0.23') {
                        // Rec. ITU-T X.660 | ISO/IEC 9834-3, clause A.3.3.1 allows "0.0.w", although it is illegal, since no W-series exist
                        $data = array();
                        $data['oid'] = array();
                        $data['oid']['identifier'] = array('w');
                        $data['oid']['unicode-label'] = array('W');
                } else {
                        $data = ft_get_oid_data($oid);
                }

                $output[$oid] = array();
                $output[$oid]['asn1id'] = array();
                $output[$oid]['iri'] = array();
                $output[$oid]['checksum'] = array();

                if (isset($data['oid']['identifier'])) {
                        foreach ($data['oid']['identifier'] as $asn1id) {
                                $output[$oid]['checksum'][] = $oid.'|ASN1|'.$asn1id.'|'.(_is_standardized($oid, $asn1id) ? '1' : '0').'|1||';
                                $std = _is_standardized($oid, $asn1id) ? "'1'" : "'0'";
                                $output[$oid]['asn1id'][] = "INSERT INTO `asn1id` (oid, name, standardized, well_known) VALUES ('oid:$oid', '$asn1id', $std, '1');";
                        }
                } else {
                        //echo "-- Warning: Has no ASN.1 identifier: $oid\n";
                }
                if (isset($data['oid']['unicode-label'])) {
                        foreach ($data['oid']['unicode-label'] as $iri) {
                                $output[$oid]['checksum'][] = $oid.'|IRI|'.$iri.'|'.(_is_long($oid) ? '1' : '0').'|1||';

                                $std = _is_long($oid) ? "'1'" : "'0'";

                                if (strpos($iri, '&#') !== false) {
                                        $ucstr = html_entity_decode($iri, ENT_COMPAT | ENT_HTML401, "UTF-8");
                                        $tmp = array();
                                        preg_match_all('/./u', $ucstr, $m);
                                        foreach ($m[0] as $o) {
                                                $tmp[] = mb_ord($o);
                                        }
                                        $iri = 'char('.implode(',',$tmp).')';
                                } else {
                                        $iri = "'$iri'";
                                }

                                $output[$oid]['iri'][] = "INSERT INTO `iri` (oid, name, longarc, well_known) VALUES ('oid:$oid', $iri, $std, '1');";
                        }
                }
        }

        return $output[$oid];
}

// ---

$interesting_oids = array();

foreach (asn1_get_standardized_array() as $tmp => $oid) {
        $interesting_oids[] = $oid;
}

foreach (iri_get_long_arcs() as $tmp => $oid) {
        $oid = substr(str_replace('/', '.', $oid),1);
        $interesting_oids[] = $oid;
}

// ----------------------------------------------------------------

$interesting_oids[] = '0'; // itu-t
        $interesting_oids[] = '0.2'; // telecom operators
        $interesting_oids[] = '0.3'; // network-operator
        $interesting_oids[] = '0.4'; // identified-organization
                $interesting_oids[] = '0.4.0'; // etsi
                        $interesting_oids[] = '0.4.0.127'; // reserved
                                $interesting_oids[] = '0.4.0.127.0'; // etsi-identified-organization
$interesting_oids[] = '1'; // iso
        $interesting_oids[] = '1.1'; // registration-authority
                $interesting_oids[] = '1.1.19785'; // cbeff
                        $interesting_oids[] = '1.1.19785.0'; // organization
        $interesting_oids[] = '1.2'; // member-body
                // country_getter defines the country OIDs
                //$interesting_oids[] = '1.2.158'; // tw
                        $interesting_oids[] = '1.2.158.1'; // organization
                //$interesting_oids[] = '1.2.276'; // de
                        $interesting_oids[] = '1.2.276.0'; // din-certco
                //$interesting_oids[] = '1.2.344'; // hk
                        $interesting_oids[] = '1.2.344.1'; // organization
                //$interesting_oids[] = '1.2.616'; // pl
                        $interesting_oids[] = '1.2.616.1'; // organization
                //$interesting_oids[] = '1.2.826'; // gb
                        $interesting_oids[] = '1.2.826.0'; // national
                                $interesting_oids[] = '1.2.826.0.1'; // eng-ltd
                                        $interesting_oids[] = '1.2.826.0.1.3680043'; // Medical Connections ( https://www.medicalconnections.co.uk/FreeUID/ )
                //$interesting_oids[] = '1.2.840'; // us
                        $interesting_oids[] = '1.2.840.1'; // organization
                                $interesting_oids[] = '1.2.840.113556'; // microsoft
                                        $interesting_oids[] = '1.2.840.113556.1'; // Microsoft Active Directory
                                                $interesting_oids[] = '1.2.840.113556.1.8000'; // companies
                                                        $interesting_oids[] = '1.2.840.113556.1.8000.2554'; // customer usage (UUID-to-OID)
                                        $interesting_oids[] = '1.2.840.113556.2'; // DICOM
        $interesting_oids[] = '1.3'; // identified-organization
                $interesting_oids[] = '1.3.6'; // dod
                        $interesting_oids[] = '1.3.6.1'; // internet
                                $interesting_oids[] = '1.3.6.1.2'; // mgmt
                                        $interesting_oids[] = '1.3.6.1.2.1'; // mib-2
                                                $interesting_oids[] = '1.3.6.1.4'; // private
                                                        $interesting_oids[] = '1.3.6.1.4.1'; // enterprise
                                                                $interesting_oids[] = '1.3.6.1.4.1.19376'; // Integrating the Healthcare Enterprise International
                                                                        $interesting_oids[] = '1.3.6.1.4.1.19376.3'; // Organizations (not in Repo!)
                                                                        $interesting_oids[] = '1.3.6.1.4.1.19376.3.276'; // IHE Deutschland
                                                                                $interesting_oids[] = '1.3.6.1.4.1.19376.3.276.1'; // OID für das OID Konzept Version 1
                                                                                        $interesting_oids[] = '1.3.6.1.4.1.19376.3.276.1.4'; // Identifikation des ID-Pools für Institutionen (Organisationen, Einheiten, etc.)
                                                                                                        $interesting_oids[] = '1.3.6.1.4.1.19376.3.276.1.4.1'; // Krankenhäuser
                                                                                                        $interesting_oids[] = '1.3.6.1.4.1.19376.3.276.1.4.2'; // Praxen niedergelassener Ärzte
                                                                                                        $interesting_oids[] = '1.3.6.1.4.1.19376.3.276.1.4.3'; // Systeme
                                                                $interesting_oids[] = '1.3.6.1.4.1.12798'; // Members of Internet-Käyttäjät Ikuisesti (IKI)
                                                                        $interesting_oids[] = '1.3.6.1.4.1.12798.1'; // member
                                                                $interesting_oids[] = '1.3.6.1.4.1.37476'; // ViaThinkSoft
                                                                        $interesting_oids[] = '1.3.6.1.4.1.37476.9000'; // freeoid
                                                                $interesting_oids[] = '1.3.6.1.4.1.37553'; // frdlweb
                                                                        $interesting_oids[] = '1.3.6.1.4.1.37553.8'; // WEID
                                                                                $interesting_oids[] = '1.3.6.1.4.1.37553.8.8'; // private
                                                                                $interesting_oids[] = '1.3.6.1.4.1.37553.8.9'; // ns
                                                                                        $interesting_oids[] = '1.3.6.1.4.1.37553.8.9.17704'; // dns
                                                                                        $interesting_oids[] = '1.3.6.1.4.1.37553.8.9.1439221'; // uuid
                                                                $interesting_oids[] = '1.3.6.1.4.1.54392'; // Waterjuice
# Is not on oid-info.com, but has no alphanum/unicode ID anyway
#                                                                       $interesting_oids[] = '1.3.6.1.4.1.54392.1'; // Waterjuice "UUID-to-OID" (2x64 bits)
#                                                                       $interesting_oids[] = '1.3.6.1.4.1.54392.2'; // Waterjuice "UUID-to-OID" (4x32 bits)
#                                                                       $interesting_oids[] = '1.3.6.1.4.1.54392.3'; // Waterjuice "UUID-to-OID" (8x16 bits)
#                                                                       $interesting_oids[] = '1.3.6.1.4.1.54392.4'; // Waterjuice FreeOID "old"
#                                                                       $interesting_oids[] = '1.3.6.1.4.1.54392.5'; // Waterjuice FreeOID "new"
                                                                $interesting_oids[] = '1.3.6.1.4.1.61117'; // R74n
                                                                        $interesting_oids[] = '1.3.6.1.4.1.61117.9000'; // R74n FreeOID
$interesting_oids[] = '2'; // joint-iso-itu-t
        $interesting_oids[] = '2.16'; // country
                // country_getter defines the country OIDs
                //$interesting_oids[] = '2.16.158'; // tw
                        $interesting_oids[] = '2.16.158.1'; // organization
                //$interesting_oids[] = '2.16.344'; // hk
                        $interesting_oids[] = '2.16.344.1'; // organization
                //$interesting_oids[] = '2.16.616'; // pl
                        $interesting_oids[] = '2.16.616.1'; // organization
                //$interesting_oids[] = '2.16.840'; // us
                        $interesting_oids[] = '2.16.840.1'; // organization
                                $interesting_oids[] = '2.16.840.1.113883'; // hl7
                                        $interesting_oids[] = '2.16.840.1.113883.3'; // externalUseRoots
                                        $interesting_oids[] = '2.16.840.1.113883.6'; // externalCodeSystems
                                        $interesting_oids[] = '2.16.840.1.113883.13'; // externalValueSets
        $interesting_oids[] = '2.23'; // international-organizations
        $interesting_oids[] = '2.25'; // uuid
        $interesting_oids[] = '2.40'; // upu
                $interesting_oids[] = '2.40.2'; // member-body
                $interesting_oids[] = '2.40.3'; // identified-organization
        $interesting_oids[] = '2.49'; // alerting
                $interesting_oids[] = '2.49.0'; // wmo
                        $interesting_oids[] = '2.49.0.0'; // authority (Countries)
                                // country_getter defines the country OIDs beneath 2.49.0.0
                        $interesting_oids[] = '2.49.0.1'; // country-msg
                                // country_getter defines the country OIDs beneath 2.49.0.1
                        $interesting_oids[] = '2.49.0.2'; // org
                        $interesting_oids[] = '2.49.0.3'; // org-msg

// ----------------------------------------------------------------

$interesting_oids = array_unique($interesting_oids);
natsort($interesting_oids);

$output = array();
foreach ($interesting_oids as $oid) {
        _process_oid($oid);
}

$check_sum = '';
foreach ($output as $oid => $data) {
        if (count($data['asn1id']) + count($data['iri']) == 0) continue;

        echo "-- $oid\n";
        foreach ($data['asn1id'] as $line_asn1) {
                echo "$line_asn1\n";
        }
        foreach ($data['iri'] as $line_iri) {
                echo "$line_iri\n";
        }
        foreach ($data['checksum'] as $chunk) {
                $check_sum .= $chunk;
        }
        echo "\n";
}
echo '-- Generator "generate_wellknown_other_sqlite" checksum '.dechex(crc32($check_sum))."\n";