From 9852101624d9b590d1f3345df754fd59a3689103 Mon Sep 17 00:00:00 2001 From: Alexander Couzens Date: Tue, 28 Mar 2023 21:23:25 +0200 Subject: [PATCH] step of epdge db --- .../plugins/osmo_epdg/osmo_epdg_db.c | 35 +++++++++++++++++-- .../plugins/osmo_epdg/osmo_epdg_db.h | 12 ++++++- .../plugins/osmo_epdg/osmo_epdg_utils.h | 5 +++ 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/src/libcharon/plugins/osmo_epdg/osmo_epdg_db.c b/src/libcharon/plugins/osmo_epdg/osmo_epdg_db.c index 75ce9a8a9..3e60f74ba 100644 --- a/src/libcharon/plugins/osmo_epdg/osmo_epdg_db.c +++ b/src/libcharon/plugins/osmo_epdg/osmo_epdg_db.c @@ -35,7 +35,25 @@ struct private_osmo_epdg_db_t { */ osmo_epdg_db_t public; + /** + * GSUP client + */ osmo_epdg_gsup_client_t *gsup; + + /** + * subscriber hash by ID + */ + hashtable_t *subscribers; + + /** + * subscriber hash by imsi (how to handle multiple?) + */ + hashtable_t *subscribers_imsi; + + /** + * subscriber by ike_sa + */ + hashtable_t *subscribers_ike_sa_t; }; METHOD(osmo_epdg_db_t, create_subscriber_imsi, osmo_epdg_ue_t *, @@ -57,12 +75,24 @@ METHOD(osmo_epdg_db_t, get_subscriber_id, osmo_epdg_ue_t *, return NULL; } +METHOD(osmo_epdg_db_t, get_subscriber_ike, osmo_epdg_ue_t *, + private_osmo_epdg_db_t *this, ike_sa_t *ike_sa) +{ + return NULL; +} + METHOD(osmo_epdg_db_t, destroy_subscriber_id, void, private_osmo_epdg_db_t *this, uint32_t id) { return NULL; } +METHOD(osmo_epdg_db_t, destroy_subscriber_ike, void, + private_osmo_epdg_db_t *this, ike_sa_t *ike_sa) +{ + return NULL; +} + METHOD(osmo_epdg_db_t, destroy_subscriber, void, private_osmo_epdg_db_t *this) { @@ -84,10 +114,11 @@ osmo_epdg_db_t *osmo_epdg_db_create(osmo_epdg_gsup_client_t *gsup) INIT(this, .public = { - .create_subscriber_imsi = _create_subscriber_imsi, - .create_subscriber = _create_subscriber, + .create_subscriber = _create_subscriber_imsi, .get_subscriber_id = _get_subscriber_id, .get_subscriber_imsi = _get_subscriber_imsi, + .get_subscriber_ike = _get_subscriber_ike, + .destroy_subscriber_ike = _destroy_subscriber_ike, .destroy_subscriber_id = _destroy_subscriber_id, .destroy_subscriber = _destroy_subscriber, .destroy = _destroy, diff --git a/src/libcharon/plugins/osmo_epdg/osmo_epdg_db.h b/src/libcharon/plugins/osmo_epdg/osmo_epdg_db.h index 6b75827d0..2f7d5baa1 100644 --- a/src/libcharon/plugins/osmo_epdg/osmo_epdg_db.h +++ b/src/libcharon/plugins/osmo_epdg/osmo_epdg_db.h @@ -38,18 +38,28 @@ struct osmo_epdg_db_t { /** * Create new subscriber by imsi, before sending authentication */ - osmo_epdg_ue_t *(*create_subscriber_imsi)(osmo_epdg_db_t *this, ike_sa_t *ike_sa, char *imsi); + osmo_epdg_ue_t *(*create_subscriber)(osmo_epdg_db_t *this, ike_sa_t *ike_sa, char *imsi); /** * Get subscriber by imsi, there might be multiple UE by this IMSI */ osmo_epdg_ue_t *(*get_subscriber_imsi)(osmo_epdg_db_t *this, char *imsi, int offset); + /** + * Get subscriber by ike + */ + osmo_epdg_ue_t *(*get_subscriber_ike)(osmo_epdg_db_t *this, ike_sa_t *ike_sa); + /** * Get subscriber by id */ osmo_epdg_ue_t *(*get_subscriber_id)(osmo_epdg_db_t *this, uint32_t id); + /** + * Destroy subscriber by imsi + */ + void (*destroy_subscriber_ike)(osmo_epdg_db_t *this, ike_sa_t *ike_sa); + /** * Destroy subscriber by imsi */ diff --git a/src/libcharon/plugins/osmo_epdg/osmo_epdg_utils.h b/src/libcharon/plugins/osmo_epdg/osmo_epdg_utils.h index b9d035738..b8e26653c 100644 --- a/src/libcharon/plugins/osmo_epdg/osmo_epdg_utils.h +++ b/src/libcharon/plugins/osmo_epdg/osmo_epdg_utils.h @@ -35,6 +35,9 @@ enum ue_state state { UE_WAIT_TUNNEL, /* Everything ready, data can flow */ UE_CONNECTED, + /* Notify the osmo-epdg about destruction, wait for an answer */ + UE_DISCONNECTING, + UE_DESTROYED, }; /* TODO: how to clean up/garbage collect */ @@ -44,7 +47,9 @@ struct osmo_epdg_ue { /* imsi should be uniq, need protected against fake UE */ char *imsi; enum ue_state state; + /* TODO: missing strongswan session pointer */ + ike_sa_t *ike_sa; }; typedef struct osmo_epdg_ue osmo_epdg_ue_t;