1 #ifndef _OSMOCOM_LAPDM_H
2 #define _OSMOCOM_LAPDM_H
6 #include <osmocore/timer.h>
7 #include <osmocore/msgb.h>
9 #include <l1a_l23_interface.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;
33 /* TS 04.06 / Section 3.5.2 */
34 struct lapdm_datalink {
35 uint8_t V_send; /* seq nr of next I frame to be transmitted */
36 uint8_t V_ack; /* last frame ACKed by peer */
37 uint8_t N_send; /* ? set to V_send at Tx time*/
38 uint8_t V_recv; /* seq nr of next I frame expected to be received */
39 uint8_t N_recv; /* expected send seq nr of the next received I frame */
41 int seq_err_cond; /* condition of sequence error */
42 uint8_t own_busy, peer_busy;
43 struct timer_list t200;
45 struct llist_head send_queue; /* frames from L3 */
46 struct msgb *send_buffer; /* current frame transmitting */
47 int send_out; /* how much was sent from send_buffer */
48 uint8_t tx_hist[8][200]; /* tx history buffer */
49 int tx_length[8]; /* length in history buffer */
50 struct llist_head tx_queue; /* frames to L1 */
51 struct lapdm_msg_ctx mctx; /* context of established connection */
52 struct msgb *rcv_buffer; /* buffer to assemble the received message */
54 struct lapdm_entity *entity;
64 struct lapdm_datalink datalink[_NR_DL_SAPI];
65 int last_tx_dequeue; /* last entity that was dequeued */
66 int tx_pending; /* currently a pending frame not confirmed by L1 */
67 struct osmocom_ms *ms;
70 const char *get_rsl_name(int value);
71 extern const char *lapdm_state_names[];
73 /* initialize a LAPDm entity */
74 void lapdm_init(struct lapdm_entity *le, struct osmocom_ms *ms);
76 /* deinitialize a LAPDm entity */
77 void lapdm_exit(struct lapdm_entity *le);
79 /* input into layer2 (from layer 1) */
80 int l2_ph_data_ind(struct msgb *msg, struct lapdm_entity *le, struct l1ctl_info_dl *l1i);
81 int l2_ph_data_conf(struct msgb *msg, struct lapdm_entity *le);
83 /* input into layer2 (from layer 3) */
84 int rslms_recvmsg(struct msgb *msg, struct osmocom_ms *ms);
86 /* sending messages up from L2 to L3 */
87 int rslms_sendmsg(struct msgb *msg, struct osmocom_ms *ms);
89 typedef int (*osmol2_cb_t)(struct msgb *msg, struct osmocom_ms *ms);
91 /* register message handler for messages that are sent from L2->L3 */
92 int osmol2_register_handler(struct osmocom_ms *ms, osmol2_cb_t cb);
94 #endif /* _OSMOCOM_LAPDM_H */