~ubuntu-branches/ubuntu/raring/modemmanager/raring

« back to all changes in this revision

Viewing changes to libqcdm/src/utils.c

  • Committer: Package Import Robot
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2012-06-22 15:04:53 UTC
  • mfrom: (1.1.18)
  • Revision ID: package-import@ubuntu.com-20120622150453-80wkj7avepp0yh1w
Tags: 0.6~git201206221719.8289a64-0ubuntu1
* upstream snapshot 2012-06-22 17:19:35 (GMT)
  + 8289a646fd19b6ddfba48214e94297ff96f731eb
  - decode: harmonize with git master
  - decode: update with latest QMI enums
  - zte: try to handle Icera devices that use PPP
  - uml290: allow setting more global modes (LP: #824114)
  - qcdm: fix 1x/HDR mode pref and add GSM/UMTS mode prefs
  - trivial: whitespace fixes
  - uml290: add mode switching tool
  - wmc: namespace stuff properly
  - qcdm: namespace stuff properly
  - wmc: add command for setting global mode
  - cdma: fix QCDM registration state checking
  - test: ignore ESN errors in info.py
  - dbus: remove 'max_replies_per_connection' limit from D-Bus configuration
* debian/patches/fix-format-string.patch: fix a missing format string in
  a fprintf call for uml290mode; it makes the build fail otherwise.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
 */
34
34
 
35
35
/* Table of CRCs for each possible byte, with a generator polynomial of 0x8408 */
36
 
const u_int16_t crc_table[256] = {
 
36
static const u_int16_t crc_table[256] = {
37
37
    0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
38
38
    0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
39
39
    0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
70
70
 
71
71
/* Calculate the CRC for a buffer using a seed of 0xffff */
72
72
u_int16_t
73
 
crc16 (const char *buffer, size_t len)
 
73
dm_crc16 (const char *buffer, size_t len)
74
74
{
75
75
    u_int16_t crc = 0xffff;
76
76
 
196
196
    qcdm_return_val_if_fail (outbuf != NULL, 0);
197
197
 
198
198
    /* Add the CRC */
199
 
    crc = crc16 (inbuf, cmd_len);
 
199
    crc = dm_crc16 (inbuf, cmd_len);
200
200
    inbuf[cmd_len++] = crc & 0xFF;
201
201
    inbuf[cmd_len++] = (crc >> 8) & 0xFF;
202
202
 
297
297
    }
298
298
 
299
299
    /* Check the CRC of the packet's data */
300
 
    crc = crc16 (outbuf, unesc_len - 2);
 
300
    crc = dm_crc16 (outbuf, unesc_len - 2);
301
301
    pkt_crc = outbuf[unesc_len - 2] & 0xFF;
302
302
    pkt_crc |= (outbuf[unesc_len - 1] & 0xFF) << 8;
303
303
    if (crc != pkt_crc) {