if (this->tsi)
{
message->add_payload(message, (payload_t*)
- ts_payload_create_from_traffic_selectors(TRUE, this->tsi));
+ ts_payload_create_from_traffic_selectors(TRUE, this->tsi, NULL));
}
if (this->tsr)
{
message->add_payload(message, (payload_t*)
- ts_payload_create_from_traffic_selectors(FALSE, this->tsr));
+ ts_payload_create_from_traffic_selectors(FALSE, this->tsr, NULL));
}
}
this->is_initiator = is_initiator;
}
-METHOD(ts_payload_t, get_traffic_selectors, linked_list_t*,
- private_ts_payload_t *this)
+/**
+ * Get a list of either traffic selectors or labels
+ */
+static linked_list_t *get_list(private_ts_payload_t *this, bool labels)
{
- traffic_selector_t *ts;
enumerator_t *enumerator;
traffic_selector_substructure_t *subst;
linked_list_t *list;
enumerator = this->substrs->create_enumerator(this->substrs);
while (enumerator->enumerate(enumerator, &subst))
{
- ts = subst->get_traffic_selector(subst);
- list->insert_last(list, ts);
+ if (labels)
+ {
+ sec_label_t *label = subst->get_sec_label(subst);
+
+ if (label)
+ {
+ list->insert_last(list, label);
+ }
+ }
+ else
+ {
+ traffic_selector_t *ts = subst->get_traffic_selector(subst);
+
+ if (ts)
+ {
+ list->insert_last(list, ts);
+ }
+ }
}
enumerator->destroy(enumerator);
return list;
}
+METHOD(ts_payload_t, get_traffic_selectors, linked_list_t*,
+ private_ts_payload_t *this)
+{
+ return get_list(this, FALSE);
+}
+
+METHOD(ts_payload_t, get_sec_labels, linked_list_t*,
+ private_ts_payload_t *this)
+{
+ return get_list(this, TRUE);
+}
+
METHOD2(payload_t, ts_payload_t, destroy, void,
private_ts_payload_t *this)
{
.get_initiator = _get_initiator,
.set_initiator = _set_initiator,
.get_traffic_selectors = _get_traffic_selectors,
+ .get_sec_labels = _get_sec_labels,
.destroy = _destroy,
},
.next_payload = PL_NONE,
* Described in header
*/
ts_payload_t *ts_payload_create_from_traffic_selectors(bool is_initiator,
- linked_list_t *traffic_selectors)
+ linked_list_t *traffic_selectors,
+ sec_label_t *label)
{
enumerator_t *enumerator;
traffic_selector_t *ts;
this->substrs->insert_last(this->substrs, subst);
}
enumerator->destroy(enumerator);
+
+ if (label)
+ {
+ subst = traffic_selector_substructure_create_from_sec_label(label);
+ this->substrs->insert_last(this->substrs, subst);
+ }
compute_length(this);
return &this->public;
/**
* Get a list of nested traffic selectors as traffic_selector_t.
*
- * Resulting list and its traffic selectors must be destroyed after usage
+ * Resulting list and its traffic selectors must be destroyed after use.
*
* @return list of traffic selectors
*/
- linked_list_t *(*get_traffic_selectors) (ts_payload_t *this);
+ linked_list_t *(*get_traffic_selectors)(ts_payload_t *this);
+
+ /**
+ * Get a list of security labels as sec_label_t.
+ *
+ * Resulting list and its security labels must be destroyed after use.
+ *
+ * @return list of security labels
+ */
+ linked_list_t *(*get_sec_labels)(ts_payload_t *this);
/**
* Destroys an ts_payload_t object.
ts_payload_t *ts_payload_create(bool is_initiator);
/**
- * Creates ts_payload with a list of traffic_selector_t
+ * Creates ts_payload with a list of traffic_selector_t and an optional security
+ * label.
*
* @param is_initiator TRUE for TSi, FALSE for TSr payload type
* @param traffic_selectors list of traffic selectors to include
+ * @param label optional security label to include
* @return ts_payload_t object
*/
ts_payload_t *ts_payload_create_from_traffic_selectors(bool is_initiator,
- linked_list_t *traffic_selectors);
+ linked_list_t *traffic_selectors,
+ sec_label_t *label);
#endif /** TS_PAYLOAD_H_ @}*/
}
/* add TSi/TSr payloads */
- ts_payload = ts_payload_create_from_traffic_selectors(TRUE, this->tsi);
+ ts_payload = ts_payload_create_from_traffic_selectors(TRUE, this->tsi, NULL);
message->add_payload(message, (payload_t*)ts_payload);
- ts_payload = ts_payload_create_from_traffic_selectors(FALSE, this->tsr);
+ ts_payload = ts_payload_create_from_traffic_selectors(FALSE, this->tsr, NULL);
message->add_payload(message, (payload_t*)ts_payload);
/* add a notify if we are not in tunnel mode */