summaryrefslogtreecommitdiffstats
path: root/tests/e1inp_ipa_bsc_test.c
blob: 5ef725e4d38e7bbb1506f14fa9f09cbb1c7397b6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <stdio.h>
#include <osmocom/abis/e1_input.h>

static int rx_cb(struct msgb *msg, struct e1inp_ts *ts)
{
	printf("received data\n");

	/* For ISDN: from the timeslot type, we can get if it's:
	 * - E1INP_TS_TYPE_SIGN: in this case, check if we have a signal
	 *   link in this timeslot, then, check if it's OML or RSL and pass
	 *   it to the upper layer.
	 * - E1INP_TS_TYPE_TRAU.
	 *
	 * For INET: we have to check if this is a control message, if it's
	 * a response to previous request id, we enable the signal links for
	 * OML and RSL. Otherwise, look up for the existing signal link and
	 * pass it to the upper layer. We don't receive TRAU frames, we use
	 * RTP.
	 */
	return 0;
}

static int rx_err_cb(int error)
{
	printf("error, malformed message\n");
	return 0;
}

int main(void)
{
	struct e1inp_line *line;
	struct e1inp_ts *sign_ts;

	e1inp_init();

#define LINENR 0

	line = e1inp_line_create(LINENR, "ipa", rx_cb, rx_err_cb);
	if (line == NULL) {
		fprintf(stderr, "problem creating E1 line\n");
		exit(EXIT_FAILURE);
	}
	sign_ts = &line->ts[0];
	if (e1inp_ts_config_sign(sign_ts, line) < 0) {
		fprintf(stderr, "problem setting timeslot in E1 line\n");
		exit(EXIT_FAILURE);
	}

	/*
	 * Depending if this is a real or virtual E1 lines:
	 * - real (ISDN): create signal link for OML and RSL before line up.
	 * - vitual (INET): we create it once we have seen response to REQ_ID.
	 *
	 * The signal link is created via e1inp_sign_link_create(...)
	 *
	 * See e1_reconfig_trx and e1_reconfig_bts in libbsc/e1_config.c,
	 * it explains how this is done with ISDN.
	 */

	if (e1inp_line_update(line, E1INP_LINE_R_BSC) < 0) {
		fprintf(stderr, "problem enabling E1 line\n");
		exit(EXIT_FAILURE);
	}

	while (1) {
		osmo_select_main(0);
	}
	return 0;
}