Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 1 | #ifndef _E1_INPUT_H |
| 2 | #define _E1_INPUT_H |
| 3 | |
| 4 | #include <stdlib.h> |
| 5 | |
| 6 | #include <openbsc/linuxlist.h> |
| 7 | #include <openbsc/gsm_data.h> |
| 8 | #include <openbsc/msgb.h> |
| 9 | #include <openbsc/select.h> |
| 10 | #include <openbsc/subchan_demux.h> |
| 11 | |
| 12 | #define NUM_E1_TS 32 |
| 13 | |
| 14 | enum e1inp_sign_type { |
| 15 | E1INP_SIGN_NONE, |
| 16 | E1INP_SIGN_OML, |
| 17 | E1INP_SIGN_RSL, |
| 18 | }; |
Harald Welte | d256d4f | 2009-03-10 19:44:48 +0000 | [diff] [blame] | 19 | const char *e1inp_signtype_name(enum e1inp_sign_type tp); |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 20 | |
| 21 | struct e1inp_ts; |
| 22 | |
| 23 | struct e1inp_sign_link { |
| 24 | /* list of signalling links */ |
| 25 | struct llist_head list; |
| 26 | |
| 27 | /* to which timeslot do we belong? */ |
| 28 | struct e1inp_ts *ts; |
| 29 | |
| 30 | enum e1inp_sign_type type; |
| 31 | |
| 32 | /* trx for msg->trx of received msgs */ |
| 33 | struct gsm_bts_trx *trx; |
| 34 | |
| 35 | /* msgb queue of to-be-transmitted msgs */ |
| 36 | struct llist_head tx_list; |
| 37 | |
| 38 | /* SAPI and TEI on the E1 TS */ |
| 39 | u_int8_t sapi; |
| 40 | u_int8_t tei; |
| 41 | |
| 42 | union { |
| 43 | struct { |
| 44 | u_int8_t channel; |
| 45 | } misdn; |
| 46 | } driver; |
| 47 | }; |
| 48 | |
| 49 | enum e1inp_ts_type { |
| 50 | E1INP_TS_TYPE_NONE, |
| 51 | E1INP_TS_TYPE_SIGN, |
| 52 | E1INP_TS_TYPE_TRAU, |
| 53 | }; |
Harald Welte | d256d4f | 2009-03-10 19:44:48 +0000 | [diff] [blame] | 54 | const char *e1inp_tstype_name(enum e1inp_ts_type tp); |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 55 | |
| 56 | /* A timeslot in the E1 interface */ |
| 57 | struct e1inp_ts { |
| 58 | enum e1inp_ts_type type; |
| 59 | int num; |
| 60 | |
| 61 | /* to which line do we belong ? */ |
| 62 | struct e1inp_line *line; |
| 63 | |
| 64 | union { |
| 65 | struct { |
| 66 | struct llist_head sign_links; |
| 67 | } sign; |
| 68 | struct { |
| 69 | /* subchannel demuxer for frames from E1 */ |
| 70 | struct subch_demux demux; |
| 71 | /* subchannel muxer for frames to E1 */ |
| 72 | struct subch_mux mux; |
| 73 | } trau; |
| 74 | }; |
| 75 | union { |
| 76 | struct { |
| 77 | /* mISDN driver has one fd for each ts */ |
| 78 | struct bsc_fd fd; |
| 79 | } misdn; |
Harald Welte | 5fd8a54 | 2009-02-13 02:43:36 +0000 | [diff] [blame] | 80 | struct { |
| 81 | /* ip.access driver has one fd for each ts */ |
| 82 | struct bsc_fd fd; |
| 83 | } ipaccess; |
| 84 | |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 85 | } driver; |
| 86 | }; |
| 87 | |
| 88 | struct e1inp_driver { |
| 89 | struct llist_head list; |
| 90 | const char *name; |
| 91 | int (*want_write)(struct e1inp_ts *ts); |
| 92 | }; |
| 93 | |
| 94 | struct e1inp_line { |
| 95 | struct llist_head list; |
| 96 | unsigned int num; |
| 97 | const char *name; |
| 98 | |
| 99 | /* array of timestlots */ |
| 100 | struct e1inp_ts ts[NUM_E1_TS]; |
| 101 | |
| 102 | struct e1inp_driver *driver; |
| 103 | void *driver_data; |
| 104 | }; |
| 105 | |
| 106 | /* register a driver with the E1 core */ |
| 107 | int e1inp_driver_register(struct e1inp_driver *drv); |
| 108 | |
| 109 | /* register a line with the E1 core */ |
| 110 | int e1inp_line_register(struct e1inp_line *line); |
| 111 | |
| 112 | /* find a sign_link for given TEI and SAPI in a TS */ |
| 113 | struct e1inp_sign_link * |
| 114 | e1inp_lookup_sign_link(struct e1inp_ts *ts, u_int8_t tei, |
| 115 | u_int8_t sapi); |
| 116 | |
| 117 | /* create a new signalling link in a E1 timeslot */ |
| 118 | struct e1inp_sign_link * |
| 119 | e1inp_sign_link_create(struct e1inp_ts *ts, enum e1inp_sign_type type, |
| 120 | struct gsm_bts_trx *trx, u_int8_t tei, |
| 121 | u_int8_t sapi); |
| 122 | |
| 123 | /* configure and initialize one e1inp_ts */ |
| 124 | int e1inp_ts_config(struct e1inp_ts *ts, struct e1inp_line *line, |
| 125 | enum e1inp_ts_type type); |
| 126 | |
| 127 | /* Call from the Stack: configuration of this TS has changed */ |
| 128 | int e1inp_update_ts(struct e1inp_ts *ts); |
| 129 | |
| 130 | /* Receive a packet from the E1 driver */ |
| 131 | int e1inp_rx_ts(struct e1inp_ts *ts, struct msgb *msg, |
| 132 | u_int8_t tei, u_int8_t sapi); |
| 133 | |
| 134 | /* called by driver if it wants to transmit on a given TS */ |
| 135 | struct msgb *e1inp_tx_ts(struct e1inp_ts *e1i_ts, |
| 136 | struct e1inp_sign_link **sign_link); |
| 137 | |
| 138 | /* called by driver in case some kind of link state event */ |
| 139 | int e1inp_event(struct e1inp_ts *ts, int evt, u_int8_t tei, u_int8_t sapi); |
| 140 | |
Holger Freyther | 0469cf6 | 2009-03-31 12:14:16 +0000 | [diff] [blame] | 141 | /* Write LAPD frames to the fd. */ |
| 142 | void e1_set_pcap_fd(int fd); |
| 143 | |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 144 | /* called by TRAU muxer to obtain the destination mux entity */ |
| 145 | struct subch_mux *e1inp_get_mux(u_int8_t e1_nr, u_int8_t ts_nr); |
| 146 | |
Holger Freyther | ff9592f | 2009-03-09 16:17:14 +0000 | [diff] [blame] | 147 | /* e1_config.c */ |
Holger Freyther | b5c00f5 | 2009-04-22 22:08:07 +0000 | [diff] [blame^] | 148 | int e1_config(struct gsm_bts *bts, int cardnr, int release_l2); |
Holger Freyther | ff9592f | 2009-03-09 16:17:14 +0000 | [diff] [blame] | 149 | int ia_config(struct gsm_bts *bts); |
| 150 | int ipaccess_setup(struct e1inp_line *line); |
| 151 | |
Harald Welte | 44d542e | 2009-03-10 18:24:35 +0000 | [diff] [blame] | 152 | struct llist_head e1inp_driver_list; |
| 153 | struct llist_head e1inp_line_list; |
Holger Freyther | ff9592f | 2009-03-09 16:17:14 +0000 | [diff] [blame] | 154 | |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 155 | #endif /* _E1_INPUT_H */ |