blob: fd11edaa330f1f44f36086de53c6c76c2a01afbf [file] [log] [blame]
Harald Weltee1de69a2011-02-04 20:38:22 +01001#ifndef OPENBSC_LAPD_H
2#define OPENBSC_LAPD_H
Matthew Fredricksonbc6649e2010-02-16 22:01:36 +01003
4#include <stdint.h>
5
Harald Welted38f1052011-02-05 19:13:00 +01006#include <osmocore/linuxlist.h>
7
Matthew Fredricksonbc6649e2010-02-16 22:01:36 +01008typedef enum {
9 LAPD_MPH_NONE = 0,
10
11 LAPD_MPH_ACTIVATE_IND,
12 LAPD_MPH_DEACTIVATE_IND,
13
14 LAPD_DL_DATA_IND,
creslin287cd8b86f2010-03-26 12:57:31 -050015 LAPD_DL_UNITDATA_IND,
Matthew Fredricksonbc6649e2010-02-16 22:01:36 +010016
17} lapd_mph_type;
18
Harald Welted38f1052011-02-05 19:13:00 +010019struct lapd_instance {
20 struct llist_head list; /* list of LAPD instances */
21 int network_side;
Matthew Fredricksonbc6649e2010-02-16 22:01:36 +010022
Harald Welted38f1052011-02-05 19:13:00 +010023 void (*transmit_cb)(uint8_t *data, int len, void *cbdata);
24 void *cbdata;
Matthew Fredricksonbc6649e2010-02-16 22:01:36 +010025
Harald Welted38f1052011-02-05 19:13:00 +010026 struct llist_head tei_list; /* list of TEI in this LAPD instance */
27};
28
29extern uint8_t *lapd_receive(struct lapd_instance *li, uint8_t *data, unsigned int len,
30 int *ilen, lapd_mph_type *prim);
31
Harald Welte4ee2eaf2011-02-05 20:20:50 +010032extern void lapd_transmit(struct lapd_instance *li, uint8_t tei, uint8_t sapi,
33 uint8_t *data, unsigned int len);
Harald Welted38f1052011-02-05 19:13:00 +010034
Harald Welte1a00d822011-02-11 18:34:51 +010035struct lapd_instance *lapd_instance_alloc(int network_side,
36 void (*tx_cb)(uint8_t *data, int len,
Harald Welted38f1052011-02-05 19:13:00 +010037 void *cbdata), void *cbdata);
Matthew Fredricksonbc6649e2010-02-16 22:01:36 +010038
Harald Weltedcf42e62011-02-13 11:58:21 +010039
40/* Start a (user-side) SAP for the specified TEI/SAPI on the LAPD instance */
41int lapd_sap_start(struct lapd_instance *li, uint8_t tei, uint8_t sapi);
42
43/* Stop a (user-side) SAP for the specified TEI/SAPI on the LAPD instance */
44int lapd_sap_stop(struct lapd_instance *li, uint8_t tei, uint8_t sapi);
Harald Welte1a00d822011-02-11 18:34:51 +010045
Harald Weltee1de69a2011-02-04 20:38:22 +010046#endif /* OPENBSC_LAPD_H */