Adding initial code jy.oak@samsung.com
[ric-app/kpimon.git] / asn1c_defs / all-defs / ber_tlv_tag.h
diff --git a/asn1c_defs/all-defs/ber_tlv_tag.h b/asn1c_defs/all-defs/ber_tlv_tag.h
new file mode 100755 (executable)
index 0000000..4386c2c
--- /dev/null
@@ -0,0 +1,60 @@
+/*-\r
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.\r
+ * Redistribution and modifications are permitted subject to BSD license.\r
+ */\r
+#ifndef        _BER_TLV_TAG_H_\r
+#define        _BER_TLV_TAG_H_\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+enum asn_tag_class {\r
+       ASN_TAG_CLASS_UNIVERSAL         = 0,    /* 0b00 */\r
+       ASN_TAG_CLASS_APPLICATION       = 1,    /* 0b01 */\r
+       ASN_TAG_CLASS_CONTEXT           = 2,    /* 0b10 */\r
+       ASN_TAG_CLASS_PRIVATE           = 3     /* 0b11 */\r
+};\r
+typedef unsigned ber_tlv_tag_t;        /* BER TAG from Tag-Length-Value */\r
+\r
+/*\r
+ * Tag class is encoded together with tag value for optimization purposes.\r
+ */\r
+#define        BER_TAG_CLASS(tag)      ((tag) & 0x3)\r
+#define        BER_TAG_VALUE(tag)      ((tag) >> 2)\r
+#define        BER_TLV_CONSTRUCTED(tagptr)     (((*(const uint8_t *)tagptr)&0x20)?1:0)\r
+\r
+#define        BER_TAGS_EQUAL(tag1, tag2)      ((tag1) == (tag2))\r
+\r
+/*\r
+ * Several functions for printing the TAG in the canonical form\r
+ * (i.e. "[PRIVATE 0]").\r
+ * Return values correspond to their libc counterparts (if any).\r
+ */\r
+ssize_t ber_tlv_tag_snprint(ber_tlv_tag_t tag, char *buf, size_t buflen);\r
+ssize_t ber_tlv_tag_fwrite(ber_tlv_tag_t tag, FILE *);\r
+char *ber_tlv_tag_string(ber_tlv_tag_t tag);\r
+\r
+\r
+/*\r
+ * This function tries to fetch the tag from the input stream.\r
+ * RETURN VALUES:\r
+ *      0:     More data expected than bufptr contains.\r
+ *     -1:     Fatal error deciphering tag.\r
+ *     >0:     Number of bytes used from bufptr. tag_r will contain the tag.\r
+ */\r
+ssize_t ber_fetch_tag(const void *bufptr, size_t size, ber_tlv_tag_t *tag_r);\r
+\r
+/*\r
+ * This function serializes the tag (T from TLV) in BER format.\r
+ * It always returns number of bytes necessary to represent the tag,\r
+ * it is a caller's responsibility to check the return value\r
+ * against the supplied buffer's size.\r
+ */\r
+size_t ber_tlv_tag_serialize(ber_tlv_tag_t tag, void *bufptr, size_t size);\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* _BER_TLV_TAG_H_ */\r