1 #ifndef _OSMOCOM_LAPDM_H
2 #define _OSMOCOM_LAPDM_H
6 #include <osmocom/core/timer.h>
7 #include <osmocom/core/msgb.h>
9 #include <l1ctl_proto.h>
14 LAPDm_STATE_SABM_SENT,
16 LAPDm_STATE_TIMER_RECOV,
17 LAPDm_STATE_DISC_SENT,
23 struct lapdm_msg_ctx {
24 struct lapdm_datalink *dl;
35 /* TS 04.06 / Section 3.5.2 */
36 struct lapdm_datalink {
37 uint8_t V_send; /* seq nr of next I frame to be transmitted */
38 uint8_t V_ack; /* last frame ACKed by peer */
39 uint8_t N_send; /* ? set to V_send at Tx time*/
40 uint8_t V_recv; /* seq nr of next I frame expected to be received */
41 uint8_t N_recv; /* expected send seq nr of the next received I frame */
43 int seq_err_cond; /* condition of sequence error */
44 uint8_t own_busy, peer_busy;
45 struct osmo_timer_list t200;
47 struct llist_head send_queue; /* frames from L3 */
48 struct msgb *send_buffer; /* current frame transmitting */
49 int send_out; /* how much was sent from send_buffer */
50 uint8_t tx_hist[8][200]; /* tx history buffer */
51 int tx_length[8]; /* length in history buffer */
52 struct llist_head tx_queue; /* frames to L1 */
53 struct lapdm_msg_ctx mctx; /* context of established connection */
54 struct msgb *rcv_buffer; /* buffer to assemble the received message */
56 struct lapdm_entity *entity;
66 struct lapdm_datalink datalink[_NR_DL_SAPI];
67 int last_tx_dequeue; /* last entity that was dequeued */
68 int tx_pending; /* currently a pending frame not confirmed by L1 */
70 void *l1_ctx; /* context for layer1 instance */
71 void *l3_ctx; /* context for layer3 instance */
74 const char *get_rsl_name(int value);
75 extern const char *lapdm_state_names[];
77 /* initialize a LAPDm entity */
78 void lapdm_init(struct lapdm_entity *le);
80 /* deinitialize a LAPDm entity */
81 void lapdm_exit(struct lapdm_entity *le);
83 /* input into layer2 (from layer 1) */
84 int l2_ph_data_ind(struct msgb *msg, struct lapdm_entity *le, struct l1ctl_info_dl *l1i);
85 int l2_ph_data_conf(struct msgb *msg, struct lapdm_entity *le);
87 /* L1 confirms channel request */
88 int l2_ph_chan_conf(struct msgb *msg, struct osmocom_ms *ms,
89 struct l1ctl_info_dl *dl);
91 /* input into layer2 (from layer 3) */
92 int rslms_recvmsg(struct msgb *msg, struct osmocom_ms *ms);
94 /* sending messages up from L2 to L3 */
95 int rslms_sendmsg(struct msgb *msg, struct osmocom_ms *ms);
97 typedef int (*osmol2_cb_t)(struct msgb *msg, struct osmocom_ms *ms);
99 /* register message handler for messages that are sent from L2->L3 */
100 int osmol2_register_handler(struct osmocom_ms *ms, osmol2_cb_t cb);
102 #endif /* _OSMOCOM_LAPDM_H */