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 | |
| 7 | #include <openbsc/linuxlist.h> |
| 8 | #include <openbsc/gsm_data.h> |
| 9 | #include <openbsc/msgb.h> |
| 10 | #include <openbsc/select.h> |
| 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 { |
| 67 | struct llist_head sign_links; |
| 68 | } sign; |
| 69 | struct { |
| 70 | /* subchannel demuxer for frames from E1 */ |
| 71 | struct subch_demux demux; |
| 72 | /* subchannel muxer for frames to E1 */ |
| 73 | struct subch_mux mux; |
| 74 | } trau; |
| 75 | }; |
| 76 | union { |
| 77 | struct { |
| 78 | /* mISDN driver has one fd for each ts */ |
| 79 | struct bsc_fd fd; |
| 80 | } misdn; |
Harald Welte | 5fd8a54 | 2009-02-13 02:43:36 +0000 | [diff] [blame] | 81 | struct { |
| 82 | /* ip.access driver has one fd for each ts */ |
| 83 | struct bsc_fd fd; |
| 84 | } ipaccess; |
| 85 | |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 86 | } driver; |
| 87 | }; |
| 88 | |
| 89 | struct e1inp_driver { |
| 90 | struct llist_head list; |
| 91 | const char *name; |
| 92 | int (*want_write)(struct e1inp_ts *ts); |
| 93 | }; |
| 94 | |
| 95 | struct e1inp_line { |
| 96 | struct llist_head list; |
| 97 | unsigned int num; |
| 98 | const char *name; |
| 99 | |
| 100 | /* array of timestlots */ |
| 101 | struct e1inp_ts ts[NUM_E1_TS]; |
| 102 | |
| 103 | struct e1inp_driver *driver; |
| 104 | void *driver_data; |
| 105 | }; |
| 106 | |
| 107 | /* register a driver with the E1 core */ |
| 108 | int e1inp_driver_register(struct e1inp_driver *drv); |
| 109 | |
| 110 | /* register a line with the E1 core */ |
| 111 | int e1inp_line_register(struct e1inp_line *line); |
| 112 | |
| 113 | /* find a sign_link for given TEI and SAPI in a TS */ |
| 114 | struct e1inp_sign_link * |
| 115 | e1inp_lookup_sign_link(struct e1inp_ts *ts, u_int8_t tei, |
| 116 | u_int8_t sapi); |
| 117 | |
| 118 | /* create a new signalling link in a E1 timeslot */ |
| 119 | struct e1inp_sign_link * |
| 120 | e1inp_sign_link_create(struct e1inp_ts *ts, enum e1inp_sign_type type, |
| 121 | struct gsm_bts_trx *trx, u_int8_t tei, |
| 122 | u_int8_t sapi); |
| 123 | |
| 124 | /* configure and initialize one e1inp_ts */ |
| 125 | int e1inp_ts_config(struct e1inp_ts *ts, struct e1inp_line *line, |
| 126 | enum e1inp_ts_type type); |
| 127 | |
| 128 | /* Call from the Stack: configuration of this TS has changed */ |
| 129 | int e1inp_update_ts(struct e1inp_ts *ts); |
| 130 | |
| 131 | /* Receive a packet from the E1 driver */ |
| 132 | int e1inp_rx_ts(struct e1inp_ts *ts, struct msgb *msg, |
| 133 | u_int8_t tei, u_int8_t sapi); |
| 134 | |
| 135 | /* called by driver if it wants to transmit on a given TS */ |
| 136 | struct msgb *e1inp_tx_ts(struct e1inp_ts *e1i_ts, |
| 137 | struct e1inp_sign_link **sign_link); |
| 138 | |
| 139 | /* called by driver in case some kind of link state event */ |
| 140 | int e1inp_event(struct e1inp_ts *ts, int evt, u_int8_t tei, u_int8_t sapi); |
| 141 | |
Holger Freyther | 0469cf6 | 2009-03-31 12:14:16 +0000 | [diff] [blame] | 142 | /* Write LAPD frames to the fd. */ |
| 143 | void e1_set_pcap_fd(int fd); |
| 144 | |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 145 | /* called by TRAU muxer to obtain the destination mux entity */ |
| 146 | struct subch_mux *e1inp_get_mux(u_int8_t e1_nr, u_int8_t ts_nr); |
| 147 | |
Holger Freyther | ff9592f | 2009-03-09 16:17:14 +0000 | [diff] [blame] | 148 | /* e1_config.c */ |
Holger Freyther | b5c00f5 | 2009-04-22 22:08:07 +0000 | [diff] [blame] | 149 | int e1_config(struct gsm_bts *bts, int cardnr, int release_l2); |
Holger Freyther | ff9592f | 2009-03-09 16:17:14 +0000 | [diff] [blame] | 150 | int ia_config(struct gsm_bts *bts); |
Harald Welte | 25de991 | 2009-04-30 15:53:07 +0000 | [diff] [blame] | 151 | int ia_config_connect(struct gsm_bts *bts, struct sockaddr_in *sin); |
Holger Freyther | ff9592f | 2009-03-09 16:17:14 +0000 | [diff] [blame] | 152 | int ipaccess_setup(struct e1inp_line *line); |
| 153 | |
Harald Welte | 44d542e | 2009-03-10 18:24:35 +0000 | [diff] [blame] | 154 | struct llist_head e1inp_driver_list; |
| 155 | struct llist_head e1inp_line_list; |
Holger Freyther | ff9592f | 2009-03-09 16:17:14 +0000 | [diff] [blame] | 156 | |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 157 | #endif /* _E1_INPUT_H */ |