libosmogsm
0.9.3
Osmocom GSM library
Main Page
Modules
Data Structures
Files
File List
Globals
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
18
enum
osmo_dl_prim
{
19
PRIM_DL_UNIT_DATA
,
20
PRIM_DL_DATA
,
21
PRIM_DL_EST
,
22
PRIM_DL_REL
,
23
PRIM_DL_SUSP
,
24
PRIM_DL_RES
,
25
PRIM_DL_RECON
,
26
PRIM_MDL_ERROR
,
27
};
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
47
struct
mdl_error_ind_param
{
48
uint8_t
cause
;
49
};
50
52
struct
dl_rel_req_param
{
53
uint8_t
mode
;
54
};
55
57
struct
osmo_dlsap_prim
{
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
66
enum
lapd_mode
{
67
LAPD_MODE_USER
,
68
LAPD_MODE_NETWORK
,
69
};
70
72
enum
lapd_state
{
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
85
enum
lapd_format
{
86
LAPD_FORM_UKN = 0,
87
LAPD_FORM_I,
88
LAPD_FORM_S,
89
LAPD_FORM_U,
90
};
91
93
struct
lapd_msg_ctx
{
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
112
struct
lapd_cr_ent
{
113
uint8_t cmd;
114
uint8_t resp;
115
};
116
117
struct
lapd_history
{
118
struct
msgb *msg;
/* message to be sent / NULL, if histoy is empty */
119
int
more;
/* if message is fragmented */
120
};
121
123
struct
lapd_datalink
{
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;
133
enum
lapd_mode
mode
;
134
int
use_sabme
;
135
int
reestablish
;
136
int
n200,
n200_est_rel
;
137
struct
lapd_msg_ctx
lctx
;
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
;
145
int
seq_err_cond
;
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
;
156
int
send_out
;
157
struct
lapd_history
*
tx_hist
;
158
uint8_t
range_hist
;
159
struct
msgb *
rcv_buffer
;
160
struct
msgb *
cont_res
;
161
};
162
163
void
lapd_dl_init(
struct
lapd_datalink
*dl, uint8_t k, uint8_t v_range,
164
int
maxf);
165
void
lapd_dl_exit(
struct
lapd_datalink
*dl);
166
void
lapd_dl_reset(
struct
lapd_datalink
*dl);
167
int
lapd_set_mode
(
struct
lapd_datalink
*dl,
enum
lapd_mode
mode);
168
int
lapd_ph_data_ind(
struct
msgb *msg,
struct
lapd_msg_ctx
*lctx);
169
int
lapd_recv_dlsap(
struct
osmo_dlsap_prim
*dp,
struct
lapd_msg_ctx
*lctx);
170
include
osmocom
gsm
lapd_core.h
Generated on Mon Jan 18 2016 13:17:41 for libosmogsm by
1.8.1.2