libosmogb 1.13.1.1-afb4 Osmocom Gb library

Macros | Functions
gprs_ns2_message.c File Reference

NS-over-FR-over-GRE implementation. More...

`#include <errno.h>`
`#include <osmocom/core/byteswap.h>`
`#include <osmocom/core/rate_ctr.h>`
`#include <osmocom/core/stat_item.h>`
`#include <osmocom/core/stats.h>`
`#include <osmocom/gsm/tlv.h>`
`#include <osmocom/gprs/gprs_msgb.h>`
`#include <osmocom/gprs/gprs_ns2.h>`
`#include <osmocom/gprs/protocol/gsm_08_16.h>`
`#include "gprs_ns2_internal.h"`

## Macros
#define | ERR_IF_NSVC_USES_SNS(nsvc, reason)

## Functions
static int | ns2_validate_reset (struct gprs_ns2_vc *nsvc, struct msgb *msg, struct tlv_parsed *tp, uint8_t *cause)
static int | ns2_validate_reset_ack (struct gprs_ns2_vc *nsvc, struct msgb *msg, struct tlv_parsed *tp, uint8_t *cause)
static int | ns2_validate_block (struct gprs_ns2_vc *nsvc, struct msgb *msg, struct tlv_parsed *tp, uint8_t *cause)
static int | ns2_validate_block_ack (struct gprs_ns2_vc *nsvc, struct msgb *msg, struct tlv_parsed *tp, uint8_t *cause)
static int | ns2_validate_status (struct gprs_ns2_vc *nsvc, struct msgb *msg, struct tlv_parsed *tp, uint8_t *cause)
int | ns2_validate (struct gprs_ns2_vc *nsvc, uint8_t pdu_type, struct msgb *msg, struct tlv_parsed *tp, uint8_t *cause)
static int | ns_vc_tx (struct gprs_ns2_vc *nsvc, struct msgb *msg)
static int | ns2_tx_simple (struct gprs_ns2_vc *nsvc, uint8_t pdu_type)
int | ns2_tx_block (struct gprs_ns2_vc *nsvc, uint8_t cause, uint16_t *nsvci)
| Transmit a NS-BLOCK on a given NS-VC. More...
int | ns2_tx_block_ack (struct gprs_ns2_vc *nsvc, uint16_t *nsvci)
| Transmit a NS-BLOCK-ACK on a given NS-VC. More...
int | ns2_tx_reset (struct gprs_ns2_vc *nsvc, uint8_t cause)
| Transmit a NS-RESET on a given NS-VC. More...
int | ns2_tx_reset_ack (struct gprs_ns2_vc *nsvc)
| Transmit a NS-RESET-ACK on a given NS-VC. More...
int | ns2_tx_unblock (struct gprs_ns2_vc *nsvc)
| Transmit a NS-UNBLOCK on a given NS-VC. More...
int | ns2_tx_unblock_ack (struct gprs_ns2_vc *nsvc)
| Transmit a NS-UNBLOCK-ACK on a given NS-VC. More...
int | ns2_tx_alive (struct gprs_ns2_vc *nsvc)
| Transmit a NS-ALIVE on a given NS-VC. More...
int | ns2_tx_alive_ack (struct gprs_ns2_vc *nsvc)
| Transmit a NS-ALIVE-ACK on a given NS-VC. More...
int | ns2_tx_unit_data (struct gprs_ns2_vc *nsvc, uint16_t bvci, uint8_t sducontrol, struct msgb *msg)
| Transmit NS-UNITDATA on a given NS-VC. More...
int | ns2_tx_status (struct gprs_ns2_vc *nsvc, uint8_t cause, uint16_t bvci, struct msgb *orig_msg, uint16_t *nsvci)
| Transmit a NS-STATUS on a given NS-VC. More...
static int | ns2_tx_sns_procedure (struct gprs_ns2_vc *nsvc, enum ns_pdu_type pdu, uint8_t trans_id, const struct gprs_ns_ie_ip4_elem *ip4_elems, unsigned int num_ip4_elems, const struct gprs_ns_ie_ip6_elem *ip6_elems, unsigned int num_ip6_elems)
| Encode + Transmit a SNS-ADD/SNS-CHANGE-WEIGHT as per Section 9.3.2/9.3.3. More...
int | ns2_tx_sns_add (struct gprs_ns2_vc *nsvc, uint8_t trans_id, const struct gprs_ns_ie_ip4_elem *ip4_elems, unsigned int num_ip4_elems, const struct gprs_ns_ie_ip6_elem *ip6_elems, unsigned int num_ip6_elems)
| Encode + Transmit a SNS-ADD as per Section 9.3.2. More...
int | ns2_tx_sns_change_weight (struct gprs_ns2_vc *nsvc, uint8_t trans_id, const struct gprs_ns_ie_ip4_elem *ip4_elems, unsigned int num_ip4_elems, const struct gprs_ns_ie_ip6_elem *ip6_elems, unsigned int num_ip6_elems)
| Encode + Transmit a SNS-CHANGE-WEIGHT as per Section 9.3.3. More...
int | ns2_tx_sns_del (struct gprs_ns2_vc *nsvc, uint8_t trans_id, const struct gprs_ns_ie_ip4_elem *ip4_elems, unsigned int num_ip4_elems, const struct gprs_ns_ie_ip6_elem *ip6_elems, unsigned int num_ip6_elems)
| Encode + Transmit a SNS-DEL as per Section 9.3.6. More...
int | ns2_tx_sns_ack (struct gprs_ns2_vc *nsvc, uint8_t trans_id, uint8_t *cause, const struct gprs_ns_ie_ip4_elem *ip4_elems, unsigned int num_ip4_elems, const struct gprs_ns_ie_ip6_elem *ip6_elems, unsigned int num_ip6_elems)
| Encode + Transmit a SNS-ACK as per Section 9.3.1. More...
int | ns2_tx_sns_config (struct gprs_ns2_vc *nsvc, bool end_flag, const struct gprs_ns_ie_ip4_elem *ip4_elems, unsigned int num_ip4_elems, const struct gprs_ns_ie_ip6_elem *ip6_elems, unsigned int num_ip6_elems)
| Encode + Transmit a SNS-CONFIG as per Section 9.3.4. More...
int | ns2_tx_sns_config_ack (struct gprs_ns2_vc *nsvc, uint8_t *cause)
| Encode + Transmit a SNS-CONFIG-ACK as per Section 9.3.5. More...
int | ns2_tx_sns_size (struct gprs_ns2_vc *nsvc, bool reset_flag, uint16_t max_nr_nsvc, int ip4_ep_nr, int ip6_ep_nr)
| Encode + transmit a SNS-SIZE as per Section 9.3.7. More...
int | ns2_tx_sns_size_ack (struct gprs_ns2_vc *nsvc, uint8_t *cause)
| Encode + Transmit a SNS-SIZE-ACK as per Section 9.3.8. More...

## Detailed Description

NS-over-FR-over-GRE implementation.

GPRS Networks Service (NS) messages on the Gb interface. 3GPP TS 08.16 version 8.0.1 Release 1999 / ETSI TS 101 299 V8.0.1 (2002-05) as well as its successor 3GPP TS 48.016

## Macro Definition Documentation

## ◆ ERR_IF_NSVC_USES_SNS

#define ERR_IF_NSVC_USES_SNS | ( |  | nsvc,
|  |  | reason
| ) |  |

Value:
do { \
if (!nsvc->nse->bss_sns_fi) \
break; \
LOGNSVC(nsvc, LOGL_DEBUG, "invalid packet %s with SNS\n", reason); \
} while (0)

## Function Documentation

## ◆ ns2_tx_alive()

int ns2_tx_alive | ( | struct gprs_ns2_vc * | nsvc | ) |

Transmit a NS-ALIVE on a given NS-VC.

Parameters

  [in] | nsvc | NS-VC on which the NS-ALIVE is to be transmitted

Returns
  0 in case of success

References LOG_CTX_GB_NSE, LOG_CTX_GB_NSVC, log_set_context(), ns2_tx_simple(), NS_PDUT_ALIVE, and gprs_ns2_vc::nse.

Referenced by alive_timeout_handler(), and start_test_procedure().

## ◆ ns2_tx_alive_ack()

int ns2_tx_alive_ack | ( | struct gprs_ns2_vc * | nsvc | ) |

Transmit a NS-ALIVE-ACK on a given NS-VC.

Parameters

  [in] | nsvc | NS-VC on which the NS-ALIVE-ACK is to be transmitted

Returns
  0 in case of success

References LOG_CTX_GB_NSE, LOG_CTX_GB_NSVC, log_set_context(), ns2_tx_simple(), NS_PDUT_ALIVE_ACK, and gprs_ns2_vc::nse.

Referenced by ns2_vc_fsm_allstate_action().

## ◆ ns2_tx_block()

int ns2_tx_block | ( | struct gprs_ns2_vc * | nsvc,
|  | uint8_t | cause,
|  | uint16_t * | nsvci
| ) |  |

Transmit a NS-BLOCK on a given NS-VC.

Parameters

  [in] | vc | NS-VC on which the NS-BLOCK is to be transmitted
  [in] | cause | Numeric NS Cause value
  [in] | nsvci | if given this NSVCI will be encoded. If NULL the nsvc->nsvci will be used.

Returns
  0 in case of success

References cause, gprs_ns2_vc::ctrg, ERR_IF_NSVC_USES_SNS, gprs_ns2_cause_str(), LOG_CTX_GB_NSE, LOG_CTX_GB_NSVC, LOG_NS_SIGNAL, log_set_context(), LOGL_INFO, msg, msgb_put(), msgb_tvlv_put(), ns2_msgb_alloc(), NS_CTR_BLOCKED, NS_IE_CAUSE, NS_IE_VCI, NS_PDUT_BLOCK, ns_vc_tx(), gprs_ns2_vc::nse, gprs_ns2_vc::nsvci, osmo_htons, gprs_ns_hdr::pdu_type, rate_ctr_group_get_ctr(), and rate_ctr_inc().

Referenced by ns2_st_blocked(), and ns2_st_blocked_onenter().

## ◆ ns2_tx_block_ack()

int ns2_tx_block_ack | ( | struct gprs_ns2_vc * | nsvc,
|  | uint16_t * | nsvci
| ) |  |

Transmit a NS-BLOCK-ACK on a given NS-VC.

Parameters

  [in] | nsvc | NS-VC on which the NS-BLOCK is to be transmitted
  [in] | nsvci | if given this NSVCI will be encoded. If NULL the nsvc->nsvci will be used.

Returns
  0 in case of success

References ERR_IF_NSVC_USES_SNS, LOG_CTX_GB_NSE, LOG_CTX_GB_NSVC, LOG_NS_TX_SIGNAL, log_set_context(), msg, msgb_put(), msgb_tvlv_put(), ns2_msgb_alloc(), NS_IE_VCI, NS_PDUT_BLOCK_ACK, ns_vc_tx(), gprs_ns2_vc::nse, gprs_ns2_vc::nsvci, osmo_htons, and gprs_ns_hdr::pdu_type.

Referenced by ns2_st_blocked(), ns2_st_unblocked(), and ns2_vc_rx().

## ◆ ns2_tx_reset()

int ns2_tx_reset | ( | struct gprs_ns2_vc * | nsvc,
|  | uint8_t | cause
| ) |  |

Transmit a NS-RESET on a given NS-VC.

Parameters

  [in] | nsvc | NS-VC used for transmission
  [in] | cause | Numeric NS cause value

Returns
  0 in case of success

References cause, ERR_IF_NSVC_USES_SNS, gprs_ns2_cause_str(), LOG_CTX_GB_NSE, LOG_CTX_GB_NSVC, LOG_NS_SIGNAL, log_set_context(), LOGL_INFO, msg, msgb_put(), msgb_tvlv_put(), ns2_msgb_alloc(), NS_IE_CAUSE, NS_IE_NSEI, NS_IE_VCI, NS_PDUT_RESET, ns_vc_tx(), gprs_ns2_vc::nse, nsei, gprs_ns2_nse::nsei, gprs_ns2_vc::nsvci, osmo_htons, and gprs_ns_hdr::pdu_type.

Referenced by ns2_st_reset_onenter().

## ◆ ns2_tx_reset_ack()

int ns2_tx_reset_ack | ( | struct gprs_ns2_vc * | nsvc | ) |

Transmit a NS-RESET-ACK on a given NS-VC.

Parameters

  [in] | nsvc | NS-VC used for transmission

Returns
  0 in case of success

References ERR_IF_NSVC_USES_SNS, LOG_CTX_GB_NSE, LOG_CTX_GB_NSVC, LOG_NS_TX_SIGNAL, log_set_context(), msg, msgb_put(), msgb_tvlv_put(), ns2_msgb_alloc(), NS_IE_NSEI, NS_IE_VCI, NS_PDUT_RESET_ACK, ns_vc_tx(), gprs_ns2_vc::nse, nsei, gprs_ns2_nse::nsei, gprs_ns2_vc::nsvci, osmo_htons, and gprs_ns_hdr::pdu_type.

Referenced by ns2_st_reset(), and ns2_vc_rx().

## ◆ ns2_tx_simple()

static int ns2_tx_simple | ( | struct gprs_ns2_vc * | nsvc,
|  | uint8_t | pdu_type
| ) |  |
| static

References LOG_CTX_GB_NSE, LOG_CTX_GB_NSVC, LOG_NS_TX_SIGNAL, log_set_context(), msg, msgb_put(), ns2_msgb_alloc(), ns_vc_tx(), gprs_ns2_vc::nse, pdu_type, and gprs_ns_hdr::pdu_type.

Referenced by ns2_tx_alive(), ns2_tx_alive_ack(), ns2_tx_unblock(), and ns2_tx_unblock_ack().

## ◆ ns2_tx_sns_ack()

int ns2_tx_sns_ack | ( | struct gprs_ns2_vc * | nsvc,
|  | uint8_t | trans_id,
|  | uint8_t * | cause,
|  | const struct gprs_ns_ie_ip4_elem * | ip4_elems,
|  | unsigned int | num_ip4_elems,
|  | const struct gprs_ns_ie_ip6_elem * | ip6_elems,
|  | unsigned int | num_ip6_elems
| ) |  |

Encode + Transmit a SNS-ACK as per Section 9.3.1.

Parameters

  [in] | nsvc | NS-VC through which to transmit the ACK
  [in] | trans_id | Transaction ID which to acknowledge
  [in] | cause | Pointer to cause value (NULL if no cause to be sent)
  [in] | ip4_elems | Array of IPv4 Elements
  [in] | num_ip4_elems | number of ip4_elems

Returns
  0 on success; negative in case of error

References gprs_ns2_nse::bss_sns_fi, cause, gprs_ns2_cause_str(), LOG_CTX_GB_NSE, LOG_CTX_GB_NSVC, LOG_NS_SIGNAL, log_set_context(), LOGL_ERROR, LOGL_INFO, LOGNSVC, msg, msgb_free(), msgb_put(), msgb_tvlv_put(), msgb_v_put(), ns2_msgb_alloc(), NS_IE_CAUSE, NS_IE_IPv4_LIST, NS_IE_IPv6_LIST, NS_IE_NSEI, ns_vc_tx(), gprs_ns2_vc::nse, nsei, gprs_ns2_nse::nsei, osmo_htons, gprs_ns_hdr::pdu_type, and SNS_PDUT_ACK.

Referenced by ns2_sns_st_configured_add(), ns2_sns_st_configured_change(), and ns2_sns_st_configured_delete().

## ◆ ns2_tx_sns_add()

int ns2_tx_sns_add | ( | struct gprs_ns2_vc * | nsvc,
|  | uint8_t | trans_id,
|  | const struct gprs_ns_ie_ip4_elem * | ip4_elems,
|  | unsigned int | num_ip4_elems,
|  | const struct gprs_ns_ie_ip6_elem * | ip6_elems,
|  | unsigned int | num_ip6_elems
| ) |  |

Encode + Transmit a SNS-ADD as per Section 9.3.2.

Parameters

  [in] | nsvc | NS-VC through which to transmit the SNS-CONFIG
  [in] | trans_id | The transaction id
  [in] | ip4_elems | Array of IPv4 Elements
  [in] | num_ip4_elems | number of ip4_elems
  [in] | ip6_elems | Array of IPv6 Elements
  [in] | num_ip6_elems | number of ip6_elems

Returns
  0 on success; negative in case of error

References ns2_tx_sns_procedure(), and SNS_PDUT_ADD.

Referenced by ns2_sns_st_local_procedure_onenter().

## ◆ ns2_tx_sns_change_weight()

int ns2_tx_sns_change_weight | ( | struct gprs_ns2_vc * | nsvc,
|  | uint8_t | trans_id,
|  | const struct gprs_ns_ie_ip4_elem * | ip4_elems,
|  | unsigned int | num_ip4_elems,
|  | const struct gprs_ns_ie_ip6_elem * | ip6_elems,
|  | unsigned int | num_ip6_elems
| ) |  |

Encode + Transmit a SNS-CHANGE-WEIGHT as per Section 9.3.3.

Parameters

  [in] | nsvc | NS-VC through which to transmit the SNS-CONFIG
  [in] | trans_id | The transaction id
  [in] | ip4_elems | Array of IPv4 Elements
  [in] | num_ip4_elems | number of ip4_elems
  [in] | ip6_elems | Array of IPv6 Elements
  [in] | num_ip6_elems | number of ip6_elems

Returns
  0 on success; negative in case of error

References ns2_tx_sns_procedure(), and SNS_PDUT_CHANGE_WEIGHT.

Referenced by ns2_sns_st_local_procedure_onenter().

## ◆ ns2_tx_sns_config()

int ns2_tx_sns_config | ( | struct gprs_ns2_vc * | nsvc,
|  | bool | end_flag,
|  | const struct gprs_ns_ie_ip4_elem * | ip4_elems,
|  | unsigned int | num_ip4_elems,
|  | const struct gprs_ns_ie_ip6_elem * | ip6_elems,
|  | unsigned int | num_ip6_elems
| ) |  |

Encode + Transmit a SNS-CONFIG as per Section 9.3.4.

Parameters

  [in] | nsvc | NS-VC through which to transmit the SNS-CONFIG
  [in] | end_flag | Whether or not this is the last SNS-CONFIG
  [in] | ip4_elems | Array of IPv4 Elements
  [in] | num_ip4_elems | number of ip4_elems

Returns
  0 on success; negative in case of error

References gprs_ns2_nse::bss_sns_fi, LOG_CTX_GB_NSE, LOG_CTX_GB_NSVC, LOG_NS_SIGNAL, log_set_context(), LOGL_ERROR, LOGL_INFO, LOGNSVC, msg, msgb_free(), msgb_put(), msgb_tvlv_put(), msgb_v_put(), ns2_msgb_alloc(), NS_IE_IPv4_LIST, NS_IE_IPv6_LIST, NS_IE_NSEI, ns_vc_tx(), gprs_ns2_vc::nse, nsei, gprs_ns2_nse::nsei, osmo_htons, gprs_ns_hdr::pdu_type, and SNS_PDUT_CONFIG.

Referenced by ns2_sns_st_bss_config_bss_onenter(), and ns2_sns_st_sgsn_wait_config_ack_onenter().

## ◆ ns2_tx_sns_config_ack()

int ns2_tx_sns_config_ack | ( | struct gprs_ns2_vc * | nsvc,
|  | uint8_t * | cause
| ) |  |

Encode + Transmit a SNS-CONFIG-ACK as per Section 9.3.5.

Parameters

  [in] | nsvc | NS-VC through which to transmit the SNS-CONFIG-ACK
  [in] | cause | Pointer to cause value (NULL if no cause to be sent)

Returns
  0 on success; negative in case of error

References gprs_ns2_nse::bss_sns_fi, cause, gprs_ns2_cause_str(), LOG_CTX_GB_NSE, LOG_CTX_GB_NSVC, LOG_NS_TX_SIGNAL, log_set_context(), LOGL_ERROR, LOGL_INFO, LOGNSVC, msg, msgb_free(), msgb_put(), msgb_tvlv_put(), ns2_msgb_alloc(), NS_IE_CAUSE, NS_IE_NSEI, ns_vc_tx(), gprs_ns2_vc::nse, nsei, gprs_ns2_nse::nsei, osmo_htons, gprs_ns_hdr::pdu_type, and SNS_PDUT_CONFIG_ACK.

Referenced by ns2_sns_st_bss_config_sgsn(), and ns2_sns_st_sgsn_wait_config().

## ◆ ns2_tx_sns_del()

int ns2_tx_sns_del | ( | struct gprs_ns2_vc * | nsvc,
|  | uint8_t | trans_id,
|  | const struct gprs_ns_ie_ip4_elem * | ip4_elems,
|  | unsigned int | num_ip4_elems,
|  | const struct gprs_ns_ie_ip6_elem * | ip6_elems,
|  | unsigned int | num_ip6_elems
| ) |  |

Encode + Transmit a SNS-DEL as per Section 9.3.6.

Parameters

  [in] | nsvc | NS-VC through which to transmit the SNS-CONFIG
  [in] | trans_id | The transaction id
  [in] | ip4_elems | Array of IPv4 Elements
  [in] | num_ip4_elems | number of ip4_elems
  [in] | ip6_elems | Array of IPv6 Elements
  [in] | num_ip6_elems | number of ip6_elems

Returns
  0 on success; negative in case of error

References ns2_tx_sns_procedure(), and SNS_PDUT_DELETE.

Referenced by ns2_sns_st_local_procedure_onenter().

## ◆ ns2_tx_sns_procedure()

static int ns2_tx_sns_procedure | ( | struct gprs_ns2_vc * | nsvc,
|  | enum ns_pdu_type | pdu,
|  | uint8_t | trans_id,
|  | const struct gprs_ns_ie_ip4_elem * | ip4_elems,
|  | unsigned int | num_ip4_elems,
|  | const struct gprs_ns_ie_ip6_elem * | ip6_elems,
|  | unsigned int | num_ip6_elems
| ) |  |
| static

Encode + Transmit a SNS-ADD/SNS-CHANGE-WEIGHT as per Section 9.3.2/9.3.3.

Parameters

  [in] | nsvc | NS-VC through which to transmit the SNS-CONFIG
  [in] | pdu | The PDU type to send out
  [in] | trans_id | The transaction id
  [in] | ip4_elems | Array of IPv4 Elements
  [in] | num_ip4_elems | number of ip4_elems
  [in] | ip6_elems | Array of IPv6 Elements
  [in] | num_ip6_elems | number of ip6_elems

Returns
  0 on success; negative in case of error

References gprs_ns2_nse::bss_sns_fi, LOG_CTX_GB_NSE, LOG_CTX_GB_NSVC, log_set_context(), LOGL_ERROR, LOGNSVC, msg, msgb_free(), msgb_put(), msgb_tvlv_put(), msgb_v_put(), ns2_msgb_alloc(), NS_IE_IPv4_LIST, NS_IE_IPv6_LIST, NS_IE_NSEI, ns_vc_tx(), gprs_ns2_vc::nse, nsei, gprs_ns2_nse::nsei, osmo_htons, and gprs_ns_hdr::pdu_type.

Referenced by ns2_tx_sns_add(), ns2_tx_sns_change_weight(), and ns2_tx_sns_del().

## ◆ ns2_tx_sns_size()

int ns2_tx_sns_size | ( | struct gprs_ns2_vc * | nsvc,
|  | bool | reset_flag,
|  | uint16_t | max_nr_nsvc,
|  | int | ip4_ep_nr,
|  | int | ip6_ep_nr
| ) |  |

Encode + transmit a SNS-SIZE as per Section 9.3.7.

Parameters

  [in] | nsvc | NS-VC through which to transmit the SNS-SIZE
  [in] | reset_flag | Whether or not to add a RESET flag
  [in] | max_nr_nsvc | Maximum number of NS-VCs
  [in] | ip4_ep_nr | Number of IPv4 endpoints (< 0 will omit the TLV)
  [in] | ip6_ep_nr | Number of IPv6 endpoints (< 0 will omit the TLV)

Returns
  0 on success; negative in case of error

References gprs_ns2_nse::bss_sns_fi, LOG_CTX_GB_NSE, LOG_CTX_GB_NSVC, LOG_NS_SIGNAL, log_set_context(), LOGL_ERROR, LOGL_INFO, LOGNSVC, msg, msgb_free(), msgb_put(), msgb_tv16_put(), msgb_tv_put(), msgb_tvlv_put(), ns2_msgb_alloc(), NS_IE_IPv4_EP_NR, NS_IE_IPv6_EP_NR, NS_IE_MAX_NR_NSVC, NS_IE_NSEI, NS_IE_RESET_FLAG, ns_vc_tx(), gprs_ns2_vc::nse, nsei, gprs_ns2_nse::nsei, osmo_htons, gprs_ns_hdr::pdu_type, and SNS_PDUT_SIZE.

Referenced by ns2_sns_st_bss_size_onenter().

## ◆ ns2_tx_sns_size_ack()

int ns2_tx_sns_size_ack | ( | struct gprs_ns2_vc * | nsvc,
|  | uint8_t * | cause
| ) |  |

Encode + Transmit a SNS-SIZE-ACK as per Section 9.3.8.

Parameters

  [in] | nsvc | NS-VC through which to transmit the SNS-SIZE-ACK
  [in] | cause | Pointer to cause value (NULL if no cause to be sent)

Returns
  0 on success; negative in case of error

References gprs_ns2_nse::bss_sns_fi, cause, gprs_ns2_cause_str(), LOG_CTX_GB_NSE, LOG_CTX_GB_NSVC, LOG_NS_SIGNAL, log_set_context(), LOGL_ERROR, LOGL_INFO, LOGNSVC, msg, msgb_free(), msgb_put(), msgb_tvlv_put(), ns2_msgb_alloc(), NS_IE_CAUSE, NS_IE_NSEI, ns_vc_tx(), gprs_ns2_vc::nse, nsei, gprs_ns2_nse::nsei, osmo_htons, gprs_ns_hdr::pdu_type, and SNS_PDUT_SIZE_ACK.

Referenced by ns2_sns_st_all_action_sgsn().

## ◆ ns2_tx_status()

int ns2_tx_status | ( | struct gprs_ns2_vc * | nsvc,
|  | uint8_t | cause,
|  | uint16_t | bvci,
|  | struct msgb * | orig_msg,
|  | uint16_t * | nsvci
| ) |  |

Transmit a NS-STATUS on a given NS-VC.

Parameters

  [in] | nsvc | NS-VC to be used for transmission
  [in] | cause | Numeric NS cause value
  [in] | bvci | BVCI to be reset within NSVC
  [in] | orig_msg | message causing the STATUS
  [in] | nsvci | if given this NSVCI will be encoded. If NULL the nsvc->nsvci will be used.

Returns
  0 in case of success

References gprs_ns2_vc::bind, bvci, cause, gprs_ns2_cause_str(), msgb::l2h, LOG_CTX_GB_NSE, LOG_CTX_GB_NSVC, LOG_NS_SIGNAL, log_set_context(), LOGL_INFO, msg, msgb_l2len(), msgb_length(), msgb_put(), msgb_tvlv_put(), gprs_ns2_vc_bind::mtu, ns2_msgb_alloc(), NS_CAUSE_BVCI_UNKNOWN, NS_CAUSE_INVAL_ESSENT_IE, NS_CAUSE_MISSING_ESSENT_IE, NS_CAUSE_NSVC_BLOCKED, NS_CAUSE_NSVC_UNKNOWN, NS_CAUSE_PDU_INCOMP_PSTATE, NS_CAUSE_PROTO_ERR_UNSPEC, NS_CAUSE_SEM_INCORR_PDU, NS_IE_CAUSE, NS_IE_PDU, NS_IE_VCI, NS_PDUT_STATUS, ns_vc_tx(), gprs_ns2_vc::nse, gprs_ns2_vc::nsvci, osmo_htons, gprs_ns_hdr::pdu_type, and TVLV_GROSS_LEN().

Referenced by ns2_vc_fsm_allstate_action(), and ns2_vc_rx().

## ◆ ns2_tx_unblock()

int ns2_tx_unblock | ( | struct gprs_ns2_vc * | nsvc | ) |

Transmit a NS-UNBLOCK on a given NS-VC.

Parameters

  [in] | nsvc | NS-VC on which the NS-UNBLOCK is to be transmitted

Returns
  0 in case of success

References ERR_IF_NSVC_USES_SNS, LOG_CTX_GB_NSE, LOG_CTX_GB_NSVC, log_set_context(), ns2_tx_simple(), NS_PDUT_UNBLOCK, and gprs_ns2_vc::nse.

Referenced by ns2_st_blocked_onenter().

## ◆ ns2_tx_unblock_ack()

int ns2_tx_unblock_ack | ( | struct gprs_ns2_vc * | nsvc | ) |

Transmit a NS-UNBLOCK-ACK on a given NS-VC.

Parameters

  [in] | nsvc | NS-VC on which the NS-UNBLOCK-ACK is to be transmitted

Returns
  0 in case of success

References ERR_IF_NSVC_USES_SNS, LOG_CTX_GB_NSE, LOG_CTX_GB_NSVC, log_set_context(), ns2_tx_simple(), NS_PDUT_UNBLOCK_ACK, and gprs_ns2_vc::nse.

Referenced by ns2_st_blocked(), and ns2_st_unblocked().

## ◆ ns2_tx_unit_data()

int ns2_tx_unit_data | ( | struct gprs_ns2_vc * | nsvc,
|  | uint16_t | bvci,
|  | uint8_t | sducontrol,
|  | struct msgb * | msg
| ) |  |

Transmit NS-UNITDATA on a given NS-VC.

Parameters

  [in] | nsvc | NS-VC on which the NS-UNITDATA is to be transmitted
  [in] | bvci | BVCI to encode in NS-UNITDATA header
  [in] | sducontrol | SDU control octet of NS header
  [in] | msg | message buffer containing payload

Returns
  0 in case of success

References bvci, gprs_ns_hdr::data, if(), LOG_CTX_GB_NSE, LOG_CTX_GB_NSVC, LOG_NS_DATA, log_set_context(), LOGL_ERROR, LOGL_INFO, LOGNSVC, msg, msgb_free(), msgb_push(), NS_PDUT_UNITDATA, ns_vc_tx(), gprs_ns2_vc::nse, and gprs_ns_hdr::pdu_type.

Referenced by gprs_ns2_recv_prim().

## ◆ ns2_validate()

int ns2_validate | ( | struct gprs_ns2_vc * | nsvc,
|  | uint8_t | pdu_type,
|  | struct msgb * | msg,
|  | struct tlv_parsed * | tp,
|  | uint8_t * | cause
| ) |  |

References cause, msg, msgb_l2len(), ns2_validate_block(), ns2_validate_block_ack(), ns2_validate_reset(), ns2_validate_reset_ack(), ns2_validate_status(), NS_CAUSE_PROTO_ERR_UNSPEC, NS_PDUT_ALIVE, NS_PDUT_ALIVE_ACK, NS_PDUT_BLOCK, NS_PDUT_BLOCK_ACK, NS_PDUT_RESET, NS_PDUT_RESET_ACK, NS_PDUT_STATUS, NS_PDUT_UNBLOCK, NS_PDUT_UNBLOCK_ACK, and pdu_type.

Referenced by ns2_vc_rx().

## ◆ ns2_validate_block()

static int ns2_validate_block | ( | struct gprs_ns2_vc * | nsvc,
|  | struct msgb * | msg,
|  | struct tlv_parsed * | tp,
|  | uint8_t * | cause
| ) |  |
| static

References cause, NS_CAUSE_MISSING_ESSENT_IE, NS_IE_CAUSE, NS_IE_VCI, and TLVP_PRES_LEN.

Referenced by ns2_validate().

## ◆ ns2_validate_block_ack()

static int ns2_validate_block_ack | ( | struct gprs_ns2_vc * | nsvc,
|  | struct msgb * | msg,
|  | struct tlv_parsed * | tp,
|  | uint8_t * | cause
| ) |  |
| static

References cause, NS_CAUSE_MISSING_ESSENT_IE, NS_IE_VCI, and TLVP_PRES_LEN.

Referenced by ns2_validate().

## ◆ ns2_validate_reset()

static int ns2_validate_reset | ( | struct gprs_ns2_vc * | nsvc,
|  | struct msgb * | msg,
|  | struct tlv_parsed * | tp,
|  | uint8_t * | cause
| ) |  |
| static

References cause, NS_CAUSE_MISSING_ESSENT_IE, NS_IE_CAUSE, NS_IE_NSEI, NS_IE_VCI, and TLVP_PRES_LEN.

Referenced by ns2_validate().

## ◆ ns2_validate_reset_ack()

static int ns2_validate_reset_ack | ( | struct gprs_ns2_vc * | nsvc,
|  | struct msgb * | msg,
|  | struct tlv_parsed * | tp,
|  | uint8_t * | cause
| ) |  |
| static

References cause, NS_CAUSE_MISSING_ESSENT_IE, NS_IE_NSEI, NS_IE_VCI, and TLVP_PRES_LEN.

Referenced by ns2_validate().

## ◆ ns2_validate_status()

static int ns2_validate_status | ( | struct gprs_ns2_vc * | nsvc,
|  | struct msgb * | msg,
|  | struct tlv_parsed * | tp,
|  | uint8_t * | cause
| ) |  |
| static

References cause, GPRS_NS2_VC_MODE_BLOCKRESET, gprs_ns2_vc::mode, NS_CAUSE_BVCI_UNKNOWN, NS_CAUSE_INVAL_ESSENT_IE, NS_CAUSE_MISSING_ESSENT_IE, NS_CAUSE_NSVC_BLOCKED, NS_CAUSE_NSVC_UNKNOWN, NS_CAUSE_PDU_INCOMP_PSTATE, NS_CAUSE_PROTO_ERR_UNSPEC, NS_CAUSE_SEM_INCORR_PDU, NS_CAUSE_UNKN_IP_TEST_FAILED, NS_IE_BVCI, NS_IE_CAUSE, NS_IE_IPv4_LIST, NS_IE_IPv6_LIST, NS_IE_PDU, NS_IE_VCI, TLVP_PRES_LEN, TLVP_PRESENT, and tlvp_val8().

Referenced by ns2_validate().

## ◆ ns_vc_tx()

static int ns_vc_tx | ( | struct gprs_ns2_vc * | nsvc,
|  | struct msgb * | msg
| ) |  |
| static

References gprs_ns2_vc::bind, msg, and gprs_ns2_vc_bind::send_vc.

Referenced by ns2_tx_block(), ns2_tx_block_ack(), ns2_tx_reset(), ns2_tx_reset_ack(), ns2_tx_simple(), ns2_tx_sns_ack(), ns2_tx_sns_config(), ns2_tx_sns_config_ack(), ns2_tx_sns_procedure(), ns2_tx_sns_size(), ns2_tx_sns_size_ack(), ns2_tx_status(), and ns2_tx_unit_data().