Loading...
Searching...
No Matches
gprs_ns.h File Reference
Libgb
`#include <stdint.h>`
`#include <netinet/in.h>`
`#include <osmocom/core/linuxlist.h>`
`#include <osmocom/core/msgb.h>`
`#include <osmocom/core/timer.h>`
`#include <osmocom/core/select.h>`
`#include <osmocom/gprs/gprs_msgb.h>`
`#include <osmocom/gprs/protocol/gsm_08_16.h>`

Go to the source code of this file.

## Data Structures

struct | gprs_ns_inst
| An instance of the NS protocol stack. More...
struct | gprs_nsvc
| Structure representing a single NS-VC. More...
struct | ns_signal_data

## Macros

#define | NS_TIMERS_COUNT 8
#define | NS_TIMERS "(tns-block|tns-block-retries|tns-reset|tns-reset-retries|tns-test|tns-alive|tns-alive-retries|tsns-prov)"
#define | NS_TIMERS_HELP
#define | NS_ALLOC_SIZE 3072
#define | NS_ALLOC_HEADROOM 20
#define | NSE_S_BLOCKED 0x0001
#define | NSE_S_ALIVE 0x0002
#define | NSE_S_RESET 0x0004
#define | NS_DESC_B(st)
#define | NS_DESC_A(st)
#define | NS_DESC_R(st)

## Typedefs

typedef int | gprs_ns_cb_t(enum gprs_ns_evt event, struct gprs_nsvc *nsvc, struct msgb *msg, uint16_t bvci)
| Osmocom GPRS callback function type.

## Enumerations

enum | ns_timeout { NS_TOUT_TNS_BLOCK , NS_TOUT_TNS_BLOCK_RETRIES , NS_TOUT_TNS_RESET , NS_TOUT_TNS_RESET_RETRIES , NS_TOUT_TNS_TEST , NS_TOUT_TNS_ALIVE , NS_TOUT_TNS_ALIVE_RETRIES , NS_TOUT_TSNS_PROV }
enum | gprs_ns_ll { GPRS_NS_LL_UDP , GPRS_NS_LL_E1 , GPRS_NS_LL_FR_GRE }
| Osmocom NS link layer types. More...
enum | gprs_ns_evt { GPRS_NS_EVT_UNIT_DATA }
| Osmoco NS events. More...
enum | gprs_ns_cs { GPRS_NS_CS_CREATED , GPRS_NS_CS_FOUND , GPRS_NS_CS_REJECTED , GPRS_NS_CS_SKIPPED , GPRS_NS_CS_ERROR }
| Osmocom NS VC create status. More...
enum | nsvc_timer_mode { NSVC_TIMER_TNS_TEST , NSVC_TIMER_TNS_ALIVE , NSVC_TIMER_TNS_RESET , _NSVC_TIMER_NR }
enum | signal_ns { S_NS_RESET , S_NS_BLOCK , S_NS_UNBLOCK , S_NS_ALIVE_EXP , S_NS_REPLACED , S_NS_MISMATCH , S_SNS_CONFIGURED }

## Functions

struct gprs_ns_inst * | gprs_ns_instantiate (gprs_ns_cb_t *cb, void *ctx)
| Create a new GPRS NS instance.
void | gprs_ns_close (struct gprs_ns_inst *nsi)
void | gprs_ns_destroy (struct gprs_ns_inst *nsi)
| Destroy an entire NS instance.
int | gprs_ns_nsip_listen (struct gprs_ns_inst *nsi)
| Create a listening socket for GPRS NS/UDP/IP.
struct gprs_nsvc * | gprs_ns_nsip_connect (struct gprs_ns_inst *nsi, struct sockaddr_in *dest, uint16_t nsei, uint16_t nsvci)
| Establish a NS connection (from the BSS) to the SGSN.
struct gprs_nsvc * | gprs_ns_nsip_connect_sns (struct gprs_ns_inst *nsi, struct sockaddr_in *dest, uint16_t nsei, uint16_t nsvci)
| Establish a NS connection (from the BSS) to the SGSN using SNS auto-configuration.
int | gprs_ns_sendmsg (struct gprs_ns_inst *nsi, struct msgb *msg)
| High-level function for transmitting a NS-UNITDATA messsage.
int | gprs_ns_rcvmsg (struct gprs_ns_inst *nsi, struct msgb *msg, struct sockaddr_in *saddr, enum gprs_ns_ll ll)
| Receive incoming NS message from underlying transport layer.
int | gprs_ns_tx_alive (struct gprs_nsvc *nsvc)
| Transmit a NS-ALIVE on a given NS-VC.
int | gprs_ns_tx_alive_ack (struct gprs_nsvc *nsvc)
| Transmit a NS-ALIVE-ACK on a given NS-VC.
int | gprs_ns_tx_reset (struct gprs_nsvc *nsvc, uint8_t cause)
| Transmit a NS-RESET on a given NSVC.
int | gprs_ns_tx_block (struct gprs_nsvc *nsvc, uint8_t cause)
| Transmit a NS-BLOCK on a given NS-VC.
int | gprs_ns_tx_unblock (struct gprs_nsvc *nsvc)
| Transmit a NS-UNBLOCK on a given NS-VC.
int | gprs_ns_frgre_listen (struct gprs_ns_inst *nsi)
struct gprs_nsvc * | gprs_nsvc_create2 (struct gprs_ns_inst *nsi, uint16_t nsvci, uint8_t sig_weight, uint8_t data_weight)
| Create a new NS-VC (Virtual Circuit) within given instance.
void | gprs_nsvc_delete (struct gprs_nsvc *nsvc)
| Delete given NS-VC.
struct gprs_nsvc * | gprs_nsvc_by_nsei (struct gprs_ns_inst *nsi, uint16_t nsei)
| Lookup struct gprs_nsvc based on NSEI.
struct gprs_nsvc * | gprs_nsvc_by_nsvci (struct gprs_ns_inst *nsi, uint16_t nsvci)
| Lookup struct gprs_nsvc based on NSVCI.
struct gprs_nsvc * | gprs_nsvc_by_rem_addr (struct gprs_ns_inst *nsi, const struct sockaddr_in *sin)
| Lookup NS-VC based on specified remote peer socket addr.
int | gprs_nsvc_reset (struct gprs_nsvc *nsvc, uint8_t cause)
| Initiate a RESET procedure.
int | gprs_ns_vty_init (struct gprs_ns_inst *nsi)
const char * | gprs_ns_ll_str (const struct gprs_nsvc *nsvc)
char * | gprs_ns_ll_str_buf (char *buf, size_t buf_len, const struct gprs_nsvc *nsvc)
char * | gprs_ns_ll_str_c (const void *ctx, const struct gprs_nsvc *nsvc)
void | gprs_ns_ll_copy (struct gprs_nsvc *nsvc, struct gprs_nsvc *other)
void | gprs_ns_ll_clear (struct gprs_nsvc *nsvc)
struct msgb * | gprs_ns_msgb_alloc (void)
const char * | gprs_ns_cause_str (enum ns_cause cause)
| Obtain a human-readable string for NS cause value.
void | gprs_ns_set_log_ss (int ss)
char * | gprs_nsvc_state_append (char *s, struct gprs_nsvc *nsvc)
| Append the nsvc state to a talloc string.

## Variables

const struct value_string | gprs_ns_signal_ns_names []

## Macro Definition Documentation

## NS_ALLOC_HEADROOM

#define NS_ALLOC_HEADROOM 20

Referenced by gprs_ns_msgb_alloc(), ns2_msgb_alloc(), and read_nsip_msg().

## NS_ALLOC_SIZE

#define NS_ALLOC_SIZE 3072

Referenced by fr_netif_ofd_cb(), gprs_ns_msgb_alloc(), ns2_msgb_alloc(), read_nsfrgre_msg(), read_nsfrgre_msg(), and read_nsip_msg().

## NS_DESC_A

#define NS_DESC_A | ( |  | st | ) |

Value:
((st) & NSE_S_ALIVE ? "ALIVE" : "DEAD")
NSE_S_ALIVE
#define NSE_S_ALIVE
Definition gprs_ns.h:45

Referenced by dump_nse(), gprs_nsvc_state_append(), and ns_set_state_with_log().

## NS_DESC_B

#define NS_DESC_B | ( |  | st | ) |

Value:
((st) & NSE_S_BLOCKED ? "BLOCKED" : "UNBLOCKED")
NSE_S_BLOCKED
#define NSE_S_BLOCKED
Definition gprs_ns.h:44

Referenced by dump_nse(), gprs_nsvc_state_append(), and ns_set_state_with_log().

## NS_DESC_R

#define NS_DESC_R | ( |  | st | ) |

Value:
((st) & NSE_S_RESET ? "RESET" : "UNRESET")
NSE_S_RESET
#define NSE_S_RESET
Definition gprs_ns.h:46

Referenced by ns_set_state_with_log().

## NS_TIMERS

#define NS_TIMERS "(tns-block|tns-block-retries|tns-reset|tns-reset-retries|tns-test|tns-alive|tns-alive-retries|tsns-prov)"

Referenced by DEFUN().

## NS_TIMERS_COUNT

#define NS_TIMERS_COUNT 8

## NS_TIMERS_HELP

#define NS_TIMERS_HELP

Value:
"(un)blocking Timer (Tns-block) timeout\n" \
"(un)blocking Timer (Tns-block) number of retries\n" \
"Reset Timer (Tns-reset) timeout\n" \
"Reset Timer (Tns-reset) number of retries\n" \
"Test Timer (Tns-test) timeout\n" \
"Alive Timer (Tns-alive) timeout\n" \
"Alive Timer (Tns-alive) number of retries\n" \
"SNS Provision Timer (Tsns-prov) timeout\n"

Referenced by DEFUN().

## NSE_S_ALIVE

#define NSE_S_ALIVE 0x0002

Referenced by gprs_active_nsvc_by_nsei(), gprs_ns_process_msg(), gprs_ns_rx_reset(), gprs_ns_rx_reset_ack(), and gprs_ns_vc_create().

## NSE_S_BLOCKED

#define NSE_S_BLOCKED 0x0001

Referenced by gprs_active_nsvc_by_nsei(), gprs_ns_process_msg(), gprs_ns_rx_reset(), gprs_ns_rx_reset_ack(), gprs_ns_rx_unitdata(), gprs_ns_timer_cb(), gprs_nsvc_create2(), and gprs_nsvc_reset().

## NSE_S_RESET

#define NSE_S_RESET 0x0004

Referenced by gprs_ns_process_msg(), gprs_ns_rx_reset_ack(), gprs_ns_timer_cb(), and gprs_nsvc_reset().

## Typedef Documentation

## gprs_ns_cb_t

typedef int gprs_ns_cb_t(enum gprs_ns_evt event, struct gprs_nsvc *nsvc, struct msgb *msg, uint16_t bvci)

Osmocom GPRS callback function type.

## Enumeration Type Documentation

## gprs_ns_cs

enum gprs_ns_cs

Osmocom NS VC create status.

Enumerator
GPRS_NS_CS_CREATED | A NSVC object has been created.
GPRS_NS_CS_FOUND | A NSVC object has been found.
GPRS_NS_CS_REJECTED | Rejected and answered message.
GPRS_NS_CS_SKIPPED | Skipped message.
GPRS_NS_CS_ERROR | Failed to process message.

## gprs_ns_evt

enum gprs_ns_evt

Osmoco NS events.

Enumerator
GPRS_NS_EVT_UNIT_DATA |

## gprs_ns_ll

enum gprs_ns_ll

Osmocom NS link layer types.

Enumerator
GPRS_NS_LL_UDP | NS/UDP/IP.
GPRS_NS_LL_E1 | NS/E1.
GPRS_NS_LL_FR_GRE | NS/FR/GRE/IP.

## ns_timeout

enum ns_timeout

Enumerator
NS_TOUT_TNS_BLOCK |
NS_TOUT_TNS_BLOCK_RETRIES |
NS_TOUT_TNS_RESET |
NS_TOUT_TNS_RESET_RETRIES |
NS_TOUT_TNS_TEST |
NS_TOUT_TNS_ALIVE |
NS_TOUT_TNS_ALIVE_RETRIES |
NS_TOUT_TSNS_PROV |

## nsvc_timer_mode

enum nsvc_timer_mode

Enumerator
NSVC_TIMER_TNS_TEST |
NSVC_TIMER_TNS_ALIVE |
NSVC_TIMER_TNS_RESET |
_NSVC_TIMER_NR |

## signal_ns

enum signal_ns

Enumerator
S_NS_RESET |
S_NS_BLOCK |
S_NS_UNBLOCK |
S_NS_ALIVE_EXP |
S_NS_REPLACED |
S_NS_MISMATCH |
S_SNS_CONFIGURED |

## Function Documentation

## gprs_ns_frgre_listen()

int gprs_ns_frgre_listen | ( | struct gprs_ns_inst * | nsi | ) |

References osmo_fd::cb, osmo_fd::data, DNS, gprs_ns_inst::enabled, gprs_ns_inst::fd, osmo_fd::fd, gprs_ns_inst::frgre, IPPROTO_GRE, gprs_ns_inst::local_ip, and nsfrgre_fd_cb().

## gprs_ns_vty_init()

int gprs_ns_vty_init | ( | struct gprs_ns_inst * | nsi | ) |

References config_write_ns(), ns_node, gprs_nsvc::nsi, and vty_nsi.