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> |
Harald Welte | 25de991 | 2009-04-30 15:53:07 +0000 | [diff] [blame] | 5 | #include <netinet/in.h> |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 6 | |
Pablo Neira Ayuso | 136f453 | 2011-03-22 16:47:59 +0100 | [diff] [blame^] | 7 | #include <osmocom/core/linuxlist.h> |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 8 | #include <openbsc/gsm_data.h> |
Pablo Neira Ayuso | 136f453 | 2011-03-22 16:47:59 +0100 | [diff] [blame^] | 9 | #include <osmocom/core/msgb.h> |
| 10 | #include <osmocom/core/select.h> |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 11 | #include <openbsc/subchan_demux.h> |
| 12 | |
| 13 | #define NUM_E1_TS 32 |
| 14 | |
| 15 | enum e1inp_sign_type { |
| 16 | E1INP_SIGN_NONE, |
| 17 | E1INP_SIGN_OML, |
| 18 | E1INP_SIGN_RSL, |
| 19 | }; |
Harald Welte | d256d4f | 2009-03-10 19:44:48 +0000 | [diff] [blame] | 20 | const char *e1inp_signtype_name(enum e1inp_sign_type tp); |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 21 | |
| 22 | struct e1inp_ts; |
| 23 | |
| 24 | struct e1inp_sign_link { |
| 25 | /* list of signalling links */ |
| 26 | struct llist_head list; |
| 27 | |
| 28 | /* to which timeslot do we belong? */ |
| 29 | struct e1inp_ts *ts; |
| 30 | |
| 31 | enum e1inp_sign_type type; |
| 32 | |
| 33 | /* trx for msg->trx of received msgs */ |
| 34 | struct gsm_bts_trx *trx; |
| 35 | |
| 36 | /* msgb queue of to-be-transmitted msgs */ |
| 37 | struct llist_head tx_list; |
| 38 | |
| 39 | /* SAPI and TEI on the E1 TS */ |
| 40 | u_int8_t sapi; |
| 41 | u_int8_t tei; |
| 42 | |
| 43 | union { |
| 44 | struct { |
| 45 | u_int8_t channel; |
| 46 | } misdn; |
| 47 | } driver; |
| 48 | }; |
| 49 | |
| 50 | enum e1inp_ts_type { |
| 51 | E1INP_TS_TYPE_NONE, |
| 52 | E1INP_TS_TYPE_SIGN, |
| 53 | E1INP_TS_TYPE_TRAU, |
| 54 | }; |
Harald Welte | d256d4f | 2009-03-10 19:44:48 +0000 | [diff] [blame] | 55 | const char *e1inp_tstype_name(enum e1inp_ts_type tp); |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 56 | |
| 57 | /* A timeslot in the E1 interface */ |
| 58 | struct e1inp_ts { |
| 59 | enum e1inp_ts_type type; |
| 60 | int num; |
| 61 | |
| 62 | /* to which line do we belong ? */ |
| 63 | struct e1inp_line *line; |
| 64 | |
| 65 | union { |
| 66 | struct { |
Harald Welte | f55b49f | 2009-05-23 06:20:41 +0000 | [diff] [blame] | 67 | /* list of all signalling links on this TS */ |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 68 | struct llist_head sign_links; |
Holger Hans Peter Freyther | d85642a | 2010-04-26 16:02:04 +0800 | [diff] [blame] | 69 | /* delay for the queue */ |
| 70 | int delay; |
Harald Welte | f55b49f | 2009-05-23 06:20:41 +0000 | [diff] [blame] | 71 | /* timer when to dequeue next frame */ |
| 72 | struct timer_list tx_timer; |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 73 | } sign; |
| 74 | struct { |
| 75 | /* subchannel demuxer for frames from E1 */ |
| 76 | struct subch_demux demux; |
| 77 | /* subchannel muxer for frames to E1 */ |
| 78 | struct subch_mux mux; |
| 79 | } trau; |
| 80 | }; |
| 81 | union { |
| 82 | struct { |
| 83 | /* mISDN driver has one fd for each ts */ |
| 84 | struct bsc_fd fd; |
| 85 | } misdn; |
Harald Welte | 5fd8a54 | 2009-02-13 02:43:36 +0000 | [diff] [blame] | 86 | struct { |
| 87 | /* ip.access driver has one fd for each ts */ |
| 88 | struct bsc_fd fd; |
| 89 | } ipaccess; |
Harald Welte | d38f105 | 2011-02-05 19:13:00 +0100 | [diff] [blame] | 90 | struct { |
| 91 | /* DAHDI driver has one fd for each ts */ |
| 92 | struct bsc_fd fd; |
| 93 | struct lapd_instance *lapd; |
| 94 | } dahdi; |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 95 | } driver; |
| 96 | }; |
| 97 | |
| 98 | struct e1inp_driver { |
| 99 | struct llist_head list; |
| 100 | const char *name; |
| 101 | int (*want_write)(struct e1inp_ts *ts); |
Harald Welte | 5455243 | 2011-02-05 12:26:55 +0100 | [diff] [blame] | 102 | int (*line_update)(struct e1inp_line *line); |
Holger Hans Peter Freyther | d85642a | 2010-04-26 16:02:04 +0800 | [diff] [blame] | 103 | int default_delay; |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 104 | }; |
| 105 | |
| 106 | struct e1inp_line { |
| 107 | struct llist_head list; |
| 108 | unsigned int num; |
| 109 | const char *name; |
| 110 | |
| 111 | /* array of timestlots */ |
| 112 | struct e1inp_ts ts[NUM_E1_TS]; |
| 113 | |
| 114 | struct e1inp_driver *driver; |
| 115 | void *driver_data; |
| 116 | }; |
| 117 | |
| 118 | /* register a driver with the E1 core */ |
| 119 | int e1inp_driver_register(struct e1inp_driver *drv); |
| 120 | |
Harald Welte | 3016d9f | 2011-02-05 13:54:41 +0100 | [diff] [blame] | 121 | /* fine a previously registered driver */ |
| 122 | struct e1inp_driver *e1inp_driver_find(const char *name); |
| 123 | |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 124 | /* register a line with the E1 core */ |
| 125 | int e1inp_line_register(struct e1inp_line *line); |
| 126 | |
Harald Welte | 3016d9f | 2011-02-05 13:54:41 +0100 | [diff] [blame] | 127 | /* get a line by its ID */ |
| 128 | struct e1inp_line *e1inp_line_get(u_int8_t e1_nr); |
| 129 | |
| 130 | /* create a line in the E1 input core */ |
| 131 | struct e1inp_line *e1inp_line_create(u_int8_t e1_nr, const char *driver_name); |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 132 | |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 133 | /* find a sign_link for given TEI and SAPI in a TS */ |
| 134 | struct e1inp_sign_link * |
| 135 | e1inp_lookup_sign_link(struct e1inp_ts *ts, u_int8_t tei, |
| 136 | u_int8_t sapi); |
| 137 | |
| 138 | /* create a new signalling link in a E1 timeslot */ |
| 139 | struct e1inp_sign_link * |
| 140 | e1inp_sign_link_create(struct e1inp_ts *ts, enum e1inp_sign_type type, |
| 141 | struct gsm_bts_trx *trx, u_int8_t tei, |
| 142 | u_int8_t sapi); |
| 143 | |
| 144 | /* configure and initialize one e1inp_ts */ |
| 145 | int e1inp_ts_config(struct e1inp_ts *ts, struct e1inp_line *line, |
| 146 | enum e1inp_ts_type type); |
| 147 | |
| 148 | /* Call from the Stack: configuration of this TS has changed */ |
| 149 | int e1inp_update_ts(struct e1inp_ts *ts); |
| 150 | |
| 151 | /* Receive a packet from the E1 driver */ |
| 152 | int e1inp_rx_ts(struct e1inp_ts *ts, struct msgb *msg, |
| 153 | u_int8_t tei, u_int8_t sapi); |
| 154 | |
| 155 | /* called by driver if it wants to transmit on a given TS */ |
| 156 | struct msgb *e1inp_tx_ts(struct e1inp_ts *e1i_ts, |
| 157 | struct e1inp_sign_link **sign_link); |
| 158 | |
| 159 | /* called by driver in case some kind of link state event */ |
| 160 | int e1inp_event(struct e1inp_ts *ts, int evt, u_int8_t tei, u_int8_t sapi); |
| 161 | |
Holger Freyther | 0469cf6 | 2009-03-31 12:14:16 +0000 | [diff] [blame] | 162 | /* Write LAPD frames to the fd. */ |
| 163 | void e1_set_pcap_fd(int fd); |
| 164 | |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 165 | /* called by TRAU muxer to obtain the destination mux entity */ |
| 166 | struct subch_mux *e1inp_get_mux(u_int8_t e1_nr, u_int8_t ts_nr); |
| 167 | |
Holger Hans Peter Freyther | 34e9749 | 2009-08-10 07:54:02 +0200 | [diff] [blame] | 168 | void e1inp_sign_link_destroy(struct e1inp_sign_link *link); |
| 169 | int e1inp_line_update(struct e1inp_line *line); |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 170 | |
Holger Freyther | ff9592f | 2009-03-09 16:17:14 +0000 | [diff] [blame] | 171 | /* e1_config.c */ |
Harald Welte | 4258182 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 172 | int e1_reconfig_ts(struct gsm_bts_trx_ts *ts); |
| 173 | int e1_reconfig_trx(struct gsm_bts_trx *trx); |
| 174 | int e1_reconfig_bts(struct gsm_bts *bts); |
| 175 | |
Harald Welte | 25de991 | 2009-04-30 15:53:07 +0000 | [diff] [blame] | 176 | int ia_config_connect(struct gsm_bts *bts, struct sockaddr_in *sin); |
Harald Welte | edb3778 | 2009-05-01 14:59:07 +0000 | [diff] [blame] | 177 | int ipaccess_setup(struct gsm_network *gsmnet); |
Holger Freyther | ff9592f | 2009-03-09 16:17:14 +0000 | [diff] [blame] | 178 | |
Harald Welte | 7572745 | 2009-05-23 05:26:29 +0000 | [diff] [blame] | 179 | extern struct llist_head e1inp_driver_list; |
| 180 | extern struct llist_head e1inp_line_list; |
Holger Freyther | ff9592f | 2009-03-09 16:17:14 +0000 | [diff] [blame] | 181 | |
Harald Welte | 3016d9f | 2011-02-05 13:54:41 +0100 | [diff] [blame] | 182 | int e1inp_vty_init(void); |
| 183 | void e1inp_init(void); |
| 184 | |
Harald Welte | d88a387 | 2011-02-14 15:26:13 +0100 | [diff] [blame] | 185 | int _abis_nm_sendmsg(struct msgb *msg, int to_trx_oml); |
| 186 | |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 187 | #endif /* _E1_INPUT_H */ |