libasn1: Add OID symbol resolution

This commit adds functions for finding OIDs by symbolic name, meaning by
their symbolic names given in the ASN.1 modules that define them.

TBD:

 - Resolve OIDs to names.
 - Support a file in /etc for additional OID resolution.
 - Add support for resolving OID arc names.
This commit is contained in:
Nicolas Williams
2019-08-24 17:02:33 -05:00
parent 6471fcaa54
commit 5465b2ddec
6 changed files with 330 additions and 18 deletions

View File

@@ -37,7 +37,7 @@
RCSID("$Id$");
FILE *privheaderfile, *headerfile, *codefile, *logfile, *templatefile;
FILE *privheaderfile, *headerfile, *oidsfile, *codefile, *logfile, *templatefile;
#define STEM "asn1"
@@ -251,6 +251,16 @@ init_generate (const char *filename, const char *base)
logfile = fopen(fn, "w");
if (logfile == NULL)
err (1, "open %s", fn);
free(fn);
fn = NULL;
if (asprintf(&fn, "%s_oids.x", base) < 0 || fn == NULL)
errx(1, "malloc");
oidsfile = fopen(fn, "w");
if (oidsfile == NULL)
err (1, "open %s", fn);
free(fn);
fn = NULL;
/* if one code file, write into the one codefile */
if (one_code_file)
@@ -461,6 +471,8 @@ generate_constant (const Symbol *s)
"{ %lu, oid_%s_variable_num };\n\n",
s->gen_name, (unsigned long)len, s->gen_name);
fprintf(oidsfile, "DEFINE_OID_WITH_NAME(%s)\n", s->gen_name);
free(list);
/* header file */