aboutsummaryrefslogtreecommitdiffstats
path: root/ggsn/ggsn.h
diff options
context:
space:
mode:
authorKeith Whyte <keith@rhizomatica.org>2023-07-14 02:48:28 +0100
committerKeith Whyte <keith@rhizomatica.org>2023-07-14 04:59:24 +0100
commitcea9044fe4deb5063a4afafa7592c2be51b194a2 (patch)
tree589f724918a16e2c5f492a884692e1cc5f24366d /ggsn/ggsn.h
parent306e7fa8533b302a09442b86b558ee5fbb95aa13 (diff)
Implement reserved IPv4 addresses for IMSIsrhizomatica/testing
Allows maintaining, via the VTY, a list of IMSI -> IPv4 address mappings to ensure the GGSN always assigns the same IP address to a UE identified by the IMSI. This is NOT an implenentation of static IP address support, it simply reserves IPs from the dynamic IP pool. No checks are done to enure that the address indeed forms part of the defined pool, this is left up to the operator to configure correctly. It may be desired to always have the same IP address assigned after a PDP context is deleted and recreated by the device, by toggling mobile data, or airplane mode. This could be useful, for example, in order to avoid having to adjust firewall or packet capture filters. One might also have a small subset of IMSIs on a network that should have a special set of firewall rules, for access to internal infrastructure or traffic shaping exemptions, as some examples. This is intented as a developer or small operator feature, but it is not the intention here that one would go about assigning 'static' IP addresses to an entire HLR of subscribers via the GGSN vty.
Diffstat (limited to 'ggsn/ggsn.h')
-rw-r--r--ggsn/ggsn.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/ggsn/ggsn.h b/ggsn/ggsn.h
index 1abbc9a..44fd3cc 100644
--- a/ggsn/ggsn.h
+++ b/ggsn/ggsn.h
@@ -8,6 +8,7 @@
#include <osmocom/core/timer.h>
#include <osmocom/core/tdef.h>
#include <osmocom/ctrl/control_if.h>
+#include <osmocom/gsm/protocol/gsm_23_003.h>
#include "../lib/tun.h"
#include "../lib/ippool.h"
@@ -35,6 +36,9 @@ struct apn_ctx_ip {
/* v4 address pool */
struct ippool_t *pool;
+ /* Static IMSI to IPv4 reserved address mappings. */
+ struct llist_head imsi_ip_map;
+
};
struct apn_name {
@@ -47,6 +51,15 @@ enum apn_gtpu_mode {
APN_GTPU_MODE_KERNEL_GTP,
};
+/*
+ * IMSI to static IP map handling
+ */
+struct imsi_map_entry {
+ struct llist_head list;
+ char imsi[OSMO_IMSI_BUF_SIZE];
+ struct in46_addr addr;
+};
+
struct apn_ctx {
/* list of APNs inside GGSN */
struct llist_head list;
@@ -161,6 +174,9 @@ extern int ggsn_stop(struct ggsn_ctx *ggsn);
extern int apn_start(struct apn_ctx *apn);
extern int apn_stop(struct apn_ctx *apn);
void ggsn_close_one_pdp(struct pdp_t *pdp);
+bool apn_supports_ipv4(const struct apn_ctx *apn);
+int apn_imsi_ip_map_add(const char *imsi, const char *ip, struct apn_ctx_ip *ctx);
+int apn_imsi_ip_map_del(const char *imsi, const char *ip, struct apn_ctx_ip *ctx);
#define LOGPAPN(level, apn, fmt, args...) \
LOGP(DGGSN, level, "APN(%s): " fmt, (apn)->cfg.name, ## args)