gsm48_rest_octets.c File Reference
`#include <string.h>`
`#include <stdlib.h>`
`#include <errno.h>`
`#include <stdbool.h>`
`#include <osmocom/core/bitvec.h>`
`#include <osmocom/gsm/bitvec_gsm.h>`
`#include <osmocom/gsm/sysinfo.h>`
`#include <osmocom/gsm/gsm48_arfcn_range_encode.h>`
`#include <osmocom/gsm/gsm48_rest_octets.h>`

## Functions

int | osmo_gsm48_rest_octets_si1_encode (uint8_t *data, uint8_t *nch_pos, int is1800_net)
static bool | append_eutran_neib_cell (struct bitvec *bv, const struct osmo_earfcn_si2q *e, size_t *e_offset, uint8_t budget)
static void | append_earfcn (struct bitvec *bv, const struct osmo_earfcn_si2q *e, size_t *e_offset, uint8_t budget)
static int | range_encode (enum osmo_gsm48_range r, int *arfcns, int arfcns_used, int *w, int f0, uint8_t *chan_list)
static int | f0_helper (int *sc, size_t length, uint8_t *chan_list)
static unsigned | range1024_p (unsigned n)
static int | append_utran_fdd_length (uint16_t u, const int *sc, size_t sc_len, size_t length)
static int | append_utran_fdd (struct bitvec *bv, uint16_t u, int *sc, size_t length)
static int | try_adding_uarfcn (struct bitvec *bv, uint16_t *scramble_list, size_t uarfcn_length, size_t *u_offset, uint16_t uarfcn, uint8_t num_sc, uint8_t start_pos, uint8_t budget)
static void | append_uarfcns (struct bitvec *bv, const uint16_t *uarfcn_list, size_t *u_offset, size_t uarfcn_length, uint16_t *scramble_list, uint8_t budget)
static size_t | si2q_earfcn_count (const struct osmo_earfcn_si2q *e)
int | osmo_gsm48_rest_octets_si2quater_encode (uint8_t *data, uint8_t si2q_index, uint8_t si2q_count, const uint16_t *uarfcn_list, size_t *u_offset, size_t uarfcn_length, uint16_t *scramble_list, struct osmo_earfcn_si2q *si2quater_neigh_list, size_t *e_offset)
static void | append_selection_params (struct bitvec *bv, const struct osmo_gsm48_si_selection_params *sp)
static void | append_power_offset (struct bitvec *bv, const struct osmo_gsm48_si_power_offset *po)
static void | append_gprs_ind (struct bitvec *bv, const struct osmo_gsm48_si3_gprs_ind *gi)
int | osmo_gsm48_rest_octets_si3_encode (uint8_t *data, const struct osmo_gsm48_si_ro_info *si3)
static int | append_lsa_params (struct bitvec *bv, const struct osmo_gsm48_lsa_params *lsa_params)
int | osmo_gsm48_rest_octets_si4_encode (uint8_t *data, const struct osmo_gsm48_si_ro_info *si4, int len)
int | osmo_gsm48_rest_octets_si6_encode (uint8_t *data, const struct osmo_gsm48_si6_ro_info *in)
static unsigned int | decode_t3192 (unsigned int t3192)
static unsigned int | decode_drx_timer (unsigned int drx)
static int | decode_gprs_cell_opt (struct osmo_gprs_cell_options *gco, struct bitvec *bv)
static void | decode_gprs_pwr_ctrl_pars (struct osmo_gprs_power_ctrl_pars *pcp, struct bitvec *bv)
int | osmo_gsm48_rest_octets_si13_decode (struct osmo_gsm48_si13_info *si13, const uint8_t *data)
| Decode SI13 Rest Octests (04.08 Chapter 10.5.2.37b). More...
static int | append_gprs_mobile_alloc (struct bitvec *bv)
static int | encode_t3192 (unsigned int t3192)
static int | encode_drx_timer (unsigned int drx)
static int | append_gprs_cell_opt (struct bitvec *bv, const struct osmo_gprs_cell_options *gco)
static void | append_gprs_pwr_ctrl_pars (struct bitvec *bv, const struct osmo_gprs_power_ctrl_pars *pcp)
int | osmo_gsm48_rest_octets_si13_encode (uint8_t *data, const struct osmo_gsm48_si13_info *si13)
void | osmo_gsm48_rest_octets_si3_decode (struct osmo_gsm48_si_ro_info *si3, const uint8_t *data)
| Decode SI3 Rest Octests (Chapter 10.5.2.34 / Table 10.4.72). More...
void | osmo_gsm48_rest_octets_si4_decode (struct osmo_gsm48_si_ro_info *si4, const uint8_t *data, int len)

## Function Documentation

## append_earfcn()

static void append_earfcn | ( | struct bitvec * | bv,
|  | const struct osmo_earfcn_si2q * | e,
|  | size_t * | e_offset,
|  | uint8_t | budget
| ) |  |

inline static

References append_eutran_neib_cell(), bitvec_set_bit(), bitvec_set_uint(), bitvec::cur_bit, H, L, OSMO_ASSERT, and SI2Q_MAX_LEN.

Referenced by osmo_gsm48_rest_octets_si2quater_encode().

## append_eutran_neib_cell()

static bool append_eutran_neib_cell | ( | struct bitvec * | bv,
|  | const struct osmo_earfcn_si2q * | e,
|  | size_t * | e_offset,
|  | uint8_t | budget
| ) |  |

inline static

References osmo_earfcn_si2q::arfcn, bitvec_set_bit(), bitvec_set_uint(), osmo_earfcn_si2q::length, osmo_earfcn_si2q::meas_bw, OSMO_ASSERT, OSMO_EARFCN_INVALID, OSMO_EARFCN_MEAS_INVALID, osmo_earfcn_si2q::prio, osmo_earfcn_si2q::prio_valid, osmo_earfcn_si2q::qrxlm, osmo_earfcn_si2q::qrxlm_valid, SI2Q_MAX_LEN, osmo_earfcn_si2q::thresh_hi, osmo_earfcn_si2q::thresh_lo, and osmo_earfcn_si2q::thresh_lo_valid.

Referenced by append_earfcn().

## append_gprs_cell_opt()

static int append_gprs_cell_opt | ( | struct bitvec * | bv,
|  | const struct osmo_gprs_cell_options * | gco
| ) |  |

static

References osmo_gprs_cell_options::bep_period, bitvec_set_bit(), bitvec_set_uint(), osmo_gprs_cell_options::bs_cv_max, osmo_gprs_cell_options::bss_paging_coordination, osmo_gprs_cell_options::ccn_active, osmo_gprs_cell_options::ctrl_ack_type_use_block, osmo_gprs_cell_options::drx_timer_max, osmo_gprs_cell_options::dtm_supported, osmo_gprs_cell_options::egprs_supported, encode_drx_timer(), encode_t3192(), osmo_gprs_cell_options::ext_info, osmo_gprs_cell_options::ext_info_present, osmo_gprs_cell_options::nmo, osmo_gprs_cell_options::pfc_supported, osmo_gprs_cell_options::t3168, osmo_gprs_cell_options::t3192, and osmo_gprs_cell_options::use_egprs_p_ch_req.

Referenced by osmo_gsm48_rest_octets_si13_encode().

## append_gprs_ind()

static void append_gprs_ind | ( | struct bitvec * | bv,
|  | const struct osmo_gsm48_si3_gprs_ind * | gi
| ) |  |

static

References bitvec_set_bit(), bitvec_set_uint(), H, L, osmo_gsm48_si3_gprs_ind::present, osmo_gsm48_si3_gprs_ind::ra_colour, and osmo_gsm48_si3_gprs_ind::si13_position.

Referenced by osmo_gsm48_rest_octets_si3_encode(), and osmo_gsm48_rest_octets_si4_encode().

## append_gprs_mobile_alloc()

static int append_gprs_mobile_alloc | ( | struct bitvec * | bv | ) |

static

References bitvec_set_bit(), and bitvec_set_uint().

Referenced by osmo_gsm48_rest_octets_si13_encode().

## append_gprs_pwr_ctrl_pars()

static void append_gprs_pwr_ctrl_pars | ( | struct bitvec * | bv,
|  | const struct osmo_gprs_power_ctrl_pars * | pcp
| ) |  |

static

References osmo_gprs_power_ctrl_pars::alpha, bitvec_set_uint(), osmo_gprs_power_ctrl_pars::n_avg_i, osmo_gprs_power_ctrl_pars::pc_meas_chan, osmo_gprs_power_ctrl_pars::t_avg_t, and osmo_gprs_power_ctrl_pars::t_avg_w.

Referenced by osmo_gsm48_rest_octets_si13_encode().

## append_lsa_params()

static int append_lsa_params | ( | struct bitvec * | bv,
|  | const struct osmo_gsm48_lsa_params * | lsa_params
| ) |  |

static

Referenced by osmo_gsm48_rest_octets_si4_encode().

## append_power_offset()

static void append_power_offset | ( | struct bitvec * | bv,
|  | const struct osmo_gsm48_si_power_offset * | po
| ) |  |

static

References bitvec_set_bit(), bitvec_set_uint(), H, L, osmo_gsm48_si_power_offset::power_offset, and osmo_gsm48_si_power_offset::present.

Referenced by osmo_gsm48_rest_octets_si3_encode(), and osmo_gsm48_rest_octets_si4_encode().

## append_selection_params()

static void append_selection_params | ( | struct bitvec * | bv,
|  | const struct osmo_gsm48_si_selection_params * | sp
| ) |  |

static

References bitvec_set_bit(), bitvec_set_uint(), osmo_gsm48_si_selection_params::cbq, osmo_gsm48_si_selection_params::cell_resel_off, H, L, osmo_gsm48_si_selection_params::penalty_time, osmo_gsm48_si_selection_params::present, and osmo_gsm48_si_selection_params::temp_offs.

Referenced by osmo_gsm48_rest_octets_si3_encode(), and osmo_gsm48_rest_octets_si4_encode().

## append_uarfcns()

static void append_uarfcns | ( | struct bitvec * | bv,
|  | const uint16_t * | uarfcn_list,
|  | size_t * | u_offset,
|  | size_t | uarfcn_length,
|  | uint16_t * | scramble_list,
|  | uint8_t | budget
| ) |  |

inline static

References bitvec_set_bit(), OSMO_ASSERT, SI2Q_MAX_LEN, and try_adding_uarfcn().

Referenced by osmo_gsm48_rest_octets_si2quater_encode().

## append_utran_fdd()

static int append_utran_fdd | ( | struct bitvec * | bv,
|  | uint16_t | u,
|  | int * | sc,
|  | size_t | length
| ) |  |

inline static

References bitvec_add_range1024(), bitvec_set_bit(), bitvec_set_uint(), bitvec::cur_bit, f0_helper(), length, and range1024_p().

Referenced by try_adding_uarfcn().

## append_utran_fdd_length()

static int append_utran_fdd_length | ( | uint16_t | u,
|  | const int * | sc,
|  | size_t | sc_len,
|  | size_t | length
| ) |  |

inline static

References f0_helper(), length, and range1024_p().

Referenced by try_adding_uarfcn().

## decode_drx_timer()

static unsigned int decode_drx_timer | ( | unsigned int | drx | ) |

static

References OSMO_ASSERT.

Referenced by decode_gprs_cell_opt().

## decode_gprs_cell_opt()

static int decode_gprs_cell_opt | ( | struct osmo_gprs_cell_options * | gco,
|  | struct bitvec * | bv
| ) |  |

static

References osmo_gprs_cell_options::bep_period, bitvec_get_uint(), osmo_gprs_cell_options::bs_cv_max, osmo_gprs_cell_options::bss_paging_coordination, osmo_gprs_cell_options::ccn_active, osmo_gprs_cell_options::ctrl_ack_type_use_block, bitvec::cur_bit, decode_drx_timer(), decode_t3192(), osmo_gprs_cell_options::drx_timer_max, osmo_gprs_cell_options::dtm_supported, osmo_gprs_cell_options::egprs_supported, osmo_gprs_cell_options::ext_info, osmo_gprs_cell_options::nmo, osmo_gprs_cell_options::pfc_supported, osmo_gprs_cell_options::t3168, osmo_gprs_cell_options::t3192, and osmo_gprs_cell_options::use_egprs_p_ch_req.

Referenced by osmo_gsm48_rest_octets_si13_decode().

## decode_gprs_pwr_ctrl_pars()

static void decode_gprs_pwr_ctrl_pars | ( | struct osmo_gprs_power_ctrl_pars * | pcp,
|  | struct bitvec * | bv
| ) |  |

static

References osmo_gprs_power_ctrl_pars::alpha, bitvec_get_uint(), osmo_gprs_power_ctrl_pars::n_avg_i, osmo_gprs_power_ctrl_pars::pc_meas_chan, osmo_gprs_power_ctrl_pars::t_avg_t, and osmo_gprs_power_ctrl_pars::t_avg_w.

Referenced by osmo_gsm48_rest_octets_si13_decode().

## decode_t3192()

static unsigned int decode_t3192 | ( | unsigned int | t3192 | ) |

static

References OSMO_ASSERT.

Referenced by decode_gprs_cell_opt().

## encode_drx_timer()

static int encode_drx_timer | ( | unsigned int | drx | ) |

static

Referenced by append_gprs_cell_opt().

## encode_t3192()

static int encode_t3192 | ( | unsigned int | t3192 | ) |

static

Referenced by append_gprs_cell_opt().

## f0_helper()

static int f0_helper | ( | int * | sc,
|  | size_t | length,
|  | uint8_t * | chan_list
| ) |  |

inline static

References length, OSMO_GSM48_ARFCN_RANGE_1024, OSMO_GSM48_RANGE_ENC_MAX_ARFCNS, and range_encode().

Referenced by append_utran_fdd(), and append_utran_fdd_length().

## osmo_gsm48_rest_octets_si13_decode()

int osmo_gsm48_rest_octets_si13_decode | ( | struct osmo_gsm48_si13_info * | si13,
|  | const uint8_t * | data
| ) |  |

Decode SI13 Rest Octests (04.08 Chapter 10.5.2.37b).

Parameters

  [out] | si13 | decoded SI13 rest octets
  [in] | encoded | SI13 rest octets

Returns
  parsed bits on success, negative on error

References osmo_gsm48_si13_info::bcch_change_mark, bitvec_get_bit_high(), bitvec_get_uint(), osmo_gsm48_si13_info::cell_opts, bitvec::cur_bit, bitvec::data, data, bitvec::data_len, decode_gprs_cell_opt(), decode_gprs_pwr_ctrl_pars(), ENOTSUP, H, osmo_gsm48_si13_info::net_ctrl_ord, osmo_gsm48_si13_info::prio_acc_thr, osmo_gsm48_si13_info::pwr_ctrl_pars, osmo_gsm48_si13_info::rac, osmo_gsm48_si13_info::si_change_field, and osmo_gsm48_si13_info::spgc_ccch_sup.

## osmo_gsm48_rest_octets_si13_encode()

int osmo_gsm48_rest_octets_si13_encode | ( | uint8_t * | data,
|  | const struct osmo_gsm48_si13_info * | si13
| ) |  |

References append_gprs_cell_opt(), append_gprs_mobile_alloc(), append_gprs_pwr_ctrl_pars(), osmo_gsm48_si13_info::bcch_change_mark, bitvec_set_bit(), bitvec_set_uint(), bitvec_spare_padding(), osmo_gsm48_si13_info::cell_opts, bitvec::data, data, bitvec::data_len, H, L, osmo_gsm48_si13_info::net_ctrl_ord, osmo_gsm48_si13_info::prio_acc_thr, osmo_gsm48_si13_info::pwr_ctrl_pars, osmo_gsm48_si13_info::rac, osmo_gsm48_si13_info::si_change_field, and osmo_gsm48_si13_info::spgc_ccch_sup.

## osmo_gsm48_rest_octets_si1_encode()

int osmo_gsm48_rest_octets_si1_encode | ( | uint8_t * | data,
|  | uint8_t * | nch_pos,
|  | int | is1800_net
| ) |  |

References bitvec_set_bit(), bitvec_set_uint(), bitvec_spare_padding(), bitvec::data, data, bitvec::data_len, H, and L.

## osmo_gsm48_rest_octets_si2quater_encode()

int osmo_gsm48_rest_octets_si2quater_encode | ( | uint8_t * | data,
|  | uint8_t | si2q_index,
|  | uint8_t | si2q_count,
|  | const uint16_t * | uarfcn_list,
|  | size_t * | u_offset,
|  | size_t | uarfcn_length,
|  | uint16_t * | scramble_list,
|  | struct osmo_earfcn_si2q * | si2quater_neigh_list,
|  | size_t * | e_offset
| ) |  |

References append_earfcn(), append_uarfcns(), bitvec_set_bit(), bitvec_set_uint(), bitvec_spare_padding(), bitvec_zero(), bitvec::cur_bit, bitvec::data, data, bitvec::data_len, L, si2q_earfcn_count(), and SI2Q_MAX_LEN.

## osmo_gsm48_rest_octets_si3_decode()

void osmo_gsm48_rest_octets_si3_decode | ( | struct osmo_gsm48_si_ro_info * | si3,
|  | const uint8_t * | data
| ) |  |

Decode SI3 Rest Octests (Chapter 10.5.2.34 / Table 10.4.72).

Parameters

  [out] | si3 | decoded SI3 rest octets
  [in] | encoded | SI3 rest octets, 4 octets long

References bitvec_get_bit_high(), bitvec_get_uint(), osmo_gsm48_si_selection_params::cbq, osmo_gsm48_si_selection_params::cell_resel_off, bitvec::data, data, bitvec::data_len, osmo_gsm48_si_ro_info::early_cm_ctrl, osmo_gsm48_si_ro_info::early_cm_restrict_3g, osmo_gsm48_si_ro_info::gprs_ind, H, osmo_gsm48_si_selection_params::penalty_time, osmo_gsm48_si_power_offset::power_offset, osmo_gsm48_si_ro_info::power_offset, osmo_gsm48_si_selection_params::present, osmo_gsm48_si_power_offset::present, osmo_gsm48_si3_gprs_ind::present, osmo_gsm48_si_ro_info::present, osmo_gsm48_si3_gprs_ind::ra_colour, osmo_gsm48_si_ro_info::scheduling, osmo_gsm48_si_ro_info::selection_params, osmo_gsm48_si3_gprs_ind::si13_position, osmo_gsm48_si_ro_info::si2quater_indicator, osmo_gsm48_si_ro_info::si2ter_indicator, osmo_gsm48_si_selection_params::temp_offs, and osmo_gsm48_si_ro_info::where.

## osmo_gsm48_rest_octets_si3_encode()

int osmo_gsm48_rest_octets_si3_encode | ( | uint8_t * | data,
|  | const struct osmo_gsm48_si_ro_info * | si3
| ) |  |

References append_gprs_ind(), append_power_offset(), append_selection_params(), bitvec_set_bit(), bitvec_set_uint(), bitvec_spare_padding(), bitvec::data, data, bitvec::data_len, osmo_gsm48_si_ro_info::early_cm_ctrl, osmo_gsm48_si_ro_info::early_cm_restrict_3g, osmo_gsm48_si_ro_info::gprs_ind, H, L, osmo_gsm48_si_ro_info::power_offset, osmo_gsm48_si_ro_info::present, osmo_gsm48_si_ro_info::scheduling, osmo_gsm48_si_ro_info::selection_params, osmo_gsm48_si_ro_info::si2quater_indicator, osmo_gsm48_si_ro_info::si2ter_indicator, and osmo_gsm48_si_ro_info::where.

## osmo_gsm48_rest_octets_si4_decode()

void osmo_gsm48_rest_octets_si4_decode | ( | struct osmo_gsm48_si_ro_info * | si4,
|  | const uint8_t * | data,
|  | int | len
| ) |  |

References bitvec_get_bit_high(), bitvec_get_uint(), osmo_gsm48_si_selection_params::cbq, osmo_gsm48_si_selection_params::cell_resel_off, bitvec::data, data, bitvec::data_len, osmo_gsm48_si_ro_info::gprs_ind, H, len, osmo_gsm48_si_selection_params::penalty_time, osmo_gsm48_si_power_offset::power_offset, osmo_gsm48_si_ro_info::power_offset, osmo_gsm48_si_selection_params::present, osmo_gsm48_si_power_offset::present, osmo_gsm48_si3_gprs_ind::present, osmo_gsm48_si3_gprs_ind::ra_colour, osmo_gsm48_si_ro_info::selection_params, osmo_gsm48_si3_gprs_ind::si13_position, and osmo_gsm48_si_selection_params::temp_offs.

## osmo_gsm48_rest_octets_si4_encode()

int osmo_gsm48_rest_octets_si4_encode | ( | uint8_t * | data,
|  | const struct osmo_gsm48_si_ro_info * | si4,
|  | int | len
| ) |  |

References append_gprs_ind(), append_lsa_params(), append_power_offset(), append_selection_params(), bitvec_set_bit(), bitvec_set_uint(), osmo_gsm48_si_ro_info::break_ind, osmo_gsm48_si_ro_info::cell_id, bitvec::data, data, bitvec::data_len, osmo_gsm48_si_ro_info::gprs_ind, H, L, len, osmo_gsm48_si_ro_info::lsa_params, osmo_gsm48_si_ro_info::power_offset, osmo_gsm48_lsa_params::present, and osmo_gsm48_si_ro_info::selection_params.

## osmo_gsm48_rest_octets_si6_encode()

int osmo_gsm48_rest_octets_si6_encode | ( | uint8_t * | data,
|  | const struct osmo_gsm48_si6_ro_info * | in
| ) |  |

References osmo_gsm48_si6_ro_info::band_indicator_1900, bitvec_set_bit(), bitvec_set_uint(), bitvec_spare_padding(), osmo_gsm48_si_pch_nch_info::call_priority, osmo_gsm48_si_pch_nch_info::call_priority_present, bitvec::data, data, bitvec::data_len, osmo_gsm48_si6_ro_info::dtm_support, osmo_gsm48_si6_ro_info::gprs_ms_txpwr_max_ccch, H, osmo_gsm48_si_vbs_vgcs_options::inband_notifications, osmo_gsm48_si_vbs_vgcs_options::inband_pagings, L, osmo_gsm48_si_dtm_support::max_lapdm, osmo_gsm48_si_gprs_ms_txpwr_max_ccch::max_txpwr, osmo_gsm48_si_pch_nch_info::nln_sacch, osmo_gsm48_si_pch_nch_info::nln_status_sacch, osmo_gsm48_si_pch_nch_info::paging_channel_restructuring, osmo_gsm48_si6_ro_info::pch_nch_info, osmo_gsm48_si_pch_nch_info::present, osmo_gsm48_si_vbs_vgcs_options::present, osmo_gsm48_si_dtm_support::present, osmo_gsm48_si_gprs_ms_txpwr_max_ccch::present, osmo_gsm48_si_dtm_support::rac, and osmo_gsm48_si6_ro_info::vbs_vgcs_options.

## range1024_p()

static unsigned range1024_p | ( | unsigned | n | ) |

static

References n.

Referenced by append_utran_fdd(), and append_utran_fdd_length().

## range_encode()

static int range_encode | ( | enum osmo_gsm48_range | r,
|  | int * | arfcns,
|  | int | arfcns_used,
|  | int * | w,
|  | int | f0,
|  | uint8_t * | chan_list
| ) |  |

static

References OSMO_GSM48_ARFCN_RANGE_1024, OSMO_GSM48_ARFCN_RANGE_128, OSMO_GSM48_ARFCN_RANGE_256, OSMO_GSM48_ARFCN_RANGE_512, osmo_gsm48_range_enc_1024(), osmo_gsm48_range_enc_128(), osmo_gsm48_range_enc_256(), osmo_gsm48_range_enc_512(), osmo_gsm48_range_enc_arfcns(), and osmo_gsm48_range_enc_filter_arfcns().

Referenced by f0_helper().

## si2q_earfcn_count()

static size_t si2q_earfcn_count | ( | const struct osmo_earfcn_si2q * | e | ) |

static

References osmo_earfcn_si2q::arfcn, osmo_earfcn_si2q::length, and OSMO_EARFCN_INVALID.

Referenced by osmo_gsm48_rest_octets_si2quater_encode().

## try_adding_uarfcn()

static int try_adding_uarfcn | ( | struct bitvec * | bv,
|  | uint16_t * | scramble_list,
|  | size_t | uarfcn_length,
|  | size_t * | u_offset,
|  | uint16_t | uarfcn,
|  | uint8_t | num_sc,
|  | uint8_t | start_pos,
|  | uint8_t | budget
| ) |  |

inline static

References append_utran_fdd(), and append_utran_fdd_length().

Referenced by append_uarfcns().