add semantic names to ipfix IANA parser

master
Oliver Gasser 2017-07-29 22:54:51 +02:00
parent 91c3eea73c
commit 5bfd299917
3 changed files with 23 additions and 2 deletions

View File

@ -432,6 +432,18 @@ struct ipfix_identifier ipfixids_iana[] = {
{ IPFIX_TYPEID_httpReasonPhrase , IPFIX_BYTES_string , 0, "httpReasonPhrase" , IPFIX_DATA_TYPE_httpReasonPhrase },
};
struct ipfix_semantic ipfixsemantic_iana[] = {
/* IANA registry */
{ IPFIX_STRUCTURED_TYPE_SEMANTIC_noneOf , "noneOf" },
{ IPFIX_STRUCTURED_TYPE_SEMANTIC_exactlyOneOf , "exactlyOneOf" },
{ IPFIX_STRUCTURED_TYPE_SEMANTIC_oneOrMoreOf , "oneOrMoreOf" },
{ IPFIX_STRUCTURED_TYPE_SEMANTIC_allOf , "allOf" },
{ IPFIX_STRUCTURED_TYPE_SEMANTIC_ordered , "ordered" },
{ IPFIX_STRUCTURED_TYPE_SEMANTIC_undefined , "undefined" },
};
#ifdef __cplusplus
}
#endif

View File

@ -36,6 +36,11 @@ struct ipfix_identifier {
uint16_t type; // IPFIX data type
};
struct ipfix_semantic {
uint16_t id;
char *name;
};
int ipfix_id_rangecheck(int id);
const struct ipfix_identifier* ipfix_id_lookup(uint16_t id, uint32_t pen);
const struct ipfix_identifier* ipfix_name_lookup(const char *name);

View File

@ -63,15 +63,19 @@ def parse_iana_csv_data_types(fh, out):
out.write(length_macros)
out.write("\n")
def parse_iana_csv_structured_data_types(fh, out):
def parse_iana_csv_structured_data_types(fh, out, struct_out):
# Value,Name,Description,Reference
reader = csv.reader(fh)
struct = "\n\nstruct ipfix_semantic ipfixsemantic_iana[] = {\n/* IANA registry */\n"
for row in reader:
if row[2] != "unassigned" and row[0] != "Value":
out.write("#define IPFIX_STRUCTURED_TYPE_SEMANTIC_{0:30} {1}\n".format(row[1], row[0]))
struct += ' {{ IPFIX_STRUCTURED_TYPE_SEMANTIC_{0:30}, {1:10} }},\n'.format(row[1], '"' + row[1] + '"')
struct += "};\n\n"
out.write("\n")
struct_out.write(struct)
def append_output(row, ids, types, lengths, struct):
elementId = row[0]
@ -112,7 +116,7 @@ def generate_ipfix_output(ie_fh, types_fh, structured_types_fh, out, struct_out)
parse_iana_csv_data_types(types_fh, out)
parse_iana_csv_ie(ie_fh, out, struct_out)
parse_iana_csv_structured_data_types(structured_types_fh, out)
parse_iana_csv_structured_data_types(structured_types_fh, out, struct_out)
# Footer
struct_out.write('#ifdef __cplusplus\n}\n#endif\n')