Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 1 | #ifndef _E1_INPUT_H |
| 2 | #define _E1_INPUT_H |
| 3 | |
| 4 | #include <stdlib.h> |
| 5 | #include <netinet/in.h> |
| 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 | }; |
| 20 | const char *e1inp_signtype_name(enum e1inp_sign_type tp); |
| 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 | }; |
| 55 | const char *e1inp_tstype_name(enum e1inp_ts_type tp); |
| 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 | /* list of all signalling links on this TS */ |
| 68 | struct llist_head sign_links; |
| 69 | /* timer when to dequeue next frame */ |
| 70 | struct timer_list tx_timer; |
| 71 | } sign; |
| 72 | struct { |
| 73 | /* subchannel demuxer for frames from E1 */ |
| 74 | struct subch_demux demux; |
| 75 | /* subchannel muxer for frames to E1 */ |
| 76 | struct subch_mux mux; |
| 77 | } trau; |
| 78 | }; |
| 79 | union { |
| 80 | struct { |
| 81 | /* mISDN driver has one fd for each ts */ |
| 82 | struct bsc_fd fd; |
| 83 | } misdn; |
| 84 | struct { |
| 85 | /* ip.access driver has one fd for each ts */ |
| 86 | struct bsc_fd fd; |
| 87 | } ipaccess; |
| 88 | |
| 89 | } driver; |
| 90 | }; |
| 91 | |
| 92 | struct e1inp_driver { |
| 93 | struct llist_head list; |
| 94 | const char *name; |
| 95 | int (*want_write)(struct e1inp_ts *ts); |
| 96 | }; |
| 97 | |
| 98 | struct e1inp_line { |
| 99 | struct llist_head list; |
| 100 | unsigned int num; |
| 101 | const char *name; |
| 102 | |
| 103 | /* array of timestlots */ |
| 104 | struct e1inp_ts ts[NUM_E1_TS]; |
| 105 | |
| 106 | struct e1inp_driver *driver; |
| 107 | void *driver_data; |
| 108 | }; |
| 109 | |
| 110 | /* register a driver with the E1 core */ |
| 111 | int e1inp_driver_register(struct e1inp_driver *drv); |
| 112 | |
| 113 | /* register a line with the E1 core */ |
| 114 | int e1inp_line_register(struct e1inp_line *line); |
| 115 | |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 116 | /* ensure a certain line exists, return pointer to it */ |
| 117 | struct e1inp_line *e1inp_line_get_create(u_int8_t e1_nr); |
| 118 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 119 | /* find a sign_link for given TEI and SAPI in a TS */ |
| 120 | struct e1inp_sign_link * |
| 121 | e1inp_lookup_sign_link(struct e1inp_ts *ts, u_int8_t tei, |
| 122 | u_int8_t sapi); |
| 123 | |
| 124 | /* create a new signalling link in a E1 timeslot */ |
| 125 | struct e1inp_sign_link * |
| 126 | e1inp_sign_link_create(struct e1inp_ts *ts, enum e1inp_sign_type type, |
| 127 | struct gsm_bts_trx *trx, u_int8_t tei, |
| 128 | u_int8_t sapi); |
| 129 | |
| 130 | /* configure and initialize one e1inp_ts */ |
| 131 | int e1inp_ts_config(struct e1inp_ts *ts, struct e1inp_line *line, |
| 132 | enum e1inp_ts_type type); |
| 133 | |
| 134 | /* Call from the Stack: configuration of this TS has changed */ |
| 135 | int e1inp_update_ts(struct e1inp_ts *ts); |
| 136 | |
| 137 | /* Receive a packet from the E1 driver */ |
| 138 | int e1inp_rx_ts(struct e1inp_ts *ts, struct msgb *msg, |
| 139 | u_int8_t tei, u_int8_t sapi); |
| 140 | |
| 141 | /* called by driver if it wants to transmit on a given TS */ |
| 142 | struct msgb *e1inp_tx_ts(struct e1inp_ts *e1i_ts, |
| 143 | struct e1inp_sign_link **sign_link); |
| 144 | |
| 145 | /* called by driver in case some kind of link state event */ |
| 146 | int e1inp_event(struct e1inp_ts *ts, int evt, u_int8_t tei, u_int8_t sapi); |
| 147 | |
| 148 | /* Write LAPD frames to the fd. */ |
| 149 | void e1_set_pcap_fd(int fd); |
| 150 | |
| 151 | /* called by TRAU muxer to obtain the destination mux entity */ |
| 152 | struct subch_mux *e1inp_get_mux(u_int8_t e1_nr, u_int8_t ts_nr); |
| 153 | |
Holger Hans Peter Freyther | 735cd9e | 2009-08-10 07:54:02 +0200 | [diff] [blame] | 154 | void e1inp_sign_link_destroy(struct e1inp_sign_link *link); |
| 155 | int e1inp_line_update(struct e1inp_line *line); |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 156 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 157 | /* e1_config.c */ |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 158 | int e1_reconfig_ts(struct gsm_bts_trx_ts *ts); |
| 159 | int e1_reconfig_trx(struct gsm_bts_trx *trx); |
| 160 | int e1_reconfig_bts(struct gsm_bts *bts); |
| 161 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 162 | int ia_config_connect(struct gsm_bts *bts, struct sockaddr_in *sin); |
| 163 | int ipaccess_setup(struct gsm_network *gsmnet); |
| 164 | |
| 165 | extern struct llist_head e1inp_driver_list; |
| 166 | extern struct llist_head e1inp_line_list; |
| 167 | |
| 168 | #endif /* _E1_INPUT_H */ |