libosmogb 1.10.0.64-ff3d
Osmocom Gb library
|
NS-over-FR-over-GRE implementation. More...
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/ip6.h>
#include <arpa/inet.h>
#include <linux/if.h>
#include <sys/ioctl.h>
#include <netpacket/packet.h>
#include <linux/if_ether.h>
#include <linux/hdlc.h>
#include <linux/hdlc/ioctl.h>
#include <linux/sockios.h>
#include <osmocom/gprs/frame_relay.h>
#include <osmocom/core/byteswap.h>
#include <osmocom/core/stat_item.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/select.h>
#include <osmocom/core/socket.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/talloc.h>
#include <osmocom/gprs/gprs_ns2.h>
#include <osmocom/core/netdev.h>
#include <osmocom/gprs/protocol/gsm_08_16.h>
#include <osmocom/gprs/protocol/gsm_08_18.h>
#include "config.h"
#include "common_vty.h"
#include "gprs_ns2_internal.h"
Data Structures | |
struct | priv_bind |
struct | priv_vc |
Macros | |
#define | GRE_PTYPE_FR 0x6559 |
#define | GRE_PTYPE_IPv4 0x0800 |
#define | GRE_PTYPE_IPv6 0x86dd |
#define | GRE_PTYPE_KAR 0x0000 /* keepalive response */ |
#define | IPPROTO_GRE 47 |
#define | E1_LINERATE 2048000 |
#define | E1_SLOTS_TOTAL 32 |
#define | E1_SLOTS_USED 31 |
#define | SUPERCHANNEL_LINERATE (E1_LINERATE*E1_SLOTS_USED)/E1_SLOTS_TOTAL |
#define | BIT_DURATION_NS (1000000000 / SUPERCHANNEL_LINERATE) |
#define | LMI_Q933A_DLCI 0 |
Functions | |
static void | free_bind (struct gprs_ns2_vc_bind *bind) |
clean up all private driver state. More... | |
static int | fr_dlci_rx_cb (void *cb_data, struct msgb *msg) |
static void | free_vc (struct gprs_ns2_vc *nsvc) |
static void | dump_vty (const struct gprs_ns2_vc_bind *bind, struct vty *vty, bool stats) |
static void | fr_dlci_status_cb (struct osmo_fr_dlc *dlc, void *cb_data, bool active) |
static struct priv_vc * | fr_alloc_vc (struct gprs_ns2_vc_bind *bind, struct gprs_ns2_vc *nsvc, uint16_t dlci) |
int | gprs_ns2_find_vc_by_dlci (struct gprs_ns2_vc_bind *bind, uint16_t dlci, struct gprs_ns2_vc **result) |
static int | fr_netif_ofd_cb (struct osmo_fd *bfd, uint32_t what) |
static int | fr_netif_write_one (struct gprs_ns2_vc_bind *bind, struct msgb *msg) |
int | gprs_ns2_is_fr_bind (struct gprs_ns2_vc_bind *bind) |
determine if given bind is for FR-GRE encapsulation. More... | |
static int | fr_vc_sendmsg (struct gprs_ns2_vc *nsvc, struct msgb *msg) |
static void | enqueue_at_head (struct gprs_ns2_vc_bind *bind, struct msgb *msg) |
static void | enqueue_at_tail (struct gprs_ns2_vc_bind *bind, struct msgb *msg) |
static int | backlog_enqueue_or_free (struct gprs_ns2_vc_bind *bind, struct msgb *msg) |
static void | fr_backlog_timer_cb (void *data) |
int | fr_tx_cb (void *data, struct msgb *msg) |
static int | devname2ifindex (const char *ifname) |
static int | open_socket (int ifindex, const struct gprs_ns2_vc_bind *nsbind) |
static int | gprs_n2_fr_ifupdown_ind_cb (struct osmo_netdev *netdev, bool if_running) |
static int | gprs_n2_fr_mtu_chg_cb (struct osmo_netdev *netdev, uint32_t new_mtu) |
static int | set_ifupdown (const char *netif, bool up) |
static int | setup_device (const char *netif, const struct gprs_ns2_vc_bind *bind) |
int | gprs_ns2_fr_bind (struct gprs_ns2_inst *nsi, const char *name, const char *netif, struct osmo_fr_network *fr_network, enum osmo_fr_role fr_role, struct gprs_ns2_vc_bind **result) |
Create a new bind for NS over FR. More... | |
enum osmo_fr_role | gprs_ns2_fr_bind_role (struct gprs_ns2_vc_bind *bind) |
Return the frame relay role of a bind. More... | |
const char * | gprs_ns2_fr_bind_netif (struct gprs_ns2_vc_bind *bind) |
Return the network interface of the bind. More... | |
struct gprs_ns2_vc_bind * | gprs_ns2_fr_bind_by_netif (struct gprs_ns2_inst *nsi, const char *netif) |
Find NS bind for a given network interface. More... | |
struct gprs_ns2_vc * | gprs_ns2_fr_connect (struct gprs_ns2_vc_bind *bind, struct gprs_ns2_nse *nse, uint16_t nsvci, uint16_t dlci) |
Create, connect and activate a new FR-based NS-VC. More... | |
struct gprs_ns2_vc * | gprs_ns2_fr_connect2 (struct gprs_ns2_vc_bind *bind, uint16_t nsei, uint16_t nsvci, uint16_t dlci) |
Create, connect and activate a new FR-based NS-VC. More... | |
struct gprs_ns2_vc * | gprs_ns2_fr_nsvc_by_dlci (struct gprs_ns2_vc_bind *bind, uint16_t dlci) |
Return the nsvc by dlci. More... | |
uint16_t | gprs_ns2_fr_nsvc_dlci (const struct gprs_ns2_vc *nsvc) |
Return the dlci of the nsvc. More... | |
Variables | |
struct gprs_ns2_vc_driver | vc_driver_fr |
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
#define BIT_DURATION_NS (1000000000 / SUPERCHANNEL_LINERATE) |
#define E1_LINERATE 2048000 |
#define E1_SLOTS_TOTAL 32 |
#define E1_SLOTS_USED 31 |
#define GRE_PTYPE_FR 0x6559 |
#define GRE_PTYPE_IPv4 0x0800 |
#define GRE_PTYPE_IPv6 0x86dd |
#define GRE_PTYPE_KAR 0x0000 /* keepalive response */ |
#define IPPROTO_GRE 47 |
#define LMI_Q933A_DLCI 0 |
#define SUPERCHANNEL_LINERATE (E1_LINERATE*E1_SLOTS_USED)/E1_SLOTS_TOTAL |
|
static |
References priv_bind::backlog, bvci, BVCI_SIGNALLING, priv_bind::dlci, enqueue_at_head(), enqueue_at_tail(), priv_bind::if_running, priv_bind::lmi_msg, LMI_Q933A_DLCI, msg, msgb_free(), msgb_length(), NS_PDUT_UNITDATA, and gprs_ns2_vc_bind::priv.
Referenced by fr_tx_cb().
|
static |
References OSMO_STRLCPY_ARRAY.
Referenced by gprs_ns2_fr_bind().
|
static |
|
static |
References priv_bind::backlog, priv_bind::list, llist_add(), msg, NS2_BIND_STAT_BACKLOG_LEN, osmo_stat_item_group_get_item(), osmo_stat_item_inc(), osmo_timer_schedule(), gprs_ns2_vc_bind::priv, priv_bind::retry_us, gprs_ns2_vc_bind::statg, and priv_bind::timer.
Referenced by backlog_enqueue_or_free().
|
static |
References priv_bind::backlog, priv_bind::list, llist_add_tail(), msg, NS2_BIND_STAT_BACKLOG_LEN, osmo_stat_item_group_get_item(), osmo_stat_item_inc(), osmo_timer_schedule(), gprs_ns2_vc_bind::priv, priv_bind::retry_us, gprs_ns2_vc_bind::statg, and priv_bind::timer.
Referenced by backlog_enqueue_or_free().
|
static |
References osmo_fr_dlc::cb_data, priv_vc::dlc, priv_vc::dlci, fr_dlci_rx_cb(), fr_dlci_status_cb(), gprs_ns2_is_fr_bind(), priv_bind::link, OSMO_ASSERT, osmo_fr_dlc_alloc(), gprs_ns2_vc::priv, gprs_ns2_vc_bind::priv, osmo_fr_dlc::rx_cb, and osmo_fr_dlc::status_cb.
Referenced by gprs_ns2_fr_connect().
|
static |
References priv_bind::backlog, data, fr_netif_write_one(), priv_bind::list, llist_add(), llist_empty(), priv_bind::lmi_msg, msg, msgb_dequeue(), NS2_BIND_STAT_BACKLOG_LEN, osmo_stat_item_dec(), osmo_stat_item_group_get_item(), osmo_timer_schedule(), gprs_ns2_vc_bind::priv, priv_bind::retry_us, gprs_ns2_vc_bind::statg, and priv_bind::timer.
Referenced by gprs_ns2_fr_bind().
|
static |
References msg, and ns2_recv_vc().
Referenced by fr_alloc_vc().
|
static |
References ns2_vc_force_unconfigured(), and ns2_vc_fsm_start().
Referenced by fr_alloc_vc().
|
static |
References osmo_fd::data, osmo_fd::fd, priv_bind::ifindex, priv_bind::link, LOGBIND, LOGL_ERROR, msg, msgb_alloc(), msgb_free(), msgb_put(), NS_ALLOC_SIZE, OSMO_FD_READ, osmo_fr_rx(), and gprs_ns2_vc_bind::priv.
Referenced by gprs_ns2_fr_bind().
|
static |
References priv_bind::backlog, BIT_DURATION_NS, osmo_fd::fd, len(), LOGBIND, LOGL_ERROR, msg, msgb_data(), msgb_free(), msgb_length(), priv_bind::ofd, gprs_ns2_vc_bind::priv, and priv_bind::retry_us.
Referenced by fr_backlog_timer_cb(), and fr_tx_cb().
int fr_tx_cb | ( | void * | data, |
struct msgb * | msg | ||
) |
References priv_bind::backlog, backlog_enqueue_or_free(), data, fr_netif_write_one(), priv_bind::list, llist_empty(), msg, and gprs_ns2_vc_bind::priv.
Referenced by gprs_ns2_fr_bind().
|
static |
References priv_vc::dlc, msg, msgb_length(), NS_CTR_BYTES_OUT, NS_CTR_BYTES_OUT_DROP, NS_CTR_PKTS_OUT, NS_CTR_PKTS_OUT_DROP, osmo_fr_tx_dlc(), OSMO_LIKELY, gprs_ns2_vc::priv, RATE_CTR_ADD_NS, and RATE_CTR_INC_NS.
Referenced by gprs_ns2_fr_bind().
|
static |
clean up all private driver state.
Should be only called by gprs_ns2_free_bind()
References priv_bind::backlog, gprs_ns2_is_fr_bind(), priv_bind::link, list, priv_bind::list, llist_empty(), llist_for_each_entry_safe, priv_bind::lmi_msg, msg, msgb_free(), priv_bind::netdev, gprs_ns2_vc_bind::nsvc, priv_bind::ofd, OSMO_ASSERT, osmo_fd_close(), osmo_fr_link_free(), osmo_netdev_free(), osmo_timer_del(), gprs_ns2_vc_bind::priv, and priv_bind::timer.
|
static |
References gprs_ns2_vc::bind, gprs_ns2_is_fr_bind(), OSMO_ASSERT, and gprs_ns2_vc::priv.
Referenced by gprs_ns2_fr_bind().
|
static |
References priv_bind::backlog, priv_bind::if_running, list, priv_bind::list, llist_for_each_entry_safe, priv_bind::lmi_msg, LOGBIND, LOGL_NOTICE, msg, msgb_free(), priv_bind::netif, osmo_netdev_get_priv_data(), osmo_timer_del(), osmo_timer_schedule(), gprs_ns2_vc_bind::priv, priv_bind::retry_us, and priv_bind::timer.
Referenced by gprs_ns2_fr_bind().
|
static |
References priv_bind::if_running, list, llist_for_each_entry, LOGBIND, LOGL_INFO, gprs_ns2_vc_bind::mtu, ns2_nse_update_mtu(), gprs_ns2_inst::nse, gprs_ns2_vc_bind::nsi, osmo_netdev_get_priv_data(), and gprs_ns2_vc_bind::priv.
Referenced by gprs_ns2_fr_bind().
int gprs_ns2_find_vc_by_dlci | ( | struct gprs_ns2_vc_bind * | bind, |
uint16_t | dlci, | ||
struct gprs_ns2_vc ** | result | ||
) |
References priv_vc::dlci, gprs_ns2_is_fr_bind(), llist_for_each_entry, gprs_ns2_vc_bind::nsvc, OSMO_ASSERT, and gprs_ns2_vc::priv.
int gprs_ns2_fr_bind | ( | struct gprs_ns2_inst * | nsi, |
const char * | name, | ||
const char * | netif, | ||
struct osmo_fr_network * | fr_network, | ||
enum osmo_fr_role | fr_role, | ||
struct gprs_ns2_vc_bind ** | result | ||
) |
Create a new bind for NS over FR.
[in] | nsi | NS instance in which to create the bind |
[in] | netif | Network interface to bind to |
[in] | fr_network | |
[in] | fr_role | |
[out] | result | pointer to the created bind or if a bind with the name exists return the bind. |
References priv_bind::backlog, osmo_fr_link::cb_data, devname2ifindex(), gprs_ns2_vc_bind::driver, dump_vty(), gprs_ns2_vc_bind::dump_vty, osmo_fd::fd, fr_backlog_timer_cb(), fr_netif_ofd_cb(), fr_tx_cb(), fr_vc_sendmsg(), FRAME_RELAY_SDU, free_vc(), gprs_ns2_vc_bind::free_vc, gprs_n2_fr_ifupdown_ind_cb(), gprs_n2_fr_mtu_chg_cb(), gprs_ns2_bind_by_name(), gprs_ns2_free_bind(), GPRS_NS2_LL_FR, priv_bind::ifindex, INIT_LLIST_HEAD, priv_bind::link, priv_bind::list, gprs_ns2_vc_bind::ll, LOGBIND, LOGL_ERROR, gprs_ns2_vc_bind::mtu, name, priv_bind::netdev, priv_bind::netif, ns2_bind_alloc(), priv_bind::ofd, open_socket(), OSMO_FD_READ, osmo_fd_register(), osmo_fd_setup(), osmo_fr_link_alloc(), osmo_fr_link_free(), osmo_netdev_alloc(), osmo_netdev_free(), osmo_netdev_register(), osmo_netdev_set_ifindex(), osmo_netdev_set_ifupdown_ind_cb(), osmo_netdev_set_mtu_chg_cb(), osmo_netdev_set_priv_data(), OSMO_STRLCPY_ARRAY, osmo_timer_setup(), gprs_ns2_vc_bind::priv, priv_bind::retry_us, gprs_ns2_vc_bind::send_vc, setup_device(), priv_bind::timer, gprs_ns2_vc_bind::transfer_capability, osmo_fr_link::tx_cb, and vc_driver_fr.
Referenced by DEFUN().
struct gprs_ns2_vc_bind * gprs_ns2_fr_bind_by_netif | ( | struct gprs_ns2_inst * | nsi, |
const char * | netif | ||
) |
Find NS bind for a given network interface.
[in] | nsi | NS instance |
[in] | netif | the network interface to search for |
References gprs_ns2_inst::binding, gprs_ns2_fr_bind_netif(), gprs_ns2_is_fr_bind(), list, llist_for_each_entry, gprs_ns2_vc_bind::nsi, and OSMO_ASSERT.
Referenced by DEFUN().
const char * gprs_ns2_fr_bind_netif | ( | struct gprs_ns2_vc_bind * | bind | ) |
Return the network interface of the bind.
[in] | bind | The bind |
References gprs_ns2_vc_bind::driver, priv_bind::netif, gprs_ns2_vc_bind::priv, and vc_driver_fr.
Referenced by config_write_nsvc(), config_write_vbind(), gprs_ns2_fr_bind_by_netif(), and gprs_ns2_ll_str_buf().
enum osmo_fr_role gprs_ns2_fr_bind_role | ( | struct gprs_ns2_vc_bind * | bind | ) |
Return the frame relay role of a bind.
[in] | bind | The bind |
References gprs_ns2_vc_bind::driver, priv_bind::link, gprs_ns2_vc_bind::priv, osmo_fr_link::role, and vc_driver_fr.
Referenced by config_write_vbind().
struct gprs_ns2_vc * gprs_ns2_fr_connect | ( | struct gprs_ns2_vc_bind * | bind, |
struct gprs_ns2_nse * | nse, | ||
uint16_t | nsvci, | ||
uint16_t | dlci | ||
) |
Create, connect and activate a new FR-based NS-VC.
[in] | bind | bind in which the new NS-VC is to be created |
[in] | nsei | NSEI of the NS Entity in which the NS-VC is to be created |
[in] | dlci | Data Link connection identifier |
References priv_bind::dlci, fr_alloc_vc(), gprs_ns2_fr_nsvc_by_dlci(), gprs_ns2_free_nsvc(), gprs_ns2_is_fr_bind(), gprs_ns2_lltype_str(), GPRS_NS2_VC_MODE_BLOCKRESET, gprs_ns2_nse::ll, priv_bind::netif, ns2_vc_alloc(), gprs_ns2_nse::nsei, gprs_ns2_vc::nsvci, gprs_ns2_vc::nsvci_is_valid, OSMO_ASSERT, osmo_identifier_sanitize_buf(), gprs_ns2_vc::priv, and gprs_ns2_vc_bind::priv.
Referenced by DEFUN(), and gprs_ns2_fr_connect2().
struct gprs_ns2_vc * gprs_ns2_fr_connect2 | ( | struct gprs_ns2_vc_bind * | bind, |
uint16_t | nsei, | ||
uint16_t | nsvci, | ||
uint16_t | dlci | ||
) |
Create, connect and activate a new FR-based NS-VC.
[in] | bind | bind in which the new NS-VC is to be created |
[in] | nsei | NSEI of the NS Entity in which the NS-VC is to be created |
[in] | dlci | Data Link connection identifier |
References gprs_ns2_create_nse(), GPRS_NS2_DIALECT_STATIC_RESETBLOCK, gprs_ns2_fr_connect(), gprs_ns2_free_nse(), gprs_ns2_is_fr_bind(), GPRS_NS2_LL_FR, gprs_ns2_nse_by_nsei(), nsei, gprs_ns2_vc_bind::nsi, gprs_ns2_nse::nsvc, and OSMO_ASSERT.
struct gprs_ns2_vc * gprs_ns2_fr_nsvc_by_dlci | ( | struct gprs_ns2_vc_bind * | bind, |
uint16_t | dlci | ||
) |
Return the nsvc by dlci.
[in] | bind | |
[in] | dlci | Data Link connection identifier |
References priv_vc::dlci, gprs_ns2_is_fr_bind(), llist_for_each_entry, gprs_ns2_vc_bind::nsvc, OSMO_ASSERT, and gprs_ns2_vc::priv.
Referenced by DEFUN(), and gprs_ns2_fr_connect().
uint16_t gprs_ns2_fr_nsvc_dlci | ( | const struct gprs_ns2_vc * | nsvc | ) |
Return the dlci of the nsvc.
[in] | nsvc |
References gprs_ns2_vc::bind, priv_vc::dlci, gprs_ns2_vc_bind::driver, gprs_ns2_vc::priv, and vc_driver_fr.
Referenced by config_write_nsvc(), and gprs_ns2_ll_str_buf().
int gprs_ns2_is_fr_bind | ( | struct gprs_ns2_vc_bind * | bind | ) |
determine if given bind is for FR-GRE encapsulation.
References gprs_ns2_vc_bind::driver, and vc_driver_fr.
Referenced by fr_alloc_vc(), free_bind(), free_vc(), gprs_ns2_find_vc_by_dlci(), gprs_ns2_fr_bind_by_netif(), gprs_ns2_fr_connect(), gprs_ns2_fr_connect2(), and gprs_ns2_fr_nsvc_by_dlci().
|
static |
References fd, LOGBIND, and LOGL_ERROR.
Referenced by gprs_ns2_fr_bind().
|
static |
References OSMO_STRLCPY_ARRAY.
Referenced by setup_device().
|
static |
References LOGBIND, LOGL_ERROR, LOGL_INFO, LOGL_NOTICE, OSMO_STRLCPY_ARRAY, set_ifupdown(), and buffer::size.
Referenced by gprs_ns2_fr_bind().
struct gprs_ns2_vc_driver vc_driver_fr |
Referenced by gprs_ns2_fr_bind(), gprs_ns2_fr_bind_netif(), gprs_ns2_fr_bind_role(), gprs_ns2_fr_nsvc_dlci(), and gprs_ns2_is_fr_bind().