summaryrefslogtreecommitdiffstats
path: root/src/host/virt_phy/include/virtphy/l1ctl_sock.h
blob: 8c96dc8994bf8654366773d48a73c95bd1ac7ca8 (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
#pragma once

#include <osmocom/core/msgb.h>
#include <osmocom/core/select.h>

#define L1CTL_SOCK_PATH	"/tmp/osmocom_l2"

/* L1CTL socket instance contains socket data. */
struct l1ctl_sock_inst {
	void *priv; /* Will be appended after osmo-fd's data pointer. */
	struct osmo_fd connection; /* L1CTL connection to l2 app */
	char* l1ctl_sock_path; /* Socket path used to connect to l23 */
	struct osmo_fd ofd; /* Osmocom file descriptor to accept L1CTL connections. */
	void (*recv_cb)(struct l1ctl_sock_inst *vui, struct msgb *msg); /* Callback function called for incoming data from l2 app. */
};

/**
 * @brief Initialise the l1ctl socket for communication with l2 apps.
 */
struct l1ctl_sock_inst *l1ctl_sock_init(
                void *ctx,
                void (*recv_cb)(struct l1ctl_sock_inst *lsi, struct msgb *msg),
                char *path);

/**
 * @brief Transmit message to l2.
 */
int l1ctl_sock_write_msg(struct l1ctl_sock_inst *lsi, struct msgb *msg);

/**
 * @brief Destroy instance.
 */
void l1ctl_sock_destroy();

/**
 * @brief Disconnect current connection.
 */
void l1ctl_sock_disconnect(struct l1ctl_sock_inst *lsi);