aboutsummaryrefslogtreecommitdiffstats
path: root/epan/crc6.c
diff options
context:
space:
mode:
authorLuis Ontanon <luis.ontanon@gmail.com>2007-07-17 22:04:00 +0000
committerLuis Ontanon <luis.ontanon@gmail.com>2007-07-17 22:04:00 +0000
commite1ed3a1b8dc1a8e527b4c8d9b1e3db02eaf690f8 (patch)
tree73e6e2dd8162c4d81b3c835af3b82c6162050be1 /epan/crc6.c
parentfc98b36914a5f593c254fcaa971d97102635cd84 (diff)
get crc10 and crc6 out of packet-iuup.c
- experimental code for a way-too-heurstic look for iuup dissector svn path=/trunk/; revision=22341
Diffstat (limited to 'epan/crc6.c')
-rw-r--r--epan/crc6.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/epan/crc6.c b/epan/crc6.c
new file mode 100644
index 0000000000..f6daaf07f0
--- /dev/null
+++ b/epan/crc6.c
@@ -0,0 +1,37 @@
+/*
+ * crc6.c
+ *
+ *
+ * Created by L. E. G. O. on 2007/07/08.
+ * Copyright 2007 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <glib.h>
+#include "crc6.h"
+
+
+guint16 update_crc6_by_bytes(guint16 crc6, guint8 byte1, guint8 byte2) {
+ int bit;
+ guint32 remainder = ( byte1<<8 | byte2 ) << 6;
+ guint32 polynomial = 0x6F << 15;
+
+ for (bit = 15;
+ bit >= 0;
+ --bit)
+ {
+ if (remainder & (0x40 << bit))
+ {
+ remainder ^= polynomial;
+ }
+ polynomial >>= 1;
+ }
+
+ return (guint16)(remainder ^ crc6);
+}
+
+