libosmogb 1.9.0.196-9975
Osmocom Gb library
frame_relay.c File Reference

Implement frame relay/PVC by Q.933. More...

#include <stdint.h>
#include <stdbool.h>
#include <unistd.h>
#include <errno.h>
#include <osmocom/gprs/frame_relay.h>
#include <osmocom/core/endian.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/tdef.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/msgb.h>
#include <osmocom/gsm/tlv.h>
#include <osmocom/vty/vty.h>
#include <osmocom/vty/tdef_vty.h>

Data Structures

struct  q933_a_hdr
 
struct  q933_a_pvc_sts
 

Macros

#define LOGPFRL(frl, lvl, fmt, args ...)    LOGP(DFR, lvl, "%s: " fmt, (frl)->name, ## args)
 
#define DFR   DLNS
 
#define LAPF_UI   0x03 /* UI control word */
 
#define Q931_PDISC_CC   0x08 /* protocol discriminator */
 
#define LMI_Q933A_CALLREF   0x00 /* NULL call-ref */
 
#define LMI_Q933A_DLCI   0 /* Q.933A DLCI */
 
#define LMI_CISCO_DLCI   1023 /* Cisco DLCI */
 
#define MAX_SUPPORTED_PVC   10
 

Enumerations

enum  q931_msgtype {
  Q931_MSGT_ALERTING = 0x01 ,
  Q931_MSGT_CALL_PROCEEDING = 0x02 ,
  Q931_MSGT_CONNECT = 0x07 ,
  Q931_MSGT_CONNECT_ACK = 0x0f ,
  Q931_MSGT_PROGRESS = 0x03 ,
  Q931_MSGT_SETUP = 0x05 ,
  Q931_MSGT_SETUP_ACK = 0x0d ,
  Q931_MSGT_RESUME = 0x26 ,
  Q931_MSGT_RESUME_ACK = 0x2e ,
  Q931_MSGT_RESUME_REJ = 0x22 ,
  Q931_MSGT_SUSPEND = 0x25 ,
  Q931_MSGT_SUSPEND_ACK = 0x2d ,
  Q931_MSGT_USER_INFO = 0x20 ,
  Q931_MSGT_DISCONNECT = 0x45 ,
  Q931_MSGT_RELEASE = 0x4d ,
  Q931_MSGT_RELEASE_COMPLETE = 0x5a ,
  Q931_MSGT_RESTART = 0x46 ,
  Q931_MSGT_RESTART_ACK = 0x4e ,
  Q931_MSGT_SEGMENT = 0x60 ,
  Q931_MSGT_CONGESTION_CONTROL = 0x79 ,
  Q931_MSGT_IFORMATION = 0x7b ,
  Q931_MSGT_NOTIFY = 0x6e ,
  Q931_MSGT_STATUS = 0x7d ,
  Q931_MSGT_STATUS_ENQUIRY = 0x75
}
 
enum  q933_type_of_report {
  Q933_REPT_FULL_STATUS = 0x00 ,
  Q933_REPT_LINK_INTEGRITY_VERIF = 0x01 ,
  Q933_REPT_SINGLE_PVC_ASYNC_STS = 0x02
}
 
enum  q933_iei {
  Q933_IEI_REPORT_TYPE = 0x51 ,
  Q933_IEI_LINK_INT_VERIF = 0x53 ,
  Q933_IEI_PVC_STATUS = 0x57
}
 
enum  q933_pvc_status {
  Q933_PVC_STATUS_DLC_ACTIVE = 0x02 ,
  Q933_PVC_STATUS_DLC_DELETE = 0x04 ,
  Q933_PVC_STATUS_DLC_NEW = 0x08
}
 

Functions

struct q933_a_hdr __attribute__ ((packed))
 
static void check_link_state (struct osmo_fr_link *link, bool valid)
 
static uint16_t q922_to_dlci (const uint8_t *hdr)
 
static void dlci_to_q922 (uint8_t *hdr, uint16_t dlci)
 
static void dlc_set_active (struct osmo_fr_dlc *dlc, bool active)
 
static struct msgbq933_msgb_alloc (uint16_t dlci, uint8_t prot_disc, uint8_t msg_type)
 
static uint8_t link_get_tx_seq (struct osmo_fr_link *link)
 
static void msgb_put_link_int_verif (struct msgb *msg, struct osmo_fr_link *link)
 
static void dlc_destroy (struct osmo_fr_dlc *dlc)
 
static void msgb_put_pvc_status (struct msgb *msg, struct osmo_fr_dlc *dlc)
 
static int tx_lmi_q933_status_enq (struct osmo_fr_link *link, uint8_t rep_type)
 
static int tx_lmi_q933_status (struct osmo_fr_link *link, uint8_t rep_type)
 
static void link_set_failed (struct osmo_fr_link *link)
 
static int rx_lmi_q933_status_enq (struct msgb *msg, struct tlv_parsed *tp)
 
static int validate_pvc_status (struct tlv_parsed *tp, size_t tp_len)
 
static int parse_full_pvc_status (struct osmo_fr_link *link, struct tlv_parsed *tp, size_t tp_len)
 
static int parse_link_pvc_status (struct osmo_fr_link *link, struct tlv_parsed *tp, size_t tp_len)
 
static size_t count_pvc_status (struct tlv_parsed *tp, size_t tp_len)
 
static int rx_lmi_q933_status (struct msgb *msg, struct tlv_parsed *tp)
 
static int rx_lmi_q922 (struct msgb *msg)
 
int osmo_fr_rx (struct msgb *msg)
 
int osmo_fr_tx_dlc (struct msgb *msg)
 
static void fr_t391_cb (void *data)
 
static void fr_t392_cb (void *data)
 
struct osmo_fr_networkosmo_fr_network_alloc (void *ctx)
 
void osmo_fr_network_free (struct osmo_fr_network *net)
 
struct osmo_fr_linkosmo_fr_link_alloc (struct osmo_fr_network *net, enum osmo_fr_role role, const char *name)
 
void osmo_fr_link_free (struct osmo_fr_link *link)
 
struct osmo_fr_dlcosmo_fr_dlc_alloc (struct osmo_fr_link *link, uint16_t dlci)
 
void osmo_fr_dlc_free (struct osmo_fr_dlc *dlc)
 
struct osmo_fr_dlcosmo_fr_dlc_by_dlci (struct osmo_fr_link *link, uint16_t dlci)
 
static void fr_dlc_dump_vty (struct vty *vty, const struct osmo_fr_dlc *dlc)
 
static void fr_link_dump_vty (struct vty *vty, const struct osmo_fr_link *link)
 
void osmo_fr_network_dump_vty (struct vty *vty, const struct osmo_fr_network *net)
 

Variables

uint8_t prot_disc
 
uint8_t call_ref
 
uint8_t msg_type
 
const struct value_string osmo_fr_role_names []
 
struct osmo_tdef fr_tdefs []
 
static const struct tlv_definition q933_att_tlvdef
 

Detailed Description

Implement frame relay/PVC by Q.933.

Macro Definition Documentation

◆ DFR

#define DFR   DLNS

◆ LAPF_UI

#define LAPF_UI   0x03 /* UI control word */

◆ LMI_CISCO_DLCI

#define LMI_CISCO_DLCI   1023 /* Cisco DLCI */

◆ LMI_Q933A_CALLREF

#define LMI_Q933A_CALLREF   0x00 /* NULL call-ref */

◆ LMI_Q933A_DLCI

#define LMI_Q933A_DLCI   0 /* Q.933A DLCI */

◆ LOGPFRL

#define LOGPFRL (   frl,
  lvl,
  fmt,
  args ... 
)     LOGP(DFR, lvl, "%s: " fmt, (frl)->name, ## args)

◆ MAX_SUPPORTED_PVC

#define MAX_SUPPORTED_PVC   10

◆ Q931_PDISC_CC

#define Q931_PDISC_CC   0x08 /* protocol discriminator */

Enumeration Type Documentation

◆ q931_msgtype

Enumerator
Q931_MSGT_ALERTING 
Q931_MSGT_CALL_PROCEEDING 
Q931_MSGT_CONNECT 
Q931_MSGT_CONNECT_ACK 
Q931_MSGT_PROGRESS 
Q931_MSGT_SETUP 
Q931_MSGT_SETUP_ACK 
Q931_MSGT_RESUME 
Q931_MSGT_RESUME_ACK 
Q931_MSGT_RESUME_REJ 
Q931_MSGT_SUSPEND 
Q931_MSGT_SUSPEND_ACK 
Q931_MSGT_USER_INFO 
Q931_MSGT_DISCONNECT 
Q931_MSGT_RELEASE 
Q931_MSGT_RELEASE_COMPLETE 
Q931_MSGT_RESTART 
Q931_MSGT_RESTART_ACK 
Q931_MSGT_SEGMENT 
Q931_MSGT_CONGESTION_CONTROL 
Q931_MSGT_IFORMATION 
Q931_MSGT_NOTIFY 
Q931_MSGT_STATUS 
Q931_MSGT_STATUS_ENQUIRY 

◆ q933_iei

enum q933_iei
Enumerator
Q933_IEI_REPORT_TYPE 
Q933_IEI_LINK_INT_VERIF 
Q933_IEI_PVC_STATUS 

◆ q933_pvc_status

Enumerator
Q933_PVC_STATUS_DLC_ACTIVE 
Q933_PVC_STATUS_DLC_DELETE 
Q933_PVC_STATUS_DLC_NEW 

◆ q933_type_of_report

Enumerator
Q933_REPT_FULL_STATUS 
Q933_REPT_LINK_INTEGRITY_VERIF 
Q933_REPT_SINGLE_PVC_ASYNC_STS 

Function Documentation

◆ check_link_state()

◆ count_pvc_status()

static size_t count_pvc_status ( struct tlv_parsed tp,
size_t  tp_len 
)
static

References Q933_IEI_PVC_STATUS, and TLVP_PRESENT.

Referenced by rx_lmi_q933_status().

◆ dlc_destroy()

static void dlc_destroy ( struct osmo_fr_dlc dlc)
static

References osmo_fr_dlc::list, and llist_del().

Referenced by msgb_put_pvc_status().

◆ dlc_set_active()

◆ dlci_to_q922()

static void dlci_to_q922 ( uint8_t *  hdr,
uint16_t  dlci 
)
inlinestatic

References hdr.

Referenced by osmo_fr_tx_dlc(), and q933_msgb_alloc().

◆ fr_dlc_dump_vty()

static void fr_dlc_dump_vty ( struct vty vty,
const struct osmo_fr_dlc dlc 
)
static

◆ fr_link_dump_vty()

◆ fr_t391_cb()

◆ fr_t392_cb()

◆ link_get_tx_seq()

static uint8_t link_get_tx_seq ( struct osmo_fr_link link)
static

◆ link_set_failed()

◆ msgb_put_link_int_verif()

static void msgb_put_link_int_verif ( struct msgb msg,
struct osmo_fr_link link 
)
static

◆ msgb_put_pvc_status()

◆ osmo_fr_dlc_alloc()

◆ osmo_fr_dlc_by_dlci()

struct osmo_fr_dlc * osmo_fr_dlc_by_dlci ( struct osmo_fr_link link,
uint16_t  dlci 
)

◆ osmo_fr_dlc_free()

void osmo_fr_dlc_free ( struct osmo_fr_dlc dlc)

References osmo_fr_dlc::list, and llist_del().

Referenced by osmo_fr_link_free().

◆ osmo_fr_link_alloc()

◆ osmo_fr_link_free()

◆ osmo_fr_network_alloc()

struct osmo_fr_network * osmo_fr_network_alloc ( void *  ctx)

◆ osmo_fr_network_dump_vty()

void osmo_fr_network_dump_vty ( struct vty vty,
const struct osmo_fr_network net 
)

◆ osmo_fr_network_free()

void osmo_fr_network_free ( struct osmo_fr_network net)

◆ osmo_fr_rx()

◆ osmo_fr_tx_dlc()

◆ parse_full_pvc_status()

◆ parse_link_pvc_status()

◆ q922_to_dlci()

static uint16_t q922_to_dlci ( const uint8_t *  hdr)
inlinestatic

References hdr.

Referenced by osmo_fr_rx().

◆ q933_msgb_alloc()

static struct msgb * q933_msgb_alloc ( uint16_t  dlci,
uint8_t  prot_disc,
uint8_t  msg_type 
)
static

◆ rx_lmi_q922()

◆ rx_lmi_q933_status()

◆ rx_lmi_q933_status_enq()

◆ tx_lmi_q933_status()

◆ tx_lmi_q933_status_enq()

◆ validate_pvc_status()

static int validate_pvc_status ( struct tlv_parsed tp,
size_t  tp_len 
)
static

Variable Documentation

◆ call_ref

uint8_t call_ref

◆ fr_tdefs

struct osmo_tdef fr_tdefs[]
Initial value:
= {
{
.T=391,
.default_val = 10,
.min_val = 5,
.max_val = 30,
.desc = "Link integrity verification polling timer",
.unit = OSMO_TDEF_S,
}, {
.T=392,
.default_val = 15,
.min_val = 5,
.max_val = 30,
.desc = "Polling verification timer",
.unit = OSMO_TDEF_S,
},
{}
}
OSMO_TDEF_S

Referenced by osmo_fr_network_alloc().

◆ msg_type

uint8_t msg_type

Referenced by q933_msgb_alloc().

◆ osmo_fr_role_names

const struct value_string osmo_fr_role_names[]
Initial value:
= {
{ FR_ROLE_NETWORK_EQUIPMENT, "NETWORK" },
{ 0, NULL }
}
@ FR_ROLE_NETWORK_EQUIPMENT
Definition: frame_relay.h:40
@ FR_ROLE_USER_EQUIPMENT
Definition: frame_relay.h:39

Referenced by osmo_fr_role_str().

◆ prot_disc

uint8_t prot_disc

Referenced by q933_msgb_alloc().

◆ q933_att_tlvdef

const struct tlv_definition q933_att_tlvdef
static
Initial value:
= {
.def = {
},
}
@ Q933_IEI_REPORT_TYPE
Definition: frame_relay.c:90
@ Q933_IEI_LINK_INT_VERIF
Definition: frame_relay.c:91
@ Q933_IEI_PVC_STATUS
Definition: frame_relay.c:92
TLV_TYPE_TLV

Referenced by rx_lmi_q922().