summaryrefslogtreecommitdiffstats
path: root/src/host/trxcon/l1ctl_link.h
blob: 01103dccc8a18b748ac92a01a0fb49bd00211223 (plain)
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
#pragma once

#include <stdint.h>

#include <osmocom/core/write_queue.h>
#include <osmocom/core/select.h>
#include <osmocom/core/timer.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/fsm.h>

#define L1CTL_LENGTH 256
#define L1CTL_HEADROOM 32

/**
 * Each L1CTL message gets its own length pushed
 * as two bytes in front before sending.
 */
#define L1CTL_MSG_LEN_FIELD 2

/* Forward declaration to avoid mutual include */
struct trx_instance;

enum l1ctl_fsm_states {
	L1CTL_STATE_IDLE = 0,
	L1CTL_STATE_CONNECTED,
};

struct l1ctl_link {
	struct osmo_fsm_inst *fsm;
	struct osmo_fd listen_bfd;
	struct osmo_wqueue wq;

	/* Bind TRX instance */
	struct trx_instance *trx;

	/* L1CTL handlers specific */
	struct osmo_timer_list fbsb_timer;
	uint8_t fbsb_conf_sent;

	/* Shutdown callback */
	void (*shutdown_cb)(struct l1ctl_link *l1l);
};

int l1ctl_link_init(struct l1ctl_link **l1l, const char *sock_path);
void l1ctl_link_shutdown(struct l1ctl_link *l1l);

int l1ctl_link_send(struct l1ctl_link *l1l, struct msgb *msg);
int l1ctl_link_close_conn(struct l1ctl_link *l1l);