aboutsummaryrefslogtreecommitdiffstats
path: root/Source/charon/config
diff options
context:
space:
mode:
Diffstat (limited to 'Source/charon/config')
-rw-r--r--Source/charon/config/sa_config.c8
-rw-r--r--Source/charon/config/sa_config.h6
-rw-r--r--Source/charon/config/traffic_selector.c19
-rw-r--r--Source/charon/config/traffic_selector.h48
4 files changed, 73 insertions, 8 deletions
diff --git a/Source/charon/config/sa_config.c b/Source/charon/config/sa_config.c
index f306127a0..51fc94a1e 100644
--- a/Source/charon/config/sa_config.c
+++ b/Source/charon/config/sa_config.c
@@ -96,7 +96,7 @@ static auth_method_t get_auth_method(private_sa_config_t *this)
/**
* implements sa_config_t.get_traffic_selectors
*/
-static size_t get_traffic_selectors(private_sa_config_t *this, traffic_selector_t ***traffic_selectors)
+static size_t get_traffic_selectors(private_sa_config_t *this, traffic_selector_t **traffic_selectors[])
{
iterator_t *iterator;
traffic_selector_t *current_ts;
@@ -118,7 +118,7 @@ static size_t get_traffic_selectors(private_sa_config_t *this, traffic_selector_
/**
* implements sa_config_t.select_traffic_selectors
*/
-static size_t select_traffic_selectors(private_sa_config_t *this, traffic_selector_t **supplied, size_t count, traffic_selector_t ***selected)
+static size_t select_traffic_selectors(private_sa_config_t *this, traffic_selector_t *supplied[], size_t count, traffic_selector_t **selected[])
{
iterator_t *iterator;
traffic_selector_t *current_ts;
@@ -307,8 +307,8 @@ sa_config_t *sa_config_create(id_type_t my_id_type, char *my_id, id_type_t other
this->public.get_my_id = (identification_t*(*)(sa_config_t*))get_my_id;
this->public.get_other_id = (identification_t*(*)(sa_config_t*))get_other_id;
this->public.get_auth_method = (auth_method_t(*)(sa_config_t*))get_auth_method;
- this->public.get_traffic_selectors = (size_t(*)(sa_config_t*,traffic_selector_t***))get_traffic_selectors;
- this->public.select_traffic_selectors = (size_t(*)(sa_config_t*,traffic_selector_t**,size_t,traffic_selector_t***))select_traffic_selectors;
+ this->public.get_traffic_selectors = (size_t(*)(sa_config_t*,traffic_selector_t**[]))get_traffic_selectors;
+ this->public.select_traffic_selectors = (size_t(*)(sa_config_t*,traffic_selector_t*[],size_t,traffic_selector_t**[]))select_traffic_selectors;
this->public.get_proposals = (size_t(*)(sa_config_t*,u_int8_t[4],u_int8_t[4],child_proposal_t**))get_proposals;
this->public.select_proposal = (child_proposal_t*(*)(sa_config_t*,u_int8_t[4],u_int8_t[4],child_proposal_t*,size_t))select_proposal;
this->public.add_traffic_selector = (void(*)(sa_config_t*,traffic_selector_t*))add_traffic_selector;
diff --git a/Source/charon/config/sa_config.h b/Source/charon/config/sa_config.h
index 490395682..b3fb41a67 100644
--- a/Source/charon/config/sa_config.h
+++ b/Source/charon/config/sa_config.h
@@ -125,7 +125,7 @@ struct sa_config_t {
* @param[out]traffic_selectors pointer where traffic selectors will be allocated
* @return number of returned traffic selectors
*/
- size_t (*get_traffic_selectors) (sa_config_t *this, traffic_selector_t ***traffic_selectors);
+ size_t (*get_traffic_selectors) (sa_config_t *this, traffic_selector_t **traffic_selectors[]);
/**
* @brief Select traffic selectors from a supplied list.
@@ -142,7 +142,7 @@ struct sa_config_t {
* @param[out]traffic_selectors pointer where selected traffic selectors will be allocated
* @return number of selected traffic selectors
*/
- size_t (*select_traffic_selectors) (sa_config_t *this, traffic_selector_t **supplied, size_t count, traffic_selector_t ***selected);
+ size_t (*select_traffic_selectors) (sa_config_t *this, traffic_selector_t *supplied[], size_t count, traffic_selector_t **selected[]);
/**
* @brief Get the list of proposals for this config.
@@ -153,7 +153,7 @@ struct sa_config_t {
* @param[out]traffic_selectors pointer where proposals will be allocated
* @return number of allocated proposals
*/
- size_t (*get_proposals) (sa_config_t *this, u_int8_t ah_spi[4], u_int8_t esp_spi[4], child_proposal_t **proposals);
+ size_t (*get_proposals) (sa_config_t *this, u_int8_t ah_spi[4], u_int8_t esp_spi[4], child_proposal_t *proposals[]);
/**
* @brief Select a proposal from a supplied list
diff --git a/Source/charon/config/traffic_selector.c b/Source/charon/config/traffic_selector.c
index 3a95c65c6..e0744899b 100644
--- a/Source/charon/config/traffic_selector.c
+++ b/Source/charon/config/traffic_selector.c
@@ -25,6 +25,7 @@
#include <utils/linked_list.h>
#include <utils/allocator.h>
#include <utils/identification.h>
+#include <arpa/inet.h>
typedef struct private_traffic_selector_t private_traffic_selector_t;
@@ -198,6 +199,22 @@ static u_int16_t get_to_port(private_traffic_selector_t *this)
}
/**
+ * Implements traffic_selector_t.get_type.
+ */
+static ts_type_t get_type(private_traffic_selector_t *this)
+{
+ return this->type;
+}
+
+/**
+ * Implements traffic_selector_t.get_protocol.
+ */
+static u_int8_t get_protocol(private_traffic_selector_t *this)
+{
+ return this->protocol;
+}
+
+/**
* Implements traffic_selector_t.clone.
*/
static traffic_selector_t *clone(private_traffic_selector_t *this)
@@ -316,6 +333,8 @@ static private_traffic_selector_t *traffic_selector_create(u_int8_t protocol, ts
this->public.get_to_address = (chunk_t(*)(traffic_selector_t*))get_to_address;
this->public.get_from_port = (u_int16_t(*)(traffic_selector_t*))get_from_port;
this->public.get_to_port = (u_int16_t(*)(traffic_selector_t*))get_to_port;
+ this->public.get_type = (ts_type_t(*)(traffic_selector_t*))get_type;
+ this->public.get_protocol = (u_int8_t(*)(traffic_selector_t*))get_protocol;
this->public.clone = (traffic_selector_t*(*)(traffic_selector_t*))clone;
this->public.destroy = (void(*)(traffic_selector_t*))destroy;
diff --git a/Source/charon/config/traffic_selector.h b/Source/charon/config/traffic_selector.h
index f26406481..5cda79f2a 100644
--- a/Source/charon/config/traffic_selector.h
+++ b/Source/charon/config/traffic_selector.h
@@ -24,7 +24,37 @@
#define _TRAFFIC_SELECTOR_H_
#include <types.h>
-#include <encoding/payloads/traffic_selector_substructure.h>
+
+typedef enum ts_type_t ts_type_t;
+
+/**
+ * Traffic selector Types.
+ *
+ * @ingroup config
+ */
+enum ts_type_t {
+ /*
+ * A range of IPv4 addresses, represented by two four (4) octet
+ * values. The first value is the beginning IPv4 address
+ * (inclusive) and the second value is the ending IPv4 address
+ * (inclusive). All addresses falling between the two specified
+ * addresses are considered to be within the list.
+ */
+ TS_IPV4_ADDR_RANGE = 7,
+ /*
+ * A range of IPv6 addresses, represented by two sixteen (16)
+ * octet values. The first value is the beginning IPv6 address
+ * (inclusive) and the second value is the ending IPv6 address
+ * (inclusive). All addresses falling between the two specified
+ * addresses are considered to be within the list.
+ */
+ TS_IPV6_ADDR_RANGE = 8
+};
+
+/**
+ * string mappings for ts_type_t
+ */
+extern mapping_t ts_type_m[];
typedef struct traffic_selector_t traffic_selector_t;
@@ -110,6 +140,22 @@ struct traffic_selector_t {
u_int16_t (*get_to_port) (traffic_selector_t *this);
/**
+ * @brief Get the type of the traffic selector.
+ *
+ * @param this calling obect
+ * @return ts_type_t specifying the type
+ */
+ ts_type_t (*get_type) (traffic_selector_t *this);
+
+ /**
+ * @brief Get the protocol id of this ts.
+ *
+ * @param this calling obect
+ * @return protocol id
+ */
+ u_int8_t (*get_protocol) (traffic_selector_t *this);
+
+ /**
* @brief Destroys the ts object
*
*