176 lines
4.9 KiB
C
176 lines
4.9 KiB
C
/**
|
|
* @file traffic_selector_substructure.h
|
|
*
|
|
* @brief Interface of traffic_selector_substructure_t.
|
|
*
|
|
*/
|
|
|
|
/*
|
|
* Copyright (C) 2005 Jan Hutter, Martin Willi
|
|
* Hochschule fuer Technik Rapperswil
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License as published by the
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
* for more details.
|
|
*/
|
|
|
|
|
|
#ifndef TRAFFIC_SELECTOR_SUBSTRUCTURE_H_
|
|
#define TRAFFIC_SELECTOR_SUBSTRUCTURE_H_
|
|
|
|
#include <types.h>
|
|
#include <encoding/payloads/payload.h>
|
|
#include <network/host.h>
|
|
|
|
/**
|
|
* Length of a TRAFFIC SELECTOR SUBSTRUCTURE without start and end address.
|
|
*
|
|
* @ingroup payloads
|
|
*/
|
|
#define TRAFFIC_SELECTOR_HEADER_LENGTH 8
|
|
|
|
|
|
typedef enum ts_type_t ts_type_t;
|
|
|
|
/**
|
|
* Traffic selector Types.
|
|
*
|
|
* @ingroup payloads
|
|
*/
|
|
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
|
|
};
|
|
|
|
extern mapping_t ts_type_m[];
|
|
|
|
typedef struct traffic_selector_substructure_t traffic_selector_substructure_t;
|
|
|
|
/**
|
|
* Object representing an IKEv2 TRAFFIC SELECTOR.
|
|
*
|
|
* The TRAFFIC SELECTOR format is described in draft section 3.13.1.
|
|
*
|
|
* @ingroup payloads
|
|
*
|
|
*/
|
|
struct traffic_selector_substructure_t {
|
|
/**
|
|
* The payload_t interface.
|
|
*/
|
|
payload_t payload_interface;
|
|
|
|
/**
|
|
* @brief Get the type of Traffic selector.
|
|
*
|
|
* @param this calling traffic_selector_substructure_t object
|
|
* @return type of traffic selector
|
|
*
|
|
*/
|
|
ts_type_t (*get_ts_type) (traffic_selector_substructure_t *this);
|
|
|
|
/**
|
|
* @brief Set the type of Traffic selector.
|
|
*
|
|
* @param this calling traffic_selector_substructure_t object
|
|
* @param ts_type type of traffic selector
|
|
*/
|
|
void (*set_ts_type) (traffic_selector_substructure_t *this,ts_type_t ts_type);
|
|
|
|
/**
|
|
* @brief Get the IP protocol ID of Traffic selector.
|
|
*
|
|
* @param this calling traffic_selector_substructure_t object
|
|
* @return type of traffic selector
|
|
*
|
|
*/
|
|
u_int8_t (*get_protocol_id) (traffic_selector_substructure_t *this);
|
|
|
|
/**
|
|
* @brief Set the IP protocol ID of Traffic selector
|
|
*
|
|
* @param this calling traffic_selector_substructure_t object
|
|
* @param protocol_id protocol ID of traffic selector
|
|
*/
|
|
void (*set_protocol_id) (traffic_selector_substructure_t *this,u_int8_t protocol_id);
|
|
|
|
/**
|
|
* @brief Get the start port and address as host_t object.
|
|
*
|
|
* Returned host_t object has to get destroyed by the caller.
|
|
*
|
|
* @param this calling traffic_selector_substructure_t object
|
|
* @return start host as host_t object
|
|
*
|
|
*/
|
|
host_t *(*get_start_host) (traffic_selector_substructure_t *this);
|
|
|
|
/**
|
|
* @brief Set the start port and address as host_t object.
|
|
*
|
|
* @param this calling traffic_selector_substructure_t object
|
|
* @param start_host start host as host_t object
|
|
*/
|
|
void (*set_start_host) (traffic_selector_substructure_t *this,host_t *start_host);
|
|
|
|
/**
|
|
* @brief Get the end port and address as host_t object.
|
|
*
|
|
* Returned host_t object has to get destroyed by the caller.
|
|
*
|
|
* @param this calling traffic_selector_substructure_t object
|
|
* @return end host as host_t object
|
|
*
|
|
*/
|
|
host_t *(*get_end_host) (traffic_selector_substructure_t *this);
|
|
|
|
/**
|
|
* @brief Set the end port and address as host_t object.
|
|
*
|
|
* @param this calling traffic_selector_substructure_t object
|
|
* @param end_host end host as host_t object
|
|
*/
|
|
void (*set_end_host) (traffic_selector_substructure_t *this,host_t *end_host);
|
|
|
|
/**
|
|
* @brief Destroys an traffic_selector_substructure_t object.
|
|
*
|
|
* @param this traffic_selector_substructure_t object to destroy
|
|
*/
|
|
void (*destroy) (traffic_selector_substructure_t *this);
|
|
};
|
|
|
|
/**
|
|
* @brief Creates an empty traffic_selector_substructure_t object.
|
|
*
|
|
* TS type is set to default TS_IPV4_ADDR_RANGE!
|
|
*
|
|
* @return created traffic_selector_substructure_t object
|
|
*
|
|
* @ingroup payloads
|
|
*/
|
|
traffic_selector_substructure_t *traffic_selector_substructure_create();
|
|
|
|
|
|
#endif //TRAFFIC_SELECTOR_SUBSTRUCTURE_H_
|