blob: bf91b4957095f21ddeb9bdf09c53441782e558e2 [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;
Harald Welte5fd8a542009-02-13 02:43:36 +000078 struct {
79 /* ip.access driver has one fd for each ts */
80 struct bsc_fd fd;
81 } ipaccess;
82
Harald Welte1fa60c82009-02-09 18:13:26 +000083 } driver;
84};
85
86struct e1inp_driver {
87 struct llist_head list;
88 const char *name;
89 int (*want_write)(struct e1inp_ts *ts);
90};
91
92struct e1inp_line {
93 struct llist_head list;
94 unsigned int num;
95 const char *name;
96
97 /* array of timestlots */
98 struct e1inp_ts ts[NUM_E1_TS];
99
100 struct e1inp_driver *driver;
101 void *driver_data;
102};
103
104/* register a driver with the E1 core */
105int e1inp_driver_register(struct e1inp_driver *drv);
106
107/* register a line with the E1 core */
108int e1inp_line_register(struct e1inp_line *line);
109
110/* find a sign_link for given TEI and SAPI in a TS */
111struct e1inp_sign_link *
112e1inp_lookup_sign_link(struct e1inp_ts *ts, u_int8_t tei,
113 u_int8_t sapi);
114
115/* create a new signalling link in a E1 timeslot */
116struct e1inp_sign_link *
117e1inp_sign_link_create(struct e1inp_ts *ts, enum e1inp_sign_type type,
118 struct gsm_bts_trx *trx, u_int8_t tei,
119 u_int8_t sapi);
120
121/* configure and initialize one e1inp_ts */
122int e1inp_ts_config(struct e1inp_ts *ts, struct e1inp_line *line,
123 enum e1inp_ts_type type);
124
125/* Call from the Stack: configuration of this TS has changed */
126int e1inp_update_ts(struct e1inp_ts *ts);
127
128/* Receive a packet from the E1 driver */
129int e1inp_rx_ts(struct e1inp_ts *ts, struct msgb *msg,
130 u_int8_t tei, u_int8_t sapi);
131
132/* called by driver if it wants to transmit on a given TS */
133struct msgb *e1inp_tx_ts(struct e1inp_ts *e1i_ts,
134 struct e1inp_sign_link **sign_link);
135
136/* called by driver in case some kind of link state event */
137int e1inp_event(struct e1inp_ts *ts, int evt, u_int8_t tei, u_int8_t sapi);
138
139/* called by TRAU muxer to obtain the destination mux entity */
140struct subch_mux *e1inp_get_mux(u_int8_t e1_nr, u_int8_t ts_nr);
141
Holger Freytherff9592f2009-03-09 16:17:14 +0000142/* e1_config.c */
143int e1_config(struct gsm_bts *bts);
144int ia_config(struct gsm_bts *bts);
145int ipaccess_setup(struct e1inp_line *line);
146
Harald Welte44d542e2009-03-10 18:24:35 +0000147struct llist_head e1inp_driver_list;
148struct llist_head e1inp_line_list;
Holger Freytherff9592f2009-03-09 16:17:14 +0000149
Harald Welte1fa60c82009-02-09 18:13:26 +0000150#endif /* _E1_INPUT_H */