libosmogb
1.4.0.160-7619
Osmocom Gb library
|
Go to the source code of this file.
Data Structures | |
struct | osmo_gprs_ns2_prim |
Typedefs | |
typedef int(* | gprs_ns2_foreach_nsvc_cb) (struct gprs_ns2_vc *nsvc, void *ctx) |
a callback to iterate over all NSVC More... | |
Enumerations | |
enum | gprs_ns2_vc_mode { NS2_VC_MODE_BLOCKRESET, NS2_VC_MODE_ALIVE } |
enum | gprs_ns2_prim { PRIM_NS_UNIT_DATA, PRIM_NS_CONGESTION, PRIM_NS_STATUS } |
Osmocom NS primitives according to 48.016 5.2 Service primitves. More... | |
enum | gprs_ns2_congestion_cause { NS_CONG_CAUSE_BACKWARD_BEGIN, NS_CONG_CAUSE_BACKWARD_END, NS_CONG_CAUSE_FORWARD_BEGIN, NS_CONG_CAUSE_FORWARD_END } |
Osmocom NS primitives according to 48.016 5.2.2.4 Service primitves. More... | |
enum | gprs_ns2_affecting_cause { NS_AFF_CAUSE_VC_FAILURE, NS_AFF_CAUSE_VC_RECOVERY, NS_AFF_CAUSE_FAILURE, NS_AFF_CAUSE_RECOVERY, NS_AFF_CAUSE_SNS_CONFIGURED, NS_AFF_CAUSE_SNS_FAILURE } |
Osmocom NS primitives according to 48.016 5.2.2.6 Service primitves. More... | |
enum | gprs_ns2_change_ip_endpoint { NS_ENDPOINT_NO_CHANGE, NS_ENDPOINT_REQUEST_CHANGE, NS_ENDPOINT_CONFIRM_CHANGE } |
Osmocom NS primitives according to 48.016 5.2.2.7 Service primitves. More... | |
Functions | |
struct gprs_ns2_inst * | gprs_ns2_instantiate (void *ctx, osmo_prim_cb cb, void *cb_data) |
Create a new GPRS NS instance. More... | |
void | gprs_ns2_free (struct gprs_ns2_inst *inst) |
Destroy a NS Instance (including all its NSEs, binds, ...). More... | |
int | gprs_ns2_dynamic_create_nse (struct gprs_ns2_inst *nsi, bool create_nse) |
Configure whether a NS Instance should dynamically create NSEs based on incoming traffic. More... | |
int | gprs_ns2_recv_prim (struct gprs_ns2_inst *nsi, struct osmo_prim_hdr *oph) |
Receive a primitive from the NS User (Gb). More... | |
int | gprs_ns2_nse_foreach_nsvc (struct gprs_ns2_nse *nse, gprs_ns2_foreach_nsvc_cb cb, void *cb_data) |
Iterate over all nsvc of a NS Entity and call the callback. More... | |
struct gprs_ns2_nse * | gprs_ns2_nse_by_nsei (struct gprs_ns2_inst *nsi, uint16_t nsei) |
Resolve a NS Entity based on its NSEI. More... | |
struct gprs_ns2_nse * | gprs_ns2_create_nse (struct gprs_ns2_inst *nsi, uint16_t nsei) |
Create a NS Entity within given NS instance. More... | |
uint16_t | gprs_ns2_nse_nsei (struct gprs_ns2_nse *nse) |
Return the NSEI. More... | |
void | gprs_ns2_free_nse (struct gprs_ns2_nse *nse) |
Destroy given NS Entity. More... | |
void | gprs_ns2_free_nses (struct gprs_ns2_inst *nsi) |
void | gprs_ns2_free_nsvc (struct gprs_ns2_vc *nsvc) |
Destroy/release given NS-VC. More... | |
struct gprs_ns2_vc * | gprs_ns2_nsvc_by_nsvci (struct gprs_ns2_inst *nsi, uint16_t nsvci) |
Resolve a NS-VC Entity based on its NS-VCI. More... | |
int | gprs_ns2_ip_bind (struct gprs_ns2_inst *nsi, const struct osmo_sockaddr *local, int dscp, struct gprs_ns2_vc_bind **result) |
Bind to an IPv4/IPv6 address. More... | |
struct gprs_ns2_vc_bind * | gprs_ns2_ip_bind_by_sockaddr (struct gprs_ns2_inst *nsi, const struct osmo_sockaddr *sockaddr) |
Find NS bind for a given socket address. More... | |
void | gprs_ns2_bind_set_mode (struct gprs_ns2_vc_bind *bind, enum gprs_ns2_vc_mode mode) |
Set the mode of given bind. More... | |
struct gprs_ns2_vc * | gprs_ns2_ip_connect (struct gprs_ns2_vc_bind *bind, const struct osmo_sockaddr *remote, struct gprs_ns2_nse *nse, uint16_t nsvci) |
Create, connect and activate a new IP-based NS-VC. More... | |
struct gprs_ns2_vc * | gprs_ns2_ip_connect2 (struct gprs_ns2_vc_bind *bind, const struct osmo_sockaddr *remote, uint16_t nsei, uint16_t nsvci) |
Create, connect and activate a new IP-based NS-VC. More... | |
struct gprs_ns2_vc * | gprs_ns2_ip_connect_inactive (struct gprs_ns2_vc_bind *bind, const struct osmo_sockaddr *remote, struct gprs_ns2_nse *nse, uint16_t nsvci) |
Create, and connect an inactive, new IP-based NS-VC. More... | |
void | gprs_ns2_free_bind (struct gprs_ns2_vc_bind *bind) |
Destroy a given bind. More... | |
void | gprs_ns2_free_binds (struct gprs_ns2_inst *nsi) |
int | gprs_ns2_ip_connect_sns (struct gprs_ns2_vc_bind *bind, const struct osmo_sockaddr *remote, uint16_t nsei) |
Create, connect and activate a new IP-SNS NSE. More... | |
const struct osmo_sockaddr * | gprs_ns2_nse_sns_remote (struct gprs_ns2_nse *nse) |
Return the initial SNS remote socket address. More... | |
const struct osmo_sockaddr * | gprs_ns2_ip_vc_remote (const struct gprs_ns2_vc *nsvc) |
Return the socket address of the remote peer of a NS-VC. More... | |
const struct osmo_sockaddr * | gprs_ns2_ip_vc_local (const struct gprs_ns2_vc *nsvc) |
Return the socket address of the local peer of a NS-VC. More... | |
bool | gprs_ns2_ip_vc_equal (const struct gprs_ns2_vc *nsvc, const struct osmo_sockaddr *local, const struct osmo_sockaddr *remote, uint16_t nsvci) |
Compare the NS-VC with the given parameter. More... | |
const struct osmo_sockaddr * | gprs_ns2_ip_bind_sockaddr (struct gprs_ns2_vc_bind *bind) |
Return the locally bound socket address of the bind. More... | |
int | gprs_ns2_is_ip_bind (struct gprs_ns2_vc_bind *bind) |
Is the given bind an IP bind? More... | |
int | gprs_ns2_ip_bind_set_dscp (struct gprs_ns2_vc_bind *bind, int dscp) |
Set the DSCP (TOS) bit value of the given bind. More... | |
struct gprs_ns2_vc * | gprs_ns2_nsvc_by_sockaddr_bind (struct gprs_ns2_vc_bind *bind, const struct osmo_sockaddr *saddr) |
Find a NS-VC by its remote socket address. More... | |
int | gprs_ns2_frgre_bind (struct gprs_ns2_inst *nsi, const struct osmo_sockaddr *local, int dscp, struct gprs_ns2_vc_bind **result) |
Create a new bind for NS over FR-GRE. More... | |
int | gprs_ns2_is_frgre_bind (struct gprs_ns2_vc_bind *bind) |
determine if given bind is for FR-GRE encapsulation. More... | |
struct gprs_ns2_vc * | gprs_ns2_nsvc_by_sockaddr_nse (struct gprs_ns2_nse *nse, const struct osmo_sockaddr *sockaddr) |
Find NS-VC for given socket address. More... | |
void | gprs_ns2_start_alive_all_nsvcs (struct gprs_ns2_nse *nse) |
Start the NS-ALIVE FSM in all NS-VCs of given NSE. More... | |
const char * | gprs_ns2_cause_str (int cause) |
Obtain a human-readable string for NS cause value. More... | |
const char * | gprs_ns2_ll_str (struct gprs_ns2_vc *nsvc) |
string-format a given NS-VC to a thread-local static buffer. More... | |
char * | gprs_ns2_ll_str_buf (char *buf, size_t buf_len, struct gprs_ns2_vc *nsvc) |
string-format a given NS-VC into a user-supplied buffer. More... | |
char * | gprs_ns2_ll_str_c (const void *ctx, struct gprs_ns2_vc *nsvc) |
string-format a given NS-VC to a dynamically allocated string. More... | |
int | gprs_ns2_vty_init (struct gprs_ns2_inst *nsi, const struct osmo_sockaddr_str *default_bind) |
gprs_ns2_vty_init initialize the vty More... | |
int | gprs_ns2_vty_create () |
gprs_ns2_vty_create parse the vty tree into ns nodes It has to be in different steps to ensure the bind is created before creating VCs. More... | |
void | gprs_ns2_vty_force_vc_mode (bool force, enum gprs_ns2_vc_mode mode, const char *reason) |
ns2_vty_force_vc_mode force a mode and prevents the vty from overwriting it. More... | |
typedef int(* gprs_ns2_foreach_nsvc_cb) (struct gprs_ns2_vc *nsvc, void *ctx) |
a callback to iterate over all NSVC
enum gprs_ns2_prim |
enum gprs_ns2_vc_mode |
int gprs_ns2_frgre_bind | ( | struct gprs_ns2_inst * | nsi, |
const struct osmo_sockaddr * | local, | ||
int | dscp, | ||
struct gprs_ns2_vc_bind ** | result | ||
) |
Create a new bind for NS over FR-GRE.
[in] | nsi | NS instance in which to create the bind |
[in] | local | local address on which to bind |
[in] | dscp | DSCP/TOS bits to use for transmitted data on this bind |
[out] | result | pointer to created bind |
References priv_bind::addr, gprs_ns2_inst::binding, osmo_fd::cb, osmo_fd::data, DLNS, gprs_ns2_vc_bind::driver, priv_bind::dscp, osmo_fd::fd, priv_bind::fd, free_vc(), gprs_ns2_vc_bind::free_vc, frgre_fd_cb(), frgre_vc_sendmsg(), INIT_LLIST_HEAD, IPPROTO_GRE, gprs_ns2_vc_bind::list, llist_add(), LOGL_ERROR, LOGP, ns2_vty_bind_apply(), gprs_ns2_vc_bind::nsi, gprs_ns2_vc_bind::nsvc, OSMO_SOCK_F_BIND, osmo_sock_init_osa_ofd(), priv, gprs_ns2_vc_bind::priv, osmo_sockaddr::sa, gprs_ns2_vc_bind::send_vc, osmo_sockaddr::u, and vc_driver_frgre.
int gprs_ns2_ip_bind | ( | struct gprs_ns2_inst * | nsi, |
const struct osmo_sockaddr * | local, | ||
int | dscp, | ||
struct gprs_ns2_vc_bind ** | result | ||
) |
Bind to an IPv4/IPv6 address.
[in] | nsi | NS Instance in which to create the NSVC |
[in] | local | the local address to bind to |
[in] | dscp | the DSCP/TOS bits used for transmitted data |
[out] | result | if set, returns the bind object |
References priv_bind::addr, gprs_ns2_inst::binding, osmo_fd::cb, osmo_fd::data, DLNS, gprs_ns2_vc_bind::driver, priv_bind::dscp, dump_vty(), gprs_ns2_vc_bind::dump_vty, osmo_fd::fd, priv_bind::fd, free_vc(), gprs_ns2_vc_bind::free_vc, gprs_ns2_ip_bind_by_sockaddr(), INIT_LLIST_HEAD, gprs_ns2_vc_bind::list, llist_add(), LOGL_ERROR, LOGP, ns2_vty_bind_apply(), gprs_ns2_vc_bind::nsi, nsip_fd_cb(), nsip_vc_sendmsg(), gprs_ns2_vc_bind::nsvc, OSMO_SOCK_F_BIND, osmo_sock_init_osa_ofd(), priv, gprs_ns2_vc_bind::priv, osmo_sockaddr::sa, gprs_ns2_vc_bind::send_vc, osmo_sockaddr::u, and vc_driver_ip.
Referenced by gprs_ns2_vty_create().
struct gprs_ns2_vc_bind* gprs_ns2_ip_bind_by_sockaddr | ( | struct gprs_ns2_inst * | nsi, |
const struct osmo_sockaddr * | sockaddr | ||
) |
Find NS bind for a given socket address.
[in] | nsi | NS instance |
[in] | sockaddr | socket address to search for |
References gprs_ns2_inst::binding, gprs_ns2_ip_bind_sockaddr(), gprs_ns2_is_ip_bind(), llist_for_each_entry, OSMO_ASSERT, and osmo_sockaddr_cmp().
Referenced by gprs_ns2_ip_bind().
int gprs_ns2_ip_bind_set_dscp | ( | struct gprs_ns2_vc_bind * | bind, |
int | dscp | ||
) |
Set the DSCP (TOS) bit value of the given bind.
References DLNS, priv_bind::dscp, osmo_fd::fd, priv_bind::fd, LOGL_ERROR, LOGP, priv, and gprs_ns2_vc_bind::priv.
Referenced by DEFUN().
const struct osmo_sockaddr* gprs_ns2_ip_bind_sockaddr | ( | struct gprs_ns2_vc_bind * | bind | ) |
Return the locally bound socket address of the bind.
[in] | bind | The bind whose local address we want to know |
References priv_bind::addr, priv, and gprs_ns2_vc_bind::priv.
Referenced by gprs_ns2_ip_bind_by_sockaddr(), gprs_ns2_ll_str_buf(), and ns2_sns_bss_fsm_start().
bool gprs_ns2_ip_vc_equal | ( | const struct gprs_ns2_vc * | nsvc, |
const struct osmo_sockaddr * | local, | ||
const struct osmo_sockaddr * | remote, | ||
uint16_t | nsvci | ||
) |
Compare the NS-VC with the given parameter.
[in] | nsvc | NS-VC to compare with |
[in] | local | The local address |
[in] | remote | The remote address |
[in] | nsvci | NS-VCI will only be used if the NS-VC in BLOCKRESET mode otherwise NS-VCI isn't applicable. |
References priv_bind::addr, gprs_ns2_vc::bind, GPRS_NS_LL_UDP, gprs_ns2_vc::ll, gprs_ns2_vc::mode, NS2_VC_MODE_BLOCKRESET, gprs_ns2_vc::nsvci, osmo_sockaddr_cmp(), gprs_ns2_vc::priv, gprs_ns2_vc_bind::priv, and priv_vc::remote.
const struct osmo_sockaddr* gprs_ns2_ip_vc_local | ( | const struct gprs_ns2_vc * | nsvc | ) |
Return the socket address of the local peer of a NS-VC.
[in] | nsvc | NS-VC whose local peer we want to know |
References priv_bind::addr, gprs_ns2_vc::bind, gprs_ns2_vc_bind::driver, GPRS_NS_LL_UDP, gprs_ns2_vc::ll, priv, and gprs_ns2_vc_bind::priv.
const struct osmo_sockaddr* gprs_ns2_ip_vc_remote | ( | const struct gprs_ns2_vc * | nsvc | ) |
Return the socket address of the remote peer of a NS-VC.
[in] | nsvc | NS-VC whose remote peer we want to know |
References GPRS_NS_LL_UDP, gprs_ns2_vc::ll, priv, gprs_ns2_vc::priv, and priv_vc::remote.
Referenced by create_missing_nsvcs(), do_sns_change_weight(), do_sns_delete(), dump_nsvc(), gprs_ns2_ll_str_buf(), and gprs_ns2_nsvc_by_sockaddr_nse().
int gprs_ns2_is_frgre_bind | ( | struct gprs_ns2_vc_bind * | bind | ) |
determine if given bind is for FR-GRE encapsulation.
References gprs_ns2_vc_bind::driver.
int gprs_ns2_is_ip_bind | ( | struct gprs_ns2_vc_bind * | bind | ) |
Is the given bind an IP bind?
References gprs_ns2_vc_bind::driver.
Referenced by DEFUN(), gprs_ns2_ip_bind_by_sockaddr(), gprs_ns2_ll_str_buf(), and ns2_sns_bss_fsm_start().
const struct osmo_sockaddr* gprs_ns2_nse_sns_remote | ( | struct gprs_ns2_nse * | nse | ) |
Return the initial SNS remote socket address.
nse | NS Entity |
References gprs_ns2_nse::bss_sns_fi, ns2_sns_state::initial, and osmo_fsm_inst::priv.
struct gprs_ns2_vc* gprs_ns2_nsvc_by_sockaddr_bind | ( | struct gprs_ns2_vc_bind * | bind, |
const struct osmo_sockaddr * | saddr | ||
) |
Find a NS-VC by its remote socket address.
[in] | bind | in which to search |
[in] | saddr | remote peer socket adddress to search |
References llist_for_each_entry, gprs_ns2_vc_bind::nsvc, osmo_sockaddr_cmp(), gprs_ns2_vc::priv, priv_vc::remote, osmo_sockaddr::sa, and osmo_sockaddr::u.
Referenced by handle_nsip_read().
int gprs_ns2_vty_create | ( | ) |
gprs_ns2_vty_create parse the vty tree into ns nodes It has to be in different steps to ensure the bind is created before creating VCs.
References ns2_vty_priv::dscp, ns2_vty_priv::frgre, gprs_ns2_bind_set_mode(), gprs_ns2_create_nse(), gprs_ns2_ip_bind(), gprs_ns2_ip_connect(), gprs_ns2_nse_by_nsei(), osmo_sockaddr_str::ip, llist_for_each_entry, ns2_vty_vc::nsei, ns2_vty_vc::nsvci, osmo_sockaddr_str_to_sockaddr(), gprs_ns2_nse::persistent, gprs_ns2_vc::persistent, osmo_sockaddr_str::port, priv, ns2_vty_vc::remote, osmo_sockaddr::sas, osmo_sockaddr::u, ns2_vty_priv::udp, ns2_vty_priv::vc_mode, and ns2_vty_priv::vtyvc.
void gprs_ns2_vty_force_vc_mode | ( | bool | force, |
enum gprs_ns2_vc_mode | mode, | ||
const char * | reason | ||
) |
ns2_vty_force_vc_mode force a mode and prevents the vty from overwriting it.
force | if true mode and reason will be set. false to allow modification via vty. |
mode | |
reason | A description shown to the user when a vty command wants to change the mode. |
References ns2_vty_priv::force_vc_mode, ns2_vty_priv::force_vc_mode_reason, priv, and ns2_vty_priv::vc_mode.
int gprs_ns2_vty_init | ( | struct gprs_ns2_inst * | nsi, |
const struct osmo_sockaddr_str * | default_bind | ||
) |
gprs_ns2_vty_init initialize the vty
[in,out] | nsi | |
[in] | default_bind | set the default address to bind to. Can be NULL. |
References CFG_LOG_NODE, CONFIG_NODE, config_write_ns(), INIT_LLIST_HEAD, install_lib_element(), install_lib_element_ve(), install_node(), L_NS_NODE, NS2_VC_MODE_BLOCKRESET, priv, ns2_vty_priv::udp, ns2_vty_priv::vc_mode, and ns2_vty_priv::vtyvc.