aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorJeff Morriss <jeff.morriss@ulticom.com>2009-10-08 14:28:23 +0000
committerJeff Morriss <jeff.morriss@ulticom.com>2009-10-08 14:28:23 +0000
commit3c960cd5a26c224c4e7c507dfed9c8176cef00a3 (patch)
tree22ce00761b3d975ec582c5c8dab3527655b17de3 /epan
parent5fa3b703a9d94cb1cf35951a74386f98108a185e (diff)
As requested by Gregory Seidman on -dev: add CRC32 functions to libwireshark.def. Use consistent indentation in crc32.c.
svn path=/trunk/; revision=30401
Diffstat (limited to 'epan')
-rw-r--r--epan/crc32.c66
-rw-r--r--epan/libwireshark.def8
2 files changed, 42 insertions, 32 deletions
diff --git a/epan/crc32.c b/epan/crc32.c
index 7ea1eb8918..bd7a023613 100644
--- a/epan/crc32.c
+++ b/epan/crc32.c
@@ -171,7 +171,8 @@ const guint32 crc32_ccitt_table[256] = {
#define CRC32_CCITT_SEED 0xFFFFFFFF
-guint32 calculate_crc32c(const void *buf, int len, guint32 crc)
+guint32
+calculate_crc32c(const void *buf, int len, guint32 crc)
{
const guint8 *p = (const guint8 *)buf;
crc = CRC32C_SWAP(crc);
@@ -184,63 +185,64 @@ guint32 calculate_crc32c(const void *buf, int len, guint32 crc)
guint32
crc32_ccitt(const guint8 *buf, guint len)
{
- return ( crc32_ccitt_seed(buf, len, CRC32_CCITT_SEED) );
+ return (crc32_ccitt_seed(buf, len, CRC32_CCITT_SEED));
}
guint32
crc32_ccitt_seed(const guint8 *buf, guint len, guint32 seed)
{
- guint i;
- guint32 crc32 = seed;
+ guint i;
+ guint32 crc32 = seed;
- for (i = 0; i < len; i++)
- crc32 = crc32_ccitt_table[(crc32 ^ buf[i]) & 0xff] ^ (crc32 >> 8);
+ for (i = 0; i < len; i++)
+ crc32 = crc32_ccitt_table[(crc32 ^ buf[i]) & 0xff] ^ (crc32 >> 8);
- return ( ~crc32 );
+ return ( ~crc32 );
}
guint32
crc32_ccitt_tvb(tvbuff_t *tvb, guint len)
{
- const guint8* buf;
+ const guint8* buf;
- tvb_ensure_bytes_exist(tvb, 0, len); /* len == -1 not allowed */
- buf = tvb_get_ptr(tvb, 0, len);
+ tvb_ensure_bytes_exist(tvb, 0, len); /* len == -1 not allowed */
+ buf = tvb_get_ptr(tvb, 0, len);
- return ( crc32_ccitt_seed(buf, len, CRC32_CCITT_SEED) );
+ return ( crc32_ccitt_seed(buf, len, CRC32_CCITT_SEED) );
}
guint32
crc32_ccitt_tvb_offset(tvbuff_t *tvb, guint offset, guint len)
{
- const guint8* buf;
+ const guint8* buf;
- tvb_ensure_bytes_exist(tvb, offset, len); /* len == -1 not allowed */
- buf = tvb_get_ptr(tvb, offset, len);
+ tvb_ensure_bytes_exist(tvb, offset, len); /* len == -1 not allowed */
+ buf = tvb_get_ptr(tvb, offset, len);
- return ( crc32_ccitt(buf, len) );
+ return ( crc32_ccitt(buf, len) );
}
guint32
crc32_ccitt_tvb_seed(tvbuff_t *tvb, guint len, guint32 seed)
{
- const guint8* buf;
+ const guint8* buf;
- tvb_ensure_bytes_exist(tvb, 0, len); /* len == -1 not allowed */
- buf = tvb_get_ptr(tvb, 0, len);
+ tvb_ensure_bytes_exist(tvb, 0, len); /* len == -1 not allowed */
+ buf = tvb_get_ptr(tvb, 0, len);
- return ( crc32_ccitt_seed(buf, len, seed) );
+ return ( crc32_ccitt_seed(buf, len, seed) );
}
guint32
-crc32_ccitt_tvb_offset_seed(tvbuff_t *tvb, guint offset, guint len, guint32 seed)
+crc32_ccitt_tvb_offset_seed(tvbuff_t *tvb, guint offset, guint len,
+ guint32 seed)
{
- const guint8* buf;
+ const guint8* buf;
- tvb_ensure_bytes_exist(tvb, offset, len); /* len == -1 not allowed */
- buf = tvb_get_ptr(tvb, offset, len);
+ tvb_ensure_bytes_exist(tvb, offset, len); /* len == -1 not allowed */
+ buf = tvb_get_ptr(tvb, offset, len);
- return ( crc32_ccitt_seed(buf, len, seed) );
+ return ( crc32_ccitt_seed(buf, len, seed) );
}
/*
@@ -255,15 +257,15 @@ crc32_ccitt_tvb_offset_seed(tvbuff_t *tvb, guint offset, guint len, guint32 seed
guint32
crc32_802_tvb(tvbuff_t *tvb, guint len)
{
- guint32 c_crc;
+ guint32 c_crc;
- c_crc = crc32_ccitt_tvb(tvb, len);
+ c_crc = crc32_ccitt_tvb(tvb, len);
- /* Byte reverse. */
- c_crc = ((unsigned char)(c_crc>>0)<<24) |
- ((unsigned char)(c_crc>>8)<<16) |
- ((unsigned char)(c_crc>>16)<<8) |
- ((unsigned char)(c_crc>>24)<<0);
+ /* Byte reverse. */
+ c_crc = ((unsigned char)(c_crc>>0)<<24) |
+ ((unsigned char)(c_crc>>8)<<16) |
+ ((unsigned char)(c_crc>>16)<<8) |
+ ((unsigned char)(c_crc>>24)<<0);
- return ( c_crc );
+ return ( c_crc );
}
diff --git a/epan/libwireshark.def b/epan/libwireshark.def
index aa97c2e942..67a46e0bc9 100644
--- a/epan/libwireshark.def
+++ b/epan/libwireshark.def
@@ -108,6 +108,14 @@ copy_file_binary_mode
copy_prefs
crc16_ccitt_tvb
crc16_plain_tvb_offset
+calculate_crc32c
+crc32_ccitt
+crc32_ccitt_seed
+crc32_ccitt_tvb
+crc32_ccitt_tvb_offset
+crc32_ccitt_tvb_seed
+crc32_ccitt_tvb_offset_seed
+crc32_802_tvb
create_dissector_handle
create_persconffile_dir
create_persconffile_profile