qcdm: namespace stuff properly
This commit is contained in:
@@ -15,8 +15,8 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LIBQCDM_ERROR_H
|
#ifndef LIBQCDM_ERRORS_H
|
||||||
#define LIBQCDM_ERROR_H
|
#define LIBQCDM_ERRORS_H
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@@ -98,5 +98,5 @@ void _qcdm_log (const char *file,
|
|||||||
#define qcdm_err(domain, ...) \
|
#define qcdm_err(domain, ...) \
|
||||||
_qcdm_log (__FILE__, __LINE__, __func__, domain, QCDM_LOGL_ERR, ## __VA_ARGS__ )
|
_qcdm_log (__FILE__, __LINE__, __func__, domain, QCDM_LOGL_ERR, ## __VA_ARGS__ )
|
||||||
|
|
||||||
#endif /* LIBQCDM_ERROR_H */
|
#endif /* LIBQCDM_ERRORS_H */
|
||||||
|
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Table of CRCs for each possible byte, with a generator polynomial of 0x8408 */
|
/* Table of CRCs for each possible byte, with a generator polynomial of 0x8408 */
|
||||||
const u_int16_t crc_table[256] = {
|
static const u_int16_t crc_table[256] = {
|
||||||
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
|
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
|
||||||
0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
|
0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
|
||||||
0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
|
0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
|
||||||
@@ -70,7 +70,7 @@ const u_int16_t crc_table[256] = {
|
|||||||
|
|
||||||
/* Calculate the CRC for a buffer using a seed of 0xffff */
|
/* Calculate the CRC for a buffer using a seed of 0xffff */
|
||||||
u_int16_t
|
u_int16_t
|
||||||
crc16 (const char *buffer, size_t len)
|
dm_crc16 (const char *buffer, size_t len)
|
||||||
{
|
{
|
||||||
u_int16_t crc = 0xffff;
|
u_int16_t crc = 0xffff;
|
||||||
|
|
||||||
@@ -196,7 +196,7 @@ dm_encapsulate_buffer (char *inbuf,
|
|||||||
qcdm_return_val_if_fail (outbuf != NULL, 0);
|
qcdm_return_val_if_fail (outbuf != NULL, 0);
|
||||||
|
|
||||||
/* Add the CRC */
|
/* Add the CRC */
|
||||||
crc = crc16 (inbuf, cmd_len);
|
crc = dm_crc16 (inbuf, cmd_len);
|
||||||
inbuf[cmd_len++] = crc & 0xFF;
|
inbuf[cmd_len++] = crc & 0xFF;
|
||||||
inbuf[cmd_len++] = (crc >> 8) & 0xFF;
|
inbuf[cmd_len++] = (crc >> 8) & 0xFF;
|
||||||
|
|
||||||
@@ -297,7 +297,7 @@ dm_decapsulate_buffer (const char *inbuf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check the CRC of the packet's data */
|
/* Check the CRC of the packet's data */
|
||||||
crc = crc16 (outbuf, unesc_len - 2);
|
crc = dm_crc16 (outbuf, unesc_len - 2);
|
||||||
pkt_crc = outbuf[unesc_len - 2] & 0xFF;
|
pkt_crc = outbuf[unesc_len - 2] & 0xFF;
|
||||||
pkt_crc |= (outbuf[unesc_len - 1] & 0xFF) << 8;
|
pkt_crc |= (outbuf[unesc_len - 1] & 0xFF) << 8;
|
||||||
if (crc != pkt_crc) {
|
if (crc != pkt_crc) {
|
||||||
|
@@ -15,8 +15,8 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef UTILS_H
|
#ifndef LIBQCDM_UTILS_H
|
||||||
#define UTILS_H
|
#define LIBQCDM_UTILS_H
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@@ -32,7 +32,7 @@ typedef u_int8_t qcdmbool;
|
|||||||
#define DIAG_CONTROL_CHAR 0x7E
|
#define DIAG_CONTROL_CHAR 0x7E
|
||||||
#define DIAG_TRAILER_LEN 3
|
#define DIAG_TRAILER_LEN 3
|
||||||
|
|
||||||
u_int16_t crc16 (const char *buffer, size_t len);
|
u_int16_t dm_crc16 (const char *buffer, size_t len);
|
||||||
|
|
||||||
size_t dm_escape (const char *inbuf,
|
size_t dm_escape (const char *inbuf,
|
||||||
size_t inbuf_len,
|
size_t inbuf_len,
|
||||||
@@ -59,5 +59,5 @@ qcdmbool dm_decapsulate_buffer (const char *inbuf,
|
|||||||
size_t *out_used,
|
size_t *out_used,
|
||||||
qcdmbool *out_need_more);
|
qcdmbool *out_need_more);
|
||||||
|
|
||||||
#endif /* UTILS_H */
|
#endif /* LIBQCDM_UTILS_H */
|
||||||
|
|
||||||
|
@@ -42,7 +42,7 @@ test_crc16_2 (void *f, void *data)
|
|||||||
guint16 expected = 0x6D69;
|
guint16 expected = 0x6D69;
|
||||||
|
|
||||||
/* CRC check */
|
/* CRC check */
|
||||||
crc = crc16 (buf, sizeof (buf));
|
crc = dm_crc16 (buf, sizeof (buf));
|
||||||
g_assert (crc == expected);
|
g_assert (crc == expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ test_crc16_1 (void *f, void *data)
|
|||||||
guint16 expected = 0x097A;
|
guint16 expected = 0x097A;
|
||||||
|
|
||||||
/* CRC check */
|
/* CRC check */
|
||||||
crc = crc16 (buf, sizeof (buf));
|
crc = dm_crc16 (buf, sizeof (buf));
|
||||||
g_assert (crc == expected);
|
g_assert (crc == expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user