blob: db565bfb4bc2f19f2016121e1d309e043c6aa177 [file] [log] [blame]
Harald Welte1fa60c82009-02-09 18:13:26 +00001#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
14enum e1inp_sign_type {
15 E1INP_SIGN_NONE,
16 E1INP_SIGN_OML,
17 E1INP_SIGN_RSL,
18};
Harald Welted256d4f2009-03-10 19:44:48 +000019const char *e1inp_signtype_name(enum e1inp_sign_type tp);
Harald Welte1fa60c82009-02-09 18:13:26 +000020
21struct e1inp_ts;
22
23struct 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
49enum e1inp_ts_type {
50 E1INP_TS_TYPE_NONE,
51 E1INP_TS_TYPE_SIGN,
52 E1INP_TS_TYPE_TRAU,
53};
Harald Welted256d4f2009-03-10 19:44:48 +000054const char *e1inp_tstype_name(enum e1inp_ts_type tp);
Harald Welte1fa60c82009-02-09 18:13:26 +000055
56/* A timeslot in the E1 interface */
57struct 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 Welte5fd8a542009-02-13 02:43:36 +000080 struct {
81 /* ip.access driver has one fd for each ts */
82 struct bsc_fd fd;
83 } ipaccess;
84
Harald Welte1fa60c82009-02-09 18:13:26 +000085 } driver;
86};
87
88struct e1inp_driver {
89 struct llist_head list;
90 const char *name;
91 int (*want_write)(struct e1inp_ts *ts);
92};
93
94struct 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 */
107int e1inp_driver_register(struct e1inp_driver *drv);
108
109/* register a line with the E1 core */
110int e1inp_line_register(struct e1inp_line *line);
111
112/* find a sign_link for given TEI and SAPI in a TS */
113struct e1inp_sign_link *
114e1inp_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 */
118struct e1inp_sign_link *
119e1inp_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 */
124int 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 */
128int e1inp_update_ts(struct e1inp_ts *ts);
129
130/* Receive a packet from the E1 driver */
131int 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 */
135struct 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 */
139int e1inp_event(struct e1inp_ts *ts, int evt, u_int8_t tei, u_int8_t sapi);
140
Holger Freyther0469cf62009-03-31 12:14:16 +0000141/* Write LAPD frames to the fd. */
142void e1_set_pcap_fd(int fd);
143
Harald Welte1fa60c82009-02-09 18:13:26 +0000144/* called by TRAU muxer to obtain the destination mux entity */
145struct subch_mux *e1inp_get_mux(u_int8_t e1_nr, u_int8_t ts_nr);
146
Holger Freytherff9592f2009-03-09 16:17:14 +0000147/* e1_config.c */
Holger Freytherb5c00f52009-04-22 22:08:07 +0000148int e1_config(struct gsm_bts *bts, int cardnr, int release_l2);
Holger Freytherff9592f2009-03-09 16:17:14 +0000149int ia_config(struct gsm_bts *bts);
150int ipaccess_setup(struct e1inp_line *line);
151
Harald Welte44d542e2009-03-10 18:24:35 +0000152struct llist_head e1inp_driver_list;
153struct llist_head e1inp_line_list;
Holger Freytherff9592f2009-03-09 16:17:14 +0000154
Harald Welte1fa60c82009-02-09 18:13:26 +0000155#endif /* _E1_INPUT_H */