Harald Welte | 6803ab2 | 2011-02-04 20:38:22 +0100 | [diff] [blame] | 1 | #ifndef OPENBSC_LAPD_H |
| 2 | #define OPENBSC_LAPD_H |
Matthew Fredrickson | 124c80e | 2010-02-16 22:01:36 +0100 | [diff] [blame] | 3 | |
| 4 | #include <stdint.h> |
| 5 | |
Pablo Neira Ayuso | dd5fff4 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 6 | #include <osmocom/core/linuxlist.h> |
Harald Welte | 306a206 | 2011-02-05 19:13:00 +0100 | [diff] [blame] | 7 | |
Matthew Fredrickson | 124c80e | 2010-02-16 22:01:36 +0100 | [diff] [blame] | 8 | typedef enum { |
| 9 | LAPD_MPH_NONE = 0, |
| 10 | |
| 11 | LAPD_MPH_ACTIVATE_IND, |
| 12 | LAPD_MPH_DEACTIVATE_IND, |
| 13 | |
| 14 | LAPD_DL_DATA_IND, |
creslin287 | 52b0e02 | 2010-03-26 12:57:31 -0500 | [diff] [blame] | 15 | LAPD_DL_UNITDATA_IND, |
Matthew Fredrickson | 124c80e | 2010-02-16 22:01:36 +0100 | [diff] [blame] | 16 | |
| 17 | } lapd_mph_type; |
| 18 | |
Harald Welte | 306a206 | 2011-02-05 19:13:00 +0100 | [diff] [blame] | 19 | struct lapd_instance { |
| 20 | struct llist_head list; /* list of LAPD instances */ |
| 21 | int network_side; |
Matthew Fredrickson | 124c80e | 2010-02-16 22:01:36 +0100 | [diff] [blame] | 22 | |
Harald Welte | 306a206 | 2011-02-05 19:13:00 +0100 | [diff] [blame] | 23 | void (*transmit_cb)(uint8_t *data, int len, void *cbdata); |
| 24 | void *cbdata; |
Matthew Fredrickson | 124c80e | 2010-02-16 22:01:36 +0100 | [diff] [blame] | 25 | |
Harald Welte | 306a206 | 2011-02-05 19:13:00 +0100 | [diff] [blame] | 26 | struct llist_head tei_list; /* list of TEI in this LAPD instance */ |
| 27 | }; |
| 28 | |
Pablo Neira Ayuso | 3f66328 | 2011-08-09 23:15:38 +0200 | [diff] [blame] | 29 | enum lapd_recv_errors { |
| 30 | LAPD_ERR_NONE = 0, |
| 31 | LAPD_ERR_BAD_LEN, |
| 32 | LAPD_ERR_BAD_ADDR, |
| 33 | LAPD_ERR_UNKNOWN_S_CMD, |
| 34 | LAPD_ERR_UNKNOWN_U_CMD, |
| 35 | LAPD_ERR_UNKNOWN_TEI, |
| 36 | LAPD_ERR_BAD_CMD, |
| 37 | __LAPD_ERR_MAX |
| 38 | }; |
| 39 | |
| 40 | extern uint8_t *lapd_receive(struct lapd_instance *li, uint8_t *data, |
| 41 | unsigned int len, int *ilen, lapd_mph_type *prim, |
| 42 | int *error); |
Harald Welte | 306a206 | 2011-02-05 19:13:00 +0100 | [diff] [blame] | 43 | |
Harald Welte | cbaa38a | 2011-02-05 20:20:50 +0100 | [diff] [blame] | 44 | extern void lapd_transmit(struct lapd_instance *li, uint8_t tei, uint8_t sapi, |
| 45 | uint8_t *data, unsigned int len); |
Harald Welte | 306a206 | 2011-02-05 19:13:00 +0100 | [diff] [blame] | 46 | |
Harald Welte | 0a47400 | 2011-02-11 18:34:51 +0100 | [diff] [blame] | 47 | struct lapd_instance *lapd_instance_alloc(int network_side, |
| 48 | void (*tx_cb)(uint8_t *data, int len, |
Harald Welte | 306a206 | 2011-02-05 19:13:00 +0100 | [diff] [blame] | 49 | void *cbdata), void *cbdata); |
Matthew Fredrickson | 124c80e | 2010-02-16 22:01:36 +0100 | [diff] [blame] | 50 | |
Harald Welte | 0303a36 | 2011-02-13 11:58:21 +0100 | [diff] [blame] | 51 | |
| 52 | /* Start a (user-side) SAP for the specified TEI/SAPI on the LAPD instance */ |
| 53 | int lapd_sap_start(struct lapd_instance *li, uint8_t tei, uint8_t sapi); |
| 54 | |
| 55 | /* Stop a (user-side) SAP for the specified TEI/SAPI on the LAPD instance */ |
| 56 | int lapd_sap_stop(struct lapd_instance *li, uint8_t tei, uint8_t sapi); |
Harald Welte | 0a47400 | 2011-02-11 18:34:51 +0100 | [diff] [blame] | 57 | |
Harald Welte | 6803ab2 | 2011-02-04 20:38:22 +0100 | [diff] [blame] | 58 | #endif /* OPENBSC_LAPD_H */ |