aboutsummaryrefslogtreecommitdiffstats
path: root/include/osmocom/netif/channel.h
blob: baeb2c855b45018a74db01b77a2d902b59ea79d0 (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
#ifndef _CHANNEL_H_
#define _CHANNEL_H_

#include <stdint.h>

enum {
	CHAN_NONE,
	CHAN_ABIS_IPA_SRV,
	CHAN_ABIS_IPA_CLI,
	CHAN_MAX,
};

struct osmo_chan;
struct msgb;

struct osmo_chan_type {
	struct llist_head head;

	char	*name;
	int	type;
	int	datasiz;

	int	(*create)(struct osmo_chan *chan);
	void	(*destroy)(struct osmo_chan *chan);
	int	(*open)(struct osmo_chan *chan);
	void	(*close)(struct osmo_chan *chan);
	int	(*enqueue)(struct osmo_chan *chan, struct msgb *msg);
};

struct osmo_chan {
	void			*ctx;
	struct osmo_chan_type	*ops;
	char			data[0];
};

void osmo_chan_init(void);

struct osmo_chan *osmo_chan_create(void *ctx, int type);
void osmo_chan_destroy(struct osmo_chan *c);

int osmo_chan_open(struct osmo_chan *c);
void osmo_chan_close(struct osmo_chan *c);

int osmo_chan_enqueue(struct osmo_chan *c, struct msgb *msg);

#endif /* _CHANNEL_H_ */