diff --git a/src/cbor.h b/src/cbor.h index 31b1036e..7ddff0ca 100644 --- a/src/cbor.h +++ b/src/cbor.h @@ -101,55 +101,505 @@ typedef enum CborType { CborInvalidType = 0xff /* equivalent to the break byte, so it will never be used */ } CborType; +typedef enum CborSimpleValue { + /* Autogenerated IANA CBOR Content-Formats (Source: https://www.iana.org/assignments/cbor-simple-values/cbor-simple-values.xhtml#simple) */ + + /* 0-19 : Standards Action */ + // False; Ref: [RFC8949] + CborSimpleValueFalse = 20, + // True; Ref: [RFC8949] + CborSimpleValueTrue = 21, + // Null; Ref: [RFC8949] + CborSimpleValueNull = 22, + // Undefined; Ref: [RFC8949] + CborSimpleValueUndefined = 23 + + /* 32-255 : Specification Required */ +} CborSimpleValue; + typedef uint64_t CborTag; typedef enum CborKnownTags { - CborDateTimeStringTag = 0, - CborUnixTime_tTag = 1, - CborPositiveBignumTag = 2, - CborNegativeBignumTag = 3, - CborDecimalTag = 4, - CborBigfloatTag = 5, - CborCOSE_Encrypt0Tag = 16, - CborCOSE_Mac0Tag = 17, - CborCOSE_Sign1Tag = 18, - CborExpectedBase64urlTag = 21, - CborExpectedBase64Tag = 22, - CborExpectedBase16Tag = 23, - CborEncodedCborTag = 24, - CborUrlTag = 32, - CborBase64urlTag = 33, - CborBase64Tag = 34, - CborRegularExpressionTag = 35, - CborMimeMessageTag = 36, - CborCOSE_EncryptTag = 96, - CborCOSE_MacTag = 97, - CborCOSE_SignTag = 98, - CborSignatureTag = 55799 + /* Autogenerated IANA CBOR Tags (Source: https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml#tags) */ + + /* 0-23 : Standards Action */ + // Standard date/time string; see Section 3.4.1; Ref: [RFC8949] + CborStdDateTimeStringTag = 0, + CborDateTimeStringTag = 0 /* depreciated but identifier kept for backwards compatibility */, + // Epoch-based date/time; see Section 3.4.2; Ref: [RFC8949] + CborEpochBasedDateTimeTag = 1, + CborUnixTime_tTag = 1 /* depreciated but identifier kept for backwards compatibility */, + // Unsigned bignum; see Section 3.4.3; Ref: [RFC8949] + CborUnsignedBignumTag = 2, + CborPositiveBignumTag = 2 /* depreciated but identifier kept for backwards compatibility */, + // Negative bignum; see Section 3.4.3; Ref: [RFC8949] + CborNegativeBignumTag = 3, + // Decimal fraction; see Section 3.4.4; Ref: [RFC8949] + CborDecimalFractionTag = 4, + CborDecimalTag = 4 /* depreciated but identifier kept for backwards compatibility */, + // Bigfloat; see Section 3.4.4; Ref: [RFC8949] + CborBigfloatTag = 5, + // COSE Single Recipient Encrypted Data Object; Ref: [RFC9052] + CborCoseSingleRecipientEncryptedDataObjectTag = 16, + CborCOSE_Encrypt0Tag = 16 /* depreciated but identifier kept for backwards compatibility */, + // COSE Mac w/o Recipients Object; Ref: [RFC9052] + CborCoseMacWORecipientsObjectTag = 17, + CborCOSE_Mac0Tag = 17 /* depreciated but identifier kept for backwards compatibility */, + // COSE Single Signer Data Object; Ref: [RFC9052] + CborCoseSingleSignerDataObjectTag = 18, + CborCOSE_Sign1Tag = 18 /* depreciated but identifier kept for backwards compatibility */, + // COSE standalone V2 countersignature; Ref: [RFC9338] + CborCoseStandaloneV2CountersignatureTag = 19, + // Expected conversion to base64url encoding; see Section 3.4.5.2; Ref: [RFC8949] + CborExpectedConversionToBase64urlEncodingTag = 21, + CborExpectedBase64urlTag = 21 /* depreciated but identifier kept for backwards compatibility */, + // Expected conversion to base64 encoding; see Section 3.4.5.2; Ref: [RFC8949] + CborExpectedConversionToBase64EncodingTag = 22, + CborExpectedBase64Tag = 22 /* depreciated but identifier kept for backwards compatibility */, + // Expected conversion to base16 encoding; see Section 3.4.5.2; Ref: [RFC8949] + CborExpectedConversionToBase16EncodingTag = 23, + CborExpectedBase16Tag = 23 /* depreciated but identifier kept for backwards compatibility */, + + /* 24-32767 : Specification Required */ + // Encoded CBOR data item; see Section 3.4.5.1; Ref: [RFC8949] + CborEncodedCborDataItemTag = 24, + CborEncodedCborTag = 24 /* depreciated but identifier kept for backwards compatibility */, + // reference the nth previously seen string; Ref: [http://cbor.schmorp.de/stringref][Marc_A._Lehmann] + CborRefTheNthPrevSeenStringTag = 25, + // Serialised Perl object with classname and constructor arguments; Ref: [http://cbor.schmorp.de/perl-object][Marc_A._Lehmann] + CborSerialisedPerlObjWithClassnameConstructorArgTag = 26, + // Serialised language-independent object with type name and constructor arguments; Ref: [http://cbor.schmorp.de/generic-object][Marc_A._Lehmann] + CborSerialisedLangIndepObjWithTypeNameConstructorArgTag = 27, + // mark value as (potentially) shared; Ref: [http://cbor.schmorp.de/value-sharing][Marc_A._Lehmann] + CborMarkValueAsSharedTag = 28, + // reference nth marked value; Ref: [http://cbor.schmorp.de/value-sharing][Marc_A._Lehmann] + CborRefNthMarkedValueTag = 29, + // Rational number; Ref: [http://peteroupc.github.io/CBOR/rational.html][Peter_Occil] + CborRationalNumberTag = 30, + // Absent value in a CBOR Array; Ref: [https://github.com/svaarala/cbor-specs/blob/master/cbor-absent-tag.rst][Sami_Vaarala] + CborAbsentValueInACborArrayTag = 31, + // URI; see Section 3.4.5.3; Ref: [RFC8949] + CborUriTag = 32, + CborUrlTag = 32 /* depreciated but identifier kept for backwards compatibility */, + // base64url; see Section 3.4.5.3; Ref: [RFC8949] + CborBase64urlTag = 33, + // base64; see Section 3.4.5.3; Ref: [RFC8949] + CborBase64Tag = 34, + // Regular expression; see Section 2.4.4.3; Ref: [RFC7049] + CborRegularExpressionTag = 35, + // MIME message; see Section 3.4.5.3; Ref: [RFC8949] + CborMimeMsgTag = 36, + CborMimeMessageTag = 36 /* depreciated but identifier kept for backwards compatibility */, + // Binary UUID ([RFC4122, Section 4.1.2]); Ref: [https://github.com/lucas-clemente/cbor-specs/blob/master/uuid.md][Lucas_Clemente] + CborBinaryUuidTag = 37, + // Language-tagged string; Ref: [RFC9290, Appendix A] + CborLanguageTaggedStringTag = 38, + // Identifier; Ref: [https://github.com/lucas-clemente/cbor-specs/blob/master/id.md][Lucas_Clemente] + CborIdTag = 39, + // Multi-dimensional Array, row-major order; Ref: [RFC8746] + CborMultiDimensionalArrayRowMajorOrderTag = 40, + // Homogeneous Array; Ref: [RFC8746] + CborHomogeneousArrayTag = 41, + // IPLD content identifier; Ref: [https://github.com/ipld/cid-cbor/][Volker_Mische] + CborIpldContentIdTag = 42, + // YANG bits datatype; see Section 6.7.; Ref: [RFC9254] + CborYangBitsDatatypeTag = 43, + // YANG enumeration datatype; see Section 6.6.; Ref: [RFC9254] + CborYangEnumerationDatatypeTag = 44, + // YANG identityref datatype; see Section 6.10.; Ref: [RFC9254] + CborYangIdentityrefDatatypeTag = 45, + // YANG instance-identifier datatype; see Section 6.13.; Ref: [RFC9254] + CborYangInstanceIdDatatypeTag = 46, + // YANG Schema Item iDentifier (sid); see Section 3.2.; Ref: [RFC9254] + CborYangSchemaItemIdTag = 47, + // IPv4, [prefixlen,IPv4], [IPv4,prefixpart]; Ref: [RFC9164] + CborIpv4Tag = 52, + // IPv6, [prefixlen,IPv6], [IPv6,prefixpart]; Ref: [RFC9164] + CborIpv6Tag = 54, + // CBOR Web Token (CWT); Ref: [RFC8392][Michael_B._Jones] + CborCborWebTokenTag = 61, + // Encoded CBOR Sequence [RFC8742]; Ref: [draft-bormann-cbor-notable-tags-02, Section 2.1] + CborEncodedCborSequenceTag = 63, + // uint8 Typed Array; Ref: [RFC8746] + CborUint8TypedArrayTag = 64, + // uint16, big endian, Typed Array; Ref: [RFC8746] + CborUint16BigEndianTypedArrayTag = 65, + // uint32, big endian, Typed Array; Ref: [RFC8746] + CborUint32BigEndianTypedArrayTag = 66, + // uint64, big endian, Typed Array; Ref: [RFC8746] + CborUint64BigEndianTypedArrayTag = 67, + // uint8 Typed Array, clamped arithmetic; Ref: [RFC8746] + CborUint8TypedArrayClampedArithmeticTag = 68, + // uint16, little endian, Typed Array; Ref: [RFC8746] + CborUint16LittleEndianTypedArrayTag = 69, + // uint32, little endian, Typed Array; Ref: [RFC8746] + CborUint32LittleEndianTypedArrayTag = 70, + // uint64, little endian, Typed Array; Ref: [RFC8746] + CborUint64LittleEndianTypedArrayTag = 71, + // sint8 Typed Array; Ref: [RFC8746] + CborSint8TypedArrayTag = 72, + // sint16, big endian, Typed Array; Ref: [RFC8746] + CborSint16BigEndianTypedArrayTag = 73, + // sint32, big endian, Typed Array; Ref: [RFC8746] + CborSint32BigEndianTypedArrayTag = 74, + // sint64, big endian, Typed Array; Ref: [RFC8746] + CborSint64BigEndianTypedArrayTag = 75, + // sint16, little endian, Typed Array; Ref: [RFC8746] + CborSint16LittleEndianTypedArrayTag = 77, + // sint32, little endian, Typed Array; Ref: [RFC8746] + CborSint32LittleEndianTypedArrayTag = 78, + // sint64, little endian, Typed Array; Ref: [RFC8746] + CborSint64LittleEndianTypedArrayTag = 79, + // IEEE 754 binary16, big endian, Typed Array; Ref: [RFC8746] + CborIeee754Binary16BigEndianTypedArrayTag = 80, + // IEEE 754 binary32, big endian, Typed Array; Ref: [RFC8746] + CborIeee754Binary32BigEndianTypedArrayTag = 81, + // IEEE 754 binary64, big endian, Typed Array; Ref: [RFC8746] + CborIeee754Binary64BigEndianTypedArrayTag = 82, + // IEEE 754 binary128, big endian, Typed Array; Ref: [RFC8746] + CborIeee754Binary128BigEndianTypedArrayTag = 83, + // IEEE 754 binary16, little endian, Typed Array; Ref: [RFC8746] + CborIeee754Binary16LittleEndianTypedArrayTag = 84, + // IEEE 754 binary32, little endian, Typed Array; Ref: [RFC8746] + CborIeee754Binary32LittleEndianTypedArrayTag = 85, + // IEEE 754 binary64, little endian, Typed Array; Ref: [RFC8746] + CborIeee754Binary64LittleEndianTypedArrayTag = 86, + // IEEE 754 binary128, little endian, Typed Array; Ref: [RFC8746] + CborIeee754Binary128LittleEndianTypedArrayTag = 87, + // COSE Encrypted Data Object; Ref: [RFC9052] + CborCoseEncryptedDataObjectTag = 96, + CborCOSE_EncryptTag = 96 /* depreciated but identifier kept for backwards compatibility */, + // COSE MACed Data Object; Ref: [RFC9052] + CborCoseMacedDataObjectTag = 97, + CborCOSE_MacTag = 97 /* depreciated but identifier kept for backwards compatibility */, + // COSE Signed Data Object; Ref: [RFC9052] + CborCoseSignedDataObjectTag = 98, + CborCOSE_SignTag = 98 /* depreciated but identifier kept for backwards compatibility */, + // Number of days since the epoch date 1970-01-01; Ref: [RFC8943] + CborNumberOfDaysSinceTheEpochDate19700101Tag = 100, + // alternatives as given by the uint + 128; see Section 9.1; Ref: [draft-bormann-cbor-notable-tags-07] + CborAlternativesAsGivenByTheUintPlus128Tag = 101, + // Geographic Coordinates; Ref: [https://github.com/allthingstalk/cbor/blob/master/CBOR-Tag103-Geographic-Coordinates.md][Danilo_Vidovic] + CborGeographicCoordinatesTag = 103, + // Geographic Coordinate Reference System WKT or EPSG number; Ref: [draft-clarke-cbor-crs] + CborGeoCoordRefSystemWktOrEpsgNumTag = 104, + // relative object identifier (BER encoding); SDNV [RFC6256] sequence; Ref: [RFC9090] + CborRelativeObjectIdTag = 110, + // object identifier (BER encoding); Ref: [RFC9090] + CborObjectIdTag = 111, + // object identifier (BER encoding), relative to 1.3.6.1.4.1; Ref: [RFC9090] + CborObjectIdRelativeTo136141Tag = 112, + // Internet of Things Data Point; Ref: [https://github.com/allthingstalk/cbor/blob/master/CBOR-Tag120-Internet-of-Things-Data-Points.md][Danilo_Vidovic] + CborInternetOfThingsDataPointTag = 120, + // Gordian Envelope; Ref: [draft-mcnally-envelope-05] + CborGordianEnvelopeTag = 200, + // mark value as having string references; Ref: [http://cbor.schmorp.de/stringref][Marc_A._Lehmann] + CborMarkValueAsHavingStringReferencesTag = 256, + // Binary MIME message; Ref: [http://peteroupc.github.io/CBOR/binarymime.html][Peter_Occil] + CborBinaryMimeMsgTag = 257, + // Mathematical finite set; Ref: [https://github.com/input-output-hk/cbor-sets-spec/blob/master/CBOR_SETS.md][Alfredo_Di_Napoli] + CborMathematicalFiniteSetTag = 258, + // Map datatype with key-value operations (e.g. `.get()/.set()/.delete()`); Ref: [https://github.com/shanewholloway/js-cbor-codec/blob/master/docs/CBOR-259-spec--explicit-maps.md][Shane_Holloway] + CborMapDatatypeWithKeyValOpSetDeleteTag = 259, + // Network Address (IPv4 or IPv6 or MAC Address) (DEPRECATED in favor of 52 and 54 for IP addresses); Ref: [http://www.employees.org/~ravir/cbor-network.txt][Ravi_Raju][RFC9164] + CborNetworkAddressTag = 260, + // Network Address Prefix (IPv4 or IPv6 Address + Mask Length) (DEPRECATED in favor of 52 and 54 for IP addresses); Ref: [https://github.com/toravir/CBOR-Tag-Specs/blob/master/networkPrefix.md][Ravi_Raju][RFC9164] + CborNetworkAddressPrefixTag = 261, + // Embedded JSON Object; Ref: [https://github.com/toravir/CBOR-Tag-Specs/blob/master/embeddedJSON.md][Ravi_Raju] + CborEmbeddedJsonObjectTag = 262, + // Hexadecimal string; Ref: [https://github.com/toravir/CBOR-Tag-Specs/blob/master/hexString.md][Ravi_Raju] + CborHexadecimalStringTag = 263, + // Decimal fraction with arbitrary exponent; Ref: [http://peteroupc.github.io/CBOR/bigfrac.html][Peter_Occil] + CborDecimalFractionWithArbitraryExponentTag = 264, + // Bigfloat with arbitrary exponent; Ref: [http://peteroupc.github.io/CBOR/bigfrac.html][Peter_Occil] + CborBigfloatWithArbitraryExponentTag = 265, + // Internationalized resource identifier (IRI); Ref: [https://peteroupc.github.io/CBOR/iri.html][Peter_Occil] + CborInternationalizedResourceIdTag = 266, + // Internationalized resource identifier reference (IRI reference); Ref: [https://peteroupc.github.io/CBOR/iri.html][Peter_Occil] + CborInternationalizedResourceIdRefTag = 267, + // Extended decimal fraction; Ref: [https://peteroupc.github.io/CBOR/extended.html][Peter_Occil] + CborExtendedDecimalFractionTag = 268, + // Extended bigfloat; Ref: [https://peteroupc.github.io/CBOR/extended.html][Peter_Occil] + CborExtendedBigfloatTag = 269, + // Extended rational number; Ref: [https://peteroupc.github.io/CBOR/extended.html][Peter_Occil] + CborExtendedRationalNumberTag = 270, + // DDoS Open Threat Signaling (DOTS) signal channel object, as defined in [RFC9132]; Ref: [RFC9132] + CborDdosOpenThreatSignalingSigChnObjTag = 271, + // Non-UTF-8 CESU-8 string; Ref: [https://github.com/svaarala/cbor-specs/blob/master/cbor-nonutf8-string-tags.rst][Sami_Vaarala] + CborNonUtf8Cesu8StringTag = 272, + // Non-UTF-8 WTF-8 string; Ref: [https://github.com/svaarala/cbor-specs/blob/master/cbor-nonutf8-string-tags.rst][Sami_Vaarala] + CborNonUtf8Wtf8StringTag = 273, + // Non-UTF-8 MUTF-8 string; Ref: [https://github.com/svaarala/cbor-specs/blob/master/cbor-nonutf8-string-tags.rst][Sami_Vaarala] + CborNonUtf8Mutf8StringTag = 274, + // Map contains only keys that are of type Text String (major type 3); Ref: [https://github.com/ecorm/cbor-tag-text-key-map][Emile_Cormier] + CborMapContainsOnlyKeysThatAreOfTypeTxtStrTag = 275, + // ERIS binary read capability; Ref: [http://purl.org/eris] + CborErisBinaryReadCapabilityTag = 276, + // Universal Geographical Area Description (GAD) shape; see Section 5; Ref: [TS 23.032][Mathew_Meins] + CborUniversalGeoAreaDescriptionShapeTag = 277, + // Universal Geographical Area Description (GAD) description of velocity; see Section 8; Ref: [TS 23.032][Mathew_Meins] + CborUniversalGeoAreaDescriptionDescriptionOfVelocityTag = 278, + // extended time; Ref: [draft-bormann-cbor-time-tag-01] + CborExtendedTimeTag = 1001, + // duration; Ref: [draft-bormann-cbor-time-tag-01] + CborDurationTag = 1002, + // period; Ref: [draft-bormann-cbor-time-tag-01] + CborPeriodTag = 1003, + // [RFC3339] full-date string; Ref: [RFC8943] + CborFullDateStringTag = 1004, + // Object type identifier; Ref: [draft-rundgren-cotx-04] + CborObjectTypeIdTag = 1010, + // Multi-dimensional Array, column-major order; Ref: [RFC8746] + CborMultiDimensionalArrayColumnMajorOrderTag = 1040, + // [COSE algorithm identifier, Base Hash value]; Ref: [draft-bormann-cbor-notable-tags-09, Section 3.1.1] + CborCoseAlgorithmIdBaseHashValueTag = 18556, + // I-Regexp; Ref: [draft-bormann-cbor-notable-tags-09, Section 2.1][draft-ietf-jsonpath-iregexp-08] + CborIRegexpTag = 21065, + // ECMAScript RegExp [https://262.ecma-international.org/14.0/#sec-regexp-regular-expression-objects]; Ref: [https://github.com/hildjj/cbor-specs/blob/main/regexp.md][Joe_Hildebrand] + CborEcmascriptRegexpTag = 21066, + // hint that indicates an additional level of indirection; Ref: [http://cbor.schmorp.de/indirection][Marc_A._Lehmann] + CborHintThatIndicatesAnAddLvlOfIndirectionTag = 22098, + // Capture [3]; Ref: [https://github.com/japhb/cbor-specs/blob/main/capture.md][Geoffrey_Broadwell] + CborCaptureTag = 25441, + + /* 32768-18446744073709551615 : First Come First Served */ + // Identifier for a FHIR constant; Ref: [Stefan_Genchev] + CborIdForAFhirConstantTag = 32768, + // External reference; Ref: [https://gitlab.com/Hawk777/cbor-specs/-/blob/main/external-reference.md][Christopher_Head] + CborExternalRefTag = 32769, + // A confidentiality clearance. The key value pairs of the map are defined in ADatP-4774.4; Ref: [Aidan_Murdock] + CborAConfidentialityClearanceTag = 42600, + // A metadata binding. The elements of the array are defined in AdatP-4778.5. The tag is also used as part of the magic number in on-disk detached and encapsulating bindings.; Ref: [Aidan_Murdock] + CborAMetadataBindingTag = 42601, + // A collection of NCMS metadata elements. The key value pairs of the map are defined in AdatP-5636.4; Ref: [Aidan_Murdock] + CborACollectionOfNcmsMetadataElementsTag = 42602, + // Single complex number: array elements are real (I) and imaginary (Q) components; Ref: [Saajan_Chana] + CborSingleComplexNumberTag = 43000, + // Array of complex numbers in interleaved form: complex value k is stored with real (I) part at array index 2k and imaginary (Q) part at index (2k + 1); Ref: [Saajan_Chana] + CborArrayOfComplexNumbersInInterleavedFormTag = 43001, + // PlatformV_IS_ID; Ref: [https://github.com/arthurwangtz/platformv-cbor][Wang_Tongzhou] + CborPlatformvIsIdTag = 50000, + // PlatformV_IS_NAME; Ref: [https://github.com/arthurwangtz/platformv-cbor][Wang_Tongzhou] + CborPlatformvIsNameTag = 50001, + // PlatformV_IS_VALUE; Ref: [https://github.com/arthurwangtz/platformv-cbor][Wang_Tongzhou] + CborPlatformvIsValueTag = 50002, + // PlatformV_HAS_COMPOSITE_VALUE; Ref: [https://github.com/arthurwangtz/platformv-cbor][Wang_Tongzhou] + CborPlatformvHasCompositeValueTag = 50003, + // PlatformV_HAS_MAPPED_VALUE; Ref: [https://github.com/arthurwangtz/platformv-cbor][Wang_Tongzhou] + CborPlatformvHasMappedValueTag = 50004, + // PlatformV_HAS_OBJ_ID; Ref: [https://github.com/arthurwangtz/platformv-cbor][Wang_Tongzhou] + CborPlatformvHasObjIdTag = 50005, + // PlatformV_HAS_OBJ_TAG; Ref: [https://github.com/arthurwangtz/platformv-cbor][Wang_Tongzhou] + CborPlatformvHasObjTagTag = 50006, + // PlatformV_HAS_CHILD; Ref: [https://github.com/arthurwangtz/platformv-cbor][Wang_Tongzhou] + CborPlatformvHasChildTag = 50007, + // PlatformV_HAS_PROPERTY; Ref: [https://github.com/arthurwangtz/platformv-cbor][Wang_Tongzhou] + CborPlatformvHasPropertyTag = 50008, + // PlatformV_HAS_META; Ref: [https://github.com/arthurwangtz/platformv-cbor][Wang_Tongzhou] + CborPlatformvHasMetaTag = 50009, + // PlatformV_HAS_EVENT; Ref: [https://github.com/arthurwangtz/platformv-cbor][Wang_Tongzhou] + CborPlatformvHasEventTag = 50010, + // PlatformV_HAS_ACTION; Ref: [https://github.com/arthurwangtz/platformv-cbor][Wang_Tongzhou] + CborPlatformvHasActionTag = 50011, + // PlatformV_IS_TYPE; Ref: [https://github.com/arthurwangtz/platformv-cbor][Wang_Tongzhou] + CborPlatformvIsTypeTag = 50012, + // Self-described CBOR; see Section 3.4.6; Ref: [RFC8949] + CborSelfDescribedCborTag = 55799, + CborSignatureTag = 55799 /* depreciated but identifier kept for backwards compatibility */, + // indicates that the file contains CBOR Sequences; Ref: [RFC9277] + CborIndicatesThatFileContainsCborSequencesTag = 55800, + // indicates that the file starts with a CBOR-Labeled Non-CBOR Data label.; Ref: [RFC9277] + CborIndicatesThatFileStartsWithCborLabeledNonCborDataLabelTag = 55801, + // Compressed byte string; Ref: [https://github.com/dectris/documentation/blob/main/cbor/dectris-compression-tag.md][Kal_Conley] + CborCompressedByteStringTag = 56500, + // Identify and define a set of record structures (each a sequence of property names) that can be referenced as tags in the included value (and the scope for the record tag definitions); Ref: [https://github.com/kriszyp/cbor-records][Kris_Zyp] + CborIdentDefineSetOfRecStrctThatCanBeRefAsTagsInIncValTag = 57342, + // Identify and define a record structure (a sequence of property names), and use that record structure definition to interpret the included values.; Ref: [https://github.com/kriszyp/cbor-records][Kris_Zyp] + CborIdentDefineRecStrctUseThatRecStrctDefInterpretIncValsTag = 57343, + // The tagged CBOR array contains attestation evidence data with an Intel TEE quote.; Ref: [Shanwei_Cen] + CborTaggedCborArrayContainsAttestEvidenceDataWithAnIntelTeeQuoteTag = 60000, + // The tagged CBOR array contains attestation evidence data with an Intel TEE report.; Ref: [Shanwei_Cen] + CborTaggedCborArrayContainsAttestEvidenceDataWithAnIntelTeeRptTag = 60001, + // The tagged CBOR array contains attestation evidence data with an Intel SGX report.; Ref: [Shanwei_Cen] + CborTaggedCborArrayContainsAttestEvidenceDataWithAnIntelSgxRptTag = 60002, + // RAINS Message; Ref: [https://britram.github.io/rains-prototype][Brian_Trammell] + CborRainsMsgTag = 15309736, + // A CBOR encoded Openswan configuration file, as stored on disk forunit test cases.; Ref: [Michael_Richardson][Samir_Hussain] + CborCborEncOpenswanConfigFileAsStoredOnDiskForunitTestCasesTag = 1330664270, + // Concise Software Identifier (CoSWID); Ref: [RFC9393] + CborConciseSoftwareIdTag = 1398229316, + // Array of content-addressed blocks and ERIS read capabilities; Ref: [Endo_Renberg] + CborArrayOfContentAddrBlocksErisReadCapTag = 1701996915, + // ERIS-FS image header; Ref: [Endo_Renberg] + CborErisFsImageHeaderTag = 1701996916, + // Intel FPGA SPDM Manifest; Ref: [Andrew_Draper] + CborIntelFpgaSpdmManifestTag = 4294967296 } CborKnownTags; +/* Start of cbor known tag feature flag autogenerated section */ /* #define the constants so we can check with #ifdef */ -#define CborDateTimeStringTag CborDateTimeStringTag -#define CborUnixTime_tTag CborUnixTime_tTag -#define CborPositiveBignumTag CborPositiveBignumTag -#define CborNegativeBignumTag CborNegativeBignumTag -#define CborDecimalTag CborDecimalTag +#define CborACollectionOfNcmsMetadataElementsTag CborACollectionOfNcmsMetadataElementsTag +#define CborAConfidentialityClearanceTag CborAConfidentialityClearanceTag +#define CborAMetadataBindingTag CborAMetadataBindingTag +#define CborAbsentValueInACborArrayTag CborAbsentValueInACborArrayTag +#define CborAlternativesAsGivenByTheUintPlus128Tag CborAlternativesAsGivenByTheUintPlus128Tag +#define CborArrayOfComplexNumbersInInterleavedFormTag CborArrayOfComplexNumbersInInterleavedFormTag +#define CborArrayOfContentAddrBlocksErisReadCapTag CborArrayOfContentAddrBlocksErisReadCapTag +#define CborBase64Tag CborBase64Tag +#define CborBase64urlTag CborBase64urlTag #define CborBigfloatTag CborBigfloatTag +#define CborBigfloatWithArbitraryExponentTag CborBigfloatWithArbitraryExponentTag +#define CborBinaryMimeMsgTag CborBinaryMimeMsgTag +#define CborBinaryUuidTag CborBinaryUuidTag #define CborCOSE_Encrypt0Tag CborCOSE_Encrypt0Tag +#define CborCOSE_EncryptTag CborCOSE_EncryptTag #define CborCOSE_Mac0Tag CborCOSE_Mac0Tag +#define CborCOSE_MacTag CborCOSE_MacTag #define CborCOSE_Sign1Tag CborCOSE_Sign1Tag -#define CborExpectedBase64urlTag CborExpectedBase64urlTag -#define CborExpectedBase64Tag CborExpectedBase64Tag -#define CborExpectedBase16Tag CborExpectedBase16Tag +#define CborCOSE_SignTag CborCOSE_SignTag +#define CborCaptureTag CborCaptureTag +#define CborCborEncOpenswanConfigFileAsStoredOnDiskForunitTestCasesTag CborCborEncOpenswanConfigFileAsStoredOnDiskForunitTestCasesTag +#define CborCborWebTokenTag CborCborWebTokenTag +#define CborCompressedByteStringTag CborCompressedByteStringTag +#define CborConciseSoftwareIdTag CborConciseSoftwareIdTag +#define CborCoseAlgorithmIdBaseHashValueTag CborCoseAlgorithmIdBaseHashValueTag +#define CborCoseEncryptedDataObjectTag CborCoseEncryptedDataObjectTag +#define CborCoseMacWORecipientsObjectTag CborCoseMacWORecipientsObjectTag +#define CborCoseMacedDataObjectTag CborCoseMacedDataObjectTag +#define CborCoseSignedDataObjectTag CborCoseSignedDataObjectTag +#define CborCoseSingleRecipientEncryptedDataObjectTag CborCoseSingleRecipientEncryptedDataObjectTag +#define CborCoseSingleSignerDataObjectTag CborCoseSingleSignerDataObjectTag +#define CborCoseStandaloneV2CountersignatureTag CborCoseStandaloneV2CountersignatureTag +#define CborDateTimeStringTag CborDateTimeStringTag +#define CborDdosOpenThreatSignalingSigChnObjTag CborDdosOpenThreatSignalingSigChnObjTag +#define CborDecimalFractionTag CborDecimalFractionTag +#define CborDecimalFractionWithArbitraryExponentTag CborDecimalFractionWithArbitraryExponentTag +#define CborDecimalTag CborDecimalTag +#define CborDurationTag CborDurationTag +#define CborEcmascriptRegexpTag CborEcmascriptRegexpTag +#define CborEmbeddedJsonObjectTag CborEmbeddedJsonObjectTag +#define CborEncodedCborDataItemTag CborEncodedCborDataItemTag +#define CborEncodedCborSequenceTag CborEncodedCborSequenceTag #define CborEncodedCborTag CborEncodedCborTag -#define CborUrlTag CborUrlTag -#define CborBase64urlTag CborBase64urlTag -#define CborBase64Tag CborBase64Tag -#define CborRegularExpressionTag CborRegularExpressionTag +#define CborEpochBasedDateTimeTag CborEpochBasedDateTimeTag +#define CborErisBinaryReadCapabilityTag CborErisBinaryReadCapabilityTag +#define CborErisFsImageHeaderTag CborErisFsImageHeaderTag +#define CborExpectedBase16Tag CborExpectedBase16Tag +#define CborExpectedBase64Tag CborExpectedBase64Tag +#define CborExpectedBase64urlTag CborExpectedBase64urlTag +#define CborExpectedConversionToBase16EncodingTag CborExpectedConversionToBase16EncodingTag +#define CborExpectedConversionToBase64EncodingTag CborExpectedConversionToBase64EncodingTag +#define CborExpectedConversionToBase64urlEncodingTag CborExpectedConversionToBase64urlEncodingTag +#define CborExtendedBigfloatTag CborExtendedBigfloatTag +#define CborExtendedDecimalFractionTag CborExtendedDecimalFractionTag +#define CborExtendedRationalNumberTag CborExtendedRationalNumberTag +#define CborExtendedTimeTag CborExtendedTimeTag +#define CborExternalRefTag CborExternalRefTag +#define CborFullDateStringTag CborFullDateStringTag +#define CborGeoCoordRefSystemWktOrEpsgNumTag CborGeoCoordRefSystemWktOrEpsgNumTag +#define CborGeographicCoordinatesTag CborGeographicCoordinatesTag +#define CborGordianEnvelopeTag CborGordianEnvelopeTag +#define CborHexadecimalStringTag CborHexadecimalStringTag +#define CborHintThatIndicatesAnAddLvlOfIndirectionTag CborHintThatIndicatesAnAddLvlOfIndirectionTag +#define CborHomogeneousArrayTag CborHomogeneousArrayTag +#define CborIRegexpTag CborIRegexpTag +#define CborIdForAFhirConstantTag CborIdForAFhirConstantTag +#define CborIdTag CborIdTag +#define CborIdentDefineRecStrctUseThatRecStrctDefInterpretIncValsTag CborIdentDefineRecStrctUseThatRecStrctDefInterpretIncValsTag +#define CborIdentDefineSetOfRecStrctThatCanBeRefAsTagsInIncValTag CborIdentDefineSetOfRecStrctThatCanBeRefAsTagsInIncValTag +#define CborIeee754Binary128BigEndianTypedArrayTag CborIeee754Binary128BigEndianTypedArrayTag +#define CborIeee754Binary128LittleEndianTypedArrayTag CborIeee754Binary128LittleEndianTypedArrayTag +#define CborIeee754Binary16BigEndianTypedArrayTag CborIeee754Binary16BigEndianTypedArrayTag +#define CborIeee754Binary16LittleEndianTypedArrayTag CborIeee754Binary16LittleEndianTypedArrayTag +#define CborIeee754Binary32BigEndianTypedArrayTag CborIeee754Binary32BigEndianTypedArrayTag +#define CborIeee754Binary32LittleEndianTypedArrayTag CborIeee754Binary32LittleEndianTypedArrayTag +#define CborIeee754Binary64BigEndianTypedArrayTag CborIeee754Binary64BigEndianTypedArrayTag +#define CborIeee754Binary64LittleEndianTypedArrayTag CborIeee754Binary64LittleEndianTypedArrayTag +#define CborIndicatesThatFileContainsCborSequencesTag CborIndicatesThatFileContainsCborSequencesTag +#define CborIndicatesThatFileStartsWithCborLabeledNonCborDataLabelTag CborIndicatesThatFileStartsWithCborLabeledNonCborDataLabelTag +#define CborIntelFpgaSpdmManifestTag CborIntelFpgaSpdmManifestTag +#define CborInternationalizedResourceIdRefTag CborInternationalizedResourceIdRefTag +#define CborInternationalizedResourceIdTag CborInternationalizedResourceIdTag +#define CborInternetOfThingsDataPointTag CborInternetOfThingsDataPointTag +#define CborIpldContentIdTag CborIpldContentIdTag +#define CborIpv4Tag CborIpv4Tag +#define CborIpv6Tag CborIpv6Tag +#define CborLanguageTaggedStringTag CborLanguageTaggedStringTag +#define CborMapContainsOnlyKeysThatAreOfTypeTxtStrTag CborMapContainsOnlyKeysThatAreOfTypeTxtStrTag +#define CborMapDatatypeWithKeyValOpSetDeleteTag CborMapDatatypeWithKeyValOpSetDeleteTag +#define CborMarkValueAsHavingStringReferencesTag CborMarkValueAsHavingStringReferencesTag +#define CborMarkValueAsSharedTag CborMarkValueAsSharedTag +#define CborMathematicalFiniteSetTag CborMathematicalFiniteSetTag #define CborMimeMessageTag CborMimeMessageTag -#define CborCOSE_EncryptTag CborCOSE_EncryptTag -#define CborCOSE_MacTag CborCOSE_MacTag -#define CborCOSE_SignTag CborCOSE_SignTag +#define CborMimeMsgTag CborMimeMsgTag +#define CborMultiDimensionalArrayColumnMajorOrderTag CborMultiDimensionalArrayColumnMajorOrderTag +#define CborMultiDimensionalArrayRowMajorOrderTag CborMultiDimensionalArrayRowMajorOrderTag +#define CborNegativeBignumTag CborNegativeBignumTag +#define CborNetworkAddressPrefixTag CborNetworkAddressPrefixTag +#define CborNetworkAddressTag CborNetworkAddressTag +#define CborNonUtf8Cesu8StringTag CborNonUtf8Cesu8StringTag +#define CborNonUtf8Mutf8StringTag CborNonUtf8Mutf8StringTag +#define CborNonUtf8Wtf8StringTag CborNonUtf8Wtf8StringTag +#define CborNumberOfDaysSinceTheEpochDate19700101Tag CborNumberOfDaysSinceTheEpochDate19700101Tag +#define CborObjectIdRelativeTo136141Tag CborObjectIdRelativeTo136141Tag +#define CborObjectIdTag CborObjectIdTag +#define CborObjectTypeIdTag CborObjectTypeIdTag +#define CborPeriodTag CborPeriodTag +#define CborPlatformvHasActionTag CborPlatformvHasActionTag +#define CborPlatformvHasChildTag CborPlatformvHasChildTag +#define CborPlatformvHasCompositeValueTag CborPlatformvHasCompositeValueTag +#define CborPlatformvHasEventTag CborPlatformvHasEventTag +#define CborPlatformvHasMappedValueTag CborPlatformvHasMappedValueTag +#define CborPlatformvHasMetaTag CborPlatformvHasMetaTag +#define CborPlatformvHasObjIdTag CborPlatformvHasObjIdTag +#define CborPlatformvHasObjTagTag CborPlatformvHasObjTagTag +#define CborPlatformvHasPropertyTag CborPlatformvHasPropertyTag +#define CborPlatformvIsIdTag CborPlatformvIsIdTag +#define CborPlatformvIsNameTag CborPlatformvIsNameTag +#define CborPlatformvIsTypeTag CborPlatformvIsTypeTag +#define CborPlatformvIsValueTag CborPlatformvIsValueTag +#define CborPositiveBignumTag CborPositiveBignumTag +#define CborRainsMsgTag CborRainsMsgTag +#define CborRationalNumberTag CborRationalNumberTag +#define CborRefNthMarkedValueTag CborRefNthMarkedValueTag +#define CborRefTheNthPrevSeenStringTag CborRefTheNthPrevSeenStringTag +#define CborRegularExpressionTag CborRegularExpressionTag +#define CborRelativeObjectIdTag CborRelativeObjectIdTag +#define CborSelfDescribedCborTag CborSelfDescribedCborTag +#define CborSerialisedLangIndepObjWithTypeNameConstructorArgTag CborSerialisedLangIndepObjWithTypeNameConstructorArgTag +#define CborSerialisedPerlObjWithClassnameConstructorArgTag CborSerialisedPerlObjWithClassnameConstructorArgTag #define CborSignatureTag CborSignatureTag +#define CborSingleComplexNumberTag CborSingleComplexNumberTag +#define CborSint16BigEndianTypedArrayTag CborSint16BigEndianTypedArrayTag +#define CborSint16LittleEndianTypedArrayTag CborSint16LittleEndianTypedArrayTag +#define CborSint32BigEndianTypedArrayTag CborSint32BigEndianTypedArrayTag +#define CborSint32LittleEndianTypedArrayTag CborSint32LittleEndianTypedArrayTag +#define CborSint64BigEndianTypedArrayTag CborSint64BigEndianTypedArrayTag +#define CborSint64LittleEndianTypedArrayTag CborSint64LittleEndianTypedArrayTag +#define CborSint8TypedArrayTag CborSint8TypedArrayTag +#define CborStdDateTimeStringTag CborStdDateTimeStringTag +#define CborTaggedCborArrayContainsAttestEvidenceDataWithAnIntelSgxRptTag CborTaggedCborArrayContainsAttestEvidenceDataWithAnIntelSgxRptTag +#define CborTaggedCborArrayContainsAttestEvidenceDataWithAnIntelTeeQuoteTag CborTaggedCborArrayContainsAttestEvidenceDataWithAnIntelTeeQuoteTag +#define CborTaggedCborArrayContainsAttestEvidenceDataWithAnIntelTeeRptTag CborTaggedCborArrayContainsAttestEvidenceDataWithAnIntelTeeRptTag +#define CborUint16BigEndianTypedArrayTag CborUint16BigEndianTypedArrayTag +#define CborUint16LittleEndianTypedArrayTag CborUint16LittleEndianTypedArrayTag +#define CborUint32BigEndianTypedArrayTag CborUint32BigEndianTypedArrayTag +#define CborUint32LittleEndianTypedArrayTag CborUint32LittleEndianTypedArrayTag +#define CborUint64BigEndianTypedArrayTag CborUint64BigEndianTypedArrayTag +#define CborUint64LittleEndianTypedArrayTag CborUint64LittleEndianTypedArrayTag +#define CborUint8TypedArrayClampedArithmeticTag CborUint8TypedArrayClampedArithmeticTag +#define CborUint8TypedArrayTag CborUint8TypedArrayTag +#define CborUniversalGeoAreaDescriptionDescriptionOfVelocityTag CborUniversalGeoAreaDescriptionDescriptionOfVelocityTag +#define CborUniversalGeoAreaDescriptionShapeTag CborUniversalGeoAreaDescriptionShapeTag +#define CborUnixTime_tTag CborUnixTime_tTag +#define CborUnsignedBignumTag CborUnsignedBignumTag +#define CborUriTag CborUriTag +#define CborUrlTag CborUrlTag +#define CborYangBitsDatatypeTag CborYangBitsDatatypeTag +#define CborYangEnumerationDatatypeTag CborYangEnumerationDatatypeTag +#define CborYangIdentityrefDatatypeTag CborYangIdentityrefDatatypeTag +#define CborYangInstanceIdDatatypeTag CborYangInstanceIdDatatypeTag +#define CborYangSchemaItemIdTag CborYangSchemaItemIdTag +/* End of cbor known tag feature flag autogenerated section */ /* Error API */ @@ -725,4 +1175,3 @@ CBOR_INLINE_API CborError cbor_value_to_pretty(FILE *out, const CborValue *value #endif #endif /* CBOR_H */ - diff --git a/tools/iana/.gitignore b/tools/iana/.gitignore new file mode 100644 index 00000000..16f2dc5f --- /dev/null +++ b/tools/iana/.gitignore @@ -0,0 +1 @@ +*.csv \ No newline at end of file diff --git a/tools/iana/c/.gitignore b/tools/iana/c/.gitignore new file mode 100644 index 00000000..ad4a1f17 --- /dev/null +++ b/tools/iana/c/.gitignore @@ -0,0 +1,176 @@ +# Created by https://www.toptal.com/developers/gitignore/api/python +# Edit at https://www.toptal.com/developers/gitignore?templates=python + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +### Python Patch ### +# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration +poetry.toml + +# ruff +.ruff_cache/ + +# LSP config files +pyrightconfig.json + +# End of https://www.toptal.com/developers/gitignore/api/python diff --git a/tools/iana/c/c_header_cbor.py b/tools/iana/c/c_header_cbor.py new file mode 100755 index 00000000..cc4d2b9b --- /dev/null +++ b/tools/iana/c/c_header_cbor.py @@ -0,0 +1,487 @@ +#!/usr/bin/python3 + +''' +MIT License + +Copyright (c) 2023, Brian Khuu +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +''' + +""" +# IANA CBOR C Header Generator + +https://github.com/mofosyne/iana-headers + +Script Description: + +This Python script performs the following tasks: +- Download the latest registry data from IANA for the specified Internet protocol standard if it is outdated or missing in the cache. +- Parse the downloaded data and generate C enumeration values. +- Update or create the C header file with the generated enumeration values, preserving any existing values. +""" + +import csv +import os +import re +import tomllib + +import iana_header_utils as utils + +script_dir = os.path.dirname(__file__) + +spacing_string = " " +iana_cbor_c_header_file_path = './src/cbor-constants.h' +iana_cache_dir_path = './cache/cbor/' + +iana_source_filepath = os.path.join(script_dir, "../iana_sources.toml") +iana_settings_filepath = os.path.join(script_dir, "iana_settings.toml") + +# Override default to tiny cbor compatibility mode (History: https://github.com/intel/tinycbor/issues/240) +tiny_cbor_style_override = False + +iana_cbor_settings = { + "simple_value" : { + "name" : "cbor_simple_value" + }, + "tag_source" : { + "name" : "cbor_tag" + } +} + +# Default Source +# This is because this script should be as standalone as possible and the url is unlikely to change +iana_cbor_simple_value_source = { + "title" : "IANA CBOR Content-Formats", + "csv_url" : "https://www.iana.org/assignments/cbor-simple-values/simple.csv", + "source_url" : "https://www.iana.org/assignments/cbor-simple-values/cbor-simple-values.xhtml#simple", +} + +iana_cbor_tag_source = { + "title" : "IANA CBOR Tags", + "csv_url" : "https://www.iana.org/assignments/cbor-tags/tags.csv", + "source_url" : "https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml#tags", +} + +# Load the iana data sources from the toml file if avaliable +try: + with open(iana_source_filepath, 'rb') as source_file: + config = tomllib.load(source_file) + iana_cbor_simple_value_source.update(config.get('iana_cbor_simple_value_source', {})) + iana_cbor_tag_source.update(config.get('iana_cbor_tag_source', {})) + print("Info: IANA Source Config File loaded") +except FileNotFoundError: + # Handle the case where the toml file doesn't exist + print(f"Warning: IANA Source Config File does not exist. Using default settings. {iana_source_filepath}") + + +# Load settings +try: + with open(iana_settings_filepath, 'rb') as config_file: + toml_data = tomllib.load(config_file) + cbor_settings = toml_data['cbor'] + + spacing_string = cbor_settings.get('spacing_string', spacing_string) + iana_cbor_c_header_file_path = cbor_settings.get('generated_header_filepath') + iana_cache_dir_path = cbor_settings.get('cache_directory_path') + + if cbor_settings.get('style_override', None) == "tiny_cbor": + tiny_cbor_style_override = True + + iana_cbor_settings["simple_value"].update(cbor_settings.get('simple_value', {})) + iana_cbor_settings["tag_source"].update(cbor_settings.get('tag_source', {})) + + print("Info: IANA Settings Config File loaded") +except FileNotFoundError: + # Handle the case where the toml file doesn't exist + print(f"Warning: IANA Settings Config File does not exist. Using default settings. {iana_settings_filepath}") + +# Path is all relative to this script +# Note: This approach was chosen to keep things simple, as each project would only have one header file) +# (Admittely, if the script location changes, you have to update the settings, but if it's an issue, we can cross that bridge later) +iana_cbor_c_header_file_path = os.path.join(script_dir, iana_cbor_c_header_file_path) +iana_cache_dir_path = os.path.join(script_dir, iana_cache_dir_path) + +default_cbor_header_c = """ +// IANA CBOR Headers +// Source: https://github.com/mofosyne/iana-headers + +""" + +############################################################################### +# Content Format Generation +def iana_cbor_simple_values_c_enum_name_generate(cbor_simple_value: str, semantics: str, typedef_enum_name: str, camel_case = False): + """ + This generates a c enum name based on cbor content type and content coding value + """ + # Do not include comments indicated by messages within `(...)` + semantics = re.sub(r'\s+\(.*\)', '', semantics) + variable_name_list = re.sub(r'[^a-zA-Z0-9_]', ' ', semantics).split() + + # Tiny Cbor Style Pascal Case Output + if camel_case: + capitalized_variable_name_list = [word.capitalize() for word in variable_name_list] + pascal_case_str = typedef_enum_name+''.join(capitalized_variable_name_list) + return pascal_case_str + + # Convert Into Screaming Snake Case Output + screaming_snake_case_str = f"{typedef_enum_name.upper()}_"+'_'.join(variable_name_list) + screaming_snake_case_str = screaming_snake_case_str.upper() + return screaming_snake_case_str + +def iana_cbor_simple_values_parse_csv(csv_content: str, typedef_enum_name: str): + """ + Parse and process IANA registration into enums + """ + csv_lines = csv_content.strip().split('\n') + csv_reader = csv.DictReader(csv_lines) + enum_list = {} + for row in csv_reader: + cbor_simple_value = row["Value"] + semantics = row["Semantics"] + reference = row["Reference"] + if cbor_simple_value.lower() == "value": # Skip first header + continue + if not cbor_simple_value or semantics.lower() == "unassigned" or semantics.lower() == "reserved": + continue + if "-" in cbor_simple_value: # is a range of value + continue + # Add to enum list + comment = '; '.join(filter(None, [semantics, f'Ref: {reference}'])) + enum_name = "" + if tiny_cbor_style_override: + enum_name = iana_cbor_simple_values_c_enum_name_generate(cbor_simple_value, semantics, typedef_enum_name, camel_case=True) + else: + enum_name = iana_cbor_simple_values_c_enum_name_generate(cbor_simple_value, semantics, typedef_enum_name) + enum_list[int(cbor_simple_value)] = {"enum_name": enum_name, "comment": comment} + return enum_list + +def iana_cbor_simple_values_c_typedef_enum_update(header_file_content: str) -> str: + typedef_enum_name = iana_cbor_settings["simple_value"]["name"] + source_name = iana_cbor_simple_value_source["title"] + source_url = iana_cbor_simple_value_source["source_url"] + csv_file_url = iana_cbor_simple_value_source["csv_url"] + cache_file_path = iana_cache_dir_path + os.path.basename(csv_file_url) + + # Generate typedef name + c_typedef_name = f"{typedef_enum_name}_t" + + if tiny_cbor_style_override: + c_typedef_name = f"{typedef_enum_name}" + + c_enum_name = c_typedef_name + + # Generate head comment + c_head_comment = spacing_string + f"/* Autogenerated {source_name} (Source: {source_url}) */\n" + + # Load latest IANA registrations + csv_content = utils.read_or_download_csv(csv_file_url, cache_file_path) + + # Parse and process IANA registration into enums + c_enum_list = iana_cbor_simple_values_parse_csv(csv_content, typedef_enum_name) + + # Generate enumeration header content + c_range_marker = [ + {"start":0, "end":19, "description":"Standards Action"}, + {"start":32, "end":255, "description":"Specification Required"} + ] + return utils.update_c_typedef_enum(header_file_content, c_typedef_name, c_enum_name, c_head_comment, c_enum_list, c_range_marker, spacing_string=spacing_string) + + +############################################################################### +# Content Format Generation + +def iana_cbor_tag_c_enum_name_generate(tag_value, semantics, typedef_enum_name, max_words_without_abbreviation = 6): + def clean_semantics(semantic_str): + # Handle special edge case e.g. `A confidentiality clearance. The key value pairs of the map are defined in ADatP-4774.4` + # Handle special edge case e.g. `DDoS Open Threat Signaling (DOTS) signal channel object, as defined in [RFC9132]` + semantic_str = re.sub(r'[.,].* defined in .*', '', semantic_str) + #semantic_str = re.sub(r', as defined in \[RFC\d+\]', '', semantic_str) + # Handle special edge case e.g. `[COSE algorithm identifier, Base Hash value]` + if (semantics[0] == '[' and semantics[-1] == ']') or (semantics[0] == '(' and semantics[-1] == ')') : + semantic_str = semantic_str[1:-1] # Remove the brackets + # Remove content within parentheses and square brackets + semantic_str = re.sub(r'\(.*?\)', '', semantic_str) + semantic_str = re.sub(r'\[.*?\]', '', semantic_str) + # Clear any straggling ) + semantic_str = re.sub(r'\(', ' ', semantic_str) + semantic_str = re.sub(r'\)', ' ', semantic_str) + # Clear any straggling ] + semantic_str = re.sub(r'\[', ' ', semantic_str) + semantic_str = re.sub(r'\]', ' ', semantic_str) + # Clear any extra spaces around + semantic_str = semantic_str.strip() + return semantic_str.strip() + + def variable_name_abbreviator(variable_name_list_input, camel_case = False): + # Split the variable name into words and process each word + variable_name_list = variable_name_list_input.split() + variable_name_list = [word.replace('+', 'PLUS') for word in variable_name_list] + variable_name_list = [word.strip('_') for word in variable_name_list] + + processed_variable_name_list = [] + for word in variable_name_list: + processed_variable_name_list.extend(re.sub(r'\W+', ' ', word).split()) + + variable_name_list = processed_variable_name_list + + # Abbreviate most commonly recognised + very_common_word_abbreviations = { + "standard": "std", + "identifier": "id", + "message": "msg", + "configuration": "config", + "reference": "ref", + "referenced": "ref", + "previously": "prev", + # Add more abbreviations as needed + } + variable_name_list = [very_common_word_abbreviations.get(term.lower(), term) for term in variable_name_list] + + # Calculate the total character count + descriptive_total_character_count = sum(len(term) for term in variable_name_list) + if descriptive_total_character_count >= 40: + # Apply lossy compression if variable name exceeds reasonable length + print(f"long semantic tag description detected ({' '.join(variable_name_list)})") + # Abbreviate common words + word_abbreviations = { + "number": "num", + "complex": "cplx", + "index": "idx", + "attribute": "attr", + "maximum": "max", + "minimum": "min", + "communication": "comm", + "protocol": "proto", + "information": "info", + "authentication": "auth", + "representation": "repr", + "algorithm": "algo", + "version": "ver", + "encoding": "enc", + "arguments": "arg", + "object": "obj", + "language": "lang", + "independent": "indep", + "alternatives": "alt", + "text": "txt", + "string": "str", + "integer": "int", + "signal": "sig", + "channel": "chn", + "structure": "strct", + "structures": "strct", + "attestation": "attest", + "identify": "ident", + "geographic": "geo", + "geographical": "geo", + "coordinate": "coord", + "included": "inc", + "value": "val", + "values": "vals", + "record": "rec", + "report": "rpt", + "definition": "def", + "addressed": "addr", + "capabilities": "cap", + "additional": "add", + "operation": "op", + "operations": "op", + "level": "lvl", + "levels": "lvls", + "encode": "enc", + "encoded": "enc", + "component": "comp", + "condition": "cond", + "database": "db", + "element": "elem", + "environment": "env", + "parameter": "param", + "variable": "var", + "variables": "var", + "resource": "res", + "exception": "excpt", + "instance": "inst", + "organization": "org", + "response": "resp", + "security": "sec", + # Add more abbreviations as needed + } + variable_name_list = [word_abbreviations.get(term.lower(), term) for term in variable_name_list] + # Remove common words that don't contribute to the name + common_words = ["algorithm", "and", "to", "a", "from", "the", "bare"] + variable_name_list = [term for term in variable_name_list if term.lower() not in common_words] + print(f"shrunken to ({' '.join(variable_name_list)})") + + # Tiny Cbor Style Pascal Case Output + if camel_case: + capitalized_variable_name_list = [word.capitalize() for word in variable_name_list] + pascal_case_str = ''.join(capitalized_variable_name_list) + return pascal_case_str + + # Default Macro Name Output as Screaming Snake Case + screaming_snake_case_str = "_".join(variable_name_list).upper() + return screaming_snake_case_str + + # Remove unnecessary '[' and '(' (if not at the beginning) + semantics = clean_semantics(semantics) + + # Remove descriptions after ':' (if present) + semantics = semantics.split(':', 1)[0].strip() + + # Remove descriptions after ';' (if present) + semantics = semantics.split(';', 1)[0].strip() + + # Clear any _ to space + semantics = re.sub(r'\_', ' ', semantics) + + # Clear any - to space + semantics = re.sub(r'\-', ' ', semantics) + + enum_name = "" + if tiny_cbor_style_override: + # Combine tag value and descriptive terms to form the enum name + if typedef_enum_name.endswith("KnownTags"): + enum_name += typedef_enum_name[:-9] + else: + enum_name += typedef_enum_name + enum_name += variable_name_abbreviator(semantics, camel_case=True) + if typedef_enum_name.endswith("KnownTags"): + enum_name += "Tag" + else: + # Combine tag value and descriptive terms to form the enum name + enum_name += f"{typedef_enum_name.upper()}_{tag_value}" + descriptive_terms = variable_name_abbreviator(semantics) + if descriptive_terms: + enum_name += "_" + descriptive_terms + + # Cleanup + # Replace multiple underscores with a single underscore + enum_name = re.sub(r'_{2,}', '_', enum_name) + enum_name = enum_name.strip('_') + enum_name = enum_name.upper() + + return enum_name + + +def iana_cbor_tag_parse_csv(csv_content: str, typedef_enum_name: str): + """ + Parse and process IANA registration into enums + """ + csv_lines = csv_content.strip().split('\n') + csv_reader = csv.DictReader(csv_lines) + c_enum_list = {} + for row in csv_reader: + cbor_tag = row["Tag"] + data_item = row["Data Item"] + semantics = row["Semantics"] + reference = row["Reference"] + template = row["Template"] + if cbor_tag.lower() == "tag": # Skip first header + continue + if not cbor_tag or "unassigned" in data_item.lower() or "reserved" in semantics.lower(): + continue + if "always invalid" in semantics.lower(): + # Always invalid; see Section 10.1,[draft-bormann-cbor-notable-tags-02] + # The purpose of these tag number registrations is to enable the tag numbers to be reserved for internal use by implementation + continue + if "-" in cbor_tag: # is a range of value + continue + # Add to enum list + enum_name = iana_cbor_tag_c_enum_name_generate(cbor_tag, semantics, typedef_enum_name) + comment = '; '.join(filter(None, [semantics, f'Ref: {reference}'])) + c_enum_list[int(cbor_tag)] = {"enum_name": enum_name, "comment": comment} + return c_enum_list + +def iana_cbor_tag_c_typedef_enum_update(header_file_content: str) -> str: + typedef_enum_name = iana_cbor_settings["tag_source"]["name"] + source_name = iana_cbor_tag_source["title"] + source_url = iana_cbor_tag_source["source_url"] + csv_file_url = iana_cbor_tag_source["csv_url"] + cache_file_path = iana_cache_dir_path + os.path.basename(csv_file_url) + + # Generate typedef name + c_typedef_name = f"{typedef_enum_name}_t" + + if tiny_cbor_style_override: + c_typedef_name = f"{typedef_enum_name}" + + c_enum_name = c_typedef_name + + # Generate head comment + c_head_comment = spacing_string + f"/* Autogenerated {source_name} (Source: {source_url}) */\n" + + # Load latest IANA registrations + csv_content = utils.read_or_download_csv(csv_file_url, cache_file_path) + + # Parse and process IANA registration into enums + c_enum_list = iana_cbor_tag_parse_csv(csv_content, typedef_enum_name) + + # Generate enumeration header content + c_range_marker = [ + {"start":0, "end":23, "description":"Standards Action"}, + {"start":24, "end":32767, "description":"Specification Required"}, + {"start":32768, "end":18446744073709551615, "description":"First Come First Served"} + ] + header_file_content = utils.update_c_typedef_enum(header_file_content, c_typedef_name, c_enum_name, c_head_comment, c_enum_list, c_range_marker, spacing_string=spacing_string) + + # Generate constants for cbor tag feature flag + # Note: Not convinced this is a good idea, so is restricted to tiny cbor compatibility mode + if tiny_cbor_style_override: + c_macro_list = {} + for id_value, row in c_enum_list.items(): + c_macro_list[row["enum_name"]] = {"value": row["enum_name"]} + if "depreciated_enum_name" in row: + c_macro_list[row["depreciated_enum_name"]] = {"value": row["depreciated_enum_name"]} + header_file_content = utils.update_c_const_macro(header_file_content, "cbor known tag feature flag", "/* #define the constants so we can check with #ifdef */\n", c_macro_list) + + return header_file_content + + +############################################################################### +# Create Header + +def iana_cbor_c_header_update(header_filepath: str): + # If file doesn't exist yet then write a new file + os.makedirs(os.path.dirname(header_filepath), exist_ok=True) + if not os.path.exists(header_filepath): + with open(header_filepath, 'w+') as file: + file.write(default_cbor_header_c) + + # Get latest header content + with open(header_filepath, 'r') as file: + header_file_content = file.read() + + # Resync All Values + header_file_content = iana_cbor_simple_values_c_typedef_enum_update(header_file_content) + header_file_content = iana_cbor_tag_c_typedef_enum_update(header_file_content) + + # Write new header content + with open(header_filepath, 'w') as file: + file.write(header_file_content) + + # Indicate header has been synced + print(f"C header file '{header_filepath}' updated successfully.") + +def main(): + iana_cbor_c_header_update(iana_cbor_c_header_file_path) + +if __name__ == "__main__": + main() diff --git a/tools/iana/c/iana_header_utils.py b/tools/iana/c/iana_header_utils.py new file mode 100644 index 00000000..4db9cb78 --- /dev/null +++ b/tools/iana/c/iana_header_utils.py @@ -0,0 +1,190 @@ +import os +import re +import time +import email +import requests + + +############################################################################### +# CSV Handlers + +def _download_csv(csv_url: str, cache_file: str) -> str: + """Downloads CSV content from a URL and saves it to a cache file.""" + response = requests.get(csv_url) + response.raise_for_status() + + csv_content = response.text + os.makedirs(os.path.dirname(cache_file), exist_ok=True) + with open(cache_file, "w", encoding="utf-8") as file: + file.write(csv_content) + + return csv_content + +def _read_cache_csv(cache_file: str) -> str: + """Reads the cached CSV content from a file.""" + with open(cache_file, "r", encoding="utf-8") as file: + return file.read() + +def read_or_download_csv(csv_url: str, cache_file: str) -> str: + """ + Fetches CSV content either from a URL or from a cache file. + + Will only download and overwrite the cache file if the remote file has changed since last download. + """ + try: + response = requests.head(csv_url) + if not os.path.exists(cache_file) or 'last-modified' not in response.headers: + return _download_csv(csv_url, cache_file) + + remote_last_modified = response.headers['last-modified'] + remote_timestamp = time.mktime(email.utils.parsedate_to_datetime(remote_last_modified).timetuple()) + cached_timestamp = os.path.getmtime(cache_file) + if remote_timestamp > cached_timestamp: + return _download_csv(csv_url, cache_file) + + return _read_cache_csv(cache_file) + + except requests.RequestException as err: + if os.path.exists(cache_file): + return _read_cache_csv(cache_file) + raise Exception("Error fetching CSV and no cache available.") from err + +############################################################################### +# C Code Generation Utilities + +def get_content_of_typedef_enum(c_code: str, typedef_enum_name: str) -> str: + match = re.search(fr'typedef enum [^{{]*\{{([^}}]*)\}} {typedef_enum_name};', c_code, flags=re.DOTALL) + if not match: + return None + + return match.group(1) + +def override_enum_from_existing_typedef_enum(header_file_content: str, c_typedef_name: str, c_enum_list, depreciated_enum_support = True): + """ + Check for existing enum so we do not break it + """ + def extract_enum_values_from_typedef_enum(c_code: str, existing_enum_content: str) -> str: + matches = re.findall(r'(\w+)\s*=\s*(\d+)', existing_enum_content) + + enum_values = {} + for match in matches: + enum_name, enum_value = match + if int(enum_value) in enum_values: + enum_values[int(enum_value)].append(enum_name) + else: + enum_values[int(enum_value)] = [enum_name] + + return enum_values + + existing_enum_content = get_content_of_typedef_enum(header_file_content, c_typedef_name) + existing_enum_name_list = extract_enum_values_from_typedef_enum(header_file_content, existing_enum_content) + for id_value, existing_enum_name_list_entry in sorted(existing_enum_name_list.items()): + for existing_enum_name in existing_enum_name_list_entry: + # Check if we already have a generated value for this existing entry + if id_value in c_enum_list: # Override + expected_enum_name = c_enum_list[id_value]["enum_name"] + # Check if duplicated + if existing_enum_name != expected_enum_name: + # Existing Enum Name Does Not Match With This Name + if depreciated_enum_support: + # Preserve But Mark As Depreciated / Backward Compatible + c_enum_list[id_value]["depreciated_enum_name"] = existing_enum_name + else: + # Preserve But Override + c_enum_list[id_value]["enum_name"] = existing_enum_name + else: # Add + c_enum_list[id_value] = {"enum_name" : existing_enum_name} + return c_enum_list + +def generate_c_enum_content(c_head_comment, c_enum_list, c_range_marker = None, spacing_string = " "): + c_range_marker_index = 0 + def range_marker_render(c_range_marker, id_value=None): + nonlocal c_range_marker_index + if c_range_marker is None: + return '' + + range_marker_content = '' + while c_range_marker_index < len(c_range_marker): + start_range = c_range_marker[c_range_marker_index].get("start") + end_range = c_range_marker[c_range_marker_index].get("end") + range_comment = c_range_marker[c_range_marker_index].get("description") + if id_value is None or start_range <= id_value: + range_marker_content += '\n' + spacing_string + f'/* {start_range}-{end_range} : {range_comment} */\n' + c_range_marker_index += 1 + continue + break + + return range_marker_content + + c_enum_content = c_head_comment + + for id_value, row in sorted(c_enum_list.items()): + c_enum_content += range_marker_render(c_range_marker, id_value) + if "comment" in row: + c_enum_content += spacing_string + f'// {row.get("comment", "")}\n' + c_enum_content += spacing_string + f'{row.get("enum_name", "")} = {id_value}' + if "depreciated_enum_name" in row: + c_enum_content += ',\n' + spacing_string + f'{row.get("depreciated_enum_name", "")} = {id_value} /* depreciated but identifier kept for backwards compatibility */' + c_enum_content += (',\n' if id_value != sorted(c_enum_list)[-1] else '\n') + + c_enum_content += range_marker_render(c_range_marker) + + return c_enum_content + +def update_c_typedef_enum(document_content, c_typedef_name, c_enum_name, c_head_comment, c_enum_list, c_range_marker = None, spacing_string = " "): + def search_and_replace_c_typedef_enum(document_content, c_enum_content, typename, enumname = None): + # Search and replace + enumname = "" if enumname is None else (enumname + " ") + pattern = fr'typedef enum [^{{]*\{{([^}}]*)\}} {typename};' + replacement = f'typedef enum {enumname}{{\n{c_enum_content}}} {typename};' + updated_document_content = re.sub(pattern, replacement, document_content, flags=re.DOTALL) + return updated_document_content + + # Check if already exist, if not then create one + if not get_content_of_typedef_enum(document_content, c_typedef_name): + document_content += f'typedef enum {{\n}} {c_typedef_name};\n\n' + + # Old name takes priority for backwards compatibility (unless overridden) + c_enum_content = override_enum_from_existing_typedef_enum(document_content, c_typedef_name, c_enum_list) + + # Generate enumeration header content + c_enum_content = generate_c_enum_content(c_head_comment, c_enum_list, c_range_marker, spacing_string=spacing_string) + + # Search for typedef enum name and replace with new content + updated_document_content = search_and_replace_c_typedef_enum(document_content, c_enum_content, c_typedef_name, c_enum_name) + + return updated_document_content + +def get_content_of_const_macro(c_code: str, section_name: str) -> str: + pattern = fr'\/\* Start of {section_name} autogenerated section \*\/(.*?)\/\* End of {section_name} autogenerated section \*\/' + match = re.search(pattern, c_code, flags=re.DOTALL) + if not match: + return None + + return match.group(1) + +def update_c_const_macro(document_content, section_name, c_head_comment, c_macro_list): + def search_and_replace_c_const_macro(document_content, section_name, new_content): + # Search and replace + pattern = fr'\/\* Start of {section_name} autogenerated section \*\/(.*?)\n\/\* End of {section_name} autogenerated section \*\/' + replacement = f'/* Start of {section_name} autogenerated section */\n{new_content}/* End of {section_name} autogenerated section */' + updated_document_content = re.sub(pattern, replacement, document_content, flags=re.DOTALL) + return updated_document_content + + # Check if already exist, if not then create one + if not get_content_of_const_macro(document_content, section_name): + document_content += f'/* Start of {section_name} autogenerated section */\n' + document_content += f'/* End of {section_name} autogenerated section */' + + # Generate enumeration header content + c_const_macro_content = c_head_comment + for macro_name, macro_data in sorted(c_macro_list.items()): + c_const_macro_content += f"#define {macro_name} {macro_data.get('value')}" + if 'comment' in macro_data: + c_const_macro_content += f" // {macro_data.get('comment')}" + c_const_macro_content += "\n" + + # Search for typedef enum name and replace with new content + updated_document_content = search_and_replace_c_const_macro(document_content, section_name, c_const_macro_content) + + return updated_document_content diff --git a/tools/iana/c/iana_settings.toml b/tools/iana/c/iana_settings.toml new file mode 100644 index 00000000..c39df12f --- /dev/null +++ b/tools/iana/c/iana_settings.toml @@ -0,0 +1,12 @@ + +[cbor] +spacing_string = " " +style_override = "tiny_cbor" +generated_header_filepath = '../../../src/cbor.h' +cache_directory_path = './cache/cbor/' + +[cbor.simple_value] +name = "CborSimpleValue" + +[cbor.tag_source] +name = "CborKnownTags" diff --git a/tools/iana/iana_sources.toml b/tools/iana/iana_sources.toml new file mode 100644 index 00000000..121c3d3b --- /dev/null +++ b/tools/iana/iana_sources.toml @@ -0,0 +1,46 @@ +[iana_cbor_simple_value_source] +title = "IANA CBOR Content-Formats" +csv_url = "https://www.iana.org/assignments/cbor-simple-values/simple.csv" +source_url = "https://www.iana.org/assignments/cbor-simple-values/cbor-simple-values.xhtml#simple" + +[iana_cbor_tag_source] +title = "IANA CBOR Tags" +csv_url = "https://www.iana.org/assignments/cbor-tags/tags.csv" +source_url = "https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml#tags" + +[iana_coap_request_response_source] +title = "IANA CoAP Request/Response" +# Method +request_csv_url = "https://www.iana.org/assignments/core-parameters/method-codes.csv" +request_source = "https://www.iana.org/assignments/core-parameters/core-parameters.xhtml#method-codes" +# Response +response_csv_url = "https://www.iana.org/assignments/core-parameters/response-codes.csv" +response_source = "https://www.iana.org/assignments/core-parameters/core-parameters.xhtml#response-codes" +# Signaling Codes +signaling_csv_url = "https://www.iana.org/assignments/core-parameters/signaling-codes.csv" +signaling_source = "https://www.iana.org/assignments/core-parameters/core-parameters.xhtml#signaling-codes" + +[iana_coap_option_source] +title = "IANA CoAP Option Numbers" +csv_url = "https://www.iana.org/assignments/core-parameters/option-numbers.csv" +source = "https://www.iana.org/assignments/core-parameters/core-parameters.xhtml#option-numbers" + +[iana_coap_content_format_source] +title = "IANA CoAP Content-Formats" +csv_url = "https://www.iana.org/assignments/core-parameters/content-formats.csv" +source = "https://www.iana.org/assignments/core-parameters/core-parameters.xhtml#content-formats" + +[iana_coap_signaling_option_numbers_source] +title = "IANA CoAP Option Numbers" +csv_url = "https://www.iana.org/assignments/core-parameters/signaling-option-numbers.csv" +source = "https://www.iana.org/assignments/core-parameters/core-parameters.xhtml#signaling-option-numbers" + +[iana_http_status_code_source] +title = "IANA HTTP Status Code" +csv_url = "https://www.iana.org/assignments/http-status-codes/http-status-codes-1.csv" +source_url = "https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml#http-status-codes-1" + +[iana_http_field_name_source] +title = "IANA HTTP Field Name" +csv_url = "https://www.iana.org/assignments/http-fields/field-names.csv" +source_url = "https://www.iana.org/assignments/http-fields/http-fields.xhtml#field-names" diff --git a/tools/iana/makefile b/tools/iana/makefile new file mode 100644 index 00000000..1b7b2e34 --- /dev/null +++ b/tools/iana/makefile @@ -0,0 +1,9 @@ + +.PHONY: generate +generate: + @echo "Generating Headers" + cd c; python3.11 ./c_header_cbor.py + +.PHONY: clean +clean: + rm -rf ./c/cache/*