Loading...
Searching...
No Matches
gprs_bssgp2.c File Reference
`#include <osmocom/core/utils.h>`
`#include <osmocom/core/byteswap.h>`
`#include <osmocom/core/msgb.h>`
`#include <osmocom/gsm/gsm48.h>`
`#include <osmocom/gsm/tlv.h>`
`#include <osmocom/gprs/gprs_ns2.h>`
`#include <osmocom/gprs/gprs_bssgp.h>`
`#include <osmocom/gprs/gprs_bssgp2.h>`

## Functions

int | bssgp2_nsi_tx_ptp (struct gprs_ns2_inst *nsi, uint16_t nsei, uint16_t bvci, struct msgb *msg, uint32_t lsp)
| transmit BSSGP PDU over NS (PTP BVC)
int | bssgp2_nsi_tx_sig (struct gprs_ns2_inst *nsi, uint16_t nsei, struct msgb *msg, uint32_t lsp)
| transmit BSSGP PDU over NS (SIGNALING BVC)
struct msgb * | bssgp2_enc_bvc_block (uint16_t bvci, enum gprs_bssgp_cause cause)
| Encode BSSGP BVC-BLOCK PDU as per TS 48.018 Section 10.4.8.
struct msgb * | bssgp2_enc_bvc_block_ack (uint16_t bvci)
| Encode BSSGP BVC-BLOCK-ACK PDU as per TS 48.018 Section 10.4.9.
struct msgb * | bssgp2_enc_bvc_unblock (uint16_t bvci)
| Encode BSSGP BVC-UNBLOCK PDU as per TS 48.018 Section 10.4.10.
struct msgb * | bssgp2_enc_bvc_unblock_ack (uint16_t bvci)
| Encode BSSGP BVC-UNBLOCK-ACK PDU as per TS 48.018 Section 10.4.11.
struct msgb * | bssgp2_enc_bvc_reset (uint16_t bvci, enum gprs_bssgp_cause cause, const struct gprs_ra_id *ra_id, uint16_t cell_id, const uint8_t *feat_bm, const uint8_t *ext_feat_bm)
| Encode BSSGP BVC-RESET PDU as per TS 48.018 Section 10.4.12.
struct msgb * | bssgp2_enc_bvc_reset_ack (uint16_t bvci, const struct gprs_ra_id *ra_id, uint16_t cell_id, const uint8_t *feat_bm, const uint8_t *ext_feat_bm)
| Encode BSSGP BVC-RESET-ACK PDU as per TS 48.018 Section 10.4.13.
struct msgb * | bssgp2_enc_status (uint8_t cause, const uint16_t *bvci, const struct msgb *orig_msg, uint16_t max_pdu_len)
| Encode BSSGP STATUS PDU as per TS 48.018 Section 10.4.14.
int | bssgp2_dec_fc_bvc (struct bssgp2_flow_ctrl *fc, const struct tlv_parsed *tp)
| Decode a FLOW-CONTROL-BVC PDU as per TS 48.018 Section 10.4.4.
struct msgb * | bssgp2_enc_fc_bvc (const struct bssgp2_flow_ctrl *fc, enum bssgp_fc_granularity *gran)
| Encode a FLOW-CONTROL-BVC PDU as per TS 48.018 Section 10.4.4.
struct msgb * | bssgp2_enc_flush_ll (uint32_t tlli, uint16_t old_bvci, const uint16_t *new_bvci, const uint16_t *nsei)
| Encode BSSGP FLUSH-LL PDU as per TS 48.018 Section 10.4.1.
struct msgb * | bssgp2_enc_fc_bvc_ack (uint8_t tag)
| Encode a FLOW-CONTROL-BVC-ACK PDU as per TS 48.018 Section 10.4.4.
int | bssgp2_dec_fc_ms (struct bssgp2_flow_ctrl *fc, struct tlv_parsed *tp)
| Decode a FLOW-CONTROL-MS PDU as per TS 48.018 Section 10.4.6.
struct msgb * | bssgp2_enc_fc_ms (const struct bssgp2_flow_ctrl *fc, enum bssgp_fc_granularity *gran)
| Encode a FLOW-CONTROL-MS PDU as per TS 48.018 Section 10.4.6.
struct msgb * | bssgp2_enc_fc_ms_ack (uint32_t tlli, uint8_t tag)
| Encode a FLOW-CONTROL-BVC-ACK PDU as per TS 48.018 Section 10.4.7.

## Variables

static const unsigned int | bssgp_fc_gran_tbl []

## Function Documentation

## bssgp2_dec_fc_bvc()

int bssgp2_dec_fc_bvc | ( | struct bssgp2_flow_ctrl * | fc,
|  | const struct tlv_parsed * | tp
| ) |  |

Decode a FLOW-CONTROL-BVC PDU as per TS 48.018 Section 10.4.4.

Parameters

  [out] | fc | caller-allocated memory for parsed output
  [in] | tp | pre-parsed TLVs; caller must ensure mandatory IE presence/length

Returns
  0 on success; negative in case of error

References bssgp2_flow_ctrl::bmax_default_ms, bssgp_fc_gran_tbl, BSSGP_IE_BMAX_DEFAULT_MS, BSSGP_IE_BUCKET_FULL_RATIO, BSSGP_IE_BUCKET_LEAK_RATE, BSSGP_IE_BVC_BUCKET_SIZE, BSSGP_IE_BVC_MEASUREMENT, BSSGP_IE_FLOW_CTRL_GRANULARITY, BSSGP_IE_R_DEFAULT_MS, BSSGP_IE_TAG, bssgp2_flow_ctrl::bucket_full_ratio, bssgp2_flow_ctrl::bucket_full_ratio_present, bssgp2_flow_ctrl::bucket_leak_rate, bssgp2_flow_ctrl::bucket_size_max, bssgp2_flow_ctrl::bvc, bssgp2_flow_ctrl::measurement, bssgp2_flow_ctrl::measurement_present, bssgp2_flow_ctrl::r_default_ms, bssgp2_flow_ctrl::tag, TLVP_PRESENT, TLVP_VAL, and bssgp2_flow_ctrl::u.

Referenced by bssgp_bvc_fsm_unblocked().

## bssgp2_dec_fc_ms()

int bssgp2_dec_fc_ms | ( | struct bssgp2_flow_ctrl * | fc,
|  | struct tlv_parsed * | tp
| ) |  |

Decode a FLOW-CONTROL-MS PDU as per TS 48.018 Section 10.4.6.

Parameters

  [out] | fc | caller-allocated memory for parsed output
  [in] | tp | pre-parsed TLVs; caller must ensure mandatory IE presence/length

Returns
  0 on success; negative in case of error

References bssgp_fc_gran_tbl, BSSGP_IE_BUCKET_FULL_RATIO, BSSGP_IE_BUCKET_LEAK_RATE, BSSGP_IE_FLOW_CTRL_GRANULARITY, BSSGP_IE_MS_BUCKET_SIZE, BSSGP_IE_TAG, BSSGP_IE_TLLI, bssgp2_flow_ctrl::bucket_full_ratio, bssgp2_flow_ctrl::bucket_full_ratio_present, bssgp2_flow_ctrl::bucket_leak_rate, bssgp2_flow_ctrl::bucket_size_max, bssgp2_flow_ctrl::ms, bssgp2_flow_ctrl::tag, bssgp2_flow_ctrl::tlli, TLVP_PRESENT, TLVP_VAL, and bssgp2_flow_ctrl::u.

## bssgp2_enc_bvc_block()

struct msgb * bssgp2_enc_bvc_block | ( | uint16_t | bvci,
|  | enum gprs_bssgp_cause | cause
| ) |  |

Encode BSSGP BVC-BLOCK PDU as per TS 48.018 Section 10.4.8.

References BSSGP_IE_BVCI, BSSGP_IE_CAUSE, bssgp_msgb_alloc(), BSSGP_PDUT_BVC_BLOCK, bvci, cause, msg, osmo_htons, and bssgp_normal_hdr::pdu_type.

Referenced by bssgp_bvc_fsm_timer_cb(), bssgp_bvc_fsm_unblocked(), and bssgp_bvc_fsm_wait_reset_ack().

## bssgp2_enc_bvc_block_ack()

struct msgb * bssgp2_enc_bvc_block_ack | ( | uint16_t | bvci | ) |

Encode BSSGP BVC-BLOCK-ACK PDU as per TS 48.018 Section 10.4.9.

References BSSGP_IE_BVCI, bssgp_msgb_alloc(), BSSGP_PDUT_BVC_BLOCK_ACK, bvci, msg, osmo_htons, and bssgp_normal_hdr::pdu_type.

Referenced by bssgp_bvc_fsm_blocked(), and bssgp_bvc_fsm_unblocked().

## bssgp2_enc_bvc_reset()

struct msgb * bssgp2_enc_bvc_reset | ( | uint16_t | bvci,
|  | enum gprs_bssgp_cause | cause,
|  | const struct gprs_ra_id * | ra_id,
|  | uint16_t | cell_id,
|  | const uint8_t * | feat_bm,
|  | const uint8_t * | ext_feat_bm
| ) |  |

Encode BSSGP BVC-RESET PDU as per TS 48.018 Section 10.4.12.

Parameters

  [in] | bvci | PTP BVCI to encode into the BVCI IE
  [in] | cause | BSSGP Cause value (reason for reset)
  [in] | ra_id | Routing Area ID to be encoded to CELL_ID IE (optional)
  [in] | cell_id | Cell ID to be encoded to CELL_ID IE (only if ra_id is non-NULL)
  [in] | feat_bm | Feature Bitmap (optional)
  [in] | ext_feat_bm | Extended Feature Bitmap (optional)

References bssgp_create_cell_id(), BSSGP_IE_BVCI, BSSGP_IE_CAUSE, BSSGP_IE_CELL_ID, BSSGP_IE_EXT_FEATURE_BITMAP, BSSGP_IE_FEATURE_BITMAP, bssgp_msgb_alloc(), BSSGP_PDUT_BVC_RESET, bvci, cause, msg, osmo_htons, bssgp_normal_hdr::pdu_type, and ra_id.

Referenced by _tx_bvc_reset().

## bssgp2_enc_bvc_reset_ack()

struct msgb * bssgp2_enc_bvc_reset_ack | ( | uint16_t | bvci,
|  | const struct gprs_ra_id * | ra_id,
|  | uint16_t | cell_id,
|  | const uint8_t * | feat_bm,
|  | const uint8_t * | ext_feat_bm
| ) |  |

Encode BSSGP BVC-RESET-ACK PDU as per TS 48.018 Section 10.4.13.

Parameters

  [in] | bvci | PTP BVCI to encode into the BVCI IE
  [in] | ra_id | Routing Area ID to be encoded to CELL_ID IE (optional)
  [in] | cell_id | Cell ID to be encoded to CELL_ID IE (only if ra_id is non-NULL)
  [in] | feat_bm | Feature Bitmap (optional)
  [in] | ext_feat_bm | Extended Feature Bitmap (optional)

References bssgp_create_cell_id(), BSSGP_IE_BVCI, BSSGP_IE_CELL_ID, BSSGP_IE_EXT_FEATURE_BITMAP, BSSGP_IE_FEATURE_BITMAP, bssgp_msgb_alloc(), BSSGP_PDUT_BVC_RESET_ACK, bvci, msg, osmo_htons, bssgp_normal_hdr::pdu_type, and ra_id.

Referenced by _tx_bvc_reset_ack().

## bssgp2_enc_bvc_unblock()

struct msgb * bssgp2_enc_bvc_unblock | ( | uint16_t | bvci | ) |

Encode BSSGP BVC-UNBLOCK PDU as per TS 48.018 Section 10.4.10.

References BSSGP_IE_BVCI, bssgp_msgb_alloc(), BSSGP_PDUT_BVC_UNBLOCK, bvci, msg, osmo_htons, and bssgp_normal_hdr::pdu_type.

Referenced by bssgp_bvc_fsm_blocked(), and bssgp_bvc_fsm_timer_cb().

## bssgp2_enc_bvc_unblock_ack()

struct msgb * bssgp2_enc_bvc_unblock_ack | ( | uint16_t | bvci | ) |

Encode BSSGP BVC-UNBLOCK-ACK PDU as per TS 48.018 Section 10.4.11.

References BSSGP_IE_BVCI, bssgp_msgb_alloc(), BSSGP_PDUT_BVC_UNBLOCK_ACK, bvci, msg, osmo_htons, and bssgp_normal_hdr::pdu_type.

Referenced by bssgp_bvc_fsm_blocked().

## bssgp2_enc_fc_bvc()

struct msgb * bssgp2_enc_fc_bvc | ( | const struct bssgp2_flow_ctrl * | fc,
|  | enum bssgp_fc_granularity * | gran
| ) |  |

Encode a FLOW-CONTROL-BVC PDU as per TS 48.018 Section 10.4.4.

Parameters

  [in] | fc | structure describing to-be-encoded FC parameters
  [in] | gran | if non-NULL: Encode using specified unit granularity

Returns
  encoded PDU or NULL in case of error

References bssgp2_flow_ctrl::bmax_default_ms, bssgp_fc_gran_tbl, BSSGP_IE_BMAX_DEFAULT_MS, BSSGP_IE_BUCKET_FULL_RATIO, BSSGP_IE_BUCKET_LEAK_RATE, BSSGP_IE_BVC_BUCKET_SIZE, BSSGP_IE_BVC_MEASUREMENT, BSSGP_IE_FLOW_CTRL_GRANULARITY, BSSGP_IE_R_DEFAULT_MS, BSSGP_IE_TAG, bssgp_msgb_alloc(), BSSGP_PDUT_FLOW_CONTROL_BVC, bssgp2_flow_ctrl::bucket_full_ratio, bssgp2_flow_ctrl::bucket_full_ratio_present, bssgp2_flow_ctrl::bucket_leak_rate, bssgp2_flow_ctrl::bucket_size_max, bssgp2_flow_ctrl::bvc, bssgp2_flow_ctrl::measurement, bssgp2_flow_ctrl::measurement_present, msg, bssgp_normal_hdr::pdu_type, bssgp2_flow_ctrl::r_default_ms, bssgp2_flow_ctrl::tag, and bssgp2_flow_ctrl::u.

Referenced by bssgp_bvc_fsm_unblocked().

## bssgp2_enc_fc_bvc_ack()

struct msgb * bssgp2_enc_fc_bvc_ack | ( | uint8_t | tag | ) |

Encode a FLOW-CONTROL-BVC-ACK PDU as per TS 48.018 Section 10.4.4.

Parameters

  [in] | tag | the tag IE value to encode

Returns
  encoded PDU or NULL in case of error

References BSSGP_IE_TAG, bssgp_msgb_alloc(), BSSGP_PDUT_FLOW_CONTROL_BVC_ACK, msg, and bssgp_normal_hdr::pdu_type.

Referenced by bssgp_bvc_fsm_unblocked().

## bssgp2_enc_fc_ms()

struct msgb * bssgp2_enc_fc_ms | ( | const struct bssgp2_flow_ctrl * | fc,
|  | enum bssgp_fc_granularity * | gran
| ) |  |

Encode a FLOW-CONTROL-MS PDU as per TS 48.018 Section 10.4.6.

Parameters

  [in] | fc | structure describing to-be-encoded FC parameters
  [in] | gran | if non-NULL: Encode using specified unit granularity

Returns
  encoded PDU or NULL in case of error

References bssgp_fc_gran_tbl, BSSGP_IE_BUCKET_FULL_RATIO, BSSGP_IE_BUCKET_LEAK_RATE, BSSGP_IE_FLOW_CTRL_GRANULARITY, BSSGP_IE_MS_BUCKET_SIZE, BSSGP_IE_TAG, BSSGP_IE_TLLI, bssgp_msgb_alloc(), BSSGP_PDUT_FLOW_CONTROL_MS, bssgp2_flow_ctrl::bucket_full_ratio, bssgp2_flow_ctrl::bucket_full_ratio_present, bssgp2_flow_ctrl::bucket_leak_rate, bssgp2_flow_ctrl::bucket_size_max, bssgp2_flow_ctrl::ms, msg, bssgp_normal_hdr::pdu_type, bssgp2_flow_ctrl::tag, bssgp2_flow_ctrl::tlli, and bssgp2_flow_ctrl::u.

## bssgp2_enc_fc_ms_ack()

struct msgb * bssgp2_enc_fc_ms_ack | ( | uint32_t | tlli,
|  | uint8_t | tag
| ) |  |

Encode a FLOW-CONTROL-BVC-ACK PDU as per TS 48.018 Section 10.4.7.

Parameters

  [in] | tlli | the TLLI IE value to encode
  [in] | tag | the tag IE value to encode

Returns
  encoded PDU or NULL in case of error

References BSSGP_IE_TAG, BSSGP_IE_TLLI, bssgp_msgb_alloc(), BSSGP_PDUT_FLOW_CONTROL_MS_ACK, msg, bssgp_normal_hdr::pdu_type, and tlli.

## bssgp2_enc_flush_ll()

struct msgb * bssgp2_enc_flush_ll | ( | uint32_t | tlli,
|  | uint16_t | old_bvci,
|  | const uint16_t * | new_bvci,
|  | const uint16_t * | nsei
| ) |  |

Encode BSSGP FLUSH-LL PDU as per TS 48.018 Section 10.4.1.

Parameters

  [in] | tlli | - the TLLI of the MS
  [in] | old_bvci | BVCI
  [in] | new_bvci2 | optional BVCI - only encoded if non-NULL
  [in] | nsei | optional - only encoded if non-NULL

Returns
  encoded PDU or NULL in case of error

References BSSGP_IE_BVCI, BSSGP_IE_TLLI, bssgp_msgb_alloc(), BSSGP_PDUT_FLUSH_LL, msg, nsei, bssgp_normal_hdr::pdu_type, and tlli.

## bssgp2_enc_status()

struct msgb * bssgp2_enc_status | ( | uint8_t | cause,
|  | const uint16_t * | bvci,
|  | const struct msgb * | orig_msg,
|  | uint16_t | max_pdu_len
| ) |  |

Encode BSSGP STATUS PDU as per TS 48.018 Section 10.4.14.

Parameters

  [in] | cause | BSSGP Cause value
  [in] | bvci | optional BVCI - only encoded if non-NULL
  [in] | msg | optional message buffer containing PDU in error - only encoded if non-NULL
  [in] | max_pdu_len | Maximum BSSGP PDU size the NS layer accepts

References BSSGP_IE_BVCI, BSSGP_IE_CAUSE, BSSGP_IE_PDU_IN_ERROR, bssgp_msgb_alloc(), BSSGP_PDUT_STATUS, bvci, cause, msg, msgb_bssgp_len, msgb_bssgph, msgb_length(), osmo_htons, and bssgp_normal_hdr::pdu_type.

Referenced by _tx_status().

## bssgp2_nsi_tx_ptp()

int bssgp2_nsi_tx_ptp | ( | struct gprs_ns2_inst * | nsi,
|  | uint16_t | nsei,
|  | uint16_t | bvci,
|  | struct msgb * | msg,
|  | uint32_t | lsp
| ) |  |

transmit BSSGP PDU over NS (PTP BVC)

Parameters

  [in] | nsi | NS Instance through which to transmit
  [in] | nsei | NSEI of NSE through which to transmit
  [in] | bvci | BVCI through which to transmit
  [in] | msg | BSSGP PDU to transmit

Returns
  0 on success; negative on error

References bvci, osmo_gprs_ns2_prim::bvci, GPRS_NS2_PRIM_UNIT_DATA, gprs_ns2_recv_prim(), osmo_gprs_ns2_prim::link_selector, msg, nsei, osmo_gprs_ns2_prim::nsei, osmo_gprs_ns2_prim::oph, PRIM_OP_REQUEST, SAP_NS, osmo_gprs_ns2_prim::u, and osmo_gprs_ns2_prim::unitdata.

Referenced by bssgp2_nsi_tx_sig(), and fi_tx_ptp().

## bssgp2_nsi_tx_sig()

int bssgp2_nsi_tx_sig | ( | struct gprs_ns2_inst * | nsi,
|  | uint16_t | nsei,
|  | struct msgb * | msg,
|  | uint32_t | lsp
| ) |  |

transmit BSSGP PDU over NS (SIGNALING BVC)

Parameters

  [in] | nsi | NS Instance through which to transmit
  [in] | nsei | NSEI of NSE through which to transmit
  [in] | msg | BSSGP PDU to transmit

Returns
  0 on success; negative on error

References bssgp2_nsi_tx_ptp(), msg, and nsei.

Referenced by fi_tx_sig().

## Variable Documentation

## bssgp_fc_gran_tbl

const unsigned int bssgp_fc_gran_tbl[]

static

Initial value:
= {
[BSSGP_FC_GRAN_100] = 100,
[BSSGP_FC_GRAN_1000] = 1000,
[BSSGP_FC_GRAN_10000] = 10000,
[BSSGP_FC_GRAN_100000] = 100000,
}
BSSGP_FC_GRAN_10000
@ BSSGP_FC_GRAN_10000
Definition gsm_08_18.h:350
BSSGP_FC_GRAN_100000
@ BSSGP_FC_GRAN_100000
Definition gsm_08_18.h:351
BSSGP_FC_GRAN_100
@ BSSGP_FC_GRAN_100
Definition gsm_08_18.h:348
BSSGP_FC_GRAN_1000
@ BSSGP_FC_GRAN_1000
Definition gsm_08_18.h:349

Referenced by bssgp2_dec_fc_bvc(), bssgp2_dec_fc_ms(), bssgp2_enc_fc_bvc(), and bssgp2_enc_fc_ms().