summaryrefslogtreecommitdiff
path: root/src/libhydra/attributes
diff options
context:
space:
mode:
authorRene Mayrhofer <rene@mayrhofer.eu.org>2010-08-09 09:43:35 +0000
committerRene Mayrhofer <rene@mayrhofer.eu.org>2010-08-09 09:43:35 +0000
commit9e7fb8577802de2abf191d783be5b6b953c22271 (patch)
treee6818532d3a85a8a840652f6dfc0d58d42c89a69 /src/libhydra/attributes
parent20e652eab94f898365fdde046ed11a2dda2f165e (diff)
downloadvyos-strongswan-9e7fb8577802de2abf191d783be5b6b953c22271.tar.gz
vyos-strongswan-9e7fb8577802de2abf191d783be5b6b953c22271.zip
New upstream release.
Diffstat (limited to 'src/libhydra/attributes')
-rw-r--r--src/libhydra/attributes/attribute_manager.c11
-rw-r--r--src/libhydra/attributes/attribute_manager.h3
-rw-r--r--src/libhydra/attributes/attribute_provider.h3
-rw-r--r--src/libhydra/attributes/attributes.c73
-rw-r--r--src/libhydra/attributes/attributes.h66
-rw-r--r--src/libhydra/attributes/mem_pool.c13
6 files changed, 141 insertions, 28 deletions
diff --git a/src/libhydra/attributes/attribute_manager.c b/src/libhydra/attributes/attribute_manager.c
index 3080b56eb..0d4cbda82 100644
--- a/src/libhydra/attributes/attribute_manager.c
+++ b/src/libhydra/attributes/attribute_manager.c
@@ -51,6 +51,8 @@ struct private_attribute_manager_t {
* Data to pass to enumerator filters
*/
typedef struct {
+ /** attribute group pool */
+ char *pool;
/** server/peer identity */
identification_t *id;
/** requesting/assigned virtual IP */
@@ -123,17 +125,20 @@ static void release_address(private_attribute_manager_t *this,
static enumerator_t *responder_enum_create(attribute_provider_t *provider,
enum_data_t *data)
{
- return provider->create_attribute_enumerator(provider, data->id, data->vip);
+ return provider->create_attribute_enumerator(provider, data->pool,
+ data->id, data->vip);
}
/**
* Implementation of attribute_manager_t.create_responder_enumerator
*/
static enumerator_t* create_responder_enumerator(
- private_attribute_manager_t *this, identification_t *id, host_t *vip)
+ private_attribute_manager_t *this, char *pool,
+ identification_t *id, host_t *vip)
{
enum_data_t *data = malloc_thing(enum_data_t);
+ data->pool = pool;
data->id = id;
data->vip = vip;
this->lock->read_lock(this->lock);
@@ -355,7 +360,7 @@ attribute_manager_t *attribute_manager_create()
this->public.acquire_address = (host_t*(*)(attribute_manager_t*, char*, identification_t*,host_t*))acquire_address;
this->public.release_address = (void(*)(attribute_manager_t*, char *, host_t*, identification_t*))release_address;
- this->public.create_responder_enumerator = (enumerator_t*(*)(attribute_manager_t*, identification_t*, host_t*))create_responder_enumerator;
+ this->public.create_responder_enumerator = (enumerator_t*(*)(attribute_manager_t*, char *name, identification_t*, host_t*))create_responder_enumerator;
this->public.add_provider = (void(*)(attribute_manager_t*, attribute_provider_t *provider))add_provider;
this->public.remove_provider = (void(*)(attribute_manager_t*, attribute_provider_t *provider))remove_provider;
this->public.handle = (attribute_handler_t*(*)(attribute_manager_t*,identification_t*, attribute_handler_t*, configuration_attribute_type_t, chunk_t))handle;
diff --git a/src/libhydra/attributes/attribute_manager.h b/src/libhydra/attributes/attribute_manager.h
index 642662366..56afef7c6 100644
--- a/src/libhydra/attributes/attribute_manager.h
+++ b/src/libhydra/attributes/attribute_manager.h
@@ -61,12 +61,13 @@ struct attribute_manager_t {
/**
* Create an enumerator over attributes to hand out to a peer.
*
+ * @param pool pool name to get attributes from
* @param id peer identity to hand out attributes to
* @param vip virtual IP to assign to peer, if any
* @return enumerator (configuration_attribute_type_t, chunk_t)
*/
enumerator_t* (*create_responder_enumerator)(attribute_manager_t *this,
- identification_t *id, host_t *vip);
+ char *pool, identification_t *id, host_t *vip);
/**
* Register an attribute provider to the manager.
diff --git a/src/libhydra/attributes/attribute_provider.h b/src/libhydra/attributes/attribute_provider.h
index f8485cc6c..e4b4e13f3 100644
--- a/src/libhydra/attributes/attribute_provider.h
+++ b/src/libhydra/attributes/attribute_provider.h
@@ -56,12 +56,13 @@ struct attribute_provider_t {
/**
* Create an enumerator over attributes to hand out to a peer.
*
+ * @param pool pool name to get attributes from
* @param id peer ID
* @param vip virtual IP to assign to peer, if any
* @return enumerator (configuration_attribute_type_t, chunk_t)
*/
enumerator_t* (*create_attribute_enumerator)(attribute_provider_t *this,
- identification_t *id, host_t *vip);
+ char *pool, identification_t *id, host_t *vip);
};
#endif /** ATTRIBUTE_PROVIDER_H_ @}*/
diff --git a/src/libhydra/attributes/attributes.c b/src/libhydra/attributes/attributes.c
index 83feed17e..ea87109e2 100644
--- a/src/libhydra/attributes/attributes.c
+++ b/src/libhydra/attributes/attributes.c
@@ -36,8 +36,77 @@ ENUM_BEGIN(configuration_attribute_type_names, INTERNAL_IP4_ADDRESS, INTERNAL_IP
"MIP6_HOME_PREFIX",
"INTERNAL_IP6_LINK",
"INTERNAL_IP6_PREFIX");
-ENUM_NEXT(configuration_attribute_type_names, INTERNAL_IP4_SERVER, INTERNAL_IP6_SERVER, INTERNAL_IP6_PREFIX,
+ENUM_NEXT(configuration_attribute_type_names, XAUTH_TYPE, XAUTH_ANSWER, INTERNAL_IP6_PREFIX,
+ "XAUTH_TYPE",
+ "XAUTH_USER_NAME",
+ "XAUTH_USER_PASSWORD",
+ "XAUTH_PASSCODE",
+ "XAUTH_MESSAGE",
+ "XAUTH_CHALLENGE",
+ "XAUTH_DOMAIN",
+ "XAUTH_STATUS",
+ "XAUTH_NEXT_PIN",
+ "XAUTH_ANSWER");
+ENUM_NEXT(configuration_attribute_type_names, INTERNAL_IP4_SERVER, INTERNAL_IP6_SERVER, XAUTH_ANSWER,
"INTERNAL_IP4_SERVER",
"INTERNAL_IP6_SERVER");
-ENUM_END(configuration_attribute_type_names, INTERNAL_IP6_SERVER);
+ENUM_NEXT(configuration_attribute_type_names, UNITY_BANNER, UNITY_DDNS_HOSTNAME, INTERNAL_IP6_SERVER,
+ "UNITY_BANNER",
+ "UNITY_SAVE_PASSWD",
+ "UNITY_DEF_DOMAIN",
+ "UNITY_SPLITDNS_NAME",
+ "UNITY_SPLIT_INCLUDE",
+ "UNITY_NATT_PORT",
+ "UNITY_LOCAL_LAN",
+ "UNITY_PFS",
+ "UNITY_FW_TYPE",
+ "UNITY_BACKUP_SERVERS",
+ "UNITY_DDNS_HOSTNAME");
+ENUM_END(configuration_attribute_type_names, UNITY_DDNS_HOSTNAME);
+ENUM_BEGIN(configuration_attribute_type_short_names, INTERNAL_IP4_ADDRESS, INTERNAL_IP6_PREFIX,
+ "ADDR",
+ "MASK",
+ "DNS",
+ "NBNS",
+ "EXP",
+ "DHCP",
+ "VER",
+ "ADDR6",
+ "MASK6",
+ "DNS6",
+ "NBNS6",
+ "DHCP6",
+ "SUBNET",
+ "SUPPORTED",
+ "SUBNET6",
+ "MIP6HPFX",
+ "LINK6",
+ "PFX6");
+ENUM_NEXT(configuration_attribute_type_short_names, XAUTH_TYPE, XAUTH_ANSWER, INTERNAL_IP6_PREFIX,
+ "XAUTH_TYPE",
+ "XAUTH_USER_NAME",
+ "XAUTH_USER_PASSWORD",
+ "XAUTH_PASSCODE",
+ "XAUTH_MESSAGE",
+ "XAUTH_CHALLENGE",
+ "XAUTH_DOMAIN",
+ "XAUTH_STATUS",
+ "XAUTH_NEXT_PIN",
+ "XAUTH_ANSWER");
+ENUM_NEXT(configuration_attribute_type_short_names, INTERNAL_IP4_SERVER, INTERNAL_IP6_SERVER, XAUTH_ANSWER,
+ "SRV",
+ "SRV6");
+ENUM_NEXT(configuration_attribute_type_short_names, UNITY_BANNER, UNITY_DDNS_HOSTNAME, INTERNAL_IP6_SERVER,
+ "UNITY_BANNER",
+ "UNITY_SAVE_PASSWD",
+ "UNITY_DEF_DOMAIN",
+ "UNITY_SPLITDNS_NAME",
+ "UNITY_SPLIT_INCLUDE",
+ "UNITY_NATT_PORT",
+ "UNITY_LOCAL_LAN",
+ "UNITY_PFS",
+ "UNITY_FW_TYPE",
+ "UNITY_BACKUP_SERVERS",
+ "UNITY_DDNS_HOSTNAME");
+ENUM_END(configuration_attribute_type_short_names, UNITY_DDNS_HOSTNAME);
diff --git a/src/libhydra/attributes/attributes.h b/src/libhydra/attributes/attributes.h
index f4a396f21..3a40ba367 100644
--- a/src/libhydra/attributes/attributes.h
+++ b/src/libhydra/attributes/attributes.h
@@ -30,27 +30,50 @@ typedef enum configuration_attribute_type_t configuration_attribute_type_t;
* Type of the attribute, as in IKEv2 RFC 3.15.1 or IKEv1 ModeConfig.
*/
enum configuration_attribute_type_t {
- INTERNAL_IP4_ADDRESS = 1,
- INTERNAL_IP4_NETMASK = 2,
- INTERNAL_IP4_DNS = 3,
- INTERNAL_IP4_NBNS = 4,
+ INTERNAL_IP4_ADDRESS = 1,
+ INTERNAL_IP4_NETMASK = 2,
+ INTERNAL_IP4_DNS = 3,
+ INTERNAL_IP4_NBNS = 4,
INTERNAL_ADDRESS_EXPIRY = 5,
- INTERNAL_IP4_DHCP = 6,
- APPLICATION_VERSION = 7,
- INTERNAL_IP6_ADDRESS = 8,
- INTERNAL_IP6_NETMASK = 9,
- INTERNAL_IP6_DNS = 10,
- INTERNAL_IP6_NBNS = 11,
- INTERNAL_IP6_DHCP = 12,
- INTERNAL_IP4_SUBNET = 13,
- SUPPORTED_ATTRIBUTES = 14,
- INTERNAL_IP6_SUBNET = 15,
- MIP6_HOME_PREFIX = 16,
- INTERNAL_IP6_LINK = 17,
- INTERNAL_IP6_PREFIX = 18,
+ INTERNAL_IP4_DHCP = 6,
+ APPLICATION_VERSION = 7,
+ INTERNAL_IP6_ADDRESS = 8,
+ INTERNAL_IP6_NETMASK = 9,
+ INTERNAL_IP6_DNS = 10,
+ INTERNAL_IP6_NBNS = 11,
+ INTERNAL_IP6_DHCP = 12,
+ INTERNAL_IP4_SUBNET = 13,
+ SUPPORTED_ATTRIBUTES = 14,
+ INTERNAL_IP6_SUBNET = 15,
+ MIP6_HOME_PREFIX = 16,
+ INTERNAL_IP6_LINK = 17,
+ INTERNAL_IP6_PREFIX = 18,
+ /* XAUTH attributes */
+ XAUTH_TYPE = 16520,
+ XAUTH_USER_NAME = 16521,
+ XAUTH_USER_PASSWORD = 16522,
+ XAUTH_PASSCODE = 16523,
+ XAUTH_MESSAGE = 16524,
+ XAUTH_CHALLENGE = 16525,
+ XAUTH_DOMAIN = 16526,
+ XAUTH_STATUS = 16527,
+ XAUTH_NEXT_PIN = 16528,
+ XAUTH_ANSWER = 16529,
/* proprietary Microsoft attributes */
- INTERNAL_IP4_SERVER = 23456,
- INTERNAL_IP6_SERVER = 23457
+ INTERNAL_IP4_SERVER = 23456,
+ INTERNAL_IP6_SERVER = 23457,
+ /* proprietary Cisco Unity attributes */
+ UNITY_BANNER = 28672,
+ UNITY_SAVE_PASSWD = 28673,
+ UNITY_DEF_DOMAIN = 28674,
+ UNITY_SPLITDNS_NAME = 28675,
+ UNITY_SPLIT_INCLUDE = 28676,
+ UNITY_NATT_PORT = 28677,
+ UNITY_LOCAL_LAN = 28678,
+ UNITY_PFS = 28679,
+ UNITY_FW_TYPE = 28680,
+ UNITY_BACKUP_SERVERS = 28681,
+ UNITY_DDNS_HOSTNAME = 28682
};
/**
@@ -58,5 +81,10 @@ enum configuration_attribute_type_t {
*/
extern enum_name_t *configuration_attribute_type_names;
+/**
+ * Short enum names for configuration_attribute_type_t.
+ */
+extern enum_name_t *configuration_attribute_type_short_names;
+
#endif /** ATTRIBUTES_H_ @}*/
diff --git a/src/libhydra/attributes/mem_pool.c b/src/libhydra/attributes/mem_pool.c
index 65018e3a9..e1d69fd6b 100644
--- a/src/libhydra/attributes/mem_pool.c
+++ b/src/libhydra/attributes/mem_pool.c
@@ -225,9 +225,18 @@ METHOD(mem_pool_t, acquire_address, host_t*,
/* check for a valid online lease, reassign */
offset = (uintptr_t)this->online->get(this->online, id);
- if (offset && offset == host2offset(this, requested))
+ if (offset)
{
- DBG1(DBG_CFG, "reassigning online lease to '%Y'", id);
+ if (offset == host2offset(this, requested))
+ {
+ DBG1(DBG_CFG, "reassigning online lease to '%Y'", id);
+ }
+ else
+ {
+ DBG1(DBG_CFG, "'%Y' already has an online lease, "
+ "unable to assign address", id);
+ offset = 0;
+ }
break;
}