This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.
Anjali Sharma hello2anjali.sharma at gmail.comI am trying to generate CRC table mentioned in openbsc/src/gprs/crc24.c file (http://lingrok.org/source/xref/openbsc/openbsc/src/gprs/crc24.c) I modified a CRC16 code to generate CRC24 (updated polynomial as per LLC specification). But I can not get right table. Below is source code. Can someone help me out? //****************************************************************************** // // Copyright (c) 1999 Axon Instruments. // All rights reserved. // //****************************************************************************** // HEADER: CRC16.cpp // PURPOSE: Contains functions calculating a 16 bit CRC code. // SOURCE: http://www.brokersys.com/snippets/ file: CRC_16F.C // #define POLYNOMIAL 0xAD85DD #define CRC_WIDTH 24 #define BITS_PER_BYTE 8 typedef unsigned int WORD; typedef unsigned int UINT; typedef char BYTE; static WORD correctCRCtable[1<<BITS_PER_BYTE] = // as per openbsc/src/gprs/crc24.c { 0x00000000, 0x00d6a776, 0x00f64557, 0x0020e221, 0x00b78115, 0x00612663, 0x0041c442, 0x00976334, 0x00340991, 0x00e2aee7, 0x00c24cc6, 0x0014ebb0, 0x00838884, 0x00552ff2, 0x0075cdd3, 0x00a36aa5, /* skip rest */ }; void InitCRCtab() { int v, i; int b; for ( b = 0; b <= (1<<BITS_PER_BYTE)-1; ++b ) { int v = b << (CRC_WIDTH-BITS_PER_BYTE); int i; for (i = BITS_PER_BYTE; --i >= 0; ) v = v&0x800000 ? (v<<1) ^ POLYNOMIAL : v<<1; if((v & 0xFFFFFF) == correctCRCtable[b]) correctCRCtable[b] = v; else { printf("Incorrect CRC table\n"); printf("correctCRCtable[%d]=0x%06x calculated=0x%06x\n", b, correctCRCtable[b], v&0xFFFFFF); exit(0); } } } int main() { InitCRCtab(); printf("Correct CRC table\n"); return 0; } /* Below is LLC specification: The FCS field shall consist of a 24 bit cyclic redundancy check (CRC) code. The CRC-24 is used to detect bit errors in the frame header and information fields. The FCS field contains the value of a CRC calculation that is performed over the entire contents of the header and information field, except for UI frames transmitted in unprotected mode, in which case the FCS field contains the value of a CRC calculation that is performed over the frame header and the first N202 octets (see subclause 8.9.6) of the information field only (see subclause 6.3.5.5.2). The information over which the CRC is calculated is referred to as the dividend in this subclause. Bit (1, 1) of the dividend is the highest-order term in the calculation (see subclause 5.7.3). CRC calculation shall be done before ciphering at the transmitting side, and after deciphering at the receiving side. NOTE: The definition below is different from that in 3GPP TS 24.022 [10] only with respect to the variable dividend length k of the LLC frames. In 3GPP TS 24.022, the RLP frame has a fixed dividend length, but the LLC frame has a variable dividend length. The CRC shall be the ones complement of the sum (modulo 2) of: - the remainder of x^k (x^23 + x^22 + x^21 +... + x^2 + x + 1) divided (modulo 2) by the generator polynomial, where k is the number of bits of the dividend; and - the remainder of the division (modulo 2) by the generator polynomial of the product of x^24 by the dividend. The CRC-24 generator polynomial is: G(x) = x^24 + x^23 + x^21 + x^20 + x^19 + x^17 + x^16 + x^15 + x^13 + x^8 + x^7 + x^5 + x^4 + x^2 + 1 The result of the CRC calculation is placed within the FCS field as described in subclause 5.7.3. NOTE: As a typical implementation at the transmitter, the initial content of the register of the device computing the remainder of the division is pre-set to all "1's" and is then modified by division by the generator polynomial (as described above) of the dividend; the ones complement of the resulting remainder is put into the FCS field. As a typical implementation at the receiver, the initial content of the register of the device computing the remainder of the division is pre-set to all "1's". The final remainder, after multiplication by x24 and then division (modulo 2) by the generator polynomial of the received frame, will be (in the absence of errors): C(x) = x^22 + x^21 + x^19 + x^18 + x^16 + x^15 + x^11 + x^8 + x^5 + x^4 */