aboutsummaryrefslogtreecommitdiffstats
path: root/Source/charon
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2006-04-10 08:07:38 +0000
committerMartin Willi <martin@strongswan.org>2006-04-10 08:07:38 +0000
commit5113680f95e522c677cdd37072cfffbdca06831e (patch)
tree973ac57accbc66b042e5307942c6cbbbf4f19579 /Source/charon
parent6862128151fb78f63685a8da5575783c426d64a7 (diff)
downloadstrongswan-5113680f95e522c677cdd37072cfffbdca06831e.tar.bz2
strongswan-5113680f95e522c677cdd37072cfffbdca06831e.tar.xz
- split up in libstrong, charon, stroke, testing done
- new leak detective with malloc hook in library - useable, but needs improvements - logger_manager has now a single instance per library - allows use of loggers from any linking prog - a LOT of other things
Diffstat (limited to 'Source/charon')
-rwxr-xr-xSource/charon/config/configuration.c5
-rw-r--r--Source/charon/config/connection.c5
-rw-r--r--Source/charon/config/policy.c5
-rw-r--r--Source/charon/config/proposal.c21
-rw-r--r--Source/charon/config/traffic_selector.c28
-rw-r--r--Source/charon/daemon.c70
-rw-r--r--Source/charon/daemon.h18
-rw-r--r--Source/charon/encoding/generator.c15
-rw-r--r--Source/charon/encoding/message.c9
-rw-r--r--Source/charon/encoding/parser.c10
-rw-r--r--Source/charon/encoding/payloads/auth_payload.c13
-rw-r--r--Source/charon/encoding/payloads/cert_payload.c16
-rw-r--r--Source/charon/encoding/payloads/certreq_payload.c16
-rw-r--r--Source/charon/encoding/payloads/configuration_attribute.c14
-rw-r--r--Source/charon/encoding/payloads/cp_payload.c8
-rw-r--r--Source/charon/encoding/payloads/delete_payload.c16
-rw-r--r--Source/charon/encoding/payloads/eap_payload.c16
-rw-r--r--Source/charon/encoding/payloads/encryption_payload.c45
-rw-r--r--Source/charon/encoding/payloads/id_payload.c15
-rw-r--r--Source/charon/encoding/payloads/ike_header.c5
-rw-r--r--Source/charon/encoding/payloads/ke_payload.c14
-rw-r--r--Source/charon/encoding/payloads/nonce_payload.c11
-rw-r--r--Source/charon/encoding/payloads/notify_payload.c22
-rw-r--r--Source/charon/encoding/payloads/proposal_substructure.c18
-rw-r--r--Source/charon/encoding/payloads/sa_payload.c8
-rw-r--r--Source/charon/encoding/payloads/traffic_selector_substructure.c13
-rw-r--r--Source/charon/encoding/payloads/transform_attribute.c19
-rw-r--r--Source/charon/encoding/payloads/transform_substructure.c8
-rw-r--r--Source/charon/encoding/payloads/ts_payload.c7
-rw-r--r--Source/charon/encoding/payloads/unknown_payload.c9
-rw-r--r--Source/charon/encoding/payloads/vendor_id_payload.c16
-rw-r--r--Source/charon/network/packet.c12
-rw-r--r--Source/charon/network/socket.c13
-rw-r--r--Source/charon/queues/event_queue.c9
-rw-r--r--Source/charon/queues/job_queue.c5
-rw-r--r--Source/charon/queues/jobs/delete_established_ike_sa_job.c5
-rw-r--r--Source/charon/queues/jobs/delete_half_open_ike_sa_job.c5
-rw-r--r--Source/charon/queues/jobs/incoming_packet_job.c7
-rw-r--r--Source/charon/queues/jobs/initiate_ike_sa_job.c7
-rw-r--r--Source/charon/queues/jobs/retransmit_request_job.c5
-rw-r--r--Source/charon/queues/send_queue.c5
-rw-r--r--Source/charon/sa/authenticator.c29
-rw-r--r--Source/charon/sa/child_sa.c21
-rw-r--r--Source/charon/sa/ike_sa.c34
-rw-r--r--Source/charon/sa/ike_sa_id.c5
-rw-r--r--Source/charon/sa/ike_sa_manager.c11
-rw-r--r--Source/charon/sa/states/ike_auth_requested.c29
-rw-r--r--Source/charon/sa/states/ike_sa_established.c7
-rw-r--r--Source/charon/sa/states/ike_sa_init_requested.c19
-rw-r--r--Source/charon/sa/states/ike_sa_init_responded.c33
-rw-r--r--Source/charon/sa/states/initiator_init.c13
-rw-r--r--Source/charon/sa/states/responder_init.c17
-rw-r--r--Source/charon/threads/kernel_interface.c23
-rw-r--r--Source/charon/threads/receiver.c9
-rw-r--r--Source/charon/threads/scheduler.c9
-rw-r--r--Source/charon/threads/sender.c9
-rwxr-xr-xSource/charon/threads/stroke_interface.c51
-rw-r--r--Source/charon/threads/thread_pool.c40
58 files changed, 457 insertions, 470 deletions
diff --git a/Source/charon/config/configuration.c b/Source/charon/config/configuration.c
index 692fdd0f9..eac1bd43a 100755
--- a/Source/charon/config/configuration.c
+++ b/Source/charon/config/configuration.c
@@ -25,7 +25,6 @@
#include "configuration.h"
#include <types.h>
-#include <utils/allocator.h>
/**
* First retransmit timeout in milliseconds.
@@ -94,7 +93,7 @@ static u_int32_t get_half_open_ike_sa_timeout (private_configuration_t *this)
*/
static void destroy(private_configuration_t *this)
{
- allocator_free(this);
+ free(this);
}
/*
@@ -102,7 +101,7 @@ static void destroy(private_configuration_t *this)
*/
configuration_t *configuration_create()
{
- private_configuration_t *this = allocator_alloc_thing(private_configuration_t);
+ private_configuration_t *this = malloc_thing(private_configuration_t);
/* public functions */
this->public.destroy = (void(*)(configuration_t*))destroy;
diff --git a/Source/charon/config/connection.c b/Source/charon/config/connection.c
index 24f16a044..d2e50c780 100644
--- a/Source/charon/config/connection.c
+++ b/Source/charon/config/connection.c
@@ -22,7 +22,6 @@
#include "connection.h"
-#include <utils/allocator.h>
#include <utils/linked_list.h>
#include <utils/logger.h>
@@ -290,7 +289,7 @@ static void destroy (private_connection_t *this)
this->other_host->destroy(this->other_host);
this->my_id->destroy(this->my_id);
this->other_id->destroy(this->other_id);
- allocator_free(this);
+ free(this);
}
/**
@@ -298,7 +297,7 @@ static void destroy (private_connection_t *this)
*/
connection_t * connection_create(host_t *my_host, host_t *other_host, identification_t *my_id, identification_t *other_id, auth_method_t auth_method)
{
- private_connection_t *this = allocator_alloc_thing(private_connection_t);
+ private_connection_t *this = malloc_thing(private_connection_t);
/* public functions */
this->public.get_my_id = (identification_t*(*)(connection_t*))get_my_id;
diff --git a/Source/charon/config/policy.c b/Source/charon/config/policy.c
index fbdc46def..cff87fc6b 100644
--- a/Source/charon/config/policy.c
+++ b/Source/charon/config/policy.c
@@ -23,7 +23,6 @@
#include "policy.h"
#include <utils/linked_list.h>
-#include <utils/allocator.h>
#include <utils/identification.h>
#include <utils/logger.h>
@@ -310,7 +309,7 @@ static status_t destroy(private_policy_t *this)
this->my_id->destroy(this->my_id);
this->other_id->destroy(this->other_id);
- allocator_free(this);
+ free(this);
return SUCCESS;
}
@@ -363,7 +362,7 @@ static policy_t *clone(private_policy_t *this)
*/
policy_t *policy_create(identification_t *my_id, identification_t *other_id)
{
- private_policy_t *this = allocator_alloc_thing(private_policy_t);
+ private_policy_t *this = malloc_thing(private_policy_t);
/* public functions */
this->public.get_my_id = (identification_t*(*)(policy_t*))get_my_id;
diff --git a/Source/charon/config/proposal.c b/Source/charon/config/proposal.c
index 760d58061..cb71a756a 100644
--- a/Source/charon/config/proposal.c
+++ b/Source/charon/config/proposal.c
@@ -20,10 +20,11 @@
* for more details.
*/
+#include <string.h>
+
#include "proposal.h"
#include <utils/linked_list.h>
-#include <utils/allocator.h>
#include <utils/identification.h>
#include <utils/logger.h>
@@ -152,7 +153,7 @@ static protocol_proposal_t *get_protocol_proposal(private_proposal_t *this, prot
if (!proto_proposal && create)
{
/* nope, create a new one */
- proto_proposal = allocator_alloc_thing(protocol_proposal_t);
+ proto_proposal = malloc_thing(protocol_proposal_t);
proto_proposal->protocol = proto;
proto_proposal->encryption_algos = linked_list_create();
proto_proposal->integrity_algos = linked_list_create();
@@ -167,7 +168,7 @@ static protocol_proposal_t *get_protocol_proposal(private_proposal_t *this, prot
{
proto_proposal->spi.len = 4;
}
- proto_proposal->spi.ptr = allocator_alloc(proto_proposal->spi.len);
+ proto_proposal->spi.ptr = malloc(proto_proposal->spi.len);
/* add to the list */
this->protocol_proposals->insert_last(this->protocol_proposals, (void*)proto_proposal);
}
@@ -179,7 +180,7 @@ static protocol_proposal_t *get_protocol_proposal(private_proposal_t *this, prot
*/
static void add_algo(linked_list_t *list, u_int8_t algo, size_t key_size)
{
- algorithm_t *algo_key = allocator_alloc_thing(algorithm_t);
+ algorithm_t *algo_key = malloc_thing(algorithm_t);
algo_key->algorithm = algo;
algo_key->key_size = key_size;
@@ -542,7 +543,7 @@ static void clone_algo_list(linked_list_t *list, linked_list_t *clone_list)
while (iterator->has_next(iterator))
{
iterator->current(iterator, (void**)&algo);
- clone_algo = allocator_alloc_thing(algorithm_t);
+ clone_algo = malloc_thing(algorithm_t);
memcpy(clone_algo, algo, sizeof(algorithm_t));
clone_list->insert_last(clone_list, (void*)clone_algo);
}
@@ -586,7 +587,7 @@ static void free_algo_list(linked_list_t *list)
while(list->get_count(list) > 0)
{
list->remove_last(list, (void**)&algo);
- allocator_free(algo);
+ free(algo);
}
list->destroy(list);
}
@@ -607,12 +608,12 @@ static void destroy(private_proposal_t *this)
free_algo_list(proto_prop->dh_groups);
free_algo_list(proto_prop->esns);
- allocator_free(proto_prop->spi.ptr);
- allocator_free(proto_prop);
+ free(proto_prop->spi.ptr);
+ free(proto_prop);
}
this->protocol_proposals->destroy(this->protocol_proposals);
- allocator_free(this);
+ free(this);
}
/*
@@ -620,7 +621,7 @@ static void destroy(private_proposal_t *this)
*/
proposal_t *proposal_create(u_int8_t number)
{
- private_proposal_t *this = allocator_alloc_thing(private_proposal_t);
+ private_proposal_t *this = malloc_thing(private_proposal_t);
this->public.add_algorithm = (void (*)(proposal_t*,protocol_id_t,transform_type_t,u_int16_t,size_t))add_algorithm;
this->public.create_algorithm_iterator = (iterator_t* (*)(proposal_t*,protocol_id_t,transform_type_t))create_algorithm_iterator;
diff --git a/Source/charon/config/traffic_selector.c b/Source/charon/config/traffic_selector.c
index 0b8193135..81272659a 100644
--- a/Source/charon/config/traffic_selector.c
+++ b/Source/charon/config/traffic_selector.c
@@ -23,9 +23,9 @@
#include "traffic_selector.h"
#include <utils/linked_list.h>
-#include <utils/allocator.h>
#include <utils/identification.h>
#include <arpa/inet.h>
+#include <string.h>
typedef struct private_traffic_selector_t private_traffic_selector_t;
@@ -133,7 +133,7 @@ static chunk_t get_from_address(private_traffic_selector_t *this)
{
u_int32_t network;
from_addr.len = sizeof(network);
- from_addr.ptr = allocator_alloc(from_addr.len);
+ from_addr.ptr = malloc(from_addr.len);
/* chunk must contain network order, convert! */
network = htonl(this->from_addr_ipv4);
memcpy(from_addr.ptr, &network, from_addr.len);
@@ -160,7 +160,7 @@ static chunk_t get_to_address(private_traffic_selector_t *this)
{
u_int32_t network;
to_addr.len = sizeof(network);
- to_addr.ptr = allocator_alloc(to_addr.len);
+ to_addr.ptr = malloc(to_addr.len);
/* chunk must contain network order, convert! */
network = htonl(this->to_addr_ipv4);
memcpy(to_addr.ptr, &network, to_addr.len);
@@ -248,7 +248,7 @@ static void update_address_range(private_traffic_selector_t *this, host_t *host)
chunk_t from = host->get_address_as_chunk(host);
this->from_addr_ipv4 = ntohl(*((u_int32_t*)from.ptr));
this->to_addr_ipv4 = this->from_addr_ipv4;
- allocator_free_chunk(&from);
+ chunk_free(&from);
}
}
}
@@ -271,7 +271,7 @@ static traffic_selector_t *clone(private_traffic_selector_t *this)
case TS_IPV6_ADDR_RANGE:
default:
{
- allocator_free(this);
+ free(this);
return NULL;
}
}
@@ -282,7 +282,7 @@ static traffic_selector_t *clone(private_traffic_selector_t *this)
*/
static void destroy(private_traffic_selector_t *this)
{
- allocator_free(this);
+ free(this);
}
/*
@@ -299,7 +299,7 @@ traffic_selector_t *traffic_selector_create_from_bytes(u_int8_t protocol, ts_typ
{
if (from_addr.len != 4 || to_addr.len != 4)
{
- allocator_free(this);
+ free(this);
return NULL;
}
/* chunk contains network order, convert! */
@@ -310,7 +310,7 @@ traffic_selector_t *traffic_selector_create_from_bytes(u_int8_t protocol, ts_typ
case TS_IPV6_ADDR_RANGE:
default:
{
- allocator_free(this);
+ free(this);
return NULL;
}
}
@@ -342,13 +342,13 @@ traffic_selector_t *traffic_selector_create_from_subnet(host_t *net, u_int8_t ne
{
this->to_addr_ipv4 = this->from_addr_ipv4 | ((1 << (32 - netbits)) - 1);
}
- allocator_free_chunk(&from);
+ chunk_free(&from);
break;
}
case AF_INET6:
default:
{
- allocator_free(this);
+ free(this);
return NULL;
}
}
@@ -373,12 +373,12 @@ traffic_selector_t *traffic_selector_create_from_string(u_int8_t protocol, ts_ty
{
if (inet_aton(from_addr, (struct in_addr*)&(this->from_addr_ipv4)) == 0)
{
- allocator_free(this);
+ free(this);
return NULL;
}
if (inet_aton(to_addr, (struct in_addr*)&(this->to_addr_ipv4)) == 0)
{
- allocator_free(this);
+ free(this);
return NULL;
}
/* convert to host order, inet_aton has network order */
@@ -388,7 +388,7 @@ traffic_selector_t *traffic_selector_create_from_string(u_int8_t protocol, ts_ty
}
case TS_IPV6_ADDR_RANGE:
{
- allocator_free(this);
+ free(this);
return NULL;
}
}
@@ -401,7 +401,7 @@ traffic_selector_t *traffic_selector_create_from_string(u_int8_t protocol, ts_ty
*/
static private_traffic_selector_t *traffic_selector_create(u_int8_t protocol, ts_type_t type, u_int16_t from_port, u_int16_t to_port)
{
- private_traffic_selector_t *this = allocator_alloc_thing(private_traffic_selector_t);
+ private_traffic_selector_t *this = malloc_thing(private_traffic_selector_t);
/* public functions */
this->public.get_subset = (traffic_selector_t*(*)(traffic_selector_t*,traffic_selector_t*))get_subset;
diff --git a/Source/charon/daemon.c b/Source/charon/daemon.c
index dcf74587c..6361f308d 100644
--- a/Source/charon/daemon.c
+++ b/Source/charon/daemon.c
@@ -26,11 +26,11 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
+#include <execinfo.h>
#include "daemon.h"
#include <types.h>
-#include <utils/allocator.h>
typedef struct private_daemon_t private_daemon_t;
@@ -90,7 +90,14 @@ daemon_t *charon;
* Implementation of private_daemon_t.run.
*/
static void run(private_daemon_t *this)
-{
+{
+ /* reselect signals for this thread */
+ sigemptyset(&(this->signal_set));
+ sigaddset(&(this->signal_set), SIGINT);
+ sigaddset(&(this->signal_set), SIGHUP);
+ sigaddset(&(this->signal_set), SIGTERM);
+ pthread_sigmask(SIG_BLOCK, &(this->signal_set), 0);
+
while(TRUE)
{
int signal_number;
@@ -237,12 +244,32 @@ static void destroy(private_daemon_t *this)
{
this->public.stroke->destroy(this->public.stroke);
}
-
- this->public.logger_manager->destroy(this->public.logger_manager);
- allocator_free(this);
+ free(this);
}
+void signal_handler(int signal)
+{
+ void *array[20];
+ size_t size;
+ char **strings;
+ size_t i;
+ logger_t *logger;
+
+ size = backtrace(array, 20);
+ strings = backtrace_symbols(array, size);
+ logger = logger_manager->get_logger(logger_manager, DAEMON);
+
+ logger->log(logger, ERROR, "Thread %u received SIGSEGV. Dumping %d frames from stack:", pthread_self(), size);
+ for (i = 0; i < size; i++)
+ {
+ logger->log(logger, ERROR, "\t%s", strings[i]);
+ }
+
+ free (strings);
+
+ charon->kill(charon, "SIGSEGV received");
+}
/**
* @brief Create the daemon.
@@ -251,7 +278,8 @@ static void destroy(private_daemon_t *this)
*/
private_daemon_t *daemon_create()
{
- private_daemon_t *this = allocator_alloc_thing(private_daemon_t);
+ private_daemon_t *this = malloc_thing(private_daemon_t);
+ struct sigaction action;
/* assign methods */
this->run = run;
@@ -259,10 +287,6 @@ private_daemon_t *daemon_create()
this->initialize = initialize;
this->public.kill = (void (*) (daemon_t*,char*))kill_daemon;
- /* first build a logger */
- this->public.logger_manager = logger_manager_create(DEFAULT_LOGLEVEL);
- this->logger = (this->public.logger_manager)->get_logger(this->public.logger_manager, DAEMON);
-
/* NULL members for clean destruction */
this->public.socket = NULL;
this->public.ike_sa_manager = NULL;
@@ -282,13 +306,22 @@ private_daemon_t *daemon_create()
this->main_thread_id = pthread_self();
- /* setup signal handling */
+ /* setup signal handling for all threads */
sigemptyset(&(this->signal_set));
+ sigaddset(&(this->signal_set), SIGSEGV);
sigaddset(&(this->signal_set), SIGINT);
sigaddset(&(this->signal_set), SIGHUP);
sigaddset(&(this->signal_set), SIGTERM);
pthread_sigmask(SIG_BLOCK, &(this->signal_set), 0);
+ /* setup SIGSEGV handler for all threads */
+ action.sa_handler = signal_handler;
+ action.sa_mask = this->signal_set;
+ action.sa_flags = 0;
+ if (sigaction(SIGSEGV, &action, NULL) == -1)
+ {
+ this->logger->log(this->logger, ERROR, "signal handler setup for SIGSEGV failed");
+ }
return this;
}
@@ -296,15 +329,15 @@ private_daemon_t *daemon_create()
* Main function, manages the daemon.
*/
int main(int argc, char *argv[])
-{
+{
private_daemon_t *private_charon;
FILE *pid_file;
struct stat stb;
- /* allocation needs initialization, before any allocs are done */
- allocator_init();
private_charon = daemon_create();
charon = (daemon_t*)private_charon;
+
+ private_charon->logger = logger_manager->get_logger(logger_manager, DAEMON);
/* check/setup PID file */
if (stat(PID_FILE, &stb) == 0)
@@ -321,18 +354,15 @@ int main(int argc, char *argv[])
fclose(pid_file);
}
- /* initialize and run daemon*/
+ /* initialize and run daemon */
private_charon->initialize(private_charon);
private_charon->run(private_charon);
/* normal termination, cleanup and exit */
private_charon->destroy(private_charon);
unlink(PID_FILE);
-
-#ifdef LEAK_DETECTIVE
- report_memory_leaks(void);
-#endif
- exit(0);
+ return 0;
}
+
diff --git a/Source/charon/daemon.h b/Source/charon/daemon.h
index 9f4d73887..da71fd1d0 100644
--- a/Source/charon/daemon.h
+++ b/Source/charon/daemon.h
@@ -118,19 +118,6 @@
*/
#define PID_FILE "/var/run/charon.pid"
-/**
- * Output of log, use NULL for syslog
- */
-#define LOG_OUTPUT NULL
-
-/**
- * @brief Default loglevel for every logger context.
- *
- * This is the maximum allowed level for ever context, the definiton
- * of the context may be less verbose.
- */
-#define DEFAULT_LOGLEVEL CONTROL | ERROR | AUDIT
-
typedef struct daemon_t daemon_t;
@@ -157,11 +144,6 @@ struct daemon_t {
* A event_queue_t instance.
*/
event_queue_t *event_queue;
-
- /**
- * A logger_manager_t instance.
- */
- logger_manager_t *logger_manager;
/**
* A ike_sa_manager_t instance.
diff --git a/Source/charon/encoding/generator.c b/Source/charon/encoding/generator.c
index 0d7394a10..ba12190dd 100644
--- a/Source/charon/encoding/generator.c
+++ b/Source/charon/encoding/generator.c
@@ -30,7 +30,6 @@
#include <types.h>
#include <daemon.h>
-#include <utils/allocator.h>
#include <utils/linked_list.h>
#include <utils/logger_manager.h>
#include <encoding/payloads/payload.h>
@@ -562,7 +561,7 @@ static void make_space_available (private_generator_t *this, size_t bits)
old_buffer_size, new_buffer_size);
/* Reallocate space for new buffer */
- this->buffer = allocator_realloc(this->buffer,new_buffer_size);
+ this->buffer = realloc(this->buffer,new_buffer_size);
this->out_position = (this->buffer + out_position_offset);
this->roof_position = (this->buffer + new_buffer_size);
@@ -629,7 +628,7 @@ static void write_to_chunk (private_generator_t *this,chunk_t *data)
if (this->current_bit > 0)
data_length++;
- data->ptr = allocator_alloc(data_length);
+ data->ptr = malloc(data_length);
memcpy(data->ptr,this->buffer,data_length);
data->len = data_length;
@@ -1028,8 +1027,8 @@ static void generate_payload (private_generator_t *this,payload_t *payload)
*/
static status_t destroy(private_generator_t *this)
{
- allocator_free(this->buffer);
- allocator_free(this);
+ free(this->buffer);
+ free(this);
return SUCCESS;
}
@@ -1040,7 +1039,7 @@ generator_t *generator_create()
{
private_generator_t *this;
- this = allocator_alloc_thing(private_generator_t);
+ this = malloc_thing(private_generator_t);
/* initiate public functions */
this->public.generate_payload = (void(*)(generator_t*, payload_t *)) generate_payload;
@@ -1063,7 +1062,7 @@ generator_t *generator_create()
/* allocate memory for buffer */
- this->buffer = allocator_alloc(GENERATOR_DATA_BUFFER_SIZE);
+ this->buffer = malloc(GENERATOR_DATA_BUFFER_SIZE);
/* initiate private variables */
this->out_position = this->buffer;
@@ -1072,7 +1071,7 @@ generator_t *generator_create()
this->current_bit = 0;
this->last_payload_length_position_offset = 0;
this->header_length_position_offset = 0;
- this->logger = charon->logger_manager->get_logger(charon->logger_manager, GENERATOR);
+ this->logger = logger_manager->get_logger(logger_manager, GENERATOR);
return &(this->public);
}
diff --git a/Source/charon/encoding/message.c b/Source/charon/encoding/message.c
index 360e44a71..a57315272 100644
--- a/Source/charon/encoding/message.c
+++ b/Source/charon/encoding/message.c
@@ -30,7 +30,6 @@
#include <encoding/generator.h>
#include <encoding/parser.h>
#include <utils/linked_list.h>
-#include <utils/allocator.h>
#include <utils/logger_manager.h>
#include <encoding/payloads/encodings.h>
#include <encoding/payloads/payload.h>
@@ -670,7 +669,7 @@ static packet_t *get_packet (private_message_t *this)
*/
static chunk_t get_packet_data (private_message_t *this)
{
- return allocator_clone_chunk(this->packet->get_data(this->packet));
+ return chunk_clone(this->packet->get_data(this->packet));
}
/**
@@ -1154,7 +1153,7 @@ static void destroy (private_message_t *this)
this->payloads->destroy(this->payloads);
this->parser->destroy(this->parser);
- allocator_free(this);
+ free(this);
}
/*
@@ -1162,7 +1161,7 @@ static void destroy (private_message_t *this)
*/
message_t *message_create_from_packet(packet_t *packet)
{
- private_message_t *this = allocator_alloc_thing(private_message_t);
+ private_message_t *this = malloc_thing(private_message_t);
/* public functions */
this->public.set_major_version = (void(*)(message_t*, u_int8_t))set_major_version;
@@ -1217,7 +1216,7 @@ message_t *message_create_from_packet(packet_t *packet)
/* parser is created from data of packet */
this->parser = parser_create(this->packet->get_data(this->packet));
- this->logger = charon->logger_manager->get_logger(charon->logger_manager, MESSAGE);
+ this->logger = logger_manager->get_logger(logger_manager, MESSAGE);
return (&this->public);
}
diff --git a/Source/charon/encoding/parser.c b/Source/charon/encoding/parser.c
index 769a815df..a589e9bde 100644
--- a/Source/charon/encoding/parser.c
+++ b/Source/charon/encoding/parser.c
@@ -22,13 +22,13 @@
#include <stdlib.h>
#include <arpa/inet.h>
+#include <string.h>
#include "parser.h"
#include <types.h>
#include <definitions.h>
#include <daemon.h>
-#include <utils/allocator.h>
#include <utils/logger.h>
#include <utils/linked_list.h>
#include <encoding/payloads/encodings.h>
@@ -566,7 +566,7 @@ static status_t parse_chunk(private_parser_t *this, int rule_number, chunk_t *ou
if (output_pos != NULL)
{
output_pos->len = length;
- output_pos->ptr = allocator_alloc(length);
+ output_pos->ptr = malloc(length);
memcpy(output_pos->ptr, this->byte_pos, length);
}
this->byte_pos += length;
@@ -1027,7 +1027,7 @@ static void reset_context (private_parser_t *this)
*/
static void destroy(private_parser_t *this)
{
- allocator_free(this);
+ free(this);
}
/*
@@ -1035,9 +1035,9 @@ static void destroy(private_parser_t *this)
*/
parser_t *parser_create(chunk_t data)
{
- private_parser_t *this = allocator_alloc_thing(private_parser_t);
+ private_parser_t *this = malloc_thing(private_parser_t);
- this->logger = charon->logger_manager->get_logger(charon->logger_manager, PARSER);
+ this->logger = logger_manager->get_logger(logger_manager, PARSER);
this->public.parse_payload = (status_t(*)(parser_t*,payload_type_t,payload_t**)) parse_payload;
this->public.reset_context = (void(*)(parser_t*)) reset_context;
diff --git a/Source/charon/encoding/payloads/auth_payload.c b/Source/charon/encoding/payloads/auth_payload.c
index 8adb6fd6d..cc7c4bfb1 100644
--- a/Source/charon/encoding/payloads/auth_payload.c
+++ b/Source/charon/encoding/payloads/auth_payload.c
@@ -23,7 +23,6 @@
#include "auth_payload.h"
#include <encoding/payloads/encodings.h>
-#include <utils/allocator.h>
typedef struct private_auth_payload_t private_auth_payload_t;
@@ -189,9 +188,9 @@ static void set_data (private_auth_payload_t *this, chunk_t data)
{
if (this->auth_data.ptr != NULL)
{
- allocator_free_chunk(&(this->auth_data));
+ chunk_free(&(this->auth_data));
}
- this->auth_data.ptr = allocator_clone_bytes(data.ptr,data.len);
+ this->auth_data.ptr = clalloc(data.ptr,data.len);
this->auth_data.len = data.len;
this->payload_length = AUTH_PAYLOAD_HEADER_LENGTH + this->auth_data.len;
}
@@ -214,7 +213,7 @@ static chunk_t get_data_clone (private_auth_payload_t *this)
{
return (this->auth_data);
}
- cloned_data.ptr = allocator_clone_bytes(this->auth_data.ptr,this->auth_data.len);
+ cloned_data.ptr = clalloc(this->auth_data.ptr,this->auth_data.len);
cloned_data.len = this->auth_data.len;
return cloned_data;
}
@@ -226,10 +225,10 @@ static void destroy(private_auth_payload_t *this)
{
if (this->auth_data.ptr != NULL)
{
- allocator_free_chunk(&(this->auth_data));
+ chunk_free(&(this->auth_data));
}
- allocator_free(this);
+ free(this);
}
/*
@@ -237,7 +236,7 @@ static void destroy(private_auth_payload_t *this)
*/
auth_payload_t *auth_payload_create()
{
- private_auth_payload_t *this = allocator_alloc_thing(private_auth_payload_t);
+ private_auth_payload_t *this = malloc_thing(private_auth_payload_t);
/* interface functions */
this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
diff --git a/Source/charon/encoding/payloads/cert_payload.c b/Source/charon/encoding/payloads/cert_payload.c
index a361f1345..146d42eda 100644
--- a/Source/charon/encoding/payloads/cert_payload.c
+++ b/Source/charon/encoding/payloads/cert_payload.c
@@ -20,9 +20,9 @@
* for more details.
*/
-#include "cert_payload.h"
+#include <stddef.h>
-#include <utils/allocator.h>
+#include "cert_payload.h"
/**
@@ -202,9 +202,9 @@ static void set_data (private_cert_payload_t *this, chunk_t data)
{
if (this->cert_data.ptr != NULL)
{
- allocator_free_chunk(&(this->cert_data));
+ chunk_free(&(this->cert_data));
}
- this->cert_data.ptr = allocator_clone_bytes(data.ptr,data.len);
+ this->cert_data.ptr = clalloc(data.ptr,data.len);
this->cert_data.len = data.len;
this->payload_length = CERT_PAYLOAD_HEADER_LENGTH + this->cert_data.len;
}
@@ -227,7 +227,7 @@ static chunk_t get_data_clone (private_cert_payload_t *this)
{
return (this->cert_data);
}
- cloned_data.ptr = allocator_clone_bytes(this->cert_data.ptr,this->cert_data.len);
+ cloned_data.ptr = clalloc(this->cert_data.ptr,this->cert_data.len);
cloned_data.len = this->cert_data.len;
return cloned_data;
}
@@ -239,10 +239,10 @@ static void destroy(private_cert_payload_t *this)
{
if (this->cert_data.ptr != NULL)
{
- allocator_free_chunk(&(this->cert_data));
+ chunk_free(&(this->cert_data));
}
- allocator_free(this);
+ free(this);
}
/*
@@ -250,7 +250,7 @@ static void destroy(private_cert_payload_t *this)
*/
cert_payload_t *cert_payload_create()
{
- private_cert_payload_t *this = allocator_alloc_thing(private_cert_payload_t);
+ private_cert_payload_t *this = malloc_thing(private_cert_payload_t);
/* interface functions */
this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
diff --git a/Source/charon/encoding/payloads/certreq_payload.c b/Source/charon/encoding/payloads/certreq_payload.c
index b7372a7a2..cdab82be4 100644
--- a/Source/charon/encoding/payloads/certreq_payload.c
+++ b/Source/charon/encoding/payloads/certreq_payload.c
@@ -20,9 +20,9 @@
* for more details.
*/
-#include "certreq_payload.h"
+#include <stddef.h>
-#include <utils/allocator.h>
+#include "certreq_payload.h"
typedef struct private_certreq_payload_t private_certreq_payload_t;
@@ -182,9 +182,9 @@ static void set_data (private_certreq_payload_t *this, chunk_t data)
{
if (this->certreq_data.ptr != NULL)
{
- allocator_free_chunk(&(this->certreq_data));
+ chunk_free(&(this->certreq_data));
}
- this->certreq_data.ptr = allocator_clone_bytes(data.ptr,data.len);
+ this->certreq_data.ptr = clalloc(data.ptr,data.len);
this->certreq_data.len = data.len;
this->payload_length = CERTREQ_PAYLOAD_HEADER_LENGTH + this->certreq_data.len;
}
@@ -207,7 +207,7 @@ static chunk_t get_data_clone (private_certreq_payload_t *this)
{
return (this->certreq_data);
}
- cloned_data.ptr = allocator_clone_bytes(this->certreq_data.ptr,this->certreq_data.len);
+ cloned_data.ptr = clalloc(this->certreq_data.ptr,this->certreq_data.len);
cloned_data.len = this->certreq_data.len;
return cloned_data;
}
@@ -219,10 +219,10 @@ static void destroy(private_certreq_payload_t *this)
{
if (this->certreq_data.ptr != NULL)
{
- allocator_free_chunk(&(this->certreq_data));
+ chunk_free(&(this->certreq_data));
}
- allocator_free(this);
+ free(this);
}
/*
@@ -230,7 +230,7 @@ static void destroy(private_certreq_payload_t *this)
*/
certreq_payload_t *certreq_payload_create()
{
- private_certreq_payload_t *this = allocator_alloc_thing(private_certreq_payload_t);
+ private_certreq_payload_t *this = malloc_thing(private_certreq_payload_t);
/* interface functions */
this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
diff --git a/Source/charon/encoding/payloads/configuration_attribute.c b/Source/charon/encoding/payloads/configuration_attribute.c
index 4f3294832..489d7f372 100644
--- a/Source/charon/encoding/payloads/configuration_attribute.c
+++ b/Source/charon/encoding/payloads/configuration_attribute.c
@@ -19,15 +19,13 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
-
-/* offsetof macro */
+
#include <stddef.h>
#include "configuration_attribute.h"
#include <encoding/payloads/encodings.h>
#include <types.h>
-#include <utils/allocator.h>
typedef struct private_configuration_attribute_t private_configuration_attribute_t;
@@ -196,10 +194,10 @@ static void set_value(private_configuration_attribute_t *this, chunk_t value)
if (this->attribute_value.ptr != NULL)
{
/* free existing value */
- allocator_free_chunk(&(this->attribute_value));
+ chunk_free(&(this->attribute_value));
}
- this->attribute_value.ptr = allocator_clone_bytes(value.ptr,value.len);
+ this->attribute_value.ptr = clalloc(value.ptr,value.len);
this->attribute_value.len = value.len;
this->attribute_length = this->attribute_value.len;
@@ -246,9 +244,9 @@ static void destroy(private_configuration_attribute_t *this)
{
if (this->attribute_value.ptr != NULL)
{
- allocator_free(this->attribute_value.ptr);
+ free(this->attribute_value.ptr);
}
- allocator_free(this);
+ free(this);
}
/*
@@ -256,7 +254,7 @@ static void destroy(private_configuration_attribute_t *this)
*/
configuration_attribute_t *configuration_attribute_create()
{
- private_configuration_attribute_t *this = allocator_alloc_thing(private_configuration_attribute_t);
+ private_configuration_attribute_t *this = malloc_thing(private_configuration_attribute_t);
/* payload interface */
this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
diff --git a/Source/charon/encoding/payloads/cp_payload.c b/Source/charon/encoding/payloads/cp_payload.c
index e9d8af77e..583488382 100644
--- a/Source/charon/encoding/payloads/cp_payload.c
+++ b/Source/charon/encoding/payloads/cp_payload.c
@@ -19,14 +19,12 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
-
-/* offsetof macro */
+
#include <stddef.h>
#include "cp_payload.h"
#include <encoding/payloads/encodings.h>
-#include <utils/allocator.h>
#include <utils/linked_list.h>
@@ -265,7 +263,7 @@ static status_t destroy(private_cp_payload_t *this)
}
this->attributes->destroy(this->attributes);
- allocator_free(this);
+ free(this);
return SUCCESS;
}
@@ -275,7 +273,7 @@ static status_t destroy(private_cp_payload_t *this)
*/
cp_payload_t *cp_payload_create()
{
- private_cp_payload_t *this = allocator_alloc_thing(private_cp_payload_t);
+ private_cp_payload_t *this = malloc_thing(private_cp_payload_t);
/* public interface */
this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
diff --git a/Source/charon/encoding/payloads/delete_payload.c b/Source/charon/encoding/payloads/delete_payload.c
index 59d877945..28e78800f 100644
--- a/Source/charon/encoding/payloads/delete_payload.c
+++ b/Source/charon/encoding/payloads/delete_payload.c
@@ -20,9 +20,9 @@
* for more details.
*/
-#include "delete_payload.h"
+#include <stddef.h>
-#include <utils/allocator.h>
+#include "delete_payload.h"
typedef struct private_delete_payload_t private_delete_payload_t;
@@ -238,9 +238,9 @@ static void set_spis (private_delete_payload_t *this, chunk_t spis)
{
if (this->spis.ptr != NULL)
{
- allocator_free_chunk(&(this->spis));
+ chunk_free(&(this->spis));
}
- this->spis.ptr = allocator_clone_bytes(spis.ptr,spis.len);
+ this->spis.ptr = clalloc(spis.ptr,spis.len);
this->spis.len = spis.len;
this->payload_length = DELETE_PAYLOAD_HEADER_LENGTH + this->spis.len;
}
@@ -263,7 +263,7 @@ static chunk_t get_spis_clone (private_delete_payload_t *this)
{
return (this->spis);
}
- cloned_spis.ptr = allocator_clone_bytes(this->spis.ptr,this->spis.len);
+ cloned_spis.ptr = clalloc(this->spis.ptr,this->spis.len);
cloned_spis.len = this->spis.len;
return cloned_spis;
}
@@ -275,10 +275,10 @@ static void destroy(private_delete_payload_t *this)
{
if (this->spis.ptr != NULL)
{
- allocator_free_chunk(&(this->spis));
+ chunk_free(&(this->spis));
}
- allocator_free(this);
+ free(this);
}
/*
@@ -286,7 +286,7 @@ static void destroy(private_delete_payload_t *this)
*/
delete_payload_t *delete_payload_create()
{
- private_delete_payload_t *this = allocator_alloc_thing(private_delete_payload_t);
+ private_delete_payload_t *this = malloc_thing(private_delete_payload_t);
/* interface functions */
this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
diff --git a/Source/charon/encoding/payloads/eap_payload.c b/Source/charon/encoding/payloads/eap_payload.c
index 2bd8d5ee0..2a0e17679 100644
--- a/Source/charon/encoding/payloads/eap_payload.c
+++ b/Source/charon/encoding/payloads/eap_payload.c
@@ -20,9 +20,9 @@
* for more details.
*/
-#include "eap_payload.h"
+#include <stddef.h>
-#include <utils/allocator.h>
+#include "eap_payload.h"
typedef struct private_eap_payload_t private_eap_payload_t;
@@ -152,9 +152,9 @@ static void set_message (private_eap_payload_t *this, chunk_t message)
{
if (this->message.ptr != NULL)
{
- allocator_free_chunk(&(this->message));
+ chunk_free(&(this->message));
}
- this->message.ptr = allocator_clone_bytes(message.ptr,message.len);
+ this->message.ptr = clalloc(message.ptr,message.len);
this->message.len = message.len;
this->payload_length = EAP_PAYLOAD_HEADER_LENGTH + this->message.len;
}
@@ -177,7 +177,7 @@ static chunk_t get_message_clone (private_eap_payload_t *this)
{
return (this->message);
}
- cloned_message.ptr = allocator_clone_bytes(this->message.ptr,this->message.len);
+ cloned_message.ptr = clalloc(this->message.ptr,this->message.len);
cloned_message.len = this->message.len;
return cloned_message;
}
@@ -189,10 +189,10 @@ static void destroy(private_eap_payload_t *this)
{
if (this->message.ptr != NULL)
{
- allocator_free_chunk(&(this->message));
+ chunk_free(&(this->message));
}
- allocator_free(this);
+ free(this);
}
/*
@@ -200,7 +200,7 @@ static void destroy(private_eap_payload_t *this)
*/
eap_payload_t *eap_payload_create()
{
- private_eap_payload_t *this = allocator_alloc_thing(private_eap_payload_t);
+ private_eap_payload_t *this = malloc_thing(private_eap_payload_t);
/* interface functions */
this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
diff --git a/Source/charon/encoding/payloads/encryption_payload.c b/Source/charon/encoding/payloads/encryption_payload.c
index 70bbe9701..e0ca74ff4 100644
--- a/Source/charon/encoding/payloads/encryption_payload.c
+++ b/Source/charon/encoding/payloads/encryption_payload.c
@@ -19,15 +19,14 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
-
-/* offsetof macro */
+
#include <stddef.h>
+#include <string.h>
#include "encryption_payload.h"
#include <daemon.h>
#include <encoding/payloads/encodings.h>
-#include <utils/allocator.h>
#include <utils/linked_list.h>
#include <utils/logger.h>
#include <encoding/generator.h>
@@ -303,7 +302,7 @@ static status_t encrypt(private_encryption_payload_t *this)
/* concatenate payload data, padding, padding len */
to_crypt.len = this->decrypted.len + padding.len + 1;
- to_crypt.ptr = allocator_alloc(to_crypt.len);
+ to_crypt.ptr = malloc(to_crypt.len);
memcpy(to_crypt.ptr, this->decrypted.ptr, this->decrypted.len);
memcpy(to_crypt.ptr + this->decrypted.len, padding.ptr, padding.len);
@@ -315,22 +314,22 @@ static status_t encrypt(private_encryption_payload_t *this)
randomizer->destroy(randomizer);
if (status != SUCCESS)
{
- allocator_free_chunk(&to_crypt);
- allocator_free_chunk(&padding);
+ chunk_free(&to_crypt);
+ chunk_free(&padding);
return status;
}
this->logger->log_chunk(this->logger, RAW|LEVEL2, "data before encryption with padding", to_crypt);
/* encrypt to_crypt chunk */
- allocator_free(this->encrypted.ptr);
+ free(this->encrypted.ptr);
status = this->crypter->encrypt(this->crypter, to_crypt, iv, &result);
- allocator_free(padding.ptr);
- allocator_free(to_crypt.ptr);
+ free(padding.ptr);
+ free(to_crypt.ptr);
if (status != SUCCESS)
{
this->logger->log(this->logger, ERROR|LEVEL1, "encryption failed");
- allocator_free(iv.ptr);
+ free(iv.ptr);
return status;
}
this->logger->log_chunk(this->logger, RAW|LEVEL2, "data after encryption", result);
@@ -338,15 +337,15 @@ static status_t encrypt(private_encryption_payload_t *this)
/* build encrypted result with iv and signature */
this->encrypted.len = iv.len + result.len + this->signer->get_block_size(this->signer);
- allocator_free(this->encrypted.ptr);
- this->encrypted.ptr = allocator_alloc(this->encrypted.len);
+ free(this->encrypted.ptr);
+ this->encrypted.ptr = malloc(this->encrypted.len);
/* fill in result, signature is left out */
memcpy(this->encrypted.ptr, iv.ptr, iv.len);
memcpy(this->encrypted.ptr + iv.len, result.ptr, result.len);
- allocator_free(result.ptr);
- allocator_free(iv.ptr);
+ free(result.ptr);
+ free(iv.ptr);
this->logger->log_chunk(this->logger, RAW|LEVEL2, "data after encryption with IV and (invalid) signature", this->encrypted);
return SUCCESS;
@@ -391,7 +390,7 @@ static status_t decrypt(private_encryption_payload_t *this)
}
/* free previus data, if any */
- allocator_free(this->decrypted.ptr);
+ free(this->decrypted.ptr);
this->logger->log_chunk(this->logger, RAW|LEVEL2, "data before decryption", concatenated);
@@ -419,7 +418,7 @@ static status_t decrypt(private_encryption_payload_t *this)
}
/* free padding */
- this->decrypted.ptr = allocator_realloc(this->decrypted.ptr, this->decrypted.len);
+ this->decrypted.ptr = realloc(this->decrypted.ptr, this->decrypted.len);
this->logger->log_chunk(this->logger, RAW|LEVEL2, "data after decryption without padding", this->decrypted);
this->logger->log(this->logger, CONTROL|LEVEL2, "decryption successful, trying to parse content");
return (this->parse(this));
@@ -518,7 +517,7 @@ static void generate(private_encryption_payload_t *this)
{
/* no paylads? */
this->logger->log(this->logger, CONTROL|LEVEL1, "generating contained payloads, but no available");
- allocator_free(this->decrypted.ptr);
+ free(this->decrypted.ptr);
this->decrypted = CHUNK_INITIALIZER;
iterator->destroy(iterator);
return;
@@ -541,7 +540,7 @@ static void generate(private_encryption_payload_t *this)
generator->generate_payload(generator, current_payload);
/* free already generated data */
- allocator_free(this->decrypted.ptr);
+ free(this->decrypted.ptr);
generator->write_to_chunk(generator, &(this->decrypted));
generator->destroy(generator);
@@ -649,9 +648,9 @@ static void destroy(private_encryption_payload_t *this)
current_payload->destroy(current_payload);
}
this->payloads->destroy(this->payloads);
- allocator_free(this->encrypted.ptr);
- allocator_free(this->decrypted.ptr);
- allocator_free(this);
+ free(this->encrypted.ptr);
+ free(this->decrypted.ptr);
+ free(this);
}
/*
@@ -659,7 +658,7 @@ static void destroy(private_encryption_payload_t *this)
*/
encryption_payload_t *encryption_payload_create()
{
- private_encryption_payload_t *this = allocator_alloc_thing(private_encryption_payload_t);
+ private_encryption_payload_t *this = malloc_thing(private_encryption_payload_t);
/* payload_t interface functions */
this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
@@ -687,7 +686,7 @@ encryption_payload_t *encryption_payload_create()
this->compute_length = compute_length;
this->generate = generate;
this->parse = parse;
- this->logger = charon->logger_manager->get_logger(charon->logger_manager, ENCRYPTION_PAYLOAD);
+ this->logger = logger_manager->get_logger(logger_manager, ENCRYPTION_PAYLOAD);
/* set default values of the fields */
this->critical = FALSE;
diff --git a/Source/charon/encoding/payloads/id_payload.c b/Source/charon/encoding/payloads/id_payload.c
index df37a06f5..6a8d7738d 100644
--- a/Source/charon/encoding/payloads/id_payload.c
+++ b/Source/charon/encoding/payloads/id_payload.c
@@ -20,10 +20,11 @@
* for more details.
*/
+#include <stddef.h>
+
#include "id_payload.h"
#include <encoding/payloads/encodings.h>
-#include <utils/allocator.h>
typedef struct private_id_payload_t private_id_payload_t;
@@ -202,9 +203,9 @@ static void set_data (private_id_payload_t *this, chunk_t data)
{
if (this->id_data.ptr != NULL)
{
- allocator_free_chunk(&(this->id_data));
+ chunk_free(&(this->id_data));
}
- this->id_data.ptr = allocator_clone_bytes(data.ptr,data.len);
+ this->id_data.ptr = clalloc(data.ptr,data.len);
this->id_data.len = data.len;
this->payload_length = ID_PAYLOAD_HEADER_LENGTH + this->id_data.len;
}
@@ -228,7 +229,7 @@ static chunk_t get_data_clone (private_id_payload_t *this)
{
return (this->id_data);
}
- cloned_data.ptr = allocator_clone_bytes(this->id_data.ptr,this->id_data.len);
+ cloned_data.ptr = clalloc(this->id_data.ptr,this->id_data.len);
cloned_data.len = this->id_data.len;
return cloned_data;
}
@@ -264,9 +265,9 @@ static void destroy(private_id_payload_t *this)
{
if (this->id_data.ptr != NULL)
{
- allocator_free_chunk(&(this->id_data));
+ chunk_free(&(this->id_data));
}
- allocator_free(this);
+ free(this);
}
/*
@@ -274,7 +275,7 @@ static void destroy(private_id_payload_t *this)
*/
id_payload_t *id_payload_create(bool is_initiator)
{
- private_id_payload_t *this = allocator_alloc_thing(private_id_payload_t);
+ private_id_payload_t *this = malloc_thing(private_id_payload_t);
/* interface functions */
this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
diff --git a/Source/charon/encoding/payloads/ike_header.c b/Source/charon/encoding/payloads/ike_header.c
index 6114c8de4..ad46d3d29 100644
--- a/Source/charon/encoding/payloads/ike_header.c
+++ b/Source/charon/encoding/payloads/ike_header.c
@@ -26,7 +26,6 @@
#include "ike_header.h"
#include <encoding/payloads/encodings.h>
-#include <utils/allocator.h>
typedef struct private_ike_header_t private_ike_header_t;
@@ -324,7 +323,7 @@ static void set_message_id(private_ike_header_t *this, u_int32_t message_id)
*/
static void destroy(ike_header_t *this)
{
- allocator_free(this);
+ free(this);
}
/**
@@ -365,7 +364,7 @@ static size_t get_length(payload_t *this)
*/
ike_header_t *ike_header_create()
{
- private_ike_header_t *this = allocator_alloc_thing(private_ike_header_t);
+ private_ike_header_t *this = malloc_thing(private_ike_header_t);
this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
this->public.payload_interface.get_encoding_rules = get_encoding_rules;
diff --git a/Source/charon/encoding/payloads/ke_payload.c b/Source/charon/encoding/payloads/ke_payload.c
index 5cbf99b25..0c92e033d 100644
--- a/Source/charon/encoding/payloads/ke_payload.c
+++ b/Source/charon/encoding/payloads/ke_payload.c
@@ -19,14 +19,12 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
-
-/* offsetof macro */
+
#include <stddef.h>
#include "ke_payload.h"
#include <encoding/payloads/encodings.h>
-#include <utils/allocator.h>
typedef struct private_ke_payload_t private_ke_payload_t;
@@ -134,9 +132,9 @@ static void destroy(private_ke_payload_t *this)
{
if (this->key_exchange_data.ptr != NULL)
{
- allocator_free(this->key_exchange_data.ptr);
+ free(this->key_exchange_data.ptr);
}
- allocator_free(this);
+ free(this);
}
/**
@@ -212,13 +210,13 @@ static void set_key_exchange_data(private_ke_payload_t *this, chunk_t key_exchan
if (this->key_exchange_data.ptr != NULL)
{
/* free existing value */
- allocator_free(this->key_exchange_data.ptr);
+ free(this->key_exchange_data.ptr);
this->key_exchange_data.ptr = NULL;
this->key_exchange_data.len = 0;
}
- this->key_exchange_data.ptr = allocator_clone_bytes(key_exchange_data.ptr,key_exchange_data.len);
+ this->key_exchange_data.ptr = clalloc(key_exchange_data.ptr,key_exchange_data.len);
this->key_exchange_data.len = key_exchange_data.len;
this->compute_length(this);
@@ -245,7 +243,7 @@ static void set_dh_group_number(private_ke_payload_t *this, diffie_hellman_group
*/
ke_payload_t *ke_payload_create()
{
- private_ke_payload_t *this = allocator_alloc_thing(private_ke_payload_t);
+ private_ke_payload_t *this = malloc_thing(private_ke_payload_t);
/* interface functions */
this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
diff --git a/Source/charon/encoding/payloads/nonce_payload.c b/Source/charon/encoding/payloads/nonce_payload.c
index aa71f8bf6..a7528fbfb 100644
--- a/Source/charon/encoding/payloads/nonce_payload.c
+++ b/Source/charon/encoding/payloads/nonce_payload.c
@@ -26,7 +26,6 @@
#include "nonce_payload.h"
#include <encoding/payloads/encodings.h>
-#include <utils/allocator.h>
typedef struct private_nonce_payload_t private_nonce_payload_t;
@@ -125,7 +124,7 @@ static status_t verify(private_nonce_payload_t *this)
*/
static status_t set_nonce(private_nonce_payload_t *this, chunk_t nonce)
{
- this->nonce.ptr = allocator_clone_bytes(nonce.ptr, nonce.len);
+ this->nonce.ptr = clalloc(nonce.ptr, nonce.len);
this->nonce.len = nonce.len;
this->payload_length = NONCE_PAYLOAD_HEADER_LENGTH + nonce.len;
return SUCCESS;
@@ -137,7 +136,7 @@ static status_t set_nonce(private_nonce_payload_t *this, chunk_t nonce)
static chunk_t get_nonce(private_nonce_payload_t *this)
{
chunk_t nonce;
- nonce.ptr = allocator_clone_bytes(this->nonce.ptr,this->nonce.len);
+ nonce.ptr = clalloc(this->nonce.ptr,this->nonce.len);
nonce.len = this->nonce.len;
return nonce;
}
@@ -199,10 +198,10 @@ static void destroy(private_nonce_payload_t *this)
{
if (this->nonce.ptr != NULL)
{
- allocator_free(this->nonce.ptr);
+ free(this->nonce.ptr);
}
- allocator_free(this);
+ free(this);
}
/*
@@ -210,7 +209,7 @@ static void destroy(private_nonce_payload_t *this)
*/
nonce_payload_t *nonce_payload_create()
{
- private_nonce_payload_t *this = allocator_alloc_thing(private_nonce_payload_t);
+ private_nonce_payload_t *this = malloc_thing(private_nonce_payload_t);
/* interface functions */
this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
diff --git a/Source/charon/encoding/payloads/notify_payload.c b/Source/charon/encoding/payloads/notify_payload.c
index b26f89b39..43d0c5322 100644
--- a/Source/charon/encoding/payloads/notify_payload.c
+++ b/Source/charon/encoding/payloads/notify_payload.c
@@ -19,15 +19,13 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
-
-/* offsetof macro */
+
#include <stddef.h>
#include "notify_payload.h"
#include <daemon.h>
#include <encoding/payloads/encodings.h>
-#include <utils/allocator.h>
/**
* String mappings for notify_message_type_t.
@@ -321,13 +319,13 @@ static void set_spi(private_notify_payload_t *this, chunk_t spi)
if (this->spi.ptr != NULL)
{
/* free existing value */
- allocator_free(this->spi.ptr);
+ free(this->spi.ptr);
this->spi.ptr = NULL;
this->spi.len = 0;
}
- this->spi.ptr = allocator_clone_bytes(spi.ptr,spi.len);
+ this->spi.ptr = clalloc(spi.ptr,spi.len);
this->spi.len = spi.len;
this->spi_size = spi.len;
@@ -352,13 +350,13 @@ static status_t set_notification_data(private_notify_payload_t *this, chunk_t no
if (this->notification_data.ptr != NULL)
{
/* free existing value */
- allocator_free(this->notification_data.ptr);
+ free(this->notification_data.ptr);
this->notification_data.ptr = NULL;
this->notification_data.len = 0;
}
- this->notification_data.ptr = allocator_clone_bytes(notification_data.ptr,notification_data.len);
+ this->notification_data.ptr = clalloc(notification_data.ptr,notification_data.len);
this->notification_data.len = notification_data.len;
this->compute_length(this);
@@ -372,14 +370,14 @@ static status_t destroy(private_notify_payload_t *this)
{
if (this->notification_data.ptr != NULL)
{
- allocator_free(this->notification_data.ptr);
+ free(this->notification_data.ptr);
}
if (this->spi.ptr != NULL)
{
- allocator_free(this->spi.ptr);
+ free(this->spi.ptr);
}
- allocator_free(this);
+ free(this);
return SUCCESS;
}
@@ -388,7 +386,7 @@ static status_t destroy(private_notify_payload_t *this)
*/
notify_payload_t *notify_payload_create()
{
- private_notify_payload_t *this = allocator_alloc_thing(private_notify_payload_t);
+ private_notify_payload_t *this = malloc_thing(private_notify_payload_t);
/* interface functions */
this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
@@ -424,7 +422,7 @@ notify_payload_t *notify_payload_create()
this->spi_size = 0;
this->notification_data.ptr = NULL;
this->notification_data.len = 0;
- this->logger = charon->logger_manager->get_logger(charon->logger_manager, PAYLOAD);
+ this->logger = logger_manager->get_logger(logger_manager, PAYLOAD);
return (&(this->public));
}
diff --git a/Source/charon/encoding/payloads/proposal_substructure.c b/Source/charon/encoding/payloads/proposal_substructure.c
index 4ee2e91f4..cb3c695b2 100644
--- a/Source/charon/encoding/payloads/proposal_substructure.c
+++ b/Source/charon/encoding/payloads/proposal_substructure.c
@@ -19,8 +19,7 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
-
- /* offsetof macro */
+
#include <stddef.h>
#include "proposal_substructure.h"
@@ -28,7 +27,6 @@
#include <encoding/payloads/encodings.h>
#include <encoding/payloads/transform_substructure.h>
#include <types.h>
-#include <utils/allocator.h>
#include <utils/linked_list.h>
@@ -307,13 +305,13 @@ static void set_spi (private_proposal_substructure_t *this, chunk_t spi)
/* first delete already set spi value */
if (this->spi.ptr != NULL)
{
- allocator_free(this->spi.ptr);
+ free(this->spi.ptr);
this->spi.ptr = NULL;
this->spi.len = 0;
this->compute_length(this);
}
- this->spi.ptr = allocator_clone_bytes(spi.ptr,spi.len);
+ this->spi.ptr = clalloc(spi.ptr,spi.len);
this->spi.len = spi.len;
this->spi_size = spi.len;
this->compute_length(this);
@@ -452,7 +450,7 @@ static private_proposal_substructure_t* clone(private_proposal_substructure_t *t
new_clone->spi_size = this->spi_size;
if (this->spi.ptr != NULL)
{
- new_clone->spi.ptr = allocator_clone_bytes(this->spi.ptr,this->spi.len);
+ new_clone->spi.ptr = clalloc(this->spi.ptr,this->spi.len);
new_clone->spi.len = this->spi.len;
}
@@ -495,10 +493,10 @@ static status_t destroy(private_proposal_substructure_t *this)
if (this->spi.ptr != NULL)
{
- allocator_free(this->spi.ptr);
+ free(this->spi.ptr);
}
- allocator_free(this);
+ free(this);
return SUCCESS;
}
@@ -508,7 +506,7 @@ static status_t destroy(private_proposal_substructure_t *this)
*/
proposal_substructure_t *proposal_substructure_create()
{
- private_proposal_substructure_t *this = allocator_alloc_thing(private_proposal_substructure_t);
+ private_proposal_substructure_t *this = malloc_thing(private_proposal_substructure_t);
/* interface functions */
this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
@@ -622,7 +620,7 @@ proposal_substructure_t *proposal_substructure_create_from_proposal(proposal_t *
/* take over general infos */
this->spi_size = proto == PROTO_IKE ? 8 : 4;
this->spi.len = this->spi_size;
- this->spi.ptr = allocator_alloc(this->spi_size);
+ this->spi.ptr = malloc(this->spi_size);
*((u_int32_t*)this->spi.ptr) = proposal->get_spi(proposal, proto);
this->proposal_number = proposal->get_number(proposal);
this->protocol_id = proto;
diff --git a/Source/charon/encoding/payloads/sa_payload.c b/Source/charon/encoding/payloads/sa_payload.c
index 91049dd65..81b4e6709 100644
--- a/Source/charon/encoding/payloads/sa_payload.c
+++ b/Source/charon/encoding/payloads/sa_payload.c
@@ -19,14 +19,12 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
-
-/* offsetof macro */
+
#include <stddef.h>
#include "sa_payload.h"
#include <encoding/payloads/encodings.h>
-#include <utils/allocator.h>
#include <utils/linked_list.h>
@@ -176,7 +174,7 @@ static status_t destroy(private_sa_payload_t *this)
}
this->proposals->destroy(this->proposals);
- allocator_free(this);
+ free(this);
return SUCCESS;
}
@@ -329,7 +327,7 @@ static void compute_length (private_sa_payload_t *this)
*/
sa_payload_t *sa_payload_create()
{
- private_sa_payload_t *this = allocator_alloc_thing(private_sa_payload_t);
+ private_sa_payload_t *this = malloc_thing(private_sa_payload_t);
/* public interface */
this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
diff --git a/Source/charon/encoding/payloads/traffic_selector_substructure.c b/Source/charon/encoding/payloads/traffic_selector_substructure.c
index 874b87e43..c1a461e8a 100644
--- a/Source/charon/encoding/payloads/traffic_selector_substructure.c
+++ b/Source/charon/encoding/payloads/traffic_selector_substructure.c
@@ -23,7 +23,6 @@
#include "traffic_selector_substructure.h"
#include <encoding/payloads/encodings.h>
-#include <utils/allocator.h>
#include <utils/linked_list.h>
/**
@@ -254,7 +253,7 @@ static void set_start_host (private_traffic_selector_substructure_t *this,host_t
this->start_port = start_host->get_port(start_host);
if (this->starting_address.ptr != NULL)
{
- allocator_free_chunk(&(this->starting_address));
+ chunk_free(&(this->starting_address));
}
this->starting_address = start_host->get_address_as_chunk(start_host);
this->compute_length(this);
@@ -276,7 +275,7 @@ static void set_end_host (private_traffic_selector_substructure_t *this,host_t *
this->end_port = end_host->get_port(end_host);
if (this->ending_address.ptr != NULL)
{
- allocator_free_chunk(&(this->ending_address));
+ chunk_free(&(this->ending_address));
}
this->ending_address = end_host->get_address_as_chunk(end_host);
this->compute_length(this);
@@ -307,9 +306,9 @@ void compute_length(private_traffic_selector_substructure_t *this)
*/
static void destroy(private_traffic_selector_substructure_t *this)
{
- allocator_free(this->starting_address.ptr);
- allocator_free(this->ending_address.ptr);
- allocator_free(this);
+ free(this->starting_address.ptr);
+ free(this->ending_address.ptr);
+ free(this);
}
/*
@@ -317,7 +316,7 @@ static void destroy(private_traffic_selector_substructure_t *this)
*/
traffic_selector_substructure_t *traffic_selector_substructure_create()
{
- private_traffic_selector_substructure_t *this = allocator_alloc_thing(private_traffic_selector_substructure_t);
+ private_traffic_selector_substructure_t *this = malloc_thing(private_traffic_selector_substructure_t);
/* interface functions */
this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
diff --git a/Source/charon/encoding/payloads/transform_attribute.c b/Source/charon/encoding/payloads/transform_attribute.c
index 9f9d82924..71cdd59e2 100644
--- a/Source/charon/encoding/payloads/transform_attribute.c
+++ b/Source/charon/encoding/payloads/transform_attribute.c
@@ -19,15 +19,14 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
-
-/* offsetof macro */
+
+#include <string.h>
#include <stddef.h>
#include "transform_attribute.h"
#include <encoding/payloads/encodings.h>
#include <types.h>
-#include <utils/allocator.h>
typedef struct private_transform_attribute_t private_transform_attribute_t;
@@ -170,7 +169,7 @@ static void set_value_chunk(private_transform_attribute_t *this, chunk_t value)
if (this->attribute_value.ptr != NULL)
{
/* free existing value */
- allocator_free(this->attribute_value.ptr);
+ free(this->attribute_value.ptr);
this->attribute_value.ptr = NULL;
this->attribute_value.len = 0;
@@ -178,7 +177,7 @@ static void set_value_chunk(private_transform_attribute_t *this, chunk_t value)
if (value.len > 2)
{
- this->attribute_value.ptr = allocator_clone_bytes(value.ptr,value.len);
+ this->attribute_value.ptr = clalloc(value.ptr,value.len);
this->attribute_value.len = value.len;
this->attribute_length_or_value = value.len;
/* attribute has not a fixed length */
@@ -198,7 +197,7 @@ static void set_value(private_transform_attribute_t *this, u_int16_t value)
if (this->attribute_value.ptr != NULL)
{
/* free existing value */
- allocator_free(this->attribute_value.ptr);
+ free(this->attribute_value.ptr);
this->attribute_value.ptr = NULL;
this->attribute_value.len = 0;
@@ -267,7 +266,7 @@ static transform_attribute_t * clone(private_transform_attribute_t *this)
if (!new_clone->attribute_format)
{
- new_clone->attribute_value.ptr = allocator_clone_bytes(this->attribute_value.ptr,this->attribute_value.len);
+ new_clone->attribute_value.ptr = clalloc(this->attribute_value.ptr,this->attribute_value.len);
new_clone->attribute_value.len = this->attribute_value.len;
}
@@ -281,9 +280,9 @@ static void destroy(private_transform_attribute_t *this)
{
if (this->attribute_value.ptr != NULL)
{
- allocator_free(this->attribute_value.ptr);
+ free(this->attribute_value.ptr);
}
- allocator_free(this);
+ free(this);
}
/*
@@ -291,7 +290,7 @@ static void destroy(private_transform_attribute_t *this)
*/
transform_attribute_t *transform_attribute_create()
{
- private_transform_attribute_t *this = allocator_alloc_thing(private_transform_attribute_t);
+ private_transform_attribute_t *this = malloc_thing(private_transform_attribute_t);
/* payload interface */
this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
diff --git a/Source/charon/encoding/payloads/transform_substructure.c b/Source/charon/encoding/payloads/transform_substructure.c
index 9b0bbf4ed..350ad63e4 100644
--- a/Source/charon/encoding/payloads/transform_substructure.c
+++ b/Source/charon/encoding/payloads/transform_substructure.c
@@ -19,8 +19,7 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
-
- /* offsetof macro */
+
#include <stddef.h>
#include "transform_substructure.h"
@@ -28,7 +27,6 @@
#include <encoding/payloads/transform_attribute.h>
#include <encoding/payloads/encodings.h>
#include <types.h>
-#include <utils/allocator.h>
#include <utils/linked_list.h>
@@ -420,7 +418,7 @@ static void destroy(private_transform_substructure_t *this)
}
this->attributes->destroy(this->attributes);
- allocator_free(this);
+ free(this);
}
/*
@@ -428,7 +426,7 @@ static void destroy(private_transform_substructure_t *this)
*/
transform_substructure_t *transform_substructure_create()
{
- private_transform_substructure_t *this = allocator_alloc_thing(private_transform_substructure_t);
+ private_transform_substructure_t *this = malloc_thing(private_transform_substructure_t);
/* payload interface */
this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
diff --git a/Source/charon/encoding/payloads/ts_payload.c b/Source/charon/encoding/payloads/ts_payload.c
index 33a0cdab8..58772e666 100644
--- a/Source/charon/encoding/payloads/ts_payload.c
+++ b/Source/charon/encoding/payloads/ts_payload.c
@@ -20,10 +20,11 @@
* for more details.
*/
+#include <stddef.h>
+
#include "ts_payload.h"
#include <encoding/payloads/encodings.h>
-#include <utils/allocator.h>
#include <utils/linked_list.h>
typedef struct private_ts_payload_t private_ts_payload_t;
@@ -297,7 +298,7 @@ static void destroy(private_ts_payload_t *this)
this->traffic_selectors->destroy(this->traffic_selectors);
- allocator_free(this);
+ free(this);
}
/*
@@ -305,7 +306,7 @@ static void destroy(private_ts_payload_t *this)
*/
ts_payload_t *ts_payload_create(bool is_initiator)
{
- private_ts_payload_t *this = allocator_alloc_thing(private_ts_payload_t);
+ private_ts_payload_t *this = malloc_thing(private_ts_payload_t);
/* interface functions */
this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
diff --git a/Source/charon/encoding/payloads/unknown_payload.c b/Source/charon/encoding/payloads/unknown_payload.c
index 5d6d2cbdb..25bb37d59 100644
--- a/Source/charon/encoding/payloads/unknown_payload.c
+++ b/Source/charon/encoding/payloads/unknown_payload.c
@@ -20,9 +20,10 @@
* for more details.
*/
+#include <stddef.h>
+
#include "unknown_payload.h"
-#include <utils/allocator.h>
typedef struct private_unknown_payload_t private_unknown_payload_t;
@@ -169,10 +170,10 @@ static void destroy(private_unknown_payload_t *this)
{
if (this->data.ptr != NULL)
{
- allocator_free_chunk(&(this->data));
+ chunk_free(&(this->data));
}
- allocator_free(this);
+ free(this);
}
/*
@@ -180,7 +181,7 @@ static void destroy(private_unknown_payload_t *this)
*/
unknown_payload_t *unknown_payload_create()
{
- private_unknown_payload_t *this = allocator_alloc_thing(private_unknown_payload_t);
+ private_unknown_payload_t *this = malloc_thing(private_unknown_payload_t);
/* interface functions */
this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
diff --git a/Source/charon/encoding/payloads/vendor_id_payload.c b/Source/charon/encoding/payloads/vendor_id_payload.c
index 28f07608b..436b82d79 100644
--- a/Source/charon/encoding/payloads/vendor_id_payload.c
+++ b/Source/charon/encoding/payloads/vendor_id_payload.c
@@ -20,9 +20,9 @@
* for more details.
*/
-#include "vendor_id_payload.h"
+#include <stddef.h>
-#include <utils/allocator.h>
+#include "vendor_id_payload.h"
typedef struct private_vendor_id_payload_t private_vendor_id_payload_t;
@@ -153,9 +153,9 @@ static void set_data (private_vendor_id_payload_t *this, chunk_t data)
{
if (this->vendor_id_data.ptr != NULL)
{
- allocator_free_chunk(&(this->vendor_id_data));
+ chunk_free(&(this->vendor_id_data));
}
- this->vendor_id_data.ptr = allocator_clone_bytes(data.ptr,data.len);
+ this->vendor_id_data.ptr = clalloc(data.ptr,data.len);
this->vendor_id_data.len = data.len;
this->payload_length = VENDOR_ID_PAYLOAD_HEADER_LENGTH + this->vendor_id_data.len;
}
@@ -178,7 +178,7 @@ static chunk_t get_data_clone (private_vendor_id_payload_t *this)
{
return (this->vendor_id_data);
}
- cloned_data.ptr = allocator_clone_bytes(this->vendor_id_data.ptr,this->vendor_id_data.len);
+ cloned_data.ptr = clalloc(this->vendor_id_data.ptr,this->vendor_id_data.len);
cloned_data.len = this->vendor_id_data.len;
return cloned_data;
}
@@ -190,9 +190,9 @@ static void destroy(private_vendor_id_payload_t *this)
{
if (this->vendor_id_data.ptr != NULL)
{
- allocator_free_chunk(&(this->vendor_id_data));
+ chunk_free(&(this->vendor_id_data));
}
- allocator_free(this);
+ free(this);
}
/*
@@ -200,7 +200,7 @@ static void destroy(private_vendor_id_payload_t *this)
*/
vendor_id_payload_t *vendor_id_payload_create()
{
- private_vendor_id_payload_t *this = allocator_alloc_thing(private_vendor_id_payload_t);
+ private_vendor_id_payload_t *this = malloc_thing(private_vendor_id_payload_t);
/* interface functions */
this->public.payload_interface.verify = (status_t (*) (payload_t *))verify;
diff --git a/Source/charon/network/packet.c b/Source/charon/network/packet.c
index b6501d8ae..6cded72a3 100644
--- a/Source/charon/network/packet.c
+++ b/Source/charon/network/packet.c
@@ -23,8 +23,6 @@
#include "packet.h"
-#include <utils/allocator.h>
-
typedef struct private_packet_t private_packet_t;
@@ -107,7 +105,7 @@ static chunk_t get_data(private_packet_t *this)
*/
static void set_data(private_packet_t *this, chunk_t data)
{
- allocator_free(this->data.ptr);
+ free(this->data.ptr);
this->data = data;
}
@@ -124,8 +122,8 @@ static void destroy(private_packet_t *this)
{
this->destination->destroy(this->destination);
}
- allocator_free(this->data.ptr);
- allocator_free(this);
+ free(this->data.ptr);
+ free(this);
}
/**
@@ -156,7 +154,7 @@ static packet_t *clone(private_packet_t *this)
/* only clone existing chunks :-) */
if (this->data.ptr != NULL)
{
- other->data.ptr = allocator_clone_bytes(this->data.ptr,this->data.len);
+ other->data.ptr = clalloc(this->data.ptr,this->data.len);
other->data.len = this->data.len;
}
else
@@ -172,7 +170,7 @@ static packet_t *clone(private_packet_t *this)
*/
packet_t *packet_create()
{
- private_packet_t *this = allocator_alloc_thing(private_packet_t);
+ private_packet_t *this = malloc_thing(private_packet_t);
this->public.set_data = (void(*) (packet_t *,chunk_t)) set_data;
this->public.get_data = (chunk_t(*) (packet_t *)) get_data;
diff --git a/Source/charon/network/socket.c b/Source/charon/network/socket.c
index c7a7ab11b..733071fab 100644
--- a/Source/charon/network/socket.c
+++ b/Source/charon/network/socket.c
@@ -40,7 +40,6 @@
#include "socket.h"
#include <daemon.h>
-#include <utils/allocator.h>
#include <utils/logger_manager.h>
@@ -218,7 +217,7 @@ status_t receiver(private_socket_t *this, packet_t **packet)
/* fill in packet */
data.len = bytes_read - IP_HEADER_LENGTH - UDP_HEADER_LENGTH;
- data.ptr = allocator_alloc(data.len);
+ data.ptr = malloc(data.len);
memcpy(data.ptr, buffer + IP_HEADER_LENGTH + UDP_HEADER_LENGTH, data.len);
pkt->set_data(pkt, data);
@@ -367,7 +366,7 @@ static status_t build_interface_list(private_socket_t *this, u_int16_t port)
}
/* add socket with interface name to list */
- interface = allocator_alloc_thing(interface_t);
+ interface = malloc_thing(interface_t);
memcpy(interface->name, buf[i].ifr_name, IFNAMSIZ);
interface->name[IFNAMSIZ-1] = '\0';
interface->socket_fd = skt;
@@ -424,11 +423,11 @@ static void destroy(private_socket_t *this)
{
interface->address->destroy(interface->address);
close(interface->socket_fd);
- allocator_free(interface);
+ free(interface);
}
this->interfaces->destroy(this->interfaces);
close(this->master_fd);
- allocator_free(this);
+ free(this);
}
/*
@@ -436,7 +435,7 @@ static void destroy(private_socket_t *this)
*/
socket_t *socket_create(u_int16_t port)
{
- private_socket_t *this = allocator_alloc_thing(private_socket_t);
+ private_socket_t *this = malloc_thing(private_socket_t);
/* public functions */
this->public.send = (status_t(*)(socket_t*, packet_t*))sender;
@@ -444,7 +443,7 @@ socket_t *socket_create(u_int16_t port)
this->public.is_listening_on = (bool (*)(socket_t*,host_t*))is_listening_on;
this->public.destroy = (void(*)(socket_t*)) destroy;
- this->logger = charon->logger_manager->get_logger(charon->logger_manager, SOCKET);
+ this->logger = logger_manager->get_logger(logger_manager, SOCKET);
this->interfaces = linked_list_create();
if (build_interface_list(this, port) != SUCCESS)
diff --git a/Source/charon/queues/event_queue.c b/Source/charon/queues/event_queue.c
index 741fe1460..ece9d1513 100644
--- a/Source/charon/queues/event_queue.c
+++ b/Source/charon/queues/event_queue.c
@@ -26,7 +26,6 @@
#include "event_queue.h"
#include <types.h>
-#include <utils/allocator.h>
#include <utils/linked_list.h>
@@ -64,7 +63,7 @@ struct event_t{
*/
static void event_destroy(event_t *event)
{
- allocator_free(event);
+ free(event);
}
/**
@@ -77,7 +76,7 @@ static void event_destroy(event_t *event)
*/
static event_t *event_create(timeval_t time, job_t *job)
{
- event_t *this = allocator_alloc_thing(event_t);
+ event_t *this = malloc_thing(event_t);
this->destroy = event_destroy;
this->time = time;
@@ -326,7 +325,7 @@ static void event_queue_destroy(private_event_queue_t *this)
pthread_cond_destroy(&(this->condvar));
- allocator_free(this);
+ free(this);
}
/*
@@ -334,7 +333,7 @@ static void event_queue_destroy(private_event_queue_t *this)
*/
event_queue_t *event_queue_create()
{
- private_event_queue_t *this = allocator_alloc_thing(private_event_queue_t);
+ private_event_queue_t *this = malloc_thing(private_event_queue_t);
this->public.get_count = (int (*) (event_queue_t *event_queue)) get_count;
this->public.get = (job_t *(*) (event_queue_t *event_queue)) get;
diff --git a/Source/charon/queues/job_queue.c b/Source/charon/queues/job_queue.c
index 9d383d743..3640395ab 100644
--- a/Source/charon/queues/job_queue.c
+++ b/Source/charon/queues/job_queue.c
@@ -25,7 +25,6 @@
#include "job_queue.h"
-#include <utils/allocator.h>
#include <utils/linked_list.h>
@@ -130,7 +129,7 @@ static void job_queue_destroy (private_job_queue_t *this)
pthread_cond_destroy(&(this->condvar));
- allocator_free(this);
+ free(this);
}
/*
@@ -139,7 +138,7 @@ static void job_queue_destroy (private_job_queue_t *this)
*/
job_queue_t *job_queue_create()
{
- private_job_queue_t *this = allocator_alloc_thing(private_job_queue_t);
+ private_job_queue_t *this = malloc_thing(private_job_queue_t);
this->public.get_count = (int(*)(job_queue_t*))get_count;
this->public.get = (job_t*(*)(job_queue_t*))get;
diff --git a/Source/charon/queues/jobs/delete_established_ike_sa_job.c b/Source/charon/queues/jobs/delete_established_ike_sa_job.c
index 595bdd11b..7251e2ca4 100644
--- a/Source/charon/queues/jobs/delete_established_ike_sa_job.c
+++ b/Source/charon/queues/jobs/delete_established_ike_sa_job.c
@@ -22,7 +22,6 @@
#include "delete_established_ike_sa_job.h"
-#include <utils/allocator.h>
typedef struct private_delete_established_ike_sa_job_t private_delete_established_ike_sa_job_t;
@@ -64,7 +63,7 @@ static ike_sa_id_t *get_ike_sa_id(private_delete_established_ike_sa_job_t *this)
static void destroy(private_delete_established_ike_sa_job_t *this)
{
this->ike_sa_id->destroy(this->ike_sa_id);
- allocator_free(this);
+ free(this);
}
/*
@@ -72,7 +71,7 @@ static void destroy(private_delete_established_ike_sa_job_t *this)
*/
delete_established_ike_sa_job_t *delete_established_ike_sa_job_create(ike_sa_id_t *ike_sa_id)
{
- private_delete_established_ike_sa_job_t *this = allocator_alloc_thing(private_delete_established_ike_sa_job_t);
+ private_delete_established_ike_sa_job_t *this = malloc_thing(private_delete_established_ike_sa_job_t);
/* interface functions */
this->public.job_interface.get_type = (job_type_t (*) (job_t *)) get_type;
diff --git a/Source/charon/queues/jobs/delete_half_open_ike_sa_job.c b/Source/charon/queues/jobs/delete_half_open_ike_sa_job.c
index 47354d6be..610285e20 100644
--- a/Source/charon/queues/jobs/delete_half_open_ike_sa_job.c
+++ b/Source/charon/queues/jobs/delete_half_open_ike_sa_job.c
@@ -22,7 +22,6 @@
#include "delete_half_open_ike_sa_job.h"
-#include <utils/allocator.h>
typedef struct private_delete_half_open_ike_sa_job_t private_delete_half_open_ike_sa_job_t;
@@ -64,7 +63,7 @@ static ike_sa_id_t *get_ike_sa_id(private_delete_half_open_ike_sa_job_t *this)
static void destroy(private_delete_half_open_ike_sa_job_t *this)
{
this->ike_sa_id->destroy(this->ike_sa_id);
- allocator_free(this);
+ free(this);
}
/*
@@ -72,7 +71,7 @@ static void destroy(private_delete_half_open_ike_sa_job_t *this)
*/
delete_half_open_ike_sa_job_t *delete_half_open_ike_sa_job_create(ike_sa_id_t *ike_sa_id)
{
- private_delete_half_open_ike_sa_job_t *this = allocator_alloc_thing(private_delete_half_open_ike_sa_job_t);
+ private_delete_half_open_ike_sa_job_t *this = malloc_thing(private_delete_half_open_ike_sa_job_t);
/* interface functions */
this->public.job_interface.get_type = (job_type_t (*) (job_t *)) get_type;
diff --git a/Source/charon/queues/jobs/incoming_packet_job.c b/Source/charon/queues/jobs/incoming_packet_job.c
index ee8dac698..fc71f63ea 100644
--- a/Source/charon/queues/jobs/incoming_packet_job.c
+++ b/Source/charon/queues/jobs/incoming_packet_job.c
@@ -23,7 +23,6 @@
#include "incoming_packet_job.h"
-#include <utils/allocator.h>
typedef struct private_incoming_packet_job_t private_incoming_packet_job_t;
@@ -68,7 +67,7 @@ static void destroy_all(private_incoming_packet_job_t *this)
{
this->packet->destroy(this->packet);
}
- allocator_free(this);
+ free(this);
}
/**
@@ -77,7 +76,7 @@ static void destroy_all(private_incoming_packet_job_t *this)
static void destroy(job_t *job)
{
private_incoming_packet_job_t *this = (private_incoming_packet_job_t *) job;
- allocator_free(this);
+ free(this);
}
/*
@@ -85,7 +84,7 @@ static void destroy(job_t *job)
*/
incoming_packet_job_t *incoming_packet_job_create(packet_t *packet)
{
- private_incoming_packet_job_t *this = allocator_alloc_thing(private_incoming_packet_job_t);
+ private_incoming_packet_job_t *this = malloc_thing(private_incoming_packet_job_t);
/* interface functions */
this->public.job_interface.get_type = (job_type_t (*) (job_t *)) get_type;
diff --git a/Source/charon/queues/jobs/initiate_ike_sa_job.c b/Source/charon/queues/jobs/initiate_ike_sa_job.c
index 8837cd8f4..ac9ace36c 100644
--- a/Source/charon/queues/jobs/initiate_ike_sa_job.c
+++ b/Source/charon/queues/jobs/initiate_ike_sa_job.c
@@ -25,7 +25,6 @@
#include "initiate_ike_sa_job.h"
-#include <utils/allocator.h>
typedef struct private_initiate_ike_sa_job_t private_initiate_ike_sa_job_t;
@@ -68,7 +67,7 @@ static connection_t *get_connection(private_initiate_ike_sa_job_t *this)
static void destroy_all(private_initiate_ike_sa_job_t *this)
{
this->connection->destroy(this->connection);
- allocator_free(this);
+ free(this);
}
/**
@@ -76,7 +75,7 @@ static void destroy_all(private_initiate_ike_sa_job_t *this)
*/
static void destroy(private_initiate_ike_sa_job_t *this)
{
- allocator_free(this);
+ free(this);
}
/*
@@ -84,7 +83,7 @@ static void destroy(private_initiate_ike_sa_job_t *this)
*/
initiate_ike_sa_job_t *initiate_ike_sa_job_create(connection_t *connection)
{
- private_initiate_ike_sa_job_t *this = allocator_alloc_thing(private_initiate_ike_sa_job_t);
+ private_initiate_ike_sa_job_t *this = malloc_thing(private_initiate_ike_sa_job_t);
/* interface functions */
this->public.job_interface.get_type = (job_type_t (*) (job_t *)) get_type;
diff --git a/Source/charon/queues/jobs/retransmit_request_job.c b/Source/charon/queues/jobs/retransmit_request_job.c
index 089ebbfec..e171df5bd 100644
--- a/Source/charon/queues/jobs/retransmit_request_job.c
+++ b/Source/charon/queues/jobs/retransmit_request_job.c
@@ -23,7 +23,6 @@
#include "retransmit_request_job.h"
-#include <utils/allocator.h>
typedef struct private_retransmit_request_job_t private_retransmit_request_job_t;
@@ -101,7 +100,7 @@ static u_int32_t get_message_id(private_retransmit_request_job_t *this)
static void destroy(private_retransmit_request_job_t *this)
{
this->ike_sa_id->destroy(this->ike_sa_id);
- allocator_free(this);
+ free(this);
}
/*
@@ -109,7 +108,7 @@ static void destroy(private_retransmit_request_job_t *this)
*/
retransmit_request_job_t *retransmit_request_job_create(u_int32_t message_id,ike_sa_id_t *ike_sa_id)
{
- private_retransmit_request_job_t *this = allocator_alloc_thing(private_retransmit_request_job_t);
+ private_retransmit_request_job_t *this = malloc_thing(private_retransmit_request_job_t);
/* interface functions */
this->public.job_interface.get_type = (job_type_t (*) (job_t *)) get_type;
diff --git a/Source/charon/queues/send_queue.c b/Source/charon/queues/send_queue.c
index df1f7b38f..0852e5303 100644
--- a/Source/charon/queues/send_queue.c
+++ b/Source/charon/queues/send_queue.c
@@ -24,7 +24,6 @@
#include "send_queue.h"
-#include <utils/allocator.h>
#include <utils/linked_list.h>
@@ -130,7 +129,7 @@ static void destroy (private_send_queue_t *this)
pthread_cond_destroy(&(this->condvar));
- allocator_free(this);
+ free(this);
}
/*
@@ -139,7 +138,7 @@ static void destroy (private_send_queue_t *this)
*/
send_queue_t *send_queue_create()
{
- private_send_queue_t *this = allocator_alloc_thing(private_send_queue_t);
+ private_send_queue_t *this = malloc_thing(private_send_queue_t);
this->public.get_count = (int(*)(send_queue_t*)) get_count;
this->public.get = (packet_t*(*)(send_queue_t*)) get;
diff --git a/Source/charon/sa/authenticator.c b/Source/charon/sa/authenticator.c
index 9c2a05cb3..32817b0a1 100644
--- a/Source/charon/sa/authenticator.c
+++ b/Source/charon/sa/authenticator.c
@@ -20,9 +20,10 @@
* for more details.
*/
+#include <string.h>
+
#include "authenticator.h"
-#include <utils/allocator.h>
#include <daemon.h>
/**
@@ -141,7 +142,7 @@ static chunk_t allocate_octets(private_authenticator_t *this,
/* 4 bytes are id type and reserved fields of id payload */
octets.len = last_message.len + other_nonce.len + prf->get_block_size(prf);
- octets.ptr = allocator_alloc(octets.len);
+ octets.ptr = malloc(octets.len);
current_pos = octets.ptr;
memcpy(current_pos,last_message.ptr,last_message.len);
current_pos += last_message.len;
@@ -175,7 +176,7 @@ static chunk_t build_preshared_secret_signature(private_authenticator_t *this,
this->prf->get_bytes(this->prf, key_pad, key_buffer);
this->prf->set_key(this->prf, key);
this->prf->allocate_bytes(this->prf, octets, &auth_data);
- allocator_free_chunk(&octets);
+ chunk_free(&octets);
this->logger->log_chunk(this->logger,RAW | LEVEL2, "Authenticated data",auth_data);
return auth_data;
@@ -217,11 +218,11 @@ static status_t verify_auth_data (private_authenticator_t *this,
other_id_payload,
initiator,
preshared_secret);
- allocator_free_chunk(&preshared_secret);
+ chunk_free(&preshared_secret);
if (auth_data.len != my_auth_data.len)
{
- allocator_free_chunk(&my_auth_data);
+ chunk_free(&my_auth_data);
status = FAILED;
}
else if (memcmp(auth_data.ptr,my_auth_data.ptr, my_auth_data.len) == 0)
@@ -237,7 +238,7 @@ static status_t verify_auth_data (private_authenticator_t *this,
status = FAILED;
}
other_id->destroy(other_id);
- allocator_free_chunk(&my_auth_data);
+ chunk_free(&my_auth_data);
return status;
}
case RSA_DIGITAL_SIGNATURE:
@@ -276,7 +277,7 @@ static status_t verify_auth_data (private_authenticator_t *this,
public_key->destroy(public_key);
other_id->destroy(other_id);
- allocator_free_chunk(&octets);
+ chunk_free(&octets);
return status;
}
default:
@@ -322,12 +323,12 @@ static status_t compute_auth_data (private_authenticator_t *this,
auth_data = this->build_preshared_secret_signature(this, last_sent_packet, other_nonce,
my_id_payload, initiator, preshared_secret);
- allocator_free_chunk(&preshared_secret);
+ chunk_free(&preshared_secret);
*auth_payload = auth_payload_create();
(*auth_payload)->set_auth_method(*auth_payload, SHARED_KEY_MESSAGE_INTEGRITY_CODE);
(*auth_payload)->set_data(*auth_payload, auth_data);
- allocator_free_chunk(&auth_data);
+ chunk_free(&auth_data);
return SUCCESS;
}
case RSA_DIGITAL_SIGNATURE:
@@ -350,7 +351,7 @@ static status_t compute_auth_data (private_authenticator_t *this,
octets = this->allocate_octets(this,last_sent_packet,other_nonce,my_id_payload,initiator);
status = private_key->build_emsa_pkcs1_signature(private_key, HASH_SHA1, octets, &auth_data);
- allocator_free_chunk(&octets);
+ chunk_free(&octets);
if (status != SUCCESS)
{
private_key->destroy(private_key);
@@ -362,7 +363,7 @@ static status_t compute_auth_data (private_authenticator_t *this,
(*auth_payload)->set_data(*auth_payload, auth_data);
private_key->destroy(private_key);
- allocator_free_chunk(&auth_data);
+ chunk_free(&auth_data);
return SUCCESS;
}
default:
@@ -377,7 +378,7 @@ static status_t compute_auth_data (private_authenticator_t *this,
*/
static void destroy (private_authenticator_t *this)
{
- allocator_free(this);
+ free(this);
}
/*
@@ -385,7 +386,7 @@ static void destroy (private_authenticator_t *this)
*/
authenticator_t *authenticator_create(protected_ike_sa_t *ike_sa)
{
- private_authenticator_t *this = allocator_alloc_thing(private_authenticator_t);
+ private_authenticator_t *this = malloc_thing(private_authenticator_t);
/* Public functions */
this->public.destroy = (void(*)(authenticator_t*))destroy;
@@ -399,7 +400,7 @@ authenticator_t *authenticator_create(protected_ike_sa_t *ike_sa)
/* private data */
this->ike_sa = ike_sa;
this->prf = this->ike_sa->get_prf(this->ike_sa);
- this->logger = charon->logger_manager->get_logger(charon->logger_manager, IKE_SA);
+ this->logger = logger_manager->get_logger(logger_manager, IKE_SA);
return &(this->public);
}
diff --git a/Source/charon/sa/child_sa.c b/Source/charon/sa/child_sa.c
index 7f19f87e6..fd82f123b 100644
--- a/Source/charon/sa/child_sa.c
+++ b/Source/charon/sa/child_sa.c
@@ -23,7 +23,6 @@
#include "child_sa.h"
-#include <utils/allocator.h>
#include <daemon.h>
@@ -305,11 +304,11 @@ static status_t install(private_child_sa_t *this, proposal_t *proposal, prf_plus
/* clean up for next round */
if (enc_algo != ENCR_UNDEFINED)
{
- allocator_free_chunk(&enc_key);
+ chunk_free(&enc_key);
}
if (int_algo != AUTH_UNDEFINED)
{
- allocator_free_chunk(&int_key);
+ chunk_free(&int_key);
}
if (status != SUCCESS)
@@ -396,7 +395,7 @@ static status_t add_policies(private_child_sa_t *this, linked_list_t *my_ts_list
{
continue;
}
- policy = allocator_alloc_thing(sa_policy_t);
+ policy = malloc_thing(sa_policy_t);
policy->upper_proto = my_ts->get_protocol(my_ts);
/* calculate net and ports for local side */
@@ -407,7 +406,7 @@ static status_t add_policies(private_child_sa_t *this, linked_list_t *my_ts_list
from_port = (from_port != to_port) ? 0 : from_port;
policy->my_net = host_create_from_chunk(family, from_addr, from_port);
policy->my_net_mask = my_ts->get_netmask(my_ts);
- allocator_free_chunk(&from_addr);
+ chunk_free(&from_addr);
/* calculate net and ports for remote side */
family = other_ts->get_type(other_ts) == TS_IPV4_ADDR_RANGE ? AF_INET : AF_INET6;
@@ -417,7 +416,7 @@ static status_t add_policies(private_child_sa_t *this, linked_list_t *my_ts_list
from_port = (from_port != to_port) ? 0 : from_port;
policy->other_net = host_create_from_chunk(family, from_addr, from_port);
policy->other_net_mask = other_ts->get_netmask(other_ts);
- allocator_free_chunk(&from_addr);
+ chunk_free(&from_addr);
/* install 3 policies: out, in and forward */
status = charon->kernel_interface->add_policy(charon->kernel_interface,
@@ -448,7 +447,7 @@ static status_t add_policies(private_child_sa_t *this, linked_list_t *my_ts_list
{
my_iter->destroy(my_iter);
other_iter->destroy(other_iter);
- allocator_free(policy);
+ free(policy);
return status;
}
@@ -491,7 +490,7 @@ static void destroy(private_child_sa_t *this)
policy->my_net->destroy(policy->my_net);
policy->other_net->destroy(policy->other_net);
- allocator_free(policy);
+ free(policy);
}
this->policies->destroy(this->policies);
@@ -510,7 +509,7 @@ static void destroy(private_child_sa_t *this)
charon->kernel_interface->del_sa(charon->kernel_interface,
this->me, this->other_esp_spi, PROTO_ESP);
}
- allocator_free(this);
+ free(this);
}
/*
@@ -519,7 +518,7 @@ static void destroy(private_child_sa_t *this)
child_sa_t * child_sa_create(host_t *me, host_t* other)
{
static u_int32_t reqid = 0xc0000000;
- private_child_sa_t *this = allocator_alloc_thing(private_child_sa_t);
+ private_child_sa_t *this = malloc_thing(private_child_sa_t);
/* public functions */
this->public.alloc = (status_t(*)(child_sa_t*,linked_list_t*))alloc;
@@ -529,7 +528,7 @@ child_sa_t * child_sa_create(host_t *me, host_t* other)
this->public.destroy = (void(*)(child_sa_t*))destroy;
/* private data */
- this->logger = charon->logger_manager->get_logger(charon->logger_manager, CHILD_SA);
+ this->logger = logger_manager->get_logger(logger_manager, CHILD_SA);
this->me = me;
this->other = other;
this->my_ah_spi = 0;
diff --git a/Source/charon/sa/ike_sa.c b/Source/charon/sa/ike_sa.c
index 43de291d1..63879f1f2 100644
--- a/Source/charon/sa/ike_sa.c
+++ b/Source/charon/sa/ike_sa.c
@@ -19,13 +19,13 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
+#include <string.h>
#include "ike_sa.h"
#include <types.h>
#include <daemon.h>
#include <definitions.h>
-#include <utils/allocator.h>
#include <utils/linked_list.h>
#include <utils/logger_manager.h>
#include <utils/randomizer.h>
@@ -526,12 +526,12 @@ static status_t build_transforms(private_ike_sa_t *this, proposal_t *proposal, d
}
/* concatenate nonces = nonce_i | nonce_r */
- nonces = allocator_alloc_as_chunk(nonce_i.len + nonce_r.len);
+ nonces = chunk_alloc(nonce_i.len + nonce_r.len);
memcpy(nonces.ptr, nonce_i.ptr, nonce_i.len);
memcpy(nonces.ptr + nonce_i.len, nonce_r.ptr, nonce_r.len);
/* concatenate prf_seed = nonce_i | nonce_r | spi_i | spi_r */
- nonces_spis = allocator_alloc_as_chunk(nonces.len + 16);
+ nonces_spis = chunk_alloc(nonces.len + 16);
memcpy(nonces_spis.ptr, nonces.ptr, nonces.len);
spi_i = this->ike_sa_id->get_initiator_spi(this->ike_sa_id);
spi_r = this->ike_sa_id->get_responder_spi(this->ike_sa_id);
@@ -544,7 +544,7 @@ static status_t build_transforms(private_ike_sa_t *this, proposal_t *proposal, d
this->prf->set_key(this->prf, nonces);
this->prf->allocate_bytes(this->prf, secret, &skeyseed);
this->logger->log_chunk(this->logger, PRIVATE | LEVEL1, "SKEYSEED", skeyseed);
- allocator_free_chunk(&secret);
+ chunk_free(&secret);
/* prf+ (SKEYSEED, Ni | Nr | SPIi | SPIr )
* = SK_d | SK_ai | SK_ar | SK_ei | SK_er | SK_pi | SK_pr
@@ -555,9 +555,9 @@ static status_t build_transforms(private_ike_sa_t *this, proposal_t *proposal, d
prf_plus = prf_plus_create(this->prf, nonces_spis);
/* clean up unused stuff */
- allocator_free_chunk(&nonces);
- allocator_free_chunk(&nonces_spis);
- allocator_free_chunk(&skeyseed);
+ chunk_free(&nonces);
+ chunk_free(&nonces_spis);
+ chunk_free(&skeyseed);
/*
@@ -572,7 +572,7 @@ static status_t build_transforms(private_ike_sa_t *this, proposal_t *proposal, d
prf_plus->allocate_bytes(prf_plus, key_size, &key);
this->logger->log_chunk(this->logger, PRIVATE, "Sk_d secret", key);
this->child_prf->set_key(this->child_prf, key);
- allocator_free_chunk(&key);
+ chunk_free(&key);
/* SK_ai/SK_ar used for integrity protection */
@@ -605,12 +605,12 @@ static status_t build_transforms(private_ike_sa_t *this, proposal_t *proposal, d
prf_plus->allocate_bytes(prf_plus, key_size, &key);
this->logger->log_chunk(this->logger, PRIVATE, "Sk_ai secret", key);
this->signer_initiator->set_key(this->signer_initiator, key);
- allocator_free_chunk(&key);
+ chunk_free(&key);
prf_plus->allocate_bytes(prf_plus, key_size, &key);
this->logger->log_chunk(this->logger, PRIVATE, "Sk_ar secret", key);
this->signer_responder->set_key(this->signer_responder, key);
- allocator_free_chunk(&key);
+ chunk_free(&key);
/* SK_ei/SK_er used for encryption */
@@ -644,12 +644,12 @@ static status_t build_transforms(private_ike_sa_t *this, proposal_t *proposal, d
prf_plus->allocate_bytes(prf_plus, key_size, &key);
this->logger->log_chunk(this->logger, PRIVATE, "Sk_ei secret", key);
this->crypter_initiator->set_key(this->crypter_initiator, key);
- allocator_free_chunk(&key);
+ chunk_free(&key);
prf_plus->allocate_bytes(prf_plus, key_size, &key);
this->logger->log_chunk(this->logger, PRIVATE, "Sk_er secret", key);
this->crypter_responder->set_key(this->crypter_responder, key);
- allocator_free_chunk(&key);
+ chunk_free(&key);
/* SK_pi/SK_pr used for authentication */
proposal->get_algorithm(proposal, PROTO_IKE, PSEUDO_RANDOM_FUNCTION, &algo);
@@ -669,12 +669,12 @@ static status_t build_transforms(private_ike_sa_t *this, proposal_t *proposal, d
prf_plus->allocate_bytes(prf_plus, key_size, &key);
this->logger->log_chunk(this->logger, PRIVATE, "Sk_pi secret", key);
this->prf_auth_i->set_key(this->prf_auth_i, key);
- allocator_free_chunk(&key);
+ chunk_free(&key);
prf_plus->allocate_bytes(prf_plus, key_size, &key);
this->logger->log_chunk(this->logger, PRIVATE, "Sk_pr secret", key);
this->prf_auth_r->set_key(this->prf_auth_r, key);
- allocator_free_chunk(&key);
+ chunk_free(&key);
/* all done, prf_plus not needed anymore */
prf_plus->destroy(prf_plus);
@@ -1038,7 +1038,7 @@ static void destroy (private_ike_sa_t *this)
this->randomizer->destroy(this->randomizer);
this->current_state->destroy(this->current_state);
- allocator_free(this);
+ free(this);
}
/*
@@ -1046,7 +1046,7 @@ static void destroy (private_ike_sa_t *this)
*/
ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id)
{
- private_ike_sa_t *this = allocator_alloc_thing(private_ike_sa_t);
+ private_ike_sa_t *this = malloc_thing(private_ike_sa_t);
/* Public functions */
this->protected.public.process_message = (status_t(*)(ike_sa_t*, message_t*)) process_message;
@@ -1090,7 +1090,7 @@ ike_sa_t * ike_sa_create(ike_sa_id_t *ike_sa_id)
this->resend_last_reply = resend_last_reply;
/* initialize private fields */
- this->logger = charon->logger_manager->get_logger(charon->logger_manager, IKE_SA);
+ this->logger = logger_manager->get_logger(logger_manager, IKE_SA);
this->ike_sa_id = ike_sa_id->clone(ike_sa_id);
this->child_sas = linked_list_create();
diff --git a/Source/charon/sa/ike_sa_id.c b/Source/charon/sa/ike_sa_id.c
index b4c285fcb..bf3a05d11 100644
--- a/Source/charon/sa/ike_sa_id.c
+++ b/Source/charon/sa/ike_sa_id.c
@@ -23,7 +23,6 @@
#include "ike_sa_id.h"
-#include <utils/allocator.h>
typedef struct private_ike_sa_id_t private_ike_sa_id_t;
@@ -155,7 +154,7 @@ static ike_sa_id_t* clone(private_ike_sa_id_t *this)
*/
static void destroy(private_ike_sa_id_t *this)
{
- allocator_free(this);
+ free(this);
}
/*
@@ -163,7 +162,7 @@ static void destroy(private_ike_sa_id_t *this)
*/
ike_sa_id_t * ike_sa_id_create(u_int64_t initiator_spi, u_int64_t responder_spi, bool is_initiator_flag)
{
- private_ike_sa_id_t *this = allocator_alloc_thing(private_ike_sa_id_t);
+ private_ike_sa_id_t *this = malloc_thing(private_ike_sa_id_t);
/* public functions */
this->public.set_responder_spi = (void(*)(ike_sa_id_t*,u_int64_t)) set_responder_spi;
diff --git a/Source/charon/sa/ike_sa_manager.c b/Source/charon/sa/ike_sa_manager.c
index 2838d2b8a..d0120fa7e 100644
--- a/Source/charon/sa/ike_sa_manager.c
+++ b/Source/charon/sa/ike_sa_manager.c
@@ -27,7 +27,6 @@
#include <daemon.h>
#include <sa/ike_sa_id.h>
-#include <utils/allocator.h>
#include <utils/logger.h>
#include <utils/logger_manager.h>
#include <utils/linked_list.h>
@@ -87,7 +86,7 @@ static status_t ike_sa_entry_destroy(ike_sa_entry_t *this)
/* also destroy IKE SA */
this->ike_sa->destroy(this->ike_sa);
this->ike_sa_id->destroy(this->ike_sa_id);
- allocator_free(this);
+ free(this);
return SUCCESS;
}
@@ -101,7 +100,7 @@ static status_t ike_sa_entry_destroy(ike_sa_entry_t *this)
*/
static ike_sa_entry_t *ike_sa_entry_create(ike_sa_id_t *ike_sa_id)
{
- ike_sa_entry_t *this = allocator_alloc_thing(ike_sa_entry_t);
+ ike_sa_entry_t *this = malloc_thing(ike_sa_entry_t);
/* destroy function */
this->destroy = ike_sa_entry_destroy;
@@ -752,7 +751,7 @@ static void destroy(private_ike_sa_manager_t *this)
this->logger->log(this->logger,CONTROL | LEVEL2,"IKE_SA's deleted");
pthread_mutex_unlock(&(this->mutex));
- allocator_free(this);
+ free(this);
}
/*
@@ -760,7 +759,7 @@ static void destroy(private_ike_sa_manager_t *this)
*/
ike_sa_manager_t *ike_sa_manager_create()
{
- private_ike_sa_manager_t *this = allocator_alloc_thing(private_ike_sa_manager_t);
+ private_ike_sa_manager_t *this = malloc_thing(private_ike_sa_manager_t);
/* assign public functions */
this->public.destroy = (void(*)(ike_sa_manager_t*))destroy;
@@ -779,7 +778,7 @@ ike_sa_manager_t *ike_sa_manager_create()
this->delete_entry = delete_entry;
/* initialize private variables */
- this->logger = charon->logger_manager->get_logger(charon->logger_manager, IKE_SA_MANAGER);
+ this->logger = logger_manager->get_logger(logger_manager, IKE_SA_MANAGER);
this->ike_sa_list = linked_list_create();
diff --git a/Source/charon/sa/states/ike_auth_requested.c b/Source/charon/sa/states/ike_auth_requested.c
index b037cfcd9..00c38a887 100644
--- a/Source/charon/sa/states/ike_auth_requested.c
+++ b/Source/charon/sa/states/ike_auth_requested.c
@@ -19,11 +19,12 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
-
+
+#include <string.h>
+
#include "ike_auth_requested.h"
#include <daemon.h>
-#include <utils/allocator.h>
#include <encoding/payloads/ts_payload.h>
#include <encoding/payloads/sa_payload.h>
#include <encoding/payloads/id_payload.h>
@@ -329,11 +330,11 @@ static status_t process_message(private_ike_auth_requested_t *this, message_t *i
}
else
{
- seed = allocator_alloc_as_chunk(this->sent_nonce.len + this->received_nonce.len);
+ seed = chunk_alloc(this->sent_nonce.len + this->received_nonce.len);
memcpy(seed.ptr, this->sent_nonce.ptr, this->sent_nonce.len);
memcpy(seed.ptr + this->sent_nonce.len, this->received_nonce.ptr, this->received_nonce.len);
prf_plus = prf_plus_create(this->ike_sa->get_child_prf(this->ike_sa), seed);
- allocator_free_chunk(&seed);
+ chunk_free(&seed);
status = this->child_sa->update(this->child_sa, this->proposal, prf_plus);
prf_plus->destroy(prf_plus);
@@ -571,9 +572,9 @@ static ike_sa_state_t get_state(private_ike_auth_requested_t *this)
*/
static void destroy(private_ike_auth_requested_t *this)
{
- allocator_free_chunk(&(this->received_nonce));
- allocator_free_chunk(&(this->sent_nonce));
- allocator_free_chunk(&(this->ike_sa_init_reply_data));
+ chunk_free(&(this->received_nonce));
+ chunk_free(&(this->sent_nonce));
+ chunk_free(&(this->ike_sa_init_reply_data));
if (this->child_sa)
{
this->child_sa->destroy(this->child_sa);
@@ -600,16 +601,16 @@ static void destroy(private_ike_auth_requested_t *this)
{
this->proposal->destroy(this->proposal);
}
- allocator_free(this);
+ free(this);
}
/**
* Implements protected_ike_sa_t.destroy_after_state_change
*/
static void destroy_after_state_change(private_ike_auth_requested_t *this)
{
- allocator_free_chunk(&(this->received_nonce));
- allocator_free_chunk(&(this->sent_nonce));
- allocator_free_chunk(&(this->ike_sa_init_reply_data));
+ chunk_free(&(this->received_nonce));
+ chunk_free(&(this->sent_nonce));
+ chunk_free(&(this->ike_sa_init_reply_data));
if (this->my_ts)
{
traffic_selector_t *ts;
@@ -632,7 +633,7 @@ static void destroy_after_state_change(private_ike_auth_requested_t *this)
{
this->proposal->destroy(this->proposal);
}
- allocator_free(this);
+ free(this);
}
/*
@@ -640,7 +641,7 @@ static void destroy_after_state_change(private_ike_auth_requested_t *this)
*/
ike_auth_requested_t *ike_auth_requested_create(protected_ike_sa_t *ike_sa,chunk_t sent_nonce,chunk_t received_nonce,chunk_t ike_sa_init_reply_data, child_sa_t *child_sa)
{
- private_ike_auth_requested_t *this = allocator_alloc_thing(private_ike_auth_requested_t);
+ private_ike_auth_requested_t *this = malloc_thing(private_ike_auth_requested_t);
/* interface functions */
this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *)) process_message;
@@ -660,7 +661,7 @@ ike_auth_requested_t *ike_auth_requested_create(protected_ike_sa_t *ike_sa,chunk
this->received_nonce = received_nonce;
this->sent_nonce = sent_nonce;
this->ike_sa_init_reply_data = ike_sa_init_reply_data;
- this->logger = charon->logger_manager->get_logger(charon->logger_manager, IKE_SA);
+ this->logger = logger_manager->get_logger(logger_manager, IKE_SA);
this->my_ts = NULL;
this->other_ts = NULL;
this->proposal = NULL;
diff --git a/Source/charon/sa/states/ike_sa_established.c b/Source/charon/sa/states/ike_sa_established.c
index f96734423..e91409f6a 100644
--- a/Source/charon/sa/states/ike_sa_established.c
+++ b/Source/charon/sa/states/ike_sa_established.c
@@ -23,7 +23,6 @@
#include "ike_sa_established.h"
#include <daemon.h>
-#include <utils/allocator.h>
#include <encoding/payloads/delete_payload.h>
@@ -214,7 +213,7 @@ static ike_sa_state_t get_state(private_ike_sa_established_t *this)
*/
static void destroy(private_ike_sa_established_t *this)
{
- allocator_free(this);
+ free(this);
}
/*
@@ -222,7 +221,7 @@ static void destroy(private_ike_sa_established_t *this)
*/
ike_sa_established_t *ike_sa_established_create(protected_ike_sa_t *ike_sa)
{
- private_ike_sa_established_t *this = allocator_alloc_thing(private_ike_sa_established_t);
+ private_ike_sa_established_t *this = malloc_thing(private_ike_sa_established_t);
/* interface functions */
this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *)) process_message;
@@ -234,7 +233,7 @@ ike_sa_established_t *ike_sa_established_create(protected_ike_sa_t *ike_sa)
/* private data */
this->ike_sa = ike_sa;
- this->logger = charon->logger_manager->get_logger(charon->logger_manager, IKE_SA);
+ this->logger = logger_manager->get_logger(logger_manager, IKE_SA);
return &(this->public);
}
diff --git a/Source/charon/sa/states/ike_sa_init_requested.c b/Source/charon/sa/states/ike_sa_init_requested.c
index 8d3ae55ed..e3769303c 100644
--- a/Source/charon/sa/states/ike_sa_init_requested.c
+++ b/Source/charon/sa/states/ike_sa_init_requested.c
@@ -23,7 +23,6 @@
#include "ike_sa_init_requested.h"
#include <daemon.h>
-#include <utils/allocator.h>
#include <encoding/payloads/sa_payload.h>
#include <encoding/payloads/ke_payload.h>
#include <encoding/payloads/nonce_payload.h>
@@ -411,7 +410,7 @@ static status_t process_message(private_ike_sa_init_requested_t *this, message_t
*/
status_t process_nonce_payload (private_ike_sa_init_requested_t *this, nonce_payload_t *nonce_payload)
{
- allocator_free(this->received_nonce.ptr);
+ free(this->received_nonce.ptr);
this->received_nonce = nonce_payload->get_nonce(nonce_payload);
return SUCCESS;
}
@@ -693,12 +692,12 @@ static ike_sa_state_t get_state(private_ike_sa_init_requested_t *this)
static void destroy_after_state_change (private_ike_sa_init_requested_t *this)
{
this->diffie_hellman->destroy(this->diffie_hellman);
- allocator_free_chunk(&(this->ike_sa_init_request_data));
+ chunk_free(&(this->ike_sa_init_request_data));
if (this->proposal)
{
this->proposal->destroy(this->proposal);
}
- allocator_free(this);
+ free(this);
}
/**
@@ -707,9 +706,9 @@ static void destroy_after_state_change (private_ike_sa_init_requested_t *this)
static void destroy(private_ike_sa_init_requested_t *this)
{
this->diffie_hellman->destroy(this->diffie_hellman);
- allocator_free(this->sent_nonce.ptr);
- allocator_free(this->received_nonce.ptr);
- allocator_free_chunk(&(this->ike_sa_init_request_data));
+ free(this->sent_nonce.ptr);
+ free(this->received_nonce.ptr);
+ chunk_free(&(this->ike_sa_init_request_data));
if (this->child_sa)
{
this->child_sa->destroy(this->child_sa);
@@ -718,7 +717,7 @@ static void destroy(private_ike_sa_init_requested_t *this)
{
this->proposal->destroy(this->proposal);
}
- allocator_free(this);
+ free(this);
}
/*
@@ -726,7 +725,7 @@ static void destroy(private_ike_sa_init_requested_t *this)
*/
ike_sa_init_requested_t *ike_sa_init_requested_create(protected_ike_sa_t *ike_sa, diffie_hellman_t *diffie_hellman, chunk_t sent_nonce,chunk_t ike_sa_init_request_data)
{
- private_ike_sa_init_requested_t *this = allocator_alloc_thing(private_ike_sa_init_requested_t);
+ private_ike_sa_init_requested_t *this = malloc_thing(private_ike_sa_init_requested_t);
/* interface functions */
this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *)) process_message;
@@ -748,7 +747,7 @@ ike_sa_init_requested_t *ike_sa_init_requested_create(protected_ike_sa_t *ike_sa
/* private data */
this->ike_sa = ike_sa;
this->received_nonce = CHUNK_INITIALIZER;
- this->logger = charon->logger_manager->get_logger(charon->logger_manager, IKE_SA);
+ this->logger = logger_manager->get_logger(logger_manager, IKE_SA);
this->diffie_hellman = diffie_hellman;
this->proposal = NULL;
this->sent_nonce = sent_nonce;
diff --git a/Source/charon/sa/states/ike_sa_init_responded.c b/Source/charon/sa/states/ike_sa_init_responded.c
index 52548749a..54c0cc26b 100644
--- a/Source/charon/sa/states/ike_sa_init_responded.c
+++ b/Source/charon/sa/states/ike_sa_init_responded.c
@@ -19,11 +19,12 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
-
+
+#include <string.h>
+
#include "ike_sa_init_responded.h"
#include <daemon.h>
-#include <utils/allocator.h>
#include <sa/authenticator.h>
#include <sa/child_sa.h>
#include <encoding/payloads/ts_payload.h>
@@ -473,11 +474,11 @@ static status_t build_sa_payload(private_ike_sa_init_responded_t *this, sa_paylo
}
/* set up child sa */
- seed = allocator_alloc_as_chunk(this->received_nonce.len + this->sent_nonce.len);
+ seed = chunk_alloc(this->received_nonce.len + this->sent_nonce.len);
memcpy(seed.ptr, this->received_nonce.ptr, this->received_nonce.len);
memcpy(seed.ptr + this->received_nonce.len, this->sent_nonce.ptr, this->sent_nonce.len);
prf_plus = prf_plus_create(this->ike_sa->get_child_prf(this->ike_sa), seed);
- allocator_free_chunk(&seed);
+ chunk_free(&seed);
connection = this->ike_sa->get_connection(this->ike_sa);
this->child_sa = child_sa_create(connection->get_my_host(connection),
@@ -607,10 +608,10 @@ static ike_sa_state_t get_state(private_ike_sa_init_responded_t *this)
*/
static void destroy(private_ike_sa_init_responded_t *this)
{
- allocator_free_chunk(&(this->received_nonce));
- allocator_free_chunk(&(this->sent_nonce));
- allocator_free_chunk(&(this->ike_sa_init_response_data));
- allocator_free_chunk(&(this->ike_sa_init_request_data));
+ chunk_free(&(this->received_nonce));
+ chunk_free(&(this->sent_nonce));
+ chunk_free(&(this->ike_sa_init_response_data));
+ chunk_free(&(this->ike_sa_init_request_data));
if (this->my_ts)
{
traffic_selector_t *ts;
@@ -634,17 +635,17 @@ static void destroy(private_ike_sa_init_responded_t *this)
this->child_sa->destroy(this->child_sa);
}
- allocator_free(this);
+ free(this);
}
/**
* Implementation of private_ike_sa_init_responded.destroy_after_state_change.
*/
static void destroy_after_state_change(private_ike_sa_init_responded_t *this)
{
- allocator_free_chunk(&(this->received_nonce));
- allocator_free_chunk(&(this->sent_nonce));
- allocator_free_chunk(&(this->ike_sa_init_response_data));
- allocator_free_chunk(&(this->ike_sa_init_request_data));
+ chunk_free(&(this->received_nonce));
+ chunk_free(&(this->sent_nonce));
+ chunk_free(&(this->ike_sa_init_response_data));
+ chunk_free(&(this->ike_sa_init_request_data));
if (this->my_ts)
{
traffic_selector_t *ts;
@@ -664,7 +665,7 @@ static void destroy_after_state_change(private_ike_sa_init_responded_t *this)
this->other_ts->destroy(this->other_ts);
}
- allocator_free(this);
+ free(this);
}
/*
@@ -672,7 +673,7 @@ static void destroy_after_state_change(private_ike_sa_init_responded_t *this)
*/
ike_sa_init_responded_t *ike_sa_init_responded_create(protected_ike_sa_t *ike_sa, chunk_t received_nonce, chunk_t sent_nonce,chunk_t ike_sa_init_request_data, chunk_t ike_sa_init_response_data)
{
- private_ike_sa_init_responded_t *this = allocator_alloc_thing(private_ike_sa_init_responded_t);
+ private_ike_sa_init_responded_t *this = malloc_thing(private_ike_sa_init_responded_t);
/* interface functions */
this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *)) process_message;
@@ -696,7 +697,7 @@ ike_sa_init_responded_t *ike_sa_init_responded_create(protected_ike_sa_t *ike_sa
this->my_ts = NULL;
this->other_ts = NULL;
this->child_sa = NULL;
- this->logger = charon->logger_manager->get_logger(charon->logger_manager, IKE_SA);
+ this->logger = logger_manager->get_logger(logger_manager, IKE_SA);
return &(this->public);
}
diff --git a/Source/charon/sa/states/initiator_init.c b/Source/charon/sa/states/initiator_init.c
index 85885130f..35d15235d 100644
--- a/Source/charon/sa/states/initiator_init.c
+++ b/Source/charon/sa/states/initiator_init.c
@@ -26,7 +26,6 @@
#include <daemon.h>
#include <sa/states/state.h>
#include <sa/states/ike_sa_init_requested.h>
-#include <utils/allocator.h>
#include <queues/jobs/retransmit_request_job.h>
#include <crypto/diffie_hellman.h>
#include <encoding/payloads/sa_payload.h>
@@ -247,7 +246,7 @@ static void build_ke_payload(private_initiator_init_t *this, message_t *request)
ke_payload->set_dh_group_number(ke_payload, dh_group);
ke_payload->set_key_exchange_data(ke_payload, key_data);
- allocator_free_chunk(&key_data);
+ chunk_free(&key_data);
this->logger->log(this->logger, CONTROL|LEVEL2, "Add KE payload to message");
request->add_payload(request, (payload_t *) ke_payload);
@@ -315,9 +314,9 @@ static void destroy(private_initiator_init_t *this)
}
if (this->sent_nonce.ptr != NULL)
{
- allocator_free(this->sent_nonce.ptr);
+ free(this->sent_nonce.ptr);
}
- allocator_free(this);
+ free(this);
}
/**
@@ -326,7 +325,7 @@ static void destroy(private_initiator_init_t *this)
static void destroy_after_state_change (private_initiator_init_t *this)
{
this->logger->log(this->logger, CONTROL | LEVEL3, "Going to destroy initiator_init_t state object");
- allocator_free(this);
+ free(this);
}
/*
@@ -334,7 +333,7 @@ static void destroy_after_state_change (private_initiator_init_t *this)
*/
initiator_init_t *initiator_init_create(protected_ike_sa_t *ike_sa)
{
- private_initiator_init_t *this = allocator_alloc_thing(private_initiator_init_t);
+ private_initiator_init_t *this = malloc_thing(private_initiator_init_t);
/* interface functions */
this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *)) process_message;
@@ -353,7 +352,7 @@ initiator_init_t *initiator_init_create(protected_ike_sa_t *ike_sa)
/* private data */
this->ike_sa = ike_sa;
- this->logger = charon->logger_manager->get_logger(charon->logger_manager, IKE_SA);
+ this->logger = logger_manager->get_logger(logger_manager, IKE_SA);
this->sent_nonce = CHUNK_INITIALIZER;
this->diffie_hellman = NULL;
diff --git a/Source/charon/sa/states/responder_init.c b/Source/charon/sa/states/responder_init.c
index 32aa6db86..10acf645c 100644
--- a/Source/charon/sa/states/responder_init.c
+++ b/Source/charon/sa/states/responder_init.c
@@ -25,7 +25,6 @@
#include <daemon.h>
#include <sa/states/state.h>
#include <sa/states/ike_sa_init_responded.h>
-#include <utils/allocator.h>
#include <encoding/payloads/sa_payload.h>
#include <encoding/payloads/ke_payload.h>
#include <encoding/payloads/nonce_payload.h>
@@ -413,7 +412,7 @@ static status_t build_ke_payload(private_responder_init_t *this,ke_payload_t *ke
ke_payload = ke_payload_create();
ke_payload->set_key_exchange_data(ke_payload,key_data);
ke_payload->set_dh_group_number(ke_payload, this->dh_group_number);
- allocator_free_chunk(&key_data);
+ chunk_free(&key_data);
this->logger->log(this->logger, CONTROL|LEVEL2, "Add KE payload to message");
response->add_payload(response,(payload_t *) ke_payload);
@@ -431,7 +430,7 @@ static status_t build_nonce_payload(private_responder_init_t *this,nonce_payload
status_t status;
this->logger->log(this->logger, CONTROL | LEVEL2, "Process received NONCE payload");
- allocator_free(this->received_nonce.ptr);
+ free(this->received_nonce.ptr);
this->received_nonce = CHUNK_INITIALIZER;
this->logger->log(this->logger, CONTROL | LEVEL2, "Get NONCE value and store it");
@@ -498,9 +497,9 @@ static void destroy(private_responder_init_t *this)
this->logger->log(this->logger, CONTROL | LEVEL1, "Going to destroy responder init state object");
this->logger->log(this->logger, CONTROL | LEVEL2, "Destroy sent nonce");
- allocator_free_chunk(&(this->sent_nonce));
+ chunk_free(&(this->sent_nonce));
this->logger->log(this->logger, CONTROL | LEVEL2, "Destroy received nonce");
- allocator_free_chunk(&(this->received_nonce));
+ chunk_free(&(this->received_nonce));
if (this->diffie_hellman != NULL)
{
@@ -512,7 +511,7 @@ static void destroy(private_responder_init_t *this)
this->proposal->destroy(this->proposal);
}
this->logger->log(this->logger, CONTROL | LEVEL2, "Destroy object");
- allocator_free(this);
+ free(this);
}
/**
@@ -534,7 +533,7 @@ static void destroy_after_state_change (private_responder_init_t *this)
}
this->logger->log(this->logger, CONTROL | LEVEL2, "Destroy object");
- allocator_free(this);
+ free(this);
}
/*
@@ -542,7 +541,7 @@ static void destroy_after_state_change (private_responder_init_t *this)
*/
responder_init_t *responder_init_create(protected_ike_sa_t *ike_sa)
{
- private_responder_init_t *this = allocator_alloc_thing(private_responder_init_t);
+ private_responder_init_t *this = malloc_thing(private_responder_init_t);
/* interface functions */
this->public.state_interface.process_message = (status_t (*) (state_t *,message_t *)) process_message;
@@ -558,7 +557,7 @@ responder_init_t *responder_init_create(protected_ike_sa_t *ike_sa)
/* private data */
this->ike_sa = ike_sa;
- this->logger = charon->logger_manager->get_logger(charon->logger_manager, IKE_SA);
+ this->logger = logger_manager->get_logger(logger_manager, IKE_SA);
this->sent_nonce = CHUNK_INITIALIZER;
this->received_nonce = CHUNK_INITIALIZER;
this->dh_group_number = MODP_UNDEFINED;
diff --git a/Source/charon/threads/kernel_interface.c b/Source/charon/threads/kernel_interface.c
index 87238d079..180ea55a5 100644
--- a/Source/charon/threads/kernel_interface.c
+++ b/Source/charon/threads/kernel_interface.c
@@ -35,7 +35,6 @@
#include "kernel_interface.h"
#include <daemon.h>
-#include <utils/allocator.h>
#include <utils/linked_list.h>
@@ -239,7 +238,7 @@ static status_t get_spi(private_kernel_interface_t *this,
}
*spi = response->sa.id.spi;
- allocator_free(response);
+ free(response);
return status;
}
@@ -329,7 +328,7 @@ static status_t add_sa( private_kernel_interface_t *this,
status = FAILED;
}
- allocator_free(response);
+ free(response);
return SUCCESS;
}
@@ -366,7 +365,7 @@ static status_t del_sa( private_kernel_interface_t *this,
status = FAILED;
}
- allocator_free(response);
+ free(response);
return SUCCESS;
}
@@ -458,7 +457,7 @@ static status_t add_policy(private_kernel_interface_t *this,
status = FAILED;
}
- allocator_free(response);
+ free(response);
return status;
}
@@ -506,7 +505,7 @@ static status_t del_policy(private_kernel_interface_t *this,
status = FAILED;
}
- allocator_free(response);
+ free(response);
return status;
}
@@ -623,7 +622,7 @@ static void receive_messages(private_kernel_interface_t *this)
else
{
/* add response to queue */
- listed_response = allocator_alloc(sizeof(response));
+ listed_response = malloc(sizeof(response));
memcpy(listed_response, &response, sizeof(response));
pthread_mutex_lock(&(this->mutex));
@@ -645,7 +644,7 @@ static void destroy(private_kernel_interface_t *this)
pthread_join(this->thread, NULL);
close(this->socket);
this->responses->destroy(this->responses);
- allocator_free(this);
+ free(this);
}
/*
@@ -653,7 +652,7 @@ static void destroy(private_kernel_interface_t *this)
*/
kernel_interface_t *kernel_interface_create()
{
- private_kernel_interface_t *this = allocator_alloc_thing(private_kernel_interface_t);
+ private_kernel_interface_t *this = malloc_thing(private_kernel_interface_t);
/* public functions */
this->public.get_spi = (status_t(*)(kernel_interface_t*,host_t*,host_t*,protocol_id_t,u_int32_t,u_int32_t*))get_spi;
@@ -675,17 +674,17 @@ kernel_interface_t *kernel_interface_create()
this->socket = socket(PF_NETLINK, SOCK_RAW, NETLINK_XFRM);
if (this->socket <= 0)
{
- allocator_free(this);
+ free(this);
charon->kill(charon, "Unable to create netlink socket");
}
if (pthread_create(&(this->thread), NULL, (void*(*)(void*))this->receive_messages, this) != 0)
{
close(this->socket);
- allocator_free(this);
+ free(this);
charon->kill(charon, "Unable to create netlink thread");
}
- charon->logger_manager->enable_log_level(charon->logger_manager, TESTER, FULL);
+ logger_manager->enable_log_level(logger_manager, TESTER, FULL);
return (&this->public);
}
diff --git a/Source/charon/threads/receiver.c b/Source/charon/threads/receiver.c
index 9058ecbc4..0cf8b7bde 100644
--- a/Source/charon/threads/receiver.c
+++ b/Source/charon/threads/receiver.c
@@ -31,7 +31,6 @@
#include <queues/job_queue.h>
#include <queues/jobs/job.h>
#include <queues/jobs/incoming_packet_job.h>
-#include <utils/allocator.h>
#include <utils/logger_manager.h>
@@ -103,7 +102,7 @@ static void destroy(private_receiver_t *this)
pthread_join(this->assigned_thread, NULL);
this->logger->log(this->logger, CONTROL | LEVEL1, "Receiver thread terminated");
- allocator_free(this);
+ free(this);
}
/*
@@ -111,17 +110,17 @@ static void destroy(private_receiver_t *this)
*/
receiver_t * receiver_create()
{
- private_receiver_t *this = allocator_alloc_thing(private_receiver_t);
+ private_receiver_t *this = malloc_thing(private_receiver_t);
this->public.destroy = (void(*)(receiver_t*)) destroy;
this->receive_packets = receive_packets;
- this->logger = charon->logger_manager->get_logger(charon->logger_manager, RECEIVER);
+ this->logger = logger_manager->get_logger(logger_manager, RECEIVER);
if (pthread_create(&(this->assigned_thread), NULL, (void*(*)(void*))this->receive_packets, this) != 0)
{
this->logger->log(this->logger, ERROR, "Receiver thread could not be started");
- allocator_free(this);
+ free(this);
charon->kill(charon, "Unable to create receiver thread");
}
diff --git a/Source/charon/threads/scheduler.c b/Source/charon/threads/scheduler.c
index 8750cdae9..47c5d6fb9 100644
--- a/Source/charon/threads/scheduler.c
+++ b/Source/charon/threads/scheduler.c
@@ -27,7 +27,6 @@
#include <daemon.h>
#include <definitions.h>
-#include <utils/allocator.h>
#include <utils/logger_manager.h>
#include <queues/job_queue.h>
@@ -98,7 +97,7 @@ static void destroy(private_scheduler_t *this)
pthread_join(this->assigned_thread, NULL);
this->logger->log(this->logger, CONTROL | LEVEL1, "Scheduler thread terminated");
- allocator_free(this);
+ free(this);
}
/*
@@ -106,18 +105,18 @@ static void destroy(private_scheduler_t *this)
*/
scheduler_t * scheduler_create()
{
- private_scheduler_t *this = allocator_alloc_thing(private_scheduler_t);
+ private_scheduler_t *this = malloc_thing(private_scheduler_t);
this->public.destroy = (void(*)(scheduler_t*)) destroy;
this->get_events = get_events;
- this->logger = charon->logger_manager->get_logger(charon->logger_manager, SCHEDULER);
+ this->logger = logger_manager->get_logger(logger_manager, SCHEDULER);
if (pthread_create(&(this->assigned_thread), NULL, (void*(*)(void*))this->get_events, this) != 0)
{
/* thread could not be created */
this->logger->log(this->logger, ERROR, "Scheduler thread could not be created!");
- allocator_free(this);
+ free(this);
charon->kill(charon, "Unable to create scheduler thread");
}
diff --git a/Source/charon/threads/sender.c b/Source/charon/threads/sender.c
index 90d9e409c..42d11beb9 100644
--- a/Source/charon/threads/sender.c
+++ b/Source/charon/threads/sender.c
@@ -29,7 +29,6 @@
#include <network/socket.h>
#include <network/packet.h>
#include <queues/send_queue.h>
-#include <utils/allocator.h>
#include <utils/logger_manager.h>
@@ -101,7 +100,7 @@ static void destroy(private_sender_t *this)
pthread_join(this->assigned_thread, NULL);
this->logger->log(this->logger, CONTROL | LEVEL1, "Sender thread terminated");
- allocator_free(this);
+ free(this);
}
/*
@@ -109,17 +108,17 @@ static void destroy(private_sender_t *this)
*/
sender_t * sender_create()
{
- private_sender_t *this = allocator_alloc_thing(private_sender_t);
+ private_sender_t *this = malloc_thing(private_sender_t);
this->send_packets = send_packets;
this->public.destroy = (void(*)(sender_t*)) destroy;
- this->logger = charon->logger_manager->get_logger(charon->logger_manager, SENDER);
+ this->logger = logger_manager->get_logger(logger_manager, SENDER);
if (pthread_create(&(this->assigned_thread), NULL, (void*(*)(void*))this->send_packets, this) != 0)
{
this->logger->log(this->logger, ERROR, "Sender thread could not be created");
- allocator_free(this);
+ free(this);
charon->kill(charon, "Unable to create sender thread");
}
diff --git a/Source/charon/threads/stroke_interface.c b/Source/charon/threads/stroke_interface.c
index 4468a37cf..b95884c03 100755
--- a/Source/charon/threads/stroke_interface.c
+++ b/Source/charon/threads/stroke_interface.c
@@ -37,7 +37,6 @@
#include <types.h>
#include <daemon.h>
#include <crypto/certificate.h>
-#include <utils/allocator.h>
#include <queues/jobs/initiate_ike_sa_job.h>
@@ -97,8 +96,8 @@ static void configuration_entry_destroy (configuration_entry_t *this)
{
this->public_key->destroy(this->public_key);
}
- allocator_free(this->name);
- allocator_free(this);
+ free(this->name);
+ free(this);
}
/**
@@ -107,7 +106,7 @@ static void configuration_entry_destroy (configuration_entry_t *this)
static configuration_entry_t * configuration_entry_create(char *name, connection_t* connection, policy_t *policy,
rsa_private_key_t *private_key, rsa_public_key_t *public_key)
{
- configuration_entry_t *entry = allocator_alloc_thing(configuration_entry_t);
+ configuration_entry_t *entry = malloc_thing(configuration_entry_t);
/* functions */
entry->destroy = configuration_entry_destroy;
@@ -117,7 +116,7 @@ static configuration_entry_t * configuration_entry_create(char *name, connection
entry->policy = policy;
entry->public_key = public_key;
entry->private_key = private_key;
- entry->name = allocator_alloc(strlen(name) + 1);
+ entry->name = malloc(strlen(name) + 1);
strcpy(entry->name, name);
return entry;
@@ -627,13 +626,11 @@ static void stroke_logtype(private_stroke_t *this, stroke_msg_t *msg)
if (msg->logtype.enable)
{
- charon->logger_manager->enable_log_level(charon->logger_manager,
- context, level);
+ logger_manager->enable_log_level(logger_manager, context, level);
}
else
{
- charon->logger_manager->disable_log_level(charon->logger_manager,
- context, level);
+ logger_manager->disable_log_level(logger_manager, context, level);
}
}
@@ -677,7 +674,7 @@ static void stroke_loglevel(private_stroke_t *this, stroke_msg_t *msg)
return;
}
- charon->logger_manager->enable_log_level(charon->logger_manager, context, level);
+ logger_manager->enable_log_level(logger_manager, context, level);
}
/**
@@ -692,11 +689,18 @@ static void stroke_receive(private_stroke_t *this)
ssize_t bytes_read;
int strokefd;
FILE *strokefile;
+ int oldstate;
+
+ /* disable cancellation by default */
+ pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
while (1)
{
+ /* wait for connections, but allow thread to terminate */
+ pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
strokefd = accept(this->socket, (struct sockaddr *)&strokeaddr, &strokeaddrlen);
-
+ pthread_setcancelstate(oldstate, NULL);
+
if (strokefd < 0)
{
this->logger->log(this->logger, ERROR, "accepting stroke connection failed: %s", strerror(errno));
@@ -713,7 +717,7 @@ static void stroke_receive(private_stroke_t *this)
}
/* read message */
- msg = allocator_alloc(msg_length);
+ msg = malloc(msg_length);
bytes_read = recv(strokefd, msg, msg_length, 0);
if (bytes_read != msg_length)
{
@@ -727,7 +731,7 @@ static void stroke_receive(private_stroke_t *this)
{
this->logger->log(this->logger, ERROR, "opening stroke output channel failed:", strerror(errno));
close(strokefd);
- allocator_free(msg);
+ free(msg);
continue;
}
@@ -773,7 +777,7 @@ static void stroke_receive(private_stroke_t *this)
this->stroke_logger->destroy(this->stroke_logger);
fclose(strokefile);
close(strokefd);
- allocator_free(msg);
+ free(msg);
}
}
@@ -972,7 +976,7 @@ static status_t get_shared_secret(credential_store_t *this, identification_t *id
preshared_secret->ptr = secret;
preshared_secret->len = strlen(secret) + 1;
- *preshared_secret = allocator_clone_chunk(*preshared_secret);
+ *preshared_secret = chunk_clone(*preshared_secret);
return SUCCESS;
}
@@ -1046,6 +1050,9 @@ static void destroy(private_stroke_t *this)
configuration_entry_t *entry;
rsa_private_key_t *priv_key;
+ pthread_cancel(this->assigned_thread);
+ pthread_join(this->assigned_thread, NULL);
+
while (this->configurations->remove_first(this->configurations, (void **)&entry) == SUCCESS)
{
entry->destroy(entry);
@@ -1060,7 +1067,7 @@ static void destroy(private_stroke_t *this)
close(this->socket);
unlink(socket_addr.sun_path);
- allocator_free(this);
+ free(this);
}
/**
@@ -1078,7 +1085,7 @@ void do_nothing(void *nothing)
*/
stroke_t *stroke_create()
{
- private_stroke_t *this = allocator_alloc_thing(private_stroke_t);
+ private_stroke_t *this = malloc_thing(private_stroke_t);
mode_t old;
/* public functions */
@@ -1097,14 +1104,14 @@ stroke_t *stroke_create()
this->stroke_receive = stroke_receive;
this->get_connection_by_name = get_connection_by_name;
- this->logger = charon->logger_manager->get_logger(charon->logger_manager, CONFIG);
+ this->logger = logger_manager->get_logger(logger_manager, CONFIG);
/* set up unix socket */
this->socket = socket(AF_UNIX, SOCK_STREAM, 0);
if (this->socket == -1)
{
this->logger->log(this->logger, ERROR, "could not create whack socket");
- allocator_free(this);
+ free(this);
return NULL;
}
@@ -1113,7 +1120,7 @@ stroke_t *stroke_create()
{
this->logger->log(this->logger, ERROR, "could not bind stroke socket: %s", strerror(errno));
close(this->socket);
- allocator_free(this);
+ free(this);
return NULL;
}
umask(old);
@@ -1123,7 +1130,7 @@ stroke_t *stroke_create()
this->logger->log(this->logger, ERROR, "could not listen on stroke socket: %s", strerror(errno));
close(this->socket);
unlink(socket_addr.sun_path);
- allocator_free(this);
+ free(this);
return NULL;
}
@@ -1133,7 +1140,7 @@ stroke_t *stroke_create()
this->logger->log(this->logger, ERROR, "Could not spawn stroke thread");
close(this->socket);
unlink(socket_addr.sun_path);
- allocator_free(this);
+ free(this);
return NULL;
}
diff --git a/Source/charon/threads/thread_pool.c b/Source/charon/threads/thread_pool.c
index 1f1584ec3..4482e795f 100644
--- a/Source/charon/threads/thread_pool.c
+++ b/Source/charon/threads/thread_pool.c
@@ -35,7 +35,6 @@
#include <queues/jobs/initiate_ike_sa_job.h>
#include <queues/jobs/retransmit_request_job.h>
#include <encoding/payloads/notify_payload.h>
-#include <utils/allocator.h>
#include <utils/logger.h>
@@ -292,8 +291,10 @@ static void process_incoming_packet_job(private_thread_pool_t *this, incoming_pa
if (status == CREATED)
{
- this->worker_logger->log(this->worker_logger, CONTROL|LEVEL3, "Create Job to delete half open IKE_SA.");
- this->create_delete_half_open_ike_sa_job(this,ike_sa_id,charon->configuration->get_half_open_ike_sa_timeout(charon->configuration));
+ this->worker_logger->log(this->worker_logger, CONTROL|LEVEL3,
+ "Create Job to delete half open IKE_SA.");
+ this->create_delete_half_open_ike_sa_job(this,ike_sa_id,
+ charon->configuration->get_half_open_ike_sa_timeout(charon->configuration));
}
status = ike_sa->process_message(ike_sa, message);
@@ -349,7 +350,8 @@ static void process_initiate_ike_sa_job(private_thread_pool_t *this, initiate_ik
}
this->worker_logger->log(this->worker_logger, CONTROL|LEVEL3, "Create Job to delete half open IKE_SA.");
- this->create_delete_half_open_ike_sa_job(this,ike_sa->get_id(ike_sa),charon->configuration->get_half_open_ike_sa_timeout(charon->configuration));
+ this->create_delete_half_open_ike_sa_job(this,ike_sa->get_id(ike_sa),
+ charon->configuration->get_half_open_ike_sa_timeout(charon->configuration));
this->worker_logger->log(this->worker_logger, CONTROL|LEVEL2, "Checking in IKE SA");
status = charon->ike_sa_manager->checkin(charon->ike_sa_manager, ike_sa);
@@ -543,19 +545,25 @@ static void destroy(private_thread_pool_t *this)
int current;
/* flag thread for termination */
for (current = 0; current < this->pool_size; current++) {
- this->pool_logger->log(this->pool_logger, CONTROL, "cancelling worker a thread #%d", current+1);
+ this->pool_logger->log(this->pool_logger, CONTROL, "cancelling worker thread #%d", current+1);
pthread_cancel(this->threads[current]);
}
/* wait for all threads */
for (current = 0; current < this->pool_size; current++) {
- pthread_join(this->threads[current], NULL);
- this->pool_logger->log(this->pool_logger, CONTROL, "worker thread #%d terminated", current+1);
- }
+ if (pthread_join(this->threads[current], NULL) == 0)
+ {
+ this->pool_logger->log(this->pool_logger, CONTROL, "worker thread #%d terminated", current+1);
+ }
+ else
+ {
+ this->pool_logger->log(this->pool_logger, ERROR, "could not terminate worker thread #%d", current+1);
+ }
+ }
/* free mem */
- allocator_free(this->threads);
- allocator_free(this);
+ free(this->threads);
+ free(this);
}
/*
@@ -565,7 +573,7 @@ thread_pool_t *thread_pool_create(size_t pool_size)
{
int current;
- private_thread_pool_t *this = allocator_alloc_thing(private_thread_pool_t);
+ private_thread_pool_t *this = malloc_thing(private_thread_pool_t);
/* fill in public fields */
this->public.destroy = (void(*)(thread_pool_t*))destroy;
@@ -581,11 +589,11 @@ thread_pool_t *thread_pool_create(size_t pool_size)
this->pool_size = pool_size;
- this->threads = allocator_alloc(sizeof(pthread_t) * pool_size);
+ this->threads = malloc(sizeof(pthread_t) * pool_size);
- this->pool_logger = charon->logger_manager->get_logger(charon->logger_manager, THREAD_POOL);
+ this->pool_logger = logger_manager->get_logger(logger_manager, THREAD_POOL);
- this->worker_logger = charon->logger_manager->get_logger(charon->logger_manager, WORKER);
+ this->worker_logger = logger_manager->get_logger(logger_manager, WORKER);
/* try to create as many threads as possible, up tu pool_size */
for (current = 0; current < pool_size; current++)
@@ -600,8 +608,8 @@ thread_pool_t *thread_pool_create(size_t pool_size)
if (current == 0)
{
this->pool_logger->log(this->pool_logger, ERROR, "Could not create any thread");
- allocator_free(this->threads);
- allocator_free(this);
+ free(this->threads);
+ free(this);
return NULL;
}
/* not all threads could be created, but at least one :-/ */