summaryrefslogtreecommitdiffstats
path: root/src/host/layer23/include/osmocom/bb/common/apn.h
blob: 94784ef71c908f4e6b1eb8821e47820f32eb7076 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* APN Context
 * (C) 2023 by sysmocom - s.m.f.c. GmbH <info@sysmocom.de>
 *
 * All Rights Reserved
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */

#pragma once

#include <osmocom/core/linuxlist.h>
#include <osmocom/core/select.h>
#include <osmocom/core/tun.h>

struct osmocom_ms;

#define APN_TYPE_IPv4	0x01	/* v4-only */
#define APN_TYPE_IPv6	0x02	/* v6-only */
#define APN_TYPE_IPv4v6	0x04	/* v4v6 dual-stack */

struct osmobb_apn {
	/* list of APNs inside MS */
	struct llist_head list;
	/* back-pointer to MS */
	struct osmocom_ms *ms;

	bool started;

	struct {
		/* Primary name */
		char *name;
		/* name of the network device */
		char *dev_name;
		/* netns name of the network device, NULL = default netns */
		char *dev_netns_name;
		/* types supported address types on this APN */
		uint32_t apn_type_mask;
		/* administratively shutdown (true) or not (false) */
		bool shutdown;
		/* transmit G-PDU sequence numbers (true) or not (false) */
		bool tx_gpdu_seq;
	} cfg;
	struct osmo_tundev *tun;
};

struct osmobb_apn *apn_alloc(struct osmocom_ms *ms, const char *name);
void apn_free(struct osmobb_apn *apn);
int apn_start(struct osmobb_apn *apn);
int apn_stop(struct osmobb_apn *apn);

#define LOGPAPN(level, apn, fmt, args...)			\
	LOGP(DTUN, level, "APN(%s): " fmt, (apn)->cfg.name, ## args)

#define LOGTUN(level, tun, fmt, args...) \
	LOGP(DTUN, level, "TUN(%s): " fmt, osmo_tundev_get_name(tun), ## args)