Compare commits

...

3 Commits

Author SHA1 Message Date
Alexander Couzens 63327450c9 ipa_client: check if stream is alive
Otherwise we might send over a non-existant stream.
2024-02-15 18:48:39 +01:00
Alexander Couzens afcdf9b932 implement static IP assignment of 10.45.0.1 2024-02-15 18:48:39 +01:00
Alexander Couzens 2771a44af7 osmo_epdg: rename provider -> simaka
In preparation to add support for the attribute provider.
The attribute provider will be used to supply the Virtual IP (vip)
2024-02-13 18:31:19 +01:00
4 changed files with 48 additions and 3 deletions

View File

@ -109,6 +109,12 @@ METHOD(osmo_epdg_ipa_client_t, send_pdu, ssize_t,
head->len = htons(msgb_length(msg) - (sizeof(struct ipaccess_head)));
head->data[0] = osmo_proto;
len = msgb_length(msg);
if (!this->stream)
{
free(msg);
return -ENOENT;
}
if (!this->stream->write_all(this->stream, msgb_data(msg), msgb_length(msg)))
{
// TODO: write error

View File

@ -59,12 +59,14 @@ static bool register_functions(private_osmo_epdg_t *this,
this->provider = osmo_epdg_provider_create(gsup);
this->listener = osmo_epdg_listener_create(gsup);
charon->bus->add_listener(charon->bus, &this->listener->listener);
charon->attributes->add_provider(charon->attributes, &this->provider->attribute);
return TRUE;
}
if (this->listener)
{
charon->bus->remove_listener(charon->bus, &this->listener->listener);
}
charon->attributes->remove_provider(charon->attributes, &this->provider->attribute);
this->provider->destroy(this->provider);
this->provider = NULL;
return TRUE;
@ -75,7 +77,7 @@ static bool register_functions(private_osmo_epdg_t *this,
*/
static simaka_provider_t* get_provider(private_osmo_epdg_t *this)
{
return &this->provider->provider;
return &this->provider->simaka;
}
METHOD(plugin_t, get_features, int,

View File

@ -138,6 +138,31 @@ METHOD(simaka_provider_t, resync, bool,
return FALSE;
}
METHOD(attribute_provider_t, acquire_address, host_t*,
private_osmo_epdg_provider_t *this, linked_list_t *pools, ike_sa_t *ike_sa,
host_t *requested)
{
host_t *address = NULL;
address = host_create_from_string_and_family("10.45.0.1", AF_INET, 0);
return address;
}
METHOD(attribute_provider_t, release_address, bool,
private_osmo_epdg_provider_t *this, linked_list_t *pools, host_t *address,
ike_sa_t *ike_sa)
{
return TRUE;
}
METHOD(attribute_provider_t, create_attribute_enumerator, enumerator_t*,
private_osmo_epdg_provider_t *this, linked_list_t *pools, ike_sa_t *ike_sa,
linked_list_t *vips)
{
/* no additional attributes for this ike_sa */
return enumerator_create_empty();
}
METHOD(osmo_epdg_provider_t, destroy, void,
private_osmo_epdg_provider_t *this)
{
@ -153,7 +178,12 @@ osmo_epdg_provider_t *osmo_epdg_provider_create(osmo_epdg_gsup_client_t *gsup)
INIT(this,
.public = {
.provider = {
.attribute = {
.acquire_address = _acquire_address,
.release_address = _release_address,
.create_attribute_enumerator = _create_attribute_enumerator,
},
.simaka = {
.get_triplet = (void*)return_false,
.get_quintuplet = _get_quintuplet,
.resync = _resync,

View File

@ -27,6 +27,7 @@
#define OSMO_EPDG_PROVIDER_H_
#include <simaka_provider.h>
#include <attributes/attribute_provider.h>
#include "gsup_client.h"
typedef struct osmo_epdg_provider_t osmo_epdg_provider_t;
@ -39,7 +40,13 @@ struct osmo_epdg_provider_t {
/**
* Implements simaka_provider_t interface.
*/
simaka_provider_t provider;
simaka_provider_t simaka;
/**
* Implements attribute_provider interface to assign config attributes and virtual ips.
*/
attribute_provider_t attribute;
/**
* Destroy a osmo_epdg_provider_t.