Adding initial code jy.oak@samsung.com
[ric-app/kpimon.git] / asn1c_defs / all-defs / ber_tlv_length.h
diff --git a/asn1c_defs/all-defs/ber_tlv_length.h b/asn1c_defs/all-defs/ber_tlv_length.h
new file mode 100755 (executable)
index 0000000..ebae5e0
--- /dev/null
@@ -0,0 +1,50 @@
+/*-\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_LENGTH_H_\r
+#define        _BER_TLV_LENGTH_H_\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+typedef ssize_t ber_tlv_len_t;\r
+\r
+/*\r
+ * This function tries to fetch the length of the BER TLV value and place it\r
+ * in *len_r.\r
+ * RETURN VALUES:\r
+ *      0:     More data expected than bufptr contains.\r
+ *     -1:     Fatal error deciphering length.\r
+ *     >0:     Number of bytes used from bufptr.\r
+ * On return with >0, len_r is constrained as -1..MAX, where -1 mean\r
+ * that the value is of indefinite length.\r
+ */\r
+ssize_t ber_fetch_length(int _is_constructed, const void *bufptr, size_t size,\r
+       ber_tlv_len_t *len_r);\r
+\r
+/*\r
+ * This function expects bufptr to be positioned over L in TLV.\r
+ * It returns number of bytes occupied by L and V together, suitable\r
+ * for skipping. The function properly handles indefinite length.\r
+ * RETURN VALUES:\r
+ *     Standard {-1,0,>0} convention.\r
+ */\r
+ssize_t ber_skip_length(\r
+       const struct asn_codec_ctx_s *opt_codec_ctx,    /* optional context */\r
+       int _is_constructed, const void *bufptr, size_t size);\r
+\r
+/*\r
+ * This function serializes the length (L from TLV) in DER format.\r
+ * It always returns number of bytes necessary to represent the length,\r
+ * it is a caller's responsibility to check the return value\r
+ * against the supplied buffer's size.\r
+ */\r
+size_t der_tlv_length_serialize(ber_tlv_len_t len, void *bufptr, size_t size);\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* _BER_TLV_LENGTH_H_ */\r