libosmogsm 0.9.6-23.20170220git32ee5af8.fc42
Osmocom GSM library
Loading...
Searching...
No Matches
lapd_core.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdint.h>
4
5#include <osmocom/core/timer.h>
6#include <osmocom/core/msgb.h>
7#include <osmocom/gsm/prim.h>
8
28
29/* Uses the same values as RLL, so no conversion for GSM is required. */
30#define MDL_CAUSE_T200_EXPIRED 0x01
31#define MDL_CAUSE_REEST_REQ 0x02
32#define MDL_CAUSE_UNSOL_UA_RESP 0x03
33#define MDL_CAUSE_UNSOL_DM_RESP 0x04
34#define MDL_CAUSE_UNSOL_DM_RESP_MF 0x05
35#define MDL_CAUSE_UNSOL_SPRV_RESP 0x06
36#define MDL_CAUSE_SEQ_ERR 0x07
37#define MDL_CAUSE_UFRM_INC_PARAM 0x08
38#define MDL_CAUSE_SFRM_INC_PARAM 0x09
39#define MDL_CAUSE_IFRM_INC_MBITS 0x0a
40#define MDL_CAUSE_IFRM_INC_LEN 0x0b
41#define MDL_CAUSE_FRM_UNIMPL 0x0c
42#define MDL_CAUSE_SABM_MF 0x0d
43#define MDL_CAUSE_SABM_INFO_NOTALL 0x0e
44#define MDL_CAUSE_FRMR 0x0f
45
48 uint8_t cause;
49};
50
53 uint8_t mode;
54};
55
58 struct osmo_prim_hdr oph;
59 union {
60 struct mdl_error_ind_param error_ind;
61 struct dl_rel_req_param rel_req;
62 } u;
63};
64
70
73 LAPD_STATE_NULL = 0,
74 LAPD_STATE_TEI_UNASS,
75 LAPD_STATE_ASS_TEI_WAIT,
76 LAPD_STATE_EST_TEI_WAIT,
77 LAPD_STATE_IDLE,
78 LAPD_STATE_SABM_SENT,
79 LAPD_STATE_DISC_SENT,
80 LAPD_STATE_MF_EST,
81 LAPD_STATE_TIMER_RECOV,
82};
83
86 LAPD_FORM_UKN = 0,
87 LAPD_FORM_I,
88 LAPD_FORM_S,
89 LAPD_FORM_U,
90};
91
94 struct lapd_datalink *dl;
95 int n201;
96 /* address */
97 uint8_t cr;
98 uint8_t sapi;
99 uint8_t tei;
100 uint8_t lpd;
101 /* control */
102 uint8_t format;
103 uint8_t p_f; /* poll / final bit */
104 uint8_t n_send;
105 uint8_t n_recv;
106 uint8_t s_u; /* S or repectivly U function bits */
107 /* length */
108 int length;
109 uint8_t more;
110};
111
113 uint8_t cmd;
114 uint8_t resp;
115};
116
118 struct msgb *msg; /* message to be sent / NULL, if histoy is empty */
119 int more; /* if message is fragmented */
120};
121
124 int (*send_dlsap)(struct osmo_dlsap_prim *dp,
125 struct lapd_msg_ctx *lctx);
126 int (*send_ph_data_req)(struct lapd_msg_ctx *lctx, struct msgb *msg);
127 int (*update_pending_frames)(struct lapd_msg_ctx *lctx);
128 struct {
130 struct lapd_cr_ent loc2rem;
131 struct lapd_cr_ent rem2loc;
132 } cr;
136 int n200, n200_est_rel;
138 int maxf;
139 uint8_t k;
140 uint8_t v_range;
141 uint8_t v_send;
142 uint8_t v_ack;
143 uint8_t v_recv;
144 uint32_t state;
146 uint8_t own_busy;
147 uint8_t peer_busy;
148 int t200_sec, t200_usec;
149 int t203_sec, t203_usec;
150 struct osmo_timer_list t200;
151 struct osmo_timer_list t203;
152 uint8_t retrans_ctr;
153 struct llist_head tx_queue;
154 struct llist_head send_queue;
155 struct msgb *send_buffer;
158 uint8_t range_hist;
159 struct msgb *rcv_buffer;
160 struct msgb *cont_res;
161};
162
163void lapd_dl_init(struct lapd_datalink *dl, uint8_t k, uint8_t v_range,
164 int maxf);
165void lapd_dl_exit(struct lapd_datalink *dl);
166void lapd_dl_reset(struct lapd_datalink *dl);
167int lapd_set_mode(struct lapd_datalink *dl, enum lapd_mode mode);
168int lapd_ph_data_ind(struct msgb *msg, struct lapd_msg_ctx *lctx);
169int lapd_recv_dlsap(struct osmo_dlsap_prim *dp, struct lapd_msg_ctx *lctx);
170
int lapd_set_mode(struct lapd_datalink *dl, enum lapd_mode mode)
Set the lapdm_mode of a LAPDm entity.
Definition lapd_core.c:333
lapd_mode
LAPD mode/role.
Definition lapd_core.h:66
lapd_format
LAPD message format (I / S / U)
Definition lapd_core.h:85
osmo_dl_prim
LAPD related primitives (L2<->L3 SAP)
Definition lapd_core.h:18
lapd_state
LAPD state (Figure B.2/Q.921)
Definition lapd_core.h:72
@ LAPD_MODE_USER
behave like user
Definition lapd_core.h:67
@ LAPD_MODE_NETWORK
behave like network
Definition lapd_core.h:68
@ PRIM_DL_REL
DL-RLEEASE.
Definition lapd_core.h:22
@ PRIM_DL_RES
DL-RESUME.
Definition lapd_core.h:24
@ PRIM_DL_SUSP
DL-SUSPEND.
Definition lapd_core.h:23
@ PRIM_DL_EST
DL-ESTABLISH.
Definition lapd_core.h:21
@ PRIM_DL_DATA
DL-DATA.
Definition lapd_core.h:20
@ PRIM_DL_UNIT_DATA
DL-UNIT-DATA.
Definition lapd_core.h:19
@ PRIM_MDL_ERROR
MDL-ERROR.
Definition lapd_core.h:26
@ PRIM_DL_RECON
DL-RECONNECT.
Definition lapd_core.h:25
for DL-REL.req
Definition lapd_core.h:52
uint8_t mode
release mode
Definition lapd_core.h:53
Definition lapd_core.h:112
Definition lapd_core.h:117
LAPD message context.
Definition lapd_core.h:93
for MDL-ERROR.ind
Definition lapd_core.h:47
uint8_t cause
generic cause value
Definition lapd_core.h:48
primitive header for LAPD DL-SAP primitives
Definition lapd_core.h:57
union osmo_dlsap_prim::@067103373254254124345322346374066073223254331017 u
request-specific data
struct osmo_prim_hdr oph
generic primitive header
Definition lapd_core.h:58