Osmocom generic CRC routines

## Files

file | crc16gen.h
file | crc32gen.h
file | crc64gen.h
file | crc8gen.h
file | crcgen.h
file | crc16gen.c
file | crc32gen.c
file | crc64gen.c
file | crc8gen.c

## Data Structures

struct | osmo_crc16gen_code
| structure describing a given CRC code of max 16 bits More...
struct | osmo_crc32gen_code
| structure describing a given CRC code of max 32 bits More...
struct | osmo_crc64gen_code
| structure describing a given CRC code of max 64 bits More...
struct | osmo_crc8gen_code
| structure describing a given CRC code of max 8 bits More...

## Functions

uint16_t | osmo_crc16gen_compute_bits (const struct osmo_crc16gen_code *code, const ubit_t *in, int len)
| Compute the CRC value of a given array of hard-bits. More...
int | osmo_crc16gen_check_bits (const struct osmo_crc16gen_code *code, const ubit_t *in, int len, const ubit_t *crc_bits)
| Checks the CRC value of a given array of hard-bits. More...
void | osmo_crc16gen_set_bits (const struct osmo_crc16gen_code *code, const ubit_t *in, int len, ubit_t *crc_bits)
| Computes and writes the CRC value of a given array of bits. More...
uint32_t | osmo_crc32gen_compute_bits (const struct osmo_crc32gen_code *code, const ubit_t *in, int len)
| Compute the CRC value of a given array of hard-bits. More...
int | osmo_crc32gen_check_bits (const struct osmo_crc32gen_code *code, const ubit_t *in, int len, const ubit_t *crc_bits)
| Checks the CRC value of a given array of hard-bits. More...
void | osmo_crc32gen_set_bits (const struct osmo_crc32gen_code *code, const ubit_t *in, int len, ubit_t *crc_bits)
| Computes and writes the CRC value of a given array of bits. More...
uint64_t | osmo_crc64gen_compute_bits (const struct osmo_crc64gen_code *code, const ubit_t *in, int len)
| Compute the CRC value of a given array of hard-bits. More...
int | osmo_crc64gen_check_bits (const struct osmo_crc64gen_code *code, const ubit_t *in, int len, const ubit_t *crc_bits)
| Checks the CRC value of a given array of hard-bits. More...
void | osmo_crc64gen_set_bits (const struct osmo_crc64gen_code *code, const ubit_t *in, int len, ubit_t *crc_bits)
| Computes and writes the CRC value of a given array of bits. More...
uint8_t | osmo_crc8gen_compute_bits (const struct osmo_crc8gen_code *code, const ubit_t *in, int len)
| Compute the CRC value of a given array of hard-bits. More...
int | osmo_crc8gen_check_bits (const struct osmo_crc8gen_code *code, const ubit_t *in, int len, const ubit_t *crc_bits)
| Checks the CRC value of a given array of hard-bits. More...
void | osmo_crc8gen_set_bits (const struct osmo_crc8gen_code *code, const ubit_t *in, int len, ubit_t *crc_bits)
| Computes and writes the CRC value of a given array of bits. More...

## Detailed Description

## Function Documentation

int osmo_crc16gen_check_bits | ( | const struct osmo_crc16gen_code * | code,
|  | const ubit_t * | in,
|  | int | len,
|  | const ubit_t * | crc_bits
| ) |  |

Checks the CRC value of a given array of hard-bits.

Parameters

  [in] | code | The CRC code description to apply
  [in] | in | Array of hard bits
  [in] | len | Length of the array of hard bits
  [in] | crc_bits | Array of hard bits with the alleged CRC

Returns
  0 if CRC matches. 1 in case of error.

The crc_bits array must have a length of code->len

References osmo_crc16gen_code::bits, and osmo_crc16gen_compute_bits().

uint16_t osmo_crc16gen_compute_bits | ( | const struct osmo_crc16gen_code * | code,
|  | const ubit_t * | in,
|  | int | len
| ) |  |

Compute the CRC value of a given array of hard-bits.

Parameters

  [in] | code | The CRC code description to apply
  [in] | in | Array of hard bits
  [in] | len | Length of the array of hard bits

Returns
  The CRC value

References osmo_crc16gen_code::bits, osmo_crc16gen_code::init, osmo_conv_decoder::len, osmo_crc16gen_code::poly, and osmo_crc16gen_code::remainder.

Referenced by osmo_crc16gen_check_bits(), and osmo_crc16gen_set_bits().

void osmo_crc16gen_set_bits | ( | const struct osmo_crc16gen_code * | code,
|  | const ubit_t * | in,
|  | int | len,
|  | ubit_t * | crc_bits
| ) |  |

Computes and writes the CRC value of a given array of bits.

Parameters

  [in] | code | The CRC code description to apply
  [in] | in | Array of hard bits
  [in] | len | Length of the array of hard bits
  [in] | crc_bits | Array of hard bits to write the computed CRC to

The crc_bits array must have a length of code->len

References osmo_crc16gen_code::bits, and osmo_crc16gen_compute_bits().

int osmo_crc32gen_check_bits | ( | const struct osmo_crc32gen_code * | code,
|  | const ubit_t * | in,
|  | int | len,
|  | const ubit_t * | crc_bits
| ) |  |

Checks the CRC value of a given array of hard-bits.

Parameters

  [in] | code | The CRC code description to apply
  [in] | in | Array of hard bits
  [in] | len | Length of the array of hard bits
  [in] | crc_bits | Array of hard bits with the alleged CRC

Returns
  0 if CRC matches. 1 in case of error.

The crc_bits array must have a length of code->len

References osmo_crc32gen_code::bits, and osmo_crc32gen_compute_bits().

uint32_t osmo_crc32gen_compute_bits | ( | const struct osmo_crc32gen_code * | code,
|  | const ubit_t * | in,
|  | int | len
| ) |  |

Compute the CRC value of a given array of hard-bits.

Parameters

  [in] | code | The CRC code description to apply
  [in] | in | Array of hard bits
  [in] | len | Length of the array of hard bits

Returns
  The CRC value

References osmo_crc32gen_code::bits, osmo_crc32gen_code::init, osmo_conv_decoder::len, osmo_crc32gen_code::poly, and osmo_crc32gen_code::remainder.

Referenced by osmo_crc32gen_check_bits(), and osmo_crc32gen_set_bits().

void osmo_crc32gen_set_bits | ( | const struct osmo_crc32gen_code * | code,
|  | const ubit_t * | in,
|  | int | len,
|  | ubit_t * | crc_bits
| ) |  |

Computes and writes the CRC value of a given array of bits.

Parameters

  [in] | code | The CRC code description to apply
  [in] | in | Array of hard bits
  [in] | len | Length of the array of hard bits
  [in] | crc_bits | Array of hard bits to write the computed CRC to

The crc_bits array must have a length of code->len

References osmo_crc32gen_code::bits, and osmo_crc32gen_compute_bits().

int osmo_crc64gen_check_bits | ( | const struct osmo_crc64gen_code * | code,
|  | const ubit_t * | in,
|  | int | len,
|  | const ubit_t * | crc_bits
| ) |  |

Checks the CRC value of a given array of hard-bits.

Parameters

  [in] | code | The CRC code description to apply
  [in] | in | Array of hard bits
  [in] | len | Length of the array of hard bits
  [in] | crc_bits | Array of hard bits with the alleged CRC

Returns
  0 if CRC matches. 1 in case of error.

The crc_bits array must have a length of code->len

References osmo_crc64gen_code::bits, and osmo_crc64gen_compute_bits().

uint64_t osmo_crc64gen_compute_bits | ( | const struct osmo_crc64gen_code * | code,
|  | const ubit_t * | in,
|  | int | len
| ) |  |

Compute the CRC value of a given array of hard-bits.

Parameters

  [in] | code | The CRC code description to apply
  [in] | in | Array of hard bits
  [in] | len | Length of the array of hard bits

Returns
  The CRC value

References osmo_crc64gen_code::bits, osmo_crc64gen_code::init, osmo_conv_decoder::len, osmo_crc64gen_code::poly, and osmo_crc64gen_code::remainder.

Referenced by osmo_crc64gen_check_bits(), and osmo_crc64gen_set_bits().

void osmo_crc64gen_set_bits | ( | const struct osmo_crc64gen_code * | code,
|  | const ubit_t * | in,
|  | int | len,
|  | ubit_t * | crc_bits
| ) |  |

Computes and writes the CRC value of a given array of bits.

Parameters

  [in] | code | The CRC code description to apply
  [in] | in | Array of hard bits
  [in] | len | Length of the array of hard bits
  [in] | crc_bits | Array of hard bits to write the computed CRC to

The crc_bits array must have a length of code->len

References osmo_crc64gen_code::bits, and osmo_crc64gen_compute_bits().

int osmo_crc8gen_check_bits | ( | const struct osmo_crc8gen_code * | code,
|  | const ubit_t * | in,
|  | int | len,
|  | const ubit_t * | crc_bits
| ) |  |

Checks the CRC value of a given array of hard-bits.

Parameters

  [in] | code | The CRC code description to apply
  [in] | in | Array of hard bits
  [in] | len | Length of the array of hard bits
  [in] | crc_bits | Array of hard bits with the alleged CRC

Returns
  0 if CRC matches. 1 in case of error.

The crc_bits array must have a length of code->len

References osmo_crc8gen_code::bits, and osmo_crc8gen_compute_bits().

uint8_t osmo_crc8gen_compute_bits | ( | const struct osmo_crc8gen_code * | code,
|  | const ubit_t * | in,
|  | int | len
| ) |  |

Compute the CRC value of a given array of hard-bits.

Parameters

  [in] | code | The CRC code description to apply
  [in] | in | Array of hard bits
  [in] | len | Length of the array of hard bits

Returns
  The CRC value

References osmo_crc8gen_code::bits, osmo_crc8gen_code::init, osmo_conv_decoder::len, osmo_crc8gen_code::poly, and osmo_crc8gen_code::remainder.

Referenced by osmo_crc8gen_check_bits(), and osmo_crc8gen_set_bits().

void osmo_crc8gen_set_bits | ( | const struct osmo_crc8gen_code * | code,
|  | const ubit_t * | in,
|  | int | len,
|  | ubit_t * | crc_bits
| ) |  |

Computes and writes the CRC value of a given array of bits.

Parameters

  [in] | code | The CRC code description to apply
  [in] | in | Array of hard bits
  [in] | len | Length of the array of hard bits
  [in] | crc_bits | Array of hard bits to write the computed CRC to

The crc_bits array must have a length of code->len

References osmo_crc8gen_code::bits, and osmo_crc8gen_compute_bits().