From d421b7660c948c2e22798a79aa480343027243c0 Mon Sep 17 00:00:00 2001
From: Guo Wenxue <guowenxue@gmail.com>
Date: Thu, 28 Mar 2019 00:09:04 +0800
Subject: [PATCH] Add tlv makefile and comment for source code
---
ch8_tlv/crc-itu-t.h | 28 ++++++++++++++++++++++++++--
1 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/ch8_tlv/crc-itu-t.h b/ch8_tlv/crc-itu-t.h
index 748bf6c..e054724 100644
--- a/ch8_tlv/crc-itu-t.h
+++ b/ch8_tlv/crc-itu-t.h
@@ -13,14 +13,38 @@
#ifndef CRC_ITU_T_H
#define CRC_ITU_T_H
-#define IoT_MAGIC_CRC 0x1E50
+#define MAGIC_CRC 0x1E50
extern const unsigned short crc_itu_t_table[256];
+
+/**
+ * crc_itu_t - Compute the CRC-ITU-T for the data buffer
+ *
+ * @crc: previous CRC value, we use $IoT_MAGIC_CRC
+ * @buffer: data pointer
+ * @len: number of bytes in the buffer
+ *
+ * Returns the updated CRC value
+ */
+extern unsigned short crc_itu_t(unsigned short magic_crc, const unsigned char *buffer, unsigned int len);
+
+
+/*
+ * ushort_to_bytes - Convert unsigned short CRC16 value to two bytes
+ * @bytes: two bytes CRC16 value saving buffer, buffer size must more than 2 bytes
+ * @crc: crc_itu_t() compute returnd value( unsigned short CRC16 checksum)
+ */
extern int ushort_to_bytes(unsigned char *bytes, unsigned short val);
+
+
+/*
+ * bytes_to_ushort - Convert two bytes mode CRC value into unsigned short CRC16 value
+ * @bytes: bytes mode CRC value first byte position
+ * @len: bytes mode CRC value length
+ */
extern unsigned short bytes_to_ushort(unsigned char *bytes, int len);
-extern unsigned short crc_itu_t(unsigned short crc, const unsigned char *buffer, unsigned int len);
static inline unsigned short crc_itu_t_byte(unsigned short crc, const unsigned char data)
{
--
Gitblit v1.9.1