From: Denis Ovsienko Date: Sat, 14 Jan 2023 22:25:18 +0000 (+0000) Subject: Remove init_crc10_table() and the entourage. X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/94f232c1ab0143c6da9fc00732b6b241b8abdf4c Remove init_crc10_table() and the entourage. As Guy Harris points out in bug report GH #1022, the function has been a busy no-op since commit e6c39e6 in 2010. While at it, fixup the Python code to work on Python 3: for i in range(len(crc_table)/8): TypeError: 'float' object cannot be interpreted as an integer --- diff --git a/checksum.c b/checksum.c index e6e84a25..c5025082 100644 --- a/checksum.c +++ b/checksum.c @@ -44,7 +44,7 @@ for i in range(256): accum ^= 0x633 crc_table.append(accum) -for i in range(len(crc_table)/8): +for i in range(int(len(crc_table)/8)): for j in range(8): sys.stdout.write("0x%04x, " % crc_table[i*8+j]) sys.stdout.write("\n") @@ -86,29 +86,6 @@ static const uint16_t crc10_table[256] = 0x021e, 0x002d, 0x004b, 0x0278, 0x0087, 0x02b4, 0x02d2, 0x00e1 }; -static void -init_crc10_table(void) -{ -#define CRC10_POLYNOMIAL 0x633 - int i, j; - uint16_t accum; - uint16_t verify_crc10_table[256]; - - for ( i = 0; i < 256; i++ ) - { - accum = ((unsigned short) i << 2); - for ( j = 0; j < 8; j++ ) - { - if ((accum <<= 1) & 0x400) accum ^= CRC10_POLYNOMIAL; - } - verify_crc10_table[i] = accum; - } - assert(memcmp(verify_crc10_table, - crc10_table, - sizeof(verify_crc10_table)) == 0); -#undef CRC10_POLYNOMIAL -} - uint16_t verify_crc10_cksum(uint16_t accum, const u_char *p, int length) { @@ -123,14 +100,6 @@ verify_crc10_cksum(uint16_t accum, const u_char *p, int length) return accum; } -/* precompute checksum tables */ -void -init_checksum(void) { - - init_crc10_table(); - -} - /* * Creates the OSI Fletcher checksum. See 8473-1, Appendix C, section C.3. * The checksum field of the passed PDU does not need to be reset to zero. diff --git a/netdissect.h b/netdissect.h index 24fda9e8..5762c584 100644 --- a/netdissect.h +++ b/netdissect.h @@ -764,7 +764,6 @@ extern void zmtp1_datagram_print(netdissect_options *, const u_char *, const u_i extern void zmtp1_print(netdissect_options *, const u_char *, u_int); /* checksum routines */ -extern void init_checksum(void); extern uint16_t verify_crc10_cksum(uint16_t, const u_char *, int); extern uint16_t create_osi_cksum(const uint8_t *, int, int); diff --git a/print.c b/print.c index fbb1b3b1..123c842c 100644 --- a/print.c +++ b/print.c @@ -249,9 +249,7 @@ static const struct printer printers[] = { void init_print(netdissect_options *ndo, uint32_t localnet, uint32_t mask) { - init_addrtoname(ndo, localnet, mask); - init_checksum(); } if_printer