blob: 29c29d0815949cc35a047606b2126235d4b83b59 [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};
19
20struct e1inp_ts;
21
22struct e1inp_sign_link {
23 /* list of signalling links */
24 struct llist_head list;
25
26 /* to which timeslot do we belong? */
27 struct e1inp_ts *ts;
28
29 enum e1inp_sign_type type;
30
31 /* trx for msg->trx of received msgs */
32 struct gsm_bts_trx *trx;
33
34 /* msgb queue of to-be-transmitted msgs */
35 struct llist_head tx_list;
36
37 /* SAPI and TEI on the E1 TS */
38 u_int8_t sapi;
39 u_int8_t tei;
40
41 union {
42 struct {
43 u_int8_t channel;
44 } misdn;
45 } driver;
46};
47
48enum e1inp_ts_type {
49 E1INP_TS_TYPE_NONE,
50 E1INP_TS_TYPE_SIGN,
51 E1INP_TS_TYPE_TRAU,
52};
53
54/* A timeslot in the E1 interface */
55struct e1inp_ts {
56 enum e1inp_ts_type type;
57 int num;
58
59 /* to which line do we belong ? */
60 struct e1inp_line *line;
61
62 union {
63 struct {
64 struct llist_head sign_links;
65 } sign;
66 struct {
67 /* subchannel demuxer for frames from E1 */
68 struct subch_demux demux;
69 /* subchannel muxer for frames to E1 */
70 struct subch_mux mux;
71 } trau;
72 };
73 union {
74 struct {
75 /* mISDN driver has one fd for each ts */
76 struct bsc_fd fd;
77 } misdn;
78 } driver;
79};
80
81struct e1inp_driver {
82 struct llist_head list;
83 const char *name;
84 int (*want_write)(struct e1inp_ts *ts);
85};
86
87struct e1inp_line {
88 struct llist_head list;
89 unsigned int num;
90 const char *name;
91
92 /* array of timestlots */
93 struct e1inp_ts ts[NUM_E1_TS];
94
95 struct e1inp_driver *driver;
96 void *driver_data;
97};
98
99/* register a driver with the E1 core */
100int e1inp_driver_register(struct e1inp_driver *drv);
101
102/* register a line with the E1 core */
103int e1inp_line_register(struct e1inp_line *line);
104
105/* find a sign_link for given TEI and SAPI in a TS */
106struct e1inp_sign_link *
107e1inp_lookup_sign_link(struct e1inp_ts *ts, u_int8_t tei,
108 u_int8_t sapi);
109
110/* create a new signalling link in a E1 timeslot */
111struct e1inp_sign_link *
112e1inp_sign_link_create(struct e1inp_ts *ts, enum e1inp_sign_type type,
113 struct gsm_bts_trx *trx, u_int8_t tei,
114 u_int8_t sapi);
115
116/* configure and initialize one e1inp_ts */
117int e1inp_ts_config(struct e1inp_ts *ts, struct e1inp_line *line,
118 enum e1inp_ts_type type);
119
120/* Call from the Stack: configuration of this TS has changed */
121int e1inp_update_ts(struct e1inp_ts *ts);
122
123/* Receive a packet from the E1 driver */
124int e1inp_rx_ts(struct e1inp_ts *ts, struct msgb *msg,
125 u_int8_t tei, u_int8_t sapi);
126
127/* called by driver if it wants to transmit on a given TS */
128struct msgb *e1inp_tx_ts(struct e1inp_ts *e1i_ts,
129 struct e1inp_sign_link **sign_link);
130
131/* called by driver in case some kind of link state event */
132int e1inp_event(struct e1inp_ts *ts, int evt, u_int8_t tei, u_int8_t sapi);
133
134/* called by TRAU muxer to obtain the destination mux entity */
135struct subch_mux *e1inp_get_mux(u_int8_t e1_nr, u_int8_t ts_nr);
136
137#endif /* _E1_INPUT_H */