libosmoisdn 1.13.1.1-afb4 Osmocom ISDN library

Files | Data Structures | Macros | Enumerations | Functions | Variables
LAPD implementation common part

Osmocom LAPD core, used for Q.921, LAPDm and others. More...

## Files
file | lapd_core.h
| primitive related stuff
file | lapd_core.c
| LAPD core implementation.

## Data Structures
struct | mdl_error_ind_param
| for MDL-ERROR.ind More...
struct | dl_rel_req_param
| for DL-REL.req More...
struct | osmo_dlsap_prim
| primitive header for LAPD DL-SAP primitives More...
struct | lapd_msg_ctx
| LAPD message context. More...
struct | lapd_cr_ent
struct | lapd_history
struct | lapd_datalink
| LAPD datalink. More...
struct | l2downstate

## Macros
#define | LOGDL(dl, level, fmt, args...) LOGP(DLLAPD, level, "(%s) " fmt, (dl)->name, ## args)
#define | MDL_CAUSE_T200_EXPIRED 0x01
#define | MDL_CAUSE_REEST_REQ 0x02
#define | MDL_CAUSE_UNSOL_UA_RESP 0x03
#define | MDL_CAUSE_UNSOL_DM_RESP 0x04
#define | MDL_CAUSE_UNSOL_DM_RESP_MF 0x05
#define | MDL_CAUSE_UNSOL_SPRV_RESP 0x06
#define | MDL_CAUSE_SEQ_ERR 0x07
#define | MDL_CAUSE_UFRM_INC_PARAM 0x08
#define | MDL_CAUSE_SFRM_INC_PARAM 0x09
#define | MDL_CAUSE_IFRM_INC_MBITS 0x0a
#define | MDL_CAUSE_IFRM_INC_LEN 0x0b
#define | MDL_CAUSE_FRM_UNIMPL 0x0c
#define | MDL_CAUSE_SABM_MF 0x0d
#define | MDL_CAUSE_SABM_INFO_NOTALL 0x0e
#define | MDL_CAUSE_FRMR 0x0f
#define | LAPD_F_RTS 0x0001
| lapd_flags More...
#define | LAPD_F_DROP_2ND_REJ 0x0002
#define | LAPD_U_SABM 0x7
#define | LAPD_U_SABME 0xf
#define | LAPD_U_DM 0x3
#define | LAPD_U_UI 0x0
#define | LAPD_U_DISC 0x8
#define | LAPD_U_UA 0xC
#define | LAPD_U_FRMR 0x11
#define | LAPD_S_RR 0x0
#define | LAPD_S_RNR 0x1
#define | LAPD_S_REJ 0x2
#define | CR_USER2NET_CMD 0
#define | CR_USER2NET_RESP 1
#define | CR_NET2USER_CMD 1
#define | CR_NET2USER_RESP 0
#define | LAPD_HEADROOM 56
#define | LAPD_TAILROOM 16
#define | SBIT(a) (1 << a)
#define | ALL_STATES 0xffffffff
#define | L2DOWNSLLEN (sizeof(l2downstatelist) / sizeof(struct l2downstate))

## Enumerations
enum | osmo_dl_prim { PRIM_DL_UNIT_DATA , PRIM_DL_DATA , PRIM_DL_EST , PRIM_DL_REL , PRIM_DL_SUSP , PRIM_DL_RES , PRIM_DL_RECON , PRIM_MDL_ERROR }
| LAPD related primitives (L2<->L3 SAP) More...
enum | lapd_mode { LAPD_MODE_USER , LAPD_MODE_NETWORK }
| LAPD mode/role. More...
enum | lapd_state { LAPD_STATE_NULL = 0 , LAPD_STATE_TEI_UNASS , LAPD_STATE_ASS_TEI_WAIT , LAPD_STATE_EST_TEI_WAIT , LAPD_STATE_IDLE , LAPD_STATE_SABM_SENT , LAPD_STATE_DISC_SENT , LAPD_STATE_MF_EST , LAPD_STATE_TIMER_RECOV }
| LAPD state (Figure B.2/Q.921) More...
enum | lapd_t200_rts { LAPD_T200_RTS_OFF = 0 , LAPD_T200_RTS_PENDING , LAPD_T200_RTS_RUNNING }
| LAPD T200 state in RTS mode. More...
enum | lapd_format { LAPD_FORM_UKN = 0 , LAPD_FORM_I , LAPD_FORM_S , LAPD_FORM_U }
| LAPD message format (I / S / U) More...

## Functions
void | lapd_dl_init (struct lapd_datalink *dl, uint8_t k, uint8_t v_range, int maxf)
| Initialize LAPD datalink instance and allocate history. More...
void | lapd_dl_init2 (struct lapd_datalink *dl, uint8_t k, uint8_t v_range, int maxf, const char *name)
| Initialize LAPD datalink instance and allocate history. More...
void | lapd_dl_set_name (struct lapd_datalink *dl, const char *name)
void | lapd_dl_exit (struct lapd_datalink *dl)
void | lapd_dl_reset (struct lapd_datalink *dl)
int | lapd_dl_set_flags (struct lapd_datalink *dl, unsigned int flags)
| Set lapd_flags to change behaviour. More...
int | lapd_set_mode (struct lapd_datalink *dl, enum lapd_mode mode)
| Set the lapdm_mode of a LAPDm entity. More...
int | lapd_ph_data_ind (struct msgb *msg, struct lapd_msg_ctx *lctx)
int | lapd_ph_rts_ind (struct lapd_msg_ctx *lctx)
| Enqueue next LAPD frame and run pending T200. More...
int | lapd_recv_dlsap (struct osmo_dlsap_prim *dp, struct lapd_msg_ctx *lctx)
int | lapd_t200_timeout (struct lapd_datalink *dl)
| Handle timeout condition of T200 in RTS mode. More...
static void | lapd_t200_cb (void *data)
static void | lapd_t203_cb (void *data)
static int | lapd_send_i (struct lapd_datalink *dl, int line, bool rts)
static int | lapd_est_req (struct osmo_dlsap_prim *dp, struct lapd_msg_ctx *lctx)
struct msgb * | lapd_msgb_alloc (int length, const char *name)
static uint8_t | do_mod (uint8_t x, uint8_t m)
static uint8_t | inc_mod (uint8_t x, uint8_t m)
static uint8_t | add_mod (uint8_t x, uint8_t y, uint8_t m)
static uint8_t | sub_mod (uint8_t x, uint8_t y, uint8_t m)
static void | lapd_dl_flush_send (struct lapd_datalink *dl)
static void | lapd_dl_flush_hist (struct lapd_datalink *dl)
static void | lapd_dl_flush_tx_queue (struct lapd_datalink *dl)
static void | lapd_dl_flush_tx (struct lapd_datalink *dl)
static const char * | lapd_state_name (enum lapd_state state)
static void | lapd_start_t200 (struct lapd_datalink *dl)
static void | lapd_start_t203 (struct lapd_datalink *dl)
static void | lapd_stop_t200 (struct lapd_datalink *dl)
static bool | lapd_is_t200_started (struct lapd_datalink *dl)
static void | lapd_stop_t203 (struct lapd_datalink *dl)
static void | lapd_dl_newstate (struct lapd_datalink *dl, uint32_t state)
static int | send_dl_l3 (uint8_t prim, uint8_t op, struct lapd_msg_ctx *lctx, struct msgb *msg)
static int | send_dl_simple (uint8_t prim, uint8_t op, struct lapd_msg_ctx *lctx)
static int | mdl_error (uint8_t cause, struct lapd_msg_ctx *lctx)
static int | lapd_send_ua (struct lapd_msg_ctx *lctx, uint8_t len, uint8_t *data)
static int | lapd_send_dm (struct lapd_msg_ctx *lctx)
static int | lapd_send_rr (struct lapd_msg_ctx *lctx, uint8_t f_bit, uint8_t cmd)
static int | lapd_send_rnr (struct lapd_msg_ctx *lctx, uint8_t f_bit, uint8_t cmd)
static int | lapd_send_rej (struct lapd_msg_ctx *lctx, uint8_t f_bit)
static int | lapd_send_resend (struct lapd_datalink *dl)
static int | lapd_reestablish (struct lapd_datalink *dl)
static int | lapd_acknowledge (struct lapd_msg_ctx *lctx)
static int | lapd_rx_u_sabm (struct msgb *msg, struct lapd_msg_ctx *lctx)
static int | lapd_rx_u_dm (struct msgb *msg, struct lapd_msg_ctx *lctx)
static int | lapd_rx_u_ui (struct msgb *msg, struct lapd_msg_ctx *lctx)
static int | lapd_rx_u_disc (struct msgb *msg, struct lapd_msg_ctx *lctx)
static int | lapd_rx_u_ua (struct msgb *msg, struct lapd_msg_ctx *lctx)
static int | lapd_rx_u_frmr (struct msgb *msg, struct lapd_msg_ctx *lctx)
static int | lapd_rx_u (struct msgb *msg, struct lapd_msg_ctx *lctx)
static int | lapd_rx_s (struct msgb *msg, struct lapd_msg_ctx *lctx)
static int | lapd_rx_i (struct msgb *msg, struct lapd_msg_ctx *lctx)
static int | lapd_udata_req (struct osmo_dlsap_prim *dp, struct lapd_msg_ctx *lctx)
static void | msg_to_tx_hist (struct lapd_history *tx_hist, const struct msgb *msg, int length, int more)
static void | msg_to_tx_hist0 (struct lapd_datalink *dl, const struct msgb *msg)
static int | lapd_data_req (struct osmo_dlsap_prim *dp, struct lapd_msg_ctx *lctx)
static int | lapd_susp_req (struct osmo_dlsap_prim *dp, struct lapd_msg_ctx *lctx)
static int | lapd_res_req (struct osmo_dlsap_prim *dp, struct lapd_msg_ctx *lctx)
static int | lapd_rel_req (struct osmo_dlsap_prim *dp, struct lapd_msg_ctx *lctx)
static int | lapd_rel_req_idle (struct osmo_dlsap_prim *dp, struct lapd_msg_ctx *lctx)

## Variables
const struct value_string | lapd_state_names []
void * | tall_lapd_ctx = NULL
static const struct l2downstate | l2downstatelist []

## Detailed Description

Osmocom LAPD core, used for Q.921, LAPDm and others.

Notes on Buffering: rcv_buffer, tx_queue, tx_hist, send_buffer, send_queue

RX data is stored in the rcv_buffer (pointer). If the message is complete, it is removed from rcv_buffer pointer and forwarded to L3. If the RX data is received while there is an incomplete rcv_buffer, it is appended to it.

TX data is stored in the send_queue first. When transmitting a frame, the first message in the send_queue is moved to the send_buffer. There it resides until all fragments are acknowledged. Fragments to be sent by I frames are stored in the tx_hist buffer for resend, if required. Also the current fragment is copied into the tx_queue. There it resides until it is forwarded to layer 1.

In case we have SAPI 0, we only have a window size of 1, so the unack- nowledged message resides always in the send_buffer. In case of a suspend, it can be written back to the first position of the send_queue.

The layer 1 normally sends a PH-READY-TO-SEND. But because we use asynchronous transfer between layer 1 and layer 2 (serial link), we must send a frame before layer 1 reaches the right timeslot to send it. So we move the tx_queue to layer 1 when there is not already a pending frame, and wait until acknowledge after the frame has been sent. If we receive an acknowledge, we can send the next frame from the buffer, if any.

The moving of tx_queue to layer 1 may also trigger T200, if desired. Also it will trigger next I frame, if possible.

T203 is optional. It will be stated when entering MF EST state. It will also be started when I or S frame is received in that state . It will be restarted in the lapd_acknowledge() function, in case outstanding frames will not trigger T200. It will be stoped, when T200 is started in MF EST state. It will also be stoped when leaving MF EST state.

## Macro Definition Documentation

## ◆ ALL_STATES

#define ALL_STATES 0xffffffff

## ◆ CR_NET2USER_CMD

#define CR_NET2USER_CMD 1

## ◆ CR_NET2USER_RESP

#define CR_NET2USER_RESP 0

## ◆ CR_USER2NET_CMD

#define CR_USER2NET_CMD 0

## ◆ CR_USER2NET_RESP

#define CR_USER2NET_RESP 1

## ◆ L2DOWNSLLEN

#define L2DOWNSLLEN (sizeof(l2downstatelist) / sizeof(struct l2downstate))

## ◆ LAPD_F_DROP_2ND_REJ

#define LAPD_F_DROP_2ND_REJ 0x0002

## ◆ LAPD_F_RTS

#define LAPD_F_RTS 0x0001

lapd_flags

## ◆ LAPD_HEADROOM

#define LAPD_HEADROOM 56

## ◆ LAPD_S_REJ

#define LAPD_S_REJ 0x2

## ◆ LAPD_S_RNR

#define LAPD_S_RNR 0x1

## ◆ LAPD_S_RR

#define LAPD_S_RR 0x0

## ◆ LAPD_TAILROOM

#define LAPD_TAILROOM 16

## ◆ LAPD_U_DISC

#define LAPD_U_DISC 0x8

## ◆ LAPD_U_DM

#define LAPD_U_DM 0x3

## ◆ LAPD_U_FRMR

#define LAPD_U_FRMR 0x11

## ◆ LAPD_U_SABM

#define LAPD_U_SABM 0x7

## ◆ LAPD_U_SABME

#define LAPD_U_SABME 0xf

## ◆ LAPD_U_UA

#define LAPD_U_UA 0xC

## ◆ LAPD_U_UI

#define LAPD_U_UI 0x0

## ◆ LOGDL

#define LOGDL | ( |  | dl,
|  |  | level,
|  |  | fmt,
|  |  | args...
| ) |  | LOGP(DLLAPD, level, "(%s) " fmt, (dl)->name, ## args)

## ◆ MDL_CAUSE_FRM_UNIMPL

#define MDL_CAUSE_FRM_UNIMPL 0x0c

## ◆ MDL_CAUSE_FRMR

#define MDL_CAUSE_FRMR 0x0f

## ◆ MDL_CAUSE_IFRM_INC_LEN

#define MDL_CAUSE_IFRM_INC_LEN 0x0b

## ◆ MDL_CAUSE_IFRM_INC_MBITS

#define MDL_CAUSE_IFRM_INC_MBITS 0x0a

## ◆ MDL_CAUSE_REEST_REQ

#define MDL_CAUSE_REEST_REQ 0x02

## ◆ MDL_CAUSE_SABM_INFO_NOTALL

#define MDL_CAUSE_SABM_INFO_NOTALL 0x0e

## ◆ MDL_CAUSE_SABM_MF

#define MDL_CAUSE_SABM_MF 0x0d

## ◆ MDL_CAUSE_SEQ_ERR

#define MDL_CAUSE_SEQ_ERR 0x07

## ◆ MDL_CAUSE_SFRM_INC_PARAM

#define MDL_CAUSE_SFRM_INC_PARAM 0x09

## ◆ MDL_CAUSE_T200_EXPIRED

#define MDL_CAUSE_T200_EXPIRED 0x01

## ◆ MDL_CAUSE_UFRM_INC_PARAM

#define MDL_CAUSE_UFRM_INC_PARAM 0x08

## ◆ MDL_CAUSE_UNSOL_DM_RESP

#define MDL_CAUSE_UNSOL_DM_RESP 0x04

## ◆ MDL_CAUSE_UNSOL_DM_RESP_MF

#define MDL_CAUSE_UNSOL_DM_RESP_MF 0x05

## ◆ MDL_CAUSE_UNSOL_SPRV_RESP

#define MDL_CAUSE_UNSOL_SPRV_RESP 0x06

## ◆ MDL_CAUSE_UNSOL_UA_RESP

#define MDL_CAUSE_UNSOL_UA_RESP 0x03

## ◆ SBIT

#define SBIT | ( |  | a | ) | (1 << a)

## Enumeration Type Documentation

## ◆ lapd_format

enum lapd_format

LAPD message format (I / S / U)

Enumerator
LAPD_FORM_UKN |
LAPD_FORM_I |
LAPD_FORM_S |
LAPD_FORM_U |

## ◆ lapd_mode

enum lapd_mode

LAPD mode/role.

Enumerator
LAPD_MODE_USER | behave like user
LAPD_MODE_NETWORK | behave like network

## ◆ lapd_state

enum lapd_state

LAPD state (Figure B.2/Q.921)

Enumerator
LAPD_STATE_NULL |
LAPD_STATE_TEI_UNASS |
LAPD_STATE_ASS_TEI_WAIT |
LAPD_STATE_EST_TEI_WAIT |
LAPD_STATE_IDLE |
LAPD_STATE_SABM_SENT |
LAPD_STATE_DISC_SENT |
LAPD_STATE_MF_EST |
LAPD_STATE_TIMER_RECOV |

## ◆ lapd_t200_rts

enum lapd_t200_rts

LAPD T200 state in RTS mode.

Enumerator
LAPD_T200_RTS_OFF |
LAPD_T200_RTS_PENDING |
LAPD_T200_RTS_RUNNING |

## ◆ osmo_dl_prim

enum osmo_dl_prim

LAPD related primitives (L2<->L3 SAP)

Enumerator
PRIM_DL_UNIT_DATA | DL-UNIT-DATA.
PRIM_DL_DATA | DL-DATA.
PRIM_DL_EST | DL-ESTABLISH.
PRIM_DL_REL | DL-RLEEASE.
PRIM_DL_SUSP | DL-SUSPEND.
PRIM_DL_RES | DL-RESUME.
PRIM_DL_RECON | DL-RECONNECT.
PRIM_MDL_ERROR | MDL-ERROR.

## Function Documentation

## ◆ add_mod()

static uint8_t add_mod | ( | uint8_t | x,
|  | uint8_t | y,
|  | uint8_t | m
| ) |  |
| inline static

References x.

Referenced by lapd_send_i().

## ◆ do_mod()

static uint8_t do_mod | ( | uint8_t | x,
|  | uint8_t | m
| ) |  |
| inline static

References x.

Referenced by lapd_acknowledge(), lapd_send_i(), lapd_send_resend(), and lapd_t200_cb().

## ◆ inc_mod()

static uint8_t inc_mod | ( | uint8_t | x,
|  | uint8_t | m
| ) |  |
| inline static

References x.

Referenced by lapd_acknowledge(), lapd_rx_i(), and lapd_send_i().

## ◆ lapd_acknowledge()

static int lapd_acknowledge | ( | struct lapd_msg_ctx * | lctx | ) |
| static

References lapd_msg_ctx::dl, do_mod(), lapd_msg_ctx::format, inc_mod(), LAPD_FORM_S, lapd_is_t200_started(), LAPD_S_REJ, lapd_start_t200(), lapd_start_t203(), LAPD_STATE_MF_EST, LAPD_STATE_TIMER_RECOV, lapd_stop_t200(), lapd_stop_t203(), lapd_datalink::lctx, LOGDL, LOGL_INFO, LOGL_NOTICE, MDL_CAUSE_SEQ_ERR, lapd_history::msg, msgb_free(), lapd_msg_ctx::n_recv, lapd_datalink::range_hist, lapd_msg_ctx::s_u, lapd_datalink::state, sub_mod(), lapd_datalink::t203_sec, lapd_datalink::t203_usec, lapd_datalink::tx_hist, lapd_datalink::v_ack, lapd_datalink::v_range, and lapd_datalink::v_send.

Referenced by lapd_rx_i(), and lapd_rx_s().

## ◆ lapd_data_req()

static int lapd_data_req | ( | struct osmo_dlsap_prim * | dp,
|  | struct lapd_msg_ctx * | lctx
| ) |  |
| static

References lapd_msg_ctx::dl, lapd_send_i(), lapd_datalink::lctx, LOGDL, LOGL_ERROR, LOGL_INFO, osmo_prim_hdr::msg, msgb_enqueue(), msgb_free(), msgb_l3len(), osmo_dlsap_prim::oph, lapd_datalink::send_queue, and tall_lapd_ctx.

## ◆ lapd_dl_exit()

void lapd_dl_exit | ( | struct lapd_datalink * | dl | ) |

References lapd_dl_newstate(), lapd_dl_reset(), LAPD_STATE_NULL, lapd_datalink::name, and lapd_datalink::tx_hist.

## ◆ lapd_dl_flush_hist()

static void lapd_dl_flush_hist | ( | struct lapd_datalink * | dl | ) |
| static

References lapd_history::msg, msgb_free(), lapd_datalink::range_hist, and lapd_datalink::tx_hist.

Referenced by lapd_dl_flush_tx(), lapd_est_req(), lapd_rel_req(), lapd_res_req(), lapd_rx_u_sabm(), and lapd_rx_u_ua().

## ◆ lapd_dl_flush_send()

static void lapd_dl_flush_send | ( | struct lapd_datalink * | dl | ) |
| static

References msgb_dequeue(), msgb_free(), lapd_datalink::send_buffer, and lapd_datalink::send_queue.

Referenced by lapd_dl_reset(), lapd_est_req(), lapd_rel_req(), lapd_rx_u_disc(), lapd_rx_u_dm(), lapd_rx_u_ua(), and lapd_t200_cb().

## ◆ lapd_dl_flush_tx()

static void lapd_dl_flush_tx | ( | struct lapd_datalink * | dl | ) |
| static

References lapd_dl_flush_hist(), and lapd_dl_flush_tx_queue().

Referenced by lapd_dl_reset(), lapd_rel_req(), lapd_rx_u_disc(), lapd_rx_u_dm(), lapd_rx_u_ua(), lapd_susp_req(), and lapd_t200_cb().

## ◆ lapd_dl_flush_tx_queue()

static void lapd_dl_flush_tx_queue | ( | struct lapd_datalink * | dl | ) |
| static

References msgb_dequeue(), msgb_free(), and lapd_datalink::tx_queue.

Referenced by lapd_dl_flush_tx(), and lapd_rx_s().

## ◆ lapd_dl_init()

void lapd_dl_init | ( | struct lapd_datalink * | dl,
|  | uint8_t | k,
|  | uint8_t | v_range,
|  | int | maxf
| ) |  |

Initialize LAPD datalink instance and allocate history.

Parameters

  [in] | dl | caller-allocated datalink structure
  [in] | k | maximum number of unacknowledged frames
  [in] | v_range | range of sequence numbers
  [in] | maxf | maximum frame size (after defragmentation)

References lapd_dl_init2().

## ◆ lapd_dl_init2()

void lapd_dl_init2 | ( | struct lapd_datalink * | dl,
|  | uint8_t | k,
|  | uint8_t | v_range,
|  | int | maxf,
|  | const char * | name
| ) |  |

Initialize LAPD datalink instance and allocate history.

Parameters

  [in] | dl | caller-allocated datalink structure
  [in] | k | maximum number of unacknowledged frames
  [in] | v_range | range of sequence numbers
  [in] | maxf | maximum frame size (after defragmentation)
  [in] | name | human-readable name for this LAPD datalink

References INIT_LLIST_HEAD, lapd_datalink::k, lapd_dl_newstate(), LAPD_STATE_IDLE, lapd_t200_cb(), lapd_t203_cb(), LOGDL, LOGL_INFO, lapd_datalink::maxf, lapd_datalink::n200, lapd_datalink::n200_est_rel, name, lapd_datalink::name, OSMO_ASSERT, osmo_timer_setup(), lapd_datalink::range_hist, lapd_datalink::reestablish, lapd_datalink::send_queue, lapd_datalink::t200, lapd_datalink::t200_sec, lapd_datalink::t200_usec, lapd_datalink::t203, lapd_datalink::t203_sec, lapd_datalink::t203_usec, tall_lapd_ctx, lapd_datalink::tx_hist, lapd_datalink::tx_queue, and lapd_datalink::v_range.

Referenced by lapd_dl_init().

## ◆ lapd_dl_newstate()

static void lapd_dl_newstate | ( | struct lapd_datalink * | dl,
|  | uint32_t | state
| ) |  |
| static

References lapd_datalink::cont_res, lapd_start_t203(), LAPD_STATE_MF_EST, lapd_state_name(), lapd_stop_t203(), LOGDL, LOGL_INFO, msgb_free(), lapd_datalink::state, lapd_datalink::t203_sec, and lapd_datalink::t203_usec.

Referenced by lapd_dl_exit(), lapd_dl_init2(), lapd_dl_reset(), lapd_est_req(), lapd_rel_req(), lapd_res_req(), lapd_rx_s(), lapd_rx_u_disc(), lapd_rx_u_dm(), lapd_rx_u_sabm(), lapd_rx_u_ua(), lapd_t200_cb(), and lapd_t203_cb().

## ◆ lapd_dl_reset()

void lapd_dl_reset | ( | struct lapd_datalink * | dl | ) |

References lapd_dl_flush_send(), lapd_dl_flush_tx(), lapd_dl_newstate(), LAPD_STATE_IDLE, lapd_stop_t200(), lapd_stop_t203(), LOGDL, LOGL_INFO, msgb_free(), lapd_datalink::rcv_buffer, and lapd_datalink::state.

Referenced by lapd_dl_exit().

## ◆ lapd_dl_set_flags()

int lapd_dl_set_flags | ( | struct lapd_datalink * | dl,
|  | unsigned int | flags
| ) |  |

Set lapd_flags to change behaviour.

Parameters

  [in] | dl | lapd_datalink instance
  [in] | flags | lapd_flags

References flags, LAPD_F_RTS, lapd_datalink::lapd_flags, lapd_is_t200_started(), LOGDL, and LOGL_ERROR.

## ◆ lapd_dl_set_name()

void lapd_dl_set_name | ( | struct lapd_datalink * | dl,
|  | const char * | name
| ) |  |

References name, lapd_datalink::name, osmo_talloc_replace_string(), and tall_lapd_ctx.

## ◆ lapd_est_req()

static int lapd_est_req | ( | struct osmo_dlsap_prim * | dp,
|  | struct lapd_msg_ctx * | lctx
| ) |  |
| static

References lapd_cr_ent::cmd, lapd_msg_ctx::cr, lapd_datalink::cr, lapd_msg_ctx::dl, lapd_msg_ctx::format, lapd_dl_flush_hist(), lapd_dl_flush_send(), lapd_dl_newstate(), LAPD_FORM_U, lapd_start_t200(), LAPD_STATE_SABM_SENT, LAPD_U_SABM, LAPD_U_SABME, lapd_datalink::lctx, msgb::len, lapd_msg_ctx::length, lapd_datalink::loc2rem, LOGDL, LOGL_INFO, lapd_msg_ctx::more, osmo_prim_hdr::msg, msg_to_tx_hist0(), msgb_free(), osmo_dlsap_prim::oph, lapd_datalink::own_busy, lapd_msg_ctx::p_f, lapd_datalink::peer_busy, lapd_datalink::rcv_buffer, lapd_datalink::retrans_ctr, lapd_msg_ctx::s_u, lapd_datalink::send_ph_data_req, lapd_datalink::use_sabme, and lapd_datalink::v_send.

Referenced by lapd_reestablish().

## ◆ lapd_is_t200_started()

static bool lapd_is_t200_started | ( | struct lapd_datalink * | dl | ) |
| static

References LAPD_F_RTS, lapd_datalink::lapd_flags, LAPD_T200_RTS_OFF, osmo_timer_pending(), lapd_datalink::t200, and lapd_datalink::t200_rts.

Referenced by lapd_acknowledge(), lapd_dl_set_flags(), and lapd_send_i().

## ◆ lapd_msgb_alloc()

struct msgb * lapd_msgb_alloc | ( | int | length,
|  | const char * | name
| ) |  |

References LAPD_HEADROOM, LAPD_TAILROOM, msgb_alloc_headroom(), and name.

Referenced by lapd_reestablish(), lapd_res_req(), lapd_rx_i(), lapd_rx_u_sabm(), lapd_send_dm(), lapd_send_i(), lapd_send_rej(), lapd_send_resend(), lapd_send_rnr(), lapd_send_rr(), lapd_send_ua(), lapd_t200_cb(), and msg_to_tx_hist().

## ◆ lapd_ph_data_ind()

int lapd_ph_data_ind | ( | struct msgb * | msg,
|  | struct lapd_msg_ctx * | lctx
| ) |  |

References lapd_msg_ctx::dl, lapd_msg_ctx::format, LAPD_FORM_I, LAPD_FORM_S, LAPD_FORM_U, lapd_rx_i(), lapd_rx_s(), lapd_rx_u(), lapd_datalink::lctx, LOGDL, LOGL_NOTICE, and msgb_free().

## ◆ lapd_ph_rts_ind()

int lapd_ph_rts_ind | ( | struct lapd_msg_ctx * | lctx | ) |

Enqueue next LAPD frame and run pending T200.

(Must be called when frame is ready to send.) The caller (LAPDm code) calls this function before it sends the next frame. If there is no frame in the TX queue, LAPD will enqueue next I-frame, if possible. If the T200 is pending, it is changed to running state.

Parameters

  [in] | lctx | LAPD context
  [out] | rc | set to 1, if timer T200 state changed to running, set to 0, if not.

References lapd_msg_ctx::dl, lapd_send_i(), LAPD_STATE_MF_EST, LAPD_STATE_TIMER_RECOV, LAPD_T200_RTS_PENDING, LAPD_T200_RTS_RUNNING, lapd_datalink::lctx, llist_empty(), lapd_datalink::state, lapd_datalink::t200_rts, and lapd_datalink::tx_queue.

## ◆ lapd_recv_dlsap()

int lapd_recv_dlsap | ( | struct osmo_dlsap_prim * | dp,
|  | struct lapd_msg_ctx * | lctx
| ) |  |

References lapd_msg_ctx::dl, L2DOWNSLLEN, l2downstatelist, lapd_state_name(), lapd_datalink::lctx, LOGDL, LOGL_INFO, LOGL_NOTICE, osmo_prim_hdr::msg, msgb_free(), name, l2downstate::op, osmo_prim_hdr::operation, osmo_dlsap_prim::oph, l2downstate::prim, osmo_prim_hdr::primitive, l2downstate::rout, SBIT, lapd_datalink::state, and l2downstate::states.

## ◆ lapd_reestablish()

static int lapd_reestablish | ( | struct lapd_datalink * | dl | ) |
| static

References lapd_est_req(), lapd_msgb_alloc(), lapd_datalink::lctx, LOGDL, LOGL_DEBUG, osmo_dlsap_prim::oph, osmo_prim_init(), PRIM_DL_EST, and PRIM_OP_REQUEST.

Referenced by lapd_rx_u_dm(), lapd_rx_u_frmr(), and lapd_t200_cb().

## ◆ lapd_rel_req()

static int lapd_rel_req | ( | struct osmo_dlsap_prim * | dp,
|  | struct lapd_msg_ctx * | lctx
| ) |  |
| static

References lapd_cr_ent::cmd, lapd_msg_ctx::cr, lapd_datalink::cr, lapd_msg_ctx::dl, lapd_msg_ctx::format, lapd_dl_flush_hist(), lapd_dl_flush_send(), lapd_dl_flush_tx(), lapd_dl_newstate(), LAPD_FORM_U, lapd_start_t200(), LAPD_STATE_DISC_SENT, LAPD_STATE_IDLE, lapd_stop_t200(), LAPD_U_DISC, lapd_datalink::lctx, lapd_msg_ctx::length, lapd_datalink::loc2rem, LOGDL, LOGL_INFO, dl_rel_req_param::mode, lapd_msg_ctx::more, osmo_prim_hdr::msg, msg_to_tx_hist0(), msgb_free(), osmo_dlsap_prim::oph, lapd_datalink::own_busy, lapd_msg_ctx::p_f, lapd_datalink::peer_busy, PRIM_DL_REL, PRIM_OP_CONFIRM, osmo_dlsap_prim::rel_req, lapd_datalink::retrans_ctr, lapd_msg_ctx::s_u, send_dl_simple(), lapd_datalink::send_ph_data_req, lapd_datalink::state, osmo_dlsap_prim::u, and lapd_datalink::v_send.

## ◆ lapd_rel_req_idle()

static int lapd_rel_req_idle | ( | struct osmo_dlsap_prim * | dp,
|  | struct lapd_msg_ctx * | lctx
| ) |  |
| static

References lapd_msg_ctx::dl, lapd_datalink::lctx, osmo_prim_hdr::msg, msgb_free(), osmo_dlsap_prim::oph, PRIM_DL_REL, PRIM_OP_CONFIRM, and send_dl_simple().

## ◆ lapd_res_req()

static int lapd_res_req | ( | struct osmo_dlsap_prim * | dp,
|  | struct lapd_msg_ctx * | lctx
| ) |  |
| static

References lapd_cr_ent::cmd, lapd_msg_ctx::cr, lapd_datalink::cr, msgb::data, lapd_msg_ctx::dl, lapd_msg_ctx::format, msgb::l3h, lapd_dl_flush_hist(), lapd_dl_newstate(), LAPD_FORM_U, lapd_msgb_alloc(), lapd_start_t200(), LAPD_STATE_SABM_SENT, LAPD_U_SABM, LAPD_U_SABME, lapd_datalink::lctx, msgb::len, lapd_msg_ctx::length, lapd_datalink::loc2rem, LOGDL, LOGL_INFO, lapd_msg_ctx::more, osmo_prim_hdr::msg, msg_to_tx_hist0(), msgb_free(), osmo_dlsap_prim::oph, lapd_datalink::own_busy, lapd_msg_ctx::p_f, lapd_datalink::peer_busy, lapd_datalink::rcv_buffer, lapd_datalink::retrans_ctr, lapd_msg_ctx::s_u, lapd_datalink::send_buffer, lapd_datalink::send_out, lapd_datalink::send_ph_data_req, lapd_datalink::use_sabme, and lapd_datalink::v_send.

## ◆ lapd_rx_i()

static int lapd_rx_i | ( | struct msgb * | msg,
|  | struct lapd_msg_ctx * | lctx
| ) |  |
| static

References lapd_msg_ctx::cr, lapd_datalink::cr, msgb::data, lapd_msg_ctx::dl, inc_mod(), msgb::l3h, lapd_acknowledge(), LAPD_F_DROP_2ND_REJ, lapd_datalink::lapd_flags, lapd_msgb_alloc(), lapd_send_dm(), lapd_send_i(), lapd_send_rej(), lapd_send_rnr(), lapd_send_rr(), LAPD_STATE_DISC_SENT, LAPD_STATE_IDLE, lapd_state_name(), LAPD_STATE_NULL, LAPD_STATE_SABM_SENT, lapd_datalink::lctx, lapd_msg_ctx::length, LOGDL, LOGL_ERROR, LOGL_INFO, LOGL_NOTICE, lapd_datalink::maxf, MDL_CAUSE_FRM_UNIMPL, MDL_CAUSE_IFRM_INC_LEN, MDL_CAUSE_IFRM_INC_MBITS, mdl_error(), lapd_msg_ctx::more, msgb_free(), msgb_l3len(), msgb_put(), msgb_trim(), lapd_msg_ctx::n201, lapd_msg_ctx::n_send, lapd_datalink::own_busy, lapd_msg_ctx::p_f, PRIM_DL_DATA, PRIM_OP_INDICATION, lapd_datalink::rcv_buffer, lapd_datalink::rem2loc, lapd_cr_ent::resp, lapd_msg_ctx::sapi, send_dl_l3(), lapd_datalink::seq_err_cond, lapd_datalink::state, lapd_datalink::update_pending_frames, lapd_datalink::v_range, and lapd_datalink::v_recv.

Referenced by lapd_ph_data_ind().

## ◆ lapd_rx_s()

static int lapd_rx_s | ( | struct msgb * | msg,
|  | struct lapd_msg_ctx * | lctx
| ) |  |
| static

References lapd_cr_ent::cmd, lapd_msg_ctx::cr, lapd_datalink::cr, lapd_msg_ctx::dl, lapd_acknowledge(), lapd_dl_flush_tx_queue(), lapd_dl_newstate(), LAPD_S_REJ, LAPD_S_RNR, LAPD_S_RR, lapd_send_dm(), lapd_send_i(), lapd_send_rnr(), lapd_send_rr(), LAPD_STATE_DISC_SENT, LAPD_STATE_IDLE, LAPD_STATE_MF_EST, lapd_state_name(), LAPD_STATE_SABM_SENT, LAPD_STATE_TIMER_RECOV, lapd_stop_t200(), lapd_datalink::lctx, lapd_msg_ctx::length, LOGDL, LOGL_ERROR, LOGL_INFO, LOGL_NOTICE, MDL_CAUSE_FRM_UNIMPL, MDL_CAUSE_SFRM_INC_PARAM, MDL_CAUSE_UNSOL_SPRV_RESP, mdl_error(), lapd_msg_ctx::more, msgb_free(), lapd_msg_ctx::n_recv, lapd_datalink::own_busy, lapd_msg_ctx::p_f, lapd_datalink::peer_busy, lapd_datalink::rem2loc, lapd_cr_ent::resp, lapd_msg_ctx::s_u, lapd_datalink::seq_err_cond, lapd_datalink::state, lapd_datalink::v_ack, and lapd_datalink::v_send.

Referenced by lapd_ph_data_ind().

## ◆ lapd_rx_u()

static int lapd_rx_u | ( | struct msgb * | msg,
|  | struct lapd_msg_ctx * | lctx
| ) |  |
| static

References lapd_msg_ctx::dl, lapd_rx_u_disc(), lapd_rx_u_dm(), lapd_rx_u_frmr(), lapd_rx_u_sabm(), lapd_rx_u_ua(), lapd_rx_u_ui(), LAPD_U_DISC, LAPD_U_DM, LAPD_U_FRMR, LAPD_U_SABM, LAPD_U_SABME, LAPD_U_UA, LAPD_U_UI, lapd_datalink::lctx, LOGDL, LOGL_NOTICE, MDL_CAUSE_FRM_UNIMPL, mdl_error(), msgb_free(), and lapd_msg_ctx::s_u.

Referenced by lapd_ph_data_ind().

## ◆ lapd_rx_u_disc()

static int lapd_rx_u_disc | ( | struct msgb * | msg,
|  | struct lapd_msg_ctx * | lctx
| ) |  |
| static

References lapd_msg_ctx::cr, lapd_datalink::cr, lapd_msg_ctx::dl, msgb::l3h, lapd_dl_flush_send(), lapd_dl_flush_tx(), lapd_dl_newstate(), lapd_send_dm(), lapd_send_ua(), LAPD_STATE_DISC_SENT, LAPD_STATE_IDLE, LAPD_STATE_MF_EST, lapd_state_name(), LAPD_STATE_SABM_SENT, LAPD_STATE_TIMER_RECOV, lapd_stop_t200(), lapd_datalink::lctx, lapd_msg_ctx::length, LOGDL, LOGL_ERROR, LOGL_INFO, MDL_CAUSE_FRM_UNIMPL, MDL_CAUSE_UFRM_INC_PARAM, mdl_error(), lapd_msg_ctx::more, msgb_free(), PRIM_DL_REL, PRIM_OP_CONFIRM, PRIM_OP_INDICATION, lapd_datalink::rem2loc, lapd_cr_ent::resp, send_dl_simple(), lapd_datalink::seq_err_cond, and lapd_datalink::state.

Referenced by lapd_rx_u().

## ◆ lapd_rx_u_dm()

static int lapd_rx_u_dm | ( | struct msgb * | msg,
|  | struct lapd_msg_ctx * | lctx
| ) |  |
| static

References lapd_cr_ent::cmd, lapd_msg_ctx::cr, lapd_datalink::cr, lapd_msg_ctx::dl, lapd_dl_flush_send(), lapd_dl_flush_tx(), lapd_dl_newstate(), lapd_reestablish(), LAPD_STATE_DISC_SENT, LAPD_STATE_IDLE, LAPD_STATE_MF_EST, lapd_state_name(), LAPD_STATE_SABM_SENT, LAPD_STATE_TIMER_RECOV, lapd_stop_t200(), lapd_datalink::lctx, LOGDL, LOGL_ERROR, LOGL_INFO, LOGL_NOTICE, MDL_CAUSE_FRM_UNIMPL, MDL_CAUSE_UNSOL_DM_RESP, MDL_CAUSE_UNSOL_DM_RESP_MF, mdl_error(), msgb_free(), lapd_msg_ctx::p_f, PRIM_DL_REL, PRIM_OP_CONFIRM, PRIM_OP_INDICATION, lapd_datalink::reestablish, lapd_datalink::rem2loc, send_dl_simple(), and lapd_datalink::state.

Referenced by lapd_rx_u().

## ◆ lapd_rx_u_frmr()

static int lapd_rx_u_frmr | ( | struct msgb * | msg,
|  | struct lapd_msg_ctx * | lctx
| ) |  |
| static

References lapd_msg_ctx::dl, lapd_reestablish(), lapd_datalink::lctx, LOGDL, LOGL_NOTICE, MDL_CAUSE_FRMR, mdl_error(), msgb_free(), and lapd_datalink::reestablish.

Referenced by lapd_rx_u().

## ◆ lapd_rx_u_sabm()

static int lapd_rx_u_sabm | ( | struct msgb * | msg,
|  | struct lapd_msg_ctx * | lctx
| ) |  |
| static

References lapd_datalink::cont_res, lapd_msg_ctx::cr, lapd_datalink::cr, msgb::data, lapd_msg_ctx::dl, msgb::l3h, lapd_dl_flush_hist(), lapd_dl_newstate(), LAPD_MODE_NETWORK, lapd_msgb_alloc(), lapd_send_dm(), lapd_send_ua(), LAPD_STATE_DISC_SENT, LAPD_STATE_IDLE, LAPD_STATE_MF_EST, lapd_state_name(), LAPD_STATE_TIMER_RECOV, lapd_stop_t200(), lapd_datalink::lctx, msgb::len, lapd_msg_ctx::length, LOGDL, LOGL_ERROR, LOGL_INFO, LOGL_NOTICE, MDL_CAUSE_FRM_UNIMPL, MDL_CAUSE_SABM_INFO_NOTALL, MDL_CAUSE_SABM_MF, MDL_CAUSE_UFRM_INC_PARAM, mdl_error(), lapd_datalink::mode, lapd_msg_ctx::more, lapd_history::msg, msgb_free(), msgb_put(), msgb_trim(), lapd_msg_ctx::n201, PRIM_DL_EST, PRIM_OP_INDICATION, lapd_datalink::rem2loc, lapd_cr_ent::resp, send_dl_l3(), send_dl_simple(), lapd_datalink::seq_err_cond, lapd_datalink::state, lapd_datalink::tx_hist, lapd_datalink::v_ack, lapd_datalink::v_recv, and lapd_datalink::v_send.

Referenced by lapd_rx_u().

## ◆ lapd_rx_u_ua()

static int lapd_rx_u_ua | ( | struct msgb * | msg,
|  | struct lapd_msg_ctx * | lctx
| ) |  |
| static

References lapd_cr_ent::cmd, lapd_msg_ctx::cr, lapd_datalink::cr, msgb::data, lapd_msg_ctx::dl, msgb::l3h, lapd_dl_flush_hist(), lapd_dl_flush_send(), lapd_dl_flush_tx(), lapd_dl_newstate(), lapd_send_i(), LAPD_STATE_DISC_SENT, LAPD_STATE_IDLE, LAPD_STATE_MF_EST, lapd_state_name(), LAPD_STATE_SABM_SENT, LAPD_STATE_TIMER_RECOV, lapd_stop_t200(), lapd_datalink::lctx, msgb::len, lapd_msg_ctx::length, LOGDL, LOGL_ERROR, LOGL_INFO, MDL_CAUSE_FRM_UNIMPL, MDL_CAUSE_UFRM_INC_PARAM, MDL_CAUSE_UNSOL_UA_RESP, mdl_error(), lapd_msg_ctx::more, lapd_history::msg, msgb_free(), lapd_msg_ctx::n201, lapd_msg_ctx::p_f, PRIM_DL_EST, PRIM_DL_REL, PRIM_OP_CONFIRM, PRIM_OP_INDICATION, lapd_datalink::rem2loc, send_dl_simple(), lapd_datalink::state, lapd_datalink::tx_hist, lapd_datalink::v_ack, lapd_datalink::v_recv, and lapd_datalink::v_send.

Referenced by lapd_rx_u().

## ◆ lapd_rx_u_ui()

static int lapd_rx_u_ui | ( | struct msgb * | msg,
|  | struct lapd_msg_ctx * | lctx
| ) |  |
| static

References lapd_msg_ctx::cr, lapd_datalink::cr, lapd_msg_ctx::dl, lapd_datalink::lctx, lapd_msg_ctx::length, LOGDL, LOGL_ERROR, LOGL_INFO, MDL_CAUSE_FRM_UNIMPL, MDL_CAUSE_UFRM_INC_PARAM, mdl_error(), lapd_msg_ctx::more, msgb_free(), msgb_trim(), lapd_msg_ctx::n201, PRIM_DL_UNIT_DATA, PRIM_OP_INDICATION, lapd_datalink::rem2loc, lapd_cr_ent::resp, and send_dl_l3().

Referenced by lapd_rx_u().

## ◆ lapd_send_dm()

static int lapd_send_dm | ( | struct lapd_msg_ctx * | lctx | ) |
| static

References lapd_msg_ctx::cr, lapd_datalink::cr, lapd_msg_ctx::dl, lapd_msg_ctx::format, LAPD_FORM_U, lapd_msgb_alloc(), LAPD_U_DM, lapd_datalink::lctx, lapd_msg_ctx::length, lapd_datalink::loc2rem, lapd_msg_ctx::more, lapd_cr_ent::resp, lapd_msg_ctx::s_u, and lapd_datalink::send_ph_data_req.

Referenced by lapd_rx_i(), lapd_rx_s(), lapd_rx_u_disc(), and lapd_rx_u_sabm().

## ◆ lapd_send_i()

static int lapd_send_i | ( | struct lapd_datalink * | dl,
|  | int | line,
|  | bool | rts
| ) |  |
| static

References add_mod(), lapd_cr_ent::cmd, lapd_msg_ctx::cr, lapd_datalink::cr, msgb::data, lapd_msg_ctx::dl, do_mod(), lapd_msg_ctx::format, inc_mod(), lapd_datalink::k, msgb::l3h, LAPD_F_RTS, lapd_datalink::lapd_flags, LAPD_FORM_I, lapd_is_t200_started(), lapd_msgb_alloc(), lapd_start_t200(), LAPD_STATE_TIMER_RECOV, lapd_stop_t203(), lapd_datalink::lctx, msgb::len, lapd_msg_ctx::length, llist_empty(), lapd_datalink::loc2rem, LOGDL, LOGL_INFO, lapd_msg_ctx::more, lapd_history::more, lapd_history::msg, msg_to_tx_hist(), msgb_dequeue(), msgb_free(), msgb_l3len(), msgb_put(), lapd_msg_ctx::n201, lapd_msg_ctx::n_recv, lapd_msg_ctx::n_send, lapd_msg_ctx::p_f, lapd_datalink::peer_busy, lapd_datalink::range_hist, lapd_datalink::send_buffer, lapd_datalink::send_out, lapd_datalink::send_ph_data_req, lapd_datalink::send_queue, lapd_datalink::state, lapd_datalink::tx_hist, lapd_datalink::tx_queue, lapd_datalink::v_ack, lapd_datalink::v_range, lapd_datalink::v_recv, and lapd_datalink::v_send.

Referenced by lapd_data_req(), lapd_ph_rts_ind(), lapd_rx_i(), lapd_rx_s(), and lapd_rx_u_ua().

## ◆ lapd_send_rej()

static int lapd_send_rej | ( | struct lapd_msg_ctx * | lctx,
|  | uint8_t | f_bit
| ) |  |
| static

References lapd_msg_ctx::cr, lapd_datalink::cr, lapd_msg_ctx::dl, lapd_msg_ctx::format, LAPD_FORM_S, lapd_msgb_alloc(), LAPD_S_REJ, lapd_datalink::lctx, lapd_msg_ctx::length, lapd_datalink::loc2rem, lapd_msg_ctx::more, lapd_msg_ctx::n_recv, lapd_msg_ctx::p_f, lapd_cr_ent::resp, lapd_msg_ctx::s_u, lapd_datalink::send_ph_data_req, and lapd_datalink::v_recv.

Referenced by lapd_rx_i().

## ◆ lapd_send_resend()

static int lapd_send_resend | ( | struct lapd_datalink * | dl | ) |
| static

References lapd_cr_ent::cmd, lapd_msg_ctx::cr, lapd_datalink::cr, msgb::data, lapd_msg_ctx::dl, do_mod(), lapd_msg_ctx::format, msgb::l3h, LAPD_FORM_U, lapd_msgb_alloc(), LAPD_STATE_SABM_SENT, LAPD_U_DISC, LAPD_U_SABM, LAPD_U_SABME, lapd_datalink::lctx, msgb::len, lapd_msg_ctx::length, lapd_datalink::loc2rem, lapd_msg_ctx::more, lapd_history::msg, msgb_put(), lapd_msg_ctx::p_f, lapd_datalink::range_hist, lapd_msg_ctx::s_u, lapd_datalink::send_ph_data_req, lapd_datalink::state, lapd_datalink::tx_hist, lapd_datalink::use_sabme, and lapd_datalink::v_send.

Referenced by lapd_t200_cb().

## ◆ lapd_send_rnr()

static int lapd_send_rnr | ( | struct lapd_msg_ctx * | lctx,
|  | uint8_t | f_bit,
|  | uint8_t | cmd
| ) |  |
| static

References lapd_cr_ent::cmd, lapd_msg_ctx::cr, lapd_datalink::cr, lapd_msg_ctx::dl, lapd_msg_ctx::format, LAPD_FORM_S, lapd_msgb_alloc(), LAPD_S_RNR, lapd_datalink::lctx, lapd_msg_ctx::length, lapd_datalink::loc2rem, lapd_msg_ctx::more, lapd_msg_ctx::n_recv, lapd_msg_ctx::p_f, lapd_cr_ent::resp, lapd_msg_ctx::s_u, lapd_datalink::send_ph_data_req, and lapd_datalink::v_recv.

Referenced by lapd_rx_i(), lapd_rx_s(), lapd_t200_cb(), and lapd_t203_cb().

## ◆ lapd_send_rr()

static int lapd_send_rr | ( | struct lapd_msg_ctx * | lctx,
|  | uint8_t | f_bit,
|  | uint8_t | cmd
| ) |  |
| static

References lapd_cr_ent::cmd, lapd_msg_ctx::cr, lapd_datalink::cr, lapd_msg_ctx::dl, lapd_msg_ctx::format, LAPD_FORM_S, lapd_msgb_alloc(), LAPD_S_RR, lapd_datalink::lctx, lapd_msg_ctx::length, lapd_datalink::loc2rem, lapd_msg_ctx::more, lapd_msg_ctx::n_recv, lapd_msg_ctx::p_f, lapd_cr_ent::resp, lapd_msg_ctx::s_u, lapd_datalink::send_ph_data_req, and lapd_datalink::v_recv.

Referenced by lapd_rx_i(), lapd_rx_s(), lapd_t200_cb(), and lapd_t203_cb().

## ◆ lapd_send_ua()

static int lapd_send_ua | ( | struct lapd_msg_ctx * | lctx,
|  | uint8_t | len,
|  | uint8_t * | data
| ) |  |
| static

References lapd_msg_ctx::cr, lapd_datalink::cr, data, lapd_msg_ctx::dl, lapd_msg_ctx::format, msgb::l3h, LAPD_FORM_U, lapd_msgb_alloc(), LAPD_U_UA, lapd_datalink::lctx, len(), lapd_msg_ctx::length, lapd_datalink::loc2rem, lapd_msg_ctx::more, msgb_put(), lapd_cr_ent::resp, lapd_msg_ctx::s_u, and lapd_datalink::send_ph_data_req.

Referenced by lapd_rx_u_disc(), and lapd_rx_u_sabm().

## ◆ lapd_set_mode()

int lapd_set_mode | ( | struct lapd_datalink * | dl,
|  | enum lapd_mode | mode
| ) |  |

Set the lapdm_mode of a LAPDm entity.

References lapd_cr_ent::cmd, lapd_datalink::cr, CR_NET2USER_CMD, CR_NET2USER_RESP, CR_USER2NET_CMD, CR_USER2NET_RESP, LAPD_MODE_NETWORK, LAPD_MODE_USER, lapd_datalink::loc2rem, lapd_datalink::mode, lapd_datalink::rem2loc, and lapd_cr_ent::resp.

## ◆ lapd_start_t200()

static void lapd_start_t200 | ( | struct lapd_datalink * | dl | ) |
| static

References LAPD_F_RTS, lapd_datalink::lapd_flags, LAPD_T200_RTS_OFF, LAPD_T200_RTS_PENDING, LOGDL, LOGL_INFO, osmo_timer_pending(), osmo_timer_schedule(), lapd_datalink::t200, lapd_datalink::t200_rts, lapd_datalink::t200_sec, and lapd_datalink::t200_usec.

Referenced by lapd_acknowledge(), lapd_est_req(), lapd_rel_req(), lapd_res_req(), lapd_send_i(), lapd_t200_cb(), and lapd_t203_cb().

## ◆ lapd_start_t203()

static void lapd_start_t203 | ( | struct lapd_datalink * | dl | ) |
| static

References LOGDL, LOGL_INFO, osmo_timer_pending(), osmo_timer_schedule(), lapd_datalink::t203, lapd_datalink::t203_sec, and lapd_datalink::t203_usec.

Referenced by lapd_acknowledge(), and lapd_dl_newstate().

## ◆ lapd_state_name()

static const char * lapd_state_name | ( | enum lapd_state | state | ) |
| inline static

References get_value_string(), and lapd_state_names.

Referenced by lapd_dl_newstate(), lapd_recv_dlsap(), lapd_rx_i(), lapd_rx_s(), lapd_rx_u_disc(), lapd_rx_u_dm(), lapd_rx_u_sabm(), lapd_rx_u_ua(), lapd_t200_cb(), lapd_t203_cb(), and mdl_error().

## ◆ lapd_stop_t200()

static void lapd_stop_t200 | ( | struct lapd_datalink * | dl | ) |
| static

References LAPD_F_RTS, lapd_datalink::lapd_flags, LAPD_T200_RTS_OFF, LOGDL, LOGL_INFO, osmo_timer_del(), osmo_timer_pending(), lapd_datalink::t200, and lapd_datalink::t200_rts.

Referenced by lapd_acknowledge(), lapd_dl_reset(), lapd_rel_req(), lapd_rx_s(), lapd_rx_u_disc(), lapd_rx_u_dm(), lapd_rx_u_sabm(), lapd_rx_u_ua(), and lapd_susp_req().

## ◆ lapd_stop_t203()

static void lapd_stop_t203 | ( | struct lapd_datalink * | dl | ) |
| static

References LOGDL, LOGL_INFO, osmo_timer_del(), osmo_timer_pending(), and lapd_datalink::t203.

Referenced by lapd_acknowledge(), lapd_dl_newstate(), lapd_dl_reset(), lapd_send_i(), and lapd_susp_req().

## ◆ lapd_susp_req()

static int lapd_susp_req | ( | struct osmo_dlsap_prim * | dp,
|  | struct lapd_msg_ctx * | lctx
| ) |  |
| static

References lapd_msg_ctx::dl, lapd_dl_flush_tx(), lapd_stop_t200(), lapd_stop_t203(), lapd_datalink::lctx, msgb::list, llist_add(), LOGDL, LOGL_INFO, osmo_prim_hdr::msg, msgb_free(), osmo_dlsap_prim::oph, PRIM_DL_SUSP, PRIM_OP_CONFIRM, lapd_datalink::send_buffer, send_dl_simple(), and lapd_datalink::send_queue.

## ◆ lapd_t200_cb()

static void lapd_t200_cb | ( | void * | data | ) |
| static

References lapd_cr_ent::cmd, lapd_msg_ctx::cr, lapd_datalink::cr, msgb::data, data, lapd_msg_ctx::dl, do_mod(), lapd_msg_ctx::format, msgb::l3h, lapd_dl_flush_send(), lapd_dl_flush_tx(), lapd_dl_newstate(), LAPD_FORM_I, lapd_msgb_alloc(), lapd_reestablish(), lapd_send_resend(), lapd_send_rnr(), lapd_send_rr(), lapd_start_t200(), LAPD_STATE_DISC_SENT, LAPD_STATE_IDLE, LAPD_STATE_MF_EST, lapd_state_name(), LAPD_STATE_SABM_SENT, LAPD_STATE_TIMER_RECOV, lapd_datalink::lctx, msgb::len, lapd_msg_ctx::length, lapd_datalink::loc2rem, LOGDL, LOGL_INFO, LOGL_NOTICE, MDL_CAUSE_T200_EXPIRED, mdl_error(), lapd_msg_ctx::more, lapd_history::more, lapd_history::msg, msgb_put(), lapd_datalink::n200, lapd_datalink::n200_est_rel, lapd_msg_ctx::n_recv, lapd_msg_ctx::n_send, lapd_datalink::own_busy, lapd_msg_ctx::p_f, PRIM_DL_REL, PRIM_OP_CONFIRM, PRIM_OP_INDICATION, lapd_datalink::range_hist, lapd_datalink::reestablish, lapd_datalink::retrans_ctr, send_dl_simple(), lapd_datalink::send_ph_data_req, lapd_datalink::seq_err_cond, lapd_datalink::state, sub_mod(), lapd_datalink::tx_hist, lapd_datalink::v_range, lapd_datalink::v_recv, and lapd_datalink::v_send.

Referenced by lapd_dl_init2(), and lapd_t200_timeout().

## ◆ lapd_t200_timeout()

int lapd_t200_timeout | ( | struct lapd_datalink * | dl | ) |

Handle timeout condition of T200 in RTS mode.

The caller (LAPDm code) implements the T200 timer and must detect timeout condition. The function gets called by LAPDm code when it detects a timeout of T200.

Parameters

  [in] | dl | caller-allocated datalink structure

References LAPD_F_RTS, lapd_datalink::lapd_flags, lapd_t200_cb(), LAPD_T200_RTS_OFF, LAPD_T200_RTS_RUNNING, OSMO_ASSERT, and lapd_datalink::t200_rts.

## ◆ lapd_t203_cb()

static void lapd_t203_cb | ( | void * | data | ) |
| static

References data, lapd_dl_newstate(), lapd_send_rnr(), lapd_send_rr(), lapd_start_t200(), LAPD_STATE_MF_EST, lapd_state_name(), LAPD_STATE_TIMER_RECOV, lapd_datalink::lctx, LOGDL, LOGL_ERROR, LOGL_INFO, lapd_datalink::own_busy, lapd_datalink::retrans_ctr, and lapd_datalink::state.

Referenced by lapd_dl_init2().

## ◆ lapd_udata_req()

static int lapd_udata_req | ( | struct osmo_dlsap_prim * | dp,
|  | struct lapd_msg_ctx * | lctx
| ) |  |
| static

References lapd_cr_ent::cmd, lapd_msg_ctx::cr, lapd_datalink::cr, lapd_msg_ctx::dl, lapd_msg_ctx::format, LAPD_FORM_U, LAPD_U_UI, lapd_datalink::lctx, msgb::len, lapd_msg_ctx::length, lapd_datalink::loc2rem, lapd_msg_ctx::more, osmo_prim_hdr::msg, osmo_dlsap_prim::oph, lapd_msg_ctx::s_u, and lapd_datalink::send_ph_data_req.

## ◆ mdl_error()

static int mdl_error | ( | uint8_t | cause,
|  | struct lapd_msg_ctx * | lctx
| ) |  |
| static

References mdl_error_ind_param::cause, lapd_msg_ctx::dl, osmo_dlsap_prim::error_ind, lapd_state_name(), lapd_datalink::lctx, LOGDL, LOGL_NOTICE, osmo_dlsap_prim::oph, osmo_prim_init(), PRIM_MDL_ERROR, PRIM_OP_INDICATION, lapd_datalink::send_dlsap, lapd_datalink::state, and osmo_dlsap_prim::u.

Referenced by lapd_rx_i(), lapd_rx_s(), lapd_rx_u(), lapd_rx_u_disc(), lapd_rx_u_dm(), lapd_rx_u_frmr(), lapd_rx_u_sabm(), lapd_rx_u_ua(), lapd_rx_u_ui(), and lapd_t200_cb().

## ◆ msg_to_tx_hist()

static void msg_to_tx_hist | ( | struct lapd_history * | tx_hist,
|  | const struct msgb * | msg,
|  | int | length,
|  | int | more
| ) |  |
| static

References msgb::data, msgb::l3h, lapd_msgb_alloc(), msgb::len, lapd_msg_ctx::length, lapd_msg_ctx::more, lapd_history::more, lapd_history::msg, and msgb_put().

Referenced by lapd_send_i(), and msg_to_tx_hist0().

## ◆ msg_to_tx_hist0()

static void msg_to_tx_hist0 | ( | struct lapd_datalink * | dl,
|  | const struct msgb * | msg
| ) |  |
| static

References lapd_msg_ctx::dl, msgb::len, msg_to_tx_hist(), and lapd_datalink::tx_hist.

Referenced by lapd_est_req(), lapd_rel_req(), and lapd_res_req().

## ◆ send_dl_l3()

static int send_dl_l3 | ( | uint8_t | prim,
|  | uint8_t | op,
|  | struct lapd_msg_ctx * | lctx,
|  | struct msgb * | msg
| ) |  |
| static

References lapd_msg_ctx::dl, lapd_datalink::lctx, osmo_dlsap_prim::oph, osmo_prim_init(), and lapd_datalink::send_dlsap.

Referenced by lapd_rx_i(), lapd_rx_u_sabm(), lapd_rx_u_ui(), and send_dl_simple().

## ◆ send_dl_simple()

static int send_dl_simple | ( | uint8_t | prim,
|  | uint8_t | op,
|  | struct lapd_msg_ctx * | lctx
| ) |  |
| inline static

References send_dl_l3().

Referenced by lapd_rel_req(), lapd_rel_req_idle(), lapd_rx_u_disc(), lapd_rx_u_dm(), lapd_rx_u_sabm(), lapd_rx_u_ua(), lapd_susp_req(), and lapd_t200_cb().

## ◆ sub_mod()

static uint8_t sub_mod | ( | uint8_t | x,
|  | uint8_t | y,
|  | uint8_t | m
| ) |  |
| inline static

References x.

Referenced by lapd_acknowledge(), and lapd_t200_cb().

## Variable Documentation

## ◆ l2downstatelist

const struct l2downstate l2downstatelist[]
| static

Referenced by lapd_recv_dlsap().

## ◆ lapd_state_names

const struct value_string lapd_state_names[]

Initial value:
= {
OSMO_VALUE_STRING(LAPD_STATE_NULL),
OSMO_VALUE_STRING(LAPD_STATE_TEI_UNASS),
OSMO_VALUE_STRING(LAPD_STATE_ASS_TEI_WAIT),
OSMO_VALUE_STRING(LAPD_STATE_EST_TEI_WAIT),
OSMO_VALUE_STRING(LAPD_STATE_IDLE),
OSMO_VALUE_STRING(LAPD_STATE_SABM_SENT),
OSMO_VALUE_STRING(LAPD_STATE_DISC_SENT),
OSMO_VALUE_STRING(LAPD_STATE_MF_EST),
OSMO_VALUE_STRING(LAPD_STATE_TIMER_RECOV),
{ 0, NULL }
}
LAPD_STATE_SABM_SENT
@ LAPD_STATE_SABM_SENT
Definition: lapd_core.h:81
LAPD_STATE_TEI_UNASS
@ LAPD_STATE_TEI_UNASS
Definition: lapd_core.h:77
LAPD_STATE_MF_EST
@ LAPD_STATE_MF_EST
Definition: lapd_core.h:83
LAPD_STATE_EST_TEI_WAIT
@ LAPD_STATE_EST_TEI_WAIT
Definition: lapd_core.h:79
LAPD_STATE_DISC_SENT
@ LAPD_STATE_DISC_SENT
Definition: lapd_core.h:82
LAPD_STATE_ASS_TEI_WAIT
@ LAPD_STATE_ASS_TEI_WAIT
Definition: lapd_core.h:78
LAPD_STATE_NULL
@ LAPD_STATE_NULL
Definition: lapd_core.h:76
LAPD_STATE_TIMER_RECOV
@ LAPD_STATE_TIMER_RECOV
Definition: lapd_core.h:84
LAPD_STATE_IDLE
@ LAPD_STATE_IDLE
Definition: lapd_core.h:80
OSMO_VALUE_STRING
#define OSMO_VALUE_STRING(x)

Referenced by lapd_state_name().

## ◆ tall_lapd_ctx

void* tall_lapd_ctx = NULL

Referenced by lapd_data_req(), lapd_dl_init2(), and lapd_dl_set_name().