asn1: Add breadcrumbs for future work

This commit is contained in:
Nicolas Williams
2020-12-16 15:10:58 -06:00
parent 7f0349e1fb
commit 45451814b3
2 changed files with 58 additions and 0 deletions

View File

@@ -48,12 +48,67 @@
#include <errno.h>
#include <err.h>
#include <roken.h>
#include <getarg.h>
#include "hash.h"
#include "symbol.h"
#include "asn1-common.h"
#include "der.h"
#include "der-private.h"
/*
* XXX We need to move all module state out of globals and into a struct that
* we pass around when parsing and compiling a module, and also that we keep on
* a linked list of parsed modules.
*
* This is needed to:
*
* - implement IMPORTS correctly, because we need to know the type of a symbol
* in order to emit an extern declaration of it
* - implement value parsing
* - implement an ASN.1 library that does value parsing
*
* Value parsing, in particular, would be fantastic. We could then have
* options in hxtool(1) to load arbitrary ASN.1 modules and then parse SAN
* values given in ASN.1 value syntax on the command-line or in files. Eat
* your heart out OpenSSL if we do this!
*
* As well we'll need a `-I' option to the compiler so it knows where to find
* modules to IMPORT FROM.
*/
typedef struct asn1_module {
/* Name of ASN.1 module file: */
const char *orig_filename;
/* Name of file to always include for common type definitions: */
const char *type_file_string;
/* Name of public header file for module: */
const char *header;
/* Name of private header file for module: */
const char *privheader;
/* Basename of module: */
const char *headerbase;
/* Open stdio file handles for output: */
FILE *privheaderfile;
FILE *headerfile;
FILE *oidsfile;
FILE *codefile;
FILE *logfile;
FILE *templatefile;
/* Module contents: */
struct sexport *exports;
struct import *imports;
Hashtab *htab; /* symbols */
/* Template state: */
struct templatehead *template;
struct tlisthead *tlistmaster;
/* CLI options and flags needed everywhere: */
getarg_strings preserve;
getarg_strings seq;
unsigned int one_code_file:1;
unsigned int support_ber:1;
unsigned int parse_units_flag:1;
unsigned int rfc1510_bitstring:1; /* Should be a getarg_strings of bitrsting types to do this for */
} *asn1_module;
void generate_type (const Symbol *);
void generate_constant (const Symbol *);
void generate_type_encode (const Symbol *);

View File

@@ -181,6 +181,8 @@ bitstring_symbol(const char *basename, const Type *t)
/* XXX Make sure this is sorted by `type' and can just index this by type */
/* XXX Make this const! */
struct {
enum typetype type;
const char *(*symbol_name)(const char *, const Type *);
@@ -932,6 +934,7 @@ generate_template_type(const char *varname,
free(szt);
/* XXX Accidentally O(N^2)? */
d = tlist_find_dup(tl);
if (d) {
#if 0