diff options
Diffstat (limited to 'Source/charon/queues')
20 files changed, 0 insertions, 2125 deletions
diff --git a/Source/charon/queues/Makefile.queues b/Source/charon/queues/Makefile.queues deleted file mode 100644 index eeb012d2b..000000000 --- a/Source/charon/queues/Makefile.queues +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (C) 2005 Jan Hutter, Martin Willi -# Hochschule fuer Technik Rapperswil -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 2 of the License, or (at your -# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# - -QUEUES_DIR= $(CHARON_DIR)queues/ - -CHARON_OBJS+= $(BUILD_DIR)event_queue.o -$(BUILD_DIR)event_queue.o : $(QUEUES_DIR)event_queue.c $(QUEUES_DIR)event_queue.h - $(CC) $(CFLAGS) -c -o $@ $< - -CHARON_OBJS+= $(BUILD_DIR)job_queue.o -$(BUILD_DIR)job_queue.o : $(QUEUES_DIR)job_queue.c $(QUEUES_DIR)job_queue.h - $(CC) $(CFLAGS) -c -o $@ $< - -CHARON_OBJS+= $(BUILD_DIR)send_queue.o -$(BUILD_DIR)send_queue.o : $(QUEUES_DIR)send_queue.c $(QUEUES_DIR)send_queue.h - $(CC) $(CFLAGS) -c -o $@ $< - - -include $(QUEUES_DIR)jobs/Makefile.jobs
\ No newline at end of file diff --git a/Source/charon/queues/event_queue.c b/Source/charon/queues/event_queue.c deleted file mode 100644 index ece9d1513..000000000 --- a/Source/charon/queues/event_queue.c +++ /dev/null @@ -1,349 +0,0 @@ -/** - * @file event_queue.c - * - * @brief Implementation of event_queue_t - * - */ - -/* - * Copyright (C) 2005 Jan Hutter, Martin Willi - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#include <pthread.h> -#include <stdlib.h> - -#include "event_queue.h" - -#include <types.h> -#include <utils/linked_list.h> - - - -typedef struct event_t event_t; - -/** - * @brief Represents an event as it is stored in the event queue. - * - * A event consists of a event time and an assigned job object. - * - */ -struct event_t{ - /** - * Time to fire the event. - */ - timeval_t time; - - /** - * Every event has its assigned job. - */ - job_t * job; - - /** - * @brief Destroys a event_t object. - * - * @param event_t calling object - */ - void (*destroy) (event_t *event); -}; - - -/** - * implements event_t.destroy - */ -static void event_destroy(event_t *event) -{ - free(event); -} - -/** - * @brief Creates a event for a specific time - * - * @param time absolute time to fire the event - * @param job job to add to job-queue at specific time - * - * @returns created event_t object - */ -static event_t *event_create(timeval_t time, job_t *job) -{ - event_t *this = malloc_thing(event_t); - - this->destroy = event_destroy; - this->time = time; - this->job = job; - - return this; -} - - -typedef struct private_event_queue_t private_event_queue_t; - -/** - * Private Variables and Functions of event_queue_t class. - * - */ -struct private_event_queue_t { - /** - * Public part. - */ - event_queue_t public; - - /** - * The events are stored in a linked list of type linked_list_t. - */ - linked_list_t *list; - - /** - * Access to linked_list is locked through this mutex. - */ - pthread_mutex_t mutex; - - /** - * If the queue is empty or an event has not to be fired - * a thread has to wait. - * - * This condvar is used to wake up such a thread. - */ - pthread_cond_t condvar; -}; - -/** - * Returns the difference of to timeval structs in microseconds - * - * @param end_time end time - * @param start_time start time - * - * @warning this function is also defined in the tester class - * In later improvements, this function can be added to a general - * class type! - * - * @return difference in microseconds (end time - start time) - */ -static long time_difference(struct timeval *end_time, struct timeval *start_time) -{ - long seconds, microseconds; - - seconds = (end_time->tv_sec - start_time->tv_sec); - microseconds = (end_time->tv_usec - start_time->tv_usec); - return ((seconds * 1000000) + microseconds); -} - - -/** - * Implements event_queue_t.get_count - */ -static int get_count (private_event_queue_t *this) -{ - int count; - pthread_mutex_lock(&(this->mutex)); - count = this->list->get_count(this->list); - pthread_mutex_unlock(&(this->mutex)); - return count; -} - -/** - * Implements event_queue_t.get - */ -static job_t *get(private_event_queue_t *this) -{ - timespec_t timeout; - timeval_t current_time; - event_t * next_event; - job_t *job; - int oldstate; - - pthread_mutex_lock(&(this->mutex)); - - while (1) - { - while(this->list->get_count(this->list) == 0) - { - /* add mutex unlock handler for cancellation, enable cancellation */ - pthread_cleanup_push((void(*)(void*))pthread_mutex_unlock, (void*)&(this->mutex)); - pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate); - - pthread_cond_wait( &(this->condvar), &(this->mutex)); - - /* reset cancellation, remove mutex-unlock handler (without executing) */ - pthread_setcancelstate(oldstate, NULL); - pthread_cleanup_pop(0); - } - - this->list->get_first(this->list,(void **) &next_event); - - gettimeofday(¤t_time,NULL); - long difference = time_difference(¤t_time,&(next_event->time)); - if (difference <= 0) - { - timeout.tv_sec = next_event->time.tv_sec; - timeout.tv_nsec = next_event->time.tv_usec * 1000; - - /* add mutex unlock handler for cancellation, enable cancellation */ - pthread_cleanup_push((void(*)(void*))pthread_mutex_unlock, (void*)&(this->mutex)); - pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate); - - pthread_cond_timedwait( &(this->condvar), &(this->mutex),&timeout); - - /* reset cancellation, remove mutex-unlock handler (without executing) */ - pthread_setcancelstate(oldstate, NULL); - pthread_cleanup_pop(0); - } - else - { - /* event available */ - this->list->remove_first(this->list,(void **) &next_event); - - job = next_event->job; - - next_event->destroy(next_event); - break; - } - - } - pthread_cond_signal( &(this->condvar)); - - pthread_mutex_unlock(&(this->mutex)); - - return job; -} - -/** - * Implements function add_absolute of event_queue_t. - * See #event_queue_s.add_absolute for description. - */ -static void add_absolute(private_event_queue_t *this, job_t *job, timeval_t time) -{ - event_t *event = event_create(time,job); - event_t *current_event; - status_t status; - - pthread_mutex_lock(&(this->mutex)); - - /* while just used to break out */ - while(1) - { - if (this->list->get_count(this->list) == 0) - { - this->list->insert_first(this->list,event); - break; - } - - /* check last entry */ - this->list->get_last(this->list,(void **) ¤t_event); - - if (time_difference(&(event->time), &(current_event->time)) >= 0) - { - /* my event has to be fired after the last event in list */ - this->list->insert_last(this->list,event); - break; - } - - /* check first entry */ - this->list->get_first(this->list,(void **) ¤t_event); - - if (time_difference(&(event->time), &(current_event->time)) < 0) - { - /* my event has to be fired before the first event in list */ - this->list->insert_first(this->list,event); - break; - } - - iterator_t * iterator; - - iterator = this->list->create_iterator(this->list,TRUE); - - iterator->has_next(iterator); - /* first element has not to be checked (already done) */ - - while(iterator->has_next(iterator)) - { - status = iterator->current(iterator,(void **) ¤t_event); - - if (time_difference(&(event->time), &(current_event->time)) <= 0) - { - /* my event has to be fired before the current event in list */ - iterator->insert_before(iterator,event); - break; - } - } - iterator->destroy(iterator); - break; - } - - pthread_cond_signal( &(this->condvar)); - pthread_mutex_unlock(&(this->mutex)); -} - -/** - * Implements event_queue_t.add_relative. - */ -static void add_relative(event_queue_t *this, job_t *job, u_int32_t ms) -{ - timeval_t current_time; - timeval_t time; - int micros = ms * 1000; - - gettimeofday(¤t_time, NULL); - - time.tv_usec = ((current_time.tv_usec + micros) % 1000000); - time.tv_sec = current_time.tv_sec + ((current_time.tv_usec + micros)/ 1000000); - - this->add_absolute(this, job, time); -} - - -/** - * Implements event_queue_t.destroy. - */ -static void event_queue_destroy(private_event_queue_t *this) -{ - while (this->list->get_count(this->list) > 0) - { - event_t *event; - - if (this->list->remove_first(this->list,(void *) &event) != SUCCESS) - { - this->list->destroy(this->list); - break; - } - event->job->destroy_all(event->job); - event->destroy(event); - } - this->list->destroy(this->list); - - pthread_mutex_destroy(&(this->mutex)); - - pthread_cond_destroy(&(this->condvar)); - - free(this); -} - -/* - * Documented in header - */ -event_queue_t *event_queue_create() -{ - 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; - this->public.add_absolute = (void (*) (event_queue_t *event_queue, job_t *job, timeval_t time)) add_absolute; - this->public.add_relative = (void (*) (event_queue_t *event_queue, job_t *job, u_int32_t ms)) add_relative; - this->public.destroy = (void (*) (event_queue_t *event_queue)) event_queue_destroy; - - this->list = linked_list_create(); - pthread_mutex_init(&(this->mutex), NULL); - pthread_cond_init(&(this->condvar), NULL); - - return (&this->public); -} diff --git a/Source/charon/queues/event_queue.h b/Source/charon/queues/event_queue.h deleted file mode 100644 index a60424100..000000000 --- a/Source/charon/queues/event_queue.h +++ /dev/null @@ -1,117 +0,0 @@ -/** - * @file event_queue.h - * - * @brief Interface of job_queue_t. - * - */ - -/* - * Copyright (C) 2005 Jan Hutter, Martin Willi - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#ifndef EVENT_QUEUE_H_ -#define EVENT_QUEUE_H_ - -#include <sys/time.h> - -#include <types.h> -#include <queues/jobs/job.h> - -typedef struct event_queue_t event_queue_t; - -/** - * @brief Event-Queue used to store timed events. - * - * Added events are sorted. The get method blocks until - * the time is elapsed to process the next event. The get - * method is called from the scheduler_t thread, which - * will add the jobs to to job_queue_t for further processing. - * - * Although the event-queue is based on a linked_list_t - * all access functions are thread-save implemented. - * - * @b Constructors: - * - event_queue_create() - * - * @ingroup queues - */ -struct event_queue_t { - - /** - * @brief Returns number of events in queue. - * - * @param event_queue calling object - * @return number of events in queue - */ - int (*get_count) (event_queue_t *event_queue); - - /** - * @brief Get the next job from the event-queue. - * - * If no event is pending, this function blocks until a job can be returned. - * - * @param event_queue calling object - * @param[out] job pointer to a job pointer where to job is returned to - * @return next job - */ - job_t *(*get) (event_queue_t *event_queue); - - /** - * @brief Adds a event to the queue, using a relative time. - * - * This function is non blocking and adds a job_t at a specific time to the list. - * The specific job object has to get destroyed by the thread which - * removes the job. - * - * @param event_queue calling object - * @param[in] job job to add to the queue (job is not copied) - * @param[in] time relative time, when the event has to get fired - */ - void (*add_relative) (event_queue_t *event_queue, job_t *job, u_int32_t ms); - - /** - * @brief Adds a event to the queue, using an absolute time. - * - * This function is non blocking and adds a job_t at a specific time to the list. - * The specific job object has to get destroyed by the thread which - * removes the job. - * - * @param event_queue calling object - * @param[in] job job to add to the queue (job is not copied) - * @param[in] absolute time time, when the event has to get fired - */ - void (*add_absolute) (event_queue_t *event_queue, job_t *job, timeval_t time); - - /** - * @brief Destroys a event_queue object. - * - * @warning The caller of this function has to make sure - * that no thread is going to add or get an event from the event_queue - * after calling this function. - * - * @param event_queue calling object - */ - void (*destroy) (event_queue_t *event_queue); -}; - -/** - * @brief Creates an empty event_queue. - * - * @returns event_queue_t object - * - * @ingroup queues - */ -event_queue_t *event_queue_create(); - -#endif /*EVENT_QUEUE_H_*/ diff --git a/Source/charon/queues/job_queue.c b/Source/charon/queues/job_queue.c deleted file mode 100644 index 3640395ab..000000000 --- a/Source/charon/queues/job_queue.c +++ /dev/null @@ -1,153 +0,0 @@ -/** - * @file job_queue.c - * - * @brief Implementation of job_queue_t - * - */ - -/* - * Copyright (C) 2005 Jan Hutter, Martin Willi - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#include <stdlib.h> -#include <pthread.h> - -#include "job_queue.h" - -#include <utils/linked_list.h> - - -typedef struct private_job_queue_t private_job_queue_t; - -/** - * @brief Private Variables and Functions of job_queue class - * - */ -struct private_job_queue_t { - - /** - * public members - */ - job_queue_t public; - - /** - * The jobs are stored in a linked list - */ - linked_list_t *list; - - /** - * access to linked_list is locked through this mutex - */ - pthread_mutex_t mutex; - - /** - * If the queue is empty a thread has to wait - * This condvar is used to wake up such a thread - */ - pthread_cond_t condvar; -}; - - -/** - * implements job_queue_t.get_count - */ -static int get_count(private_job_queue_t *this) -{ - int count; - pthread_mutex_lock(&(this->mutex)); - count = this->list->get_count(this->list); - pthread_mutex_unlock(&(this->mutex)); - return count; -} - -/** - * implements job_queue_t.get - */ -static job_t *get(private_job_queue_t *this) -{ - int oldstate; - job_t *job; - pthread_mutex_lock(&(this->mutex)); - /* go to wait while no jobs available */ - while(this->list->get_count(this->list) == 0) - { - /* add mutex unlock handler for cancellation, enable cancellation */ - pthread_cleanup_push((void(*)(void*))pthread_mutex_unlock, (void*)&(this->mutex)); - pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate); - - pthread_cond_wait( &(this->condvar), &(this->mutex)); - - /* reset cancellation, remove mutex-unlock handler (without executing) */ - pthread_setcancelstate(oldstate, NULL); - pthread_cleanup_pop(0); - } - this->list->remove_first(this->list,(void **) &job); - pthread_mutex_unlock(&(this->mutex)); - return job; -} - -/** - * implements function job_queue_t.add - */ -static void add(private_job_queue_t *this, job_t *job) -{ - pthread_mutex_lock(&(this->mutex)); - this->list->insert_last(this->list,job); - pthread_cond_signal( &(this->condvar)); - pthread_mutex_unlock(&(this->mutex)); -} - -/** - * implements job_queue_t.destroy - */ -static void job_queue_destroy (private_job_queue_t *this) -{ - while (this->list->get_count(this->list) > 0) - { - job_t *job; - if (this->list->remove_first(this->list,(void *) &job) != SUCCESS) - { - this->list->destroy(this->list); - break; - } - job->destroy_all(job); - } - this->list->destroy(this->list); - - pthread_mutex_destroy(&(this->mutex)); - - pthread_cond_destroy(&(this->condvar)); - - free(this); -} - -/* - * - * Documented in header - */ -job_queue_t *job_queue_create() -{ - 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; - this->public.add = (void(*)(job_queue_t*, job_t*))add; - this->public.destroy = (void(*)(job_queue_t*))job_queue_destroy; - - this->list = linked_list_create(); - pthread_mutex_init(&(this->mutex), NULL); - pthread_cond_init(&(this->condvar), NULL); - - return (&this->public); -} diff --git a/Source/charon/queues/job_queue.h b/Source/charon/queues/job_queue.h deleted file mode 100644 index 9fcf08001..000000000 --- a/Source/charon/queues/job_queue.h +++ /dev/null @@ -1,99 +0,0 @@ -/** - * @file job_queue.h - * - * @brief Interface of job_queue_t. - * - */ - -/* - * Copyright (C) 2005 Jan Hutter, Martin Willi - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#ifndef JOB_QUEUE_H_ -#define JOB_QUEUE_H_ - -#include <types.h> -#include <queues/jobs/job.h> - -typedef struct job_queue_t job_queue_t; - -/** - * @brief The job queue stores jobs, which will be processed by the thread_pool_t. - * - * Jobs are added from various sources, from the threads and - * from the event_queue_t. - * Although the job-queue is based on a linked_list_t - * all access functions are thread-save implemented. - * - * @b Constructors: - * - job_queue_create() - * - * @ingroup queues - */ -struct job_queue_t { - - /** - * @brief Returns number of jobs in queue. - * - * @param job_queue_t calling object - * @returns number of items in queue - */ - int (*get_count) (job_queue_t *job_queue); - - /** - * @brief Get the next job from the queue. - * - * If the queue is empty, this function blocks until a job can be returned. - * After using, the returned job has to get destroyed by the caller. - * - * @param job_queue_t calling object - * @param[out] job pointer to a job pointer where to job is returned to - * @return next job - */ - job_t *(*get) (job_queue_t *job_queue); - - /** - * @brief Adds a job to the queue. - * - * This function is non blocking and adds a job_t to the list. - * The specific job object has to get destroyed by the thread which - * removes the job. - * - * @param job_queue_t calling object - * @param job job to add to the queue (job is not copied) - */ - void (*add) (job_queue_t *job_queue, job_t *job); - - /** - * @brief Destroys a job_queue object. - * - * @warning The caller of this function has to make sure - * that no thread is going to add or get a job from the job_queue - * after calling this function. - * - * @param job_queue_t calling object - */ - void (*destroy) (job_queue_t *job_queue); -}; - -/** - * @brief Creates an empty job_queue. - * - * @return job_queue_t object - * - * @ingroup queues - */ -job_queue_t *job_queue_create(); - -#endif /*JOB_QUEUE_H_*/ diff --git a/Source/charon/queues/jobs/Makefile.jobs b/Source/charon/queues/jobs/Makefile.jobs deleted file mode 100644 index db89987bc..000000000 --- a/Source/charon/queues/jobs/Makefile.jobs +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright (C) 2005 Jan Hutter, Martin Willi -# Hochschule fuer Technik Rapperswil -# -# This program is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 2 of the License, or (at your -# option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# - -JOBS_DIR= $(QUEUES_DIR)jobs/ - -CHARON_OBJS+= $(BUILD_DIR)delete_half_open_ike_sa_job.o -$(BUILD_DIR)delete_half_open_ike_sa_job.o : $(JOBS_DIR)delete_half_open_ike_sa_job.c $(JOBS_DIR)delete_half_open_ike_sa_job.h - $(CC) $(CFLAGS) -c -o $@ $< - -CHARON_OBJS+= $(BUILD_DIR)delete_established_ike_sa_job.o -$(BUILD_DIR)delete_established_ike_sa_job.o : $(JOBS_DIR)delete_established_ike_sa_job.c $(JOBS_DIR)delete_established_ike_sa_job.h - $(CC) $(CFLAGS) -c -o $@ $< - -CHARON_OBJS+= $(BUILD_DIR)incoming_packet_job.o -$(BUILD_DIR)incoming_packet_job.o : $(JOBS_DIR)incoming_packet_job.c $(JOBS_DIR)incoming_packet_job.h - $(CC) $(CFLAGS) -c -o $@ $< - -CHARON_OBJS+= $(BUILD_DIR)initiate_ike_sa_job.o -$(BUILD_DIR)initiate_ike_sa_job.o : $(JOBS_DIR)initiate_ike_sa_job.c $(JOBS_DIR)initiate_ike_sa_job.h - $(CC) $(CFLAGS) -c -o $@ $< - -CHARON_OBJS+= $(BUILD_DIR)retransmit_request_job.o -$(BUILD_DIR)retransmit_request_job.o : $(JOBS_DIR)retransmit_request_job.c $(JOBS_DIR)retransmit_request_job.h - $(CC) $(CFLAGS) -c -o $@ $< - -CHARON_OBJS+= $(BUILD_DIR)job.o -$(BUILD_DIR)job.o : $(JOBS_DIR)job.c $(JOBS_DIR)job.h - $(CC) $(CFLAGS) -c -o $@ $< -
\ No newline at end of file diff --git a/Source/charon/queues/jobs/delete_established_ike_sa_job.c b/Source/charon/queues/jobs/delete_established_ike_sa_job.c deleted file mode 100644 index 7251e2ca4..000000000 --- a/Source/charon/queues/jobs/delete_established_ike_sa_job.c +++ /dev/null @@ -1,90 +0,0 @@ -/** - * @file delete_established_ike_sa_job.c - * - * @brief Implementation of delete_established_ike_sa_job_t. - * - */ - -/* - * Copyright (C) 2005 Jan Hutter, Martin Willi - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#include "delete_established_ike_sa_job.h" - - - -typedef struct private_delete_established_ike_sa_job_t private_delete_established_ike_sa_job_t; - -/** - * Private data of an delete_established_ike_sa_job_t object. - */ -struct private_delete_established_ike_sa_job_t { - /** - * Public delete_established_ike_sa_job_t interface. - */ - delete_established_ike_sa_job_t public; - - /** - * ID of the ike_sa to delete. - */ - ike_sa_id_t *ike_sa_id; -}; - -/** - * Implementation of job_t.get_type. - */ -static job_type_t get_type(private_delete_established_ike_sa_job_t *this) -{ - return DELETE_ESTABLISHED_IKE_SA; -} - -/** - * Implementation of delete_established_ike_sa_job_t.get_ike_sa_id - */ -static ike_sa_id_t *get_ike_sa_id(private_delete_established_ike_sa_job_t *this) -{ - return this->ike_sa_id; -} - -/** - * Implementation of job_t.destroy. - */ -static void destroy(private_delete_established_ike_sa_job_t *this) -{ - this->ike_sa_id->destroy(this->ike_sa_id); - free(this); -} - -/* - * Described in header - */ -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 = malloc_thing(private_delete_established_ike_sa_job_t); - - /* interface functions */ - this->public.job_interface.get_type = (job_type_t (*) (job_t *)) get_type; - /* same as destroy */ - this->public.job_interface.destroy_all = (void (*) (job_t *)) destroy; - this->public.job_interface.destroy = (void (*)(job_t*)) destroy; - - /* public functions */ - this->public.get_ike_sa_id = (ike_sa_id_t * (*)(delete_established_ike_sa_job_t *)) get_ike_sa_id; - this->public.destroy = (void (*)(delete_established_ike_sa_job_t *)) destroy; - - /* private variables */ - this->ike_sa_id = ike_sa_id->clone(ike_sa_id); - - return &(this->public); -} diff --git a/Source/charon/queues/jobs/delete_established_ike_sa_job.h b/Source/charon/queues/jobs/delete_established_ike_sa_job.h deleted file mode 100644 index 762dceae6..000000000 --- a/Source/charon/queues/jobs/delete_established_ike_sa_job.h +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @file delete_established_ike_sa_job.h - * - * @brief Interface of delete_established_ike_sa_job_t. - * - */ - -/* - * Copyright (C) 2005 Jan Hutter, Martin Willi - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#ifndef DELETE_ESTABLISHED_IKE_SA_JOB_H_ -#define DELETE_ESTABLISHED_IKE_SA_JOB_H_ - -#include <types.h> -#include <sa/ike_sa_id.h> -#include <queues/jobs/job.h> - - -typedef struct delete_established_ike_sa_job_t delete_established_ike_sa_job_t; - -/** - * @brief Class representing an DELETE_ESTABLISHED_IKE_SA Job. - * - * This job initiates the deletion of an IKE_SA. The SA - * to delete is specified via an ike_sa_id_t. - * - * @b Constructors: - * - delete_established_ike_sa_job_create() - * - * @ingroup jobs - */ -struct delete_established_ike_sa_job_t { - /** - * The job_t interface. - */ - job_t job_interface; - - /** - * @brief Returns the currently set ike_sa_id. - * - * @warning Returned object is not copied. - * - * @param this calling delete_established_ike_sa_job_t object - * @return ike_sa_id_t object - */ - ike_sa_id_t * (*get_ike_sa_id) (delete_established_ike_sa_job_t *this); - - /** - * @brief Destroys an delete_established_ike_sa_job_t object (including assigned data). - * - * @param this delete_established_ike_sa_job_t object to destroy - */ - void (*destroy) (delete_established_ike_sa_job_t *this); -}; - -/** - * @brief Creates a job of type DELETE_ESTABLISHED_IKE_SA. - * - * @param ike_sa_id id of the IKE_SA to delete - * @return delete_established_ike_sa_job_t object - * - * @ingroup jobs - */ -delete_established_ike_sa_job_t *delete_established_ike_sa_job_create(ike_sa_id_t *ike_sa_id); - -#endif /*DELETE_ESTABLISHED_IKE_SA_JOB_H_*/ 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 deleted file mode 100644 index 610285e20..000000000 --- a/Source/charon/queues/jobs/delete_half_open_ike_sa_job.c +++ /dev/null @@ -1,90 +0,0 @@ -/** - * @file delete_half_open_ike_sa_job.c - * - * @brief Implementation of delete_half_open_ike_sa_job_t. - * - */ - -/* - * Copyright (C) 2005 Jan Hutter, Martin Willi - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#include "delete_half_open_ike_sa_job.h" - - - -typedef struct private_delete_half_open_ike_sa_job_t private_delete_half_open_ike_sa_job_t; - -/** - * Private data of an delete_half_open_ike_sa_job_t Object - */ -struct private_delete_half_open_ike_sa_job_t { - /** - * public delete_half_open_ike_sa_job_t interface - */ - delete_half_open_ike_sa_job_t public; - - /** - * ID of the ike_sa to delete - */ - ike_sa_id_t *ike_sa_id; -}; - -/** - * Implements job_t.get_type. - */ -static job_type_t get_type(private_delete_half_open_ike_sa_job_t *this) -{ - return DELETE_HALF_OPEN_IKE_SA; -} - -/** - * Implements elete_ike_sa_job_t.get_ike_sa_id - */ -static ike_sa_id_t *get_ike_sa_id(private_delete_half_open_ike_sa_job_t *this) -{ - return this->ike_sa_id; -} - -/** - * Implements job_t.destroy. - */ -static void destroy(private_delete_half_open_ike_sa_job_t *this) -{ - this->ike_sa_id->destroy(this->ike_sa_id); - free(this); -} - -/* - * Described in header - */ -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 = 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; - /* same as destroy */ - this->public.job_interface.destroy_all = (void (*) (job_t *)) destroy; - this->public.job_interface.destroy = (void (*)(job_t *)) destroy;; - - /* public functions */ - this->public.get_ike_sa_id = (ike_sa_id_t * (*)(delete_half_open_ike_sa_job_t *)) get_ike_sa_id; - this->public.destroy = (void (*)(delete_half_open_ike_sa_job_t *)) destroy; - - /* private variables */ - this->ike_sa_id = ike_sa_id->clone(ike_sa_id); - - return &(this->public); -} diff --git a/Source/charon/queues/jobs/delete_half_open_ike_sa_job.h b/Source/charon/queues/jobs/delete_half_open_ike_sa_job.h deleted file mode 100644 index ea42be8f2..000000000 --- a/Source/charon/queues/jobs/delete_half_open_ike_sa_job.h +++ /dev/null @@ -1,79 +0,0 @@ -/** - * @file delete_half_open_ike_sa_job.h - * - * @brief Interface of delete_half_open_ike_sa_job_t. - * - */ - -/* - * Copyright (C) 2005 Jan Hutter, Martin Willi - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#ifndef DELETE_HALF_OPEN_IKE_SA_JOB_H_ -#define DELETE_HALF_OPEN_IKE_SA_JOB_H_ - -#include <types.h> -#include <sa/ike_sa_id.h> -#include <queues/jobs/job.h> - - -typedef struct delete_half_open_ike_sa_job_t delete_half_open_ike_sa_job_t; - -/** - * @brief Class representing an DELETE_HALF_OPEN_IKE_SA Job. - * - * This job is responsible for deleting of half open IKE_SAs. A half - * open IKE_SA is every IKE_SA which hasn't reache the ike_sa_established - * state. - * - * @b Constructors: - * - delete_half_open_ike_sa_job_create() - * - * @ingroup jobs - */ -struct delete_half_open_ike_sa_job_t { - /** - * The job_t interface. - */ - job_t job_interface; - - /** - * @brief Returns the currently set ike_sa_id. - * - * @warning Returned object is not copied. - * - * @param this calling delete_half_open_ike_sa_job_t object - * @return ike_sa_id_t object - */ - ike_sa_id_t * (*get_ike_sa_id) (delete_half_open_ike_sa_job_t *this); - - /** - * @brief Destroys an delete_half_open_ike_sa_job_t object (including assigned data). - * - * @param this delete_half_open_ike_sa_job_t object to destroy - */ - void (*destroy) (delete_half_open_ike_sa_job_t *this); -}; - -/** - * @brief Creates a job of type DELETE_HALF_OPEN_IKE_SA. - * - * @param ike_sa_id id of the IKE_SA to delete - * @return created delete_half_open_ike_sa_job_t object - * - * @ingroup jobs - */ -delete_half_open_ike_sa_job_t *delete_half_open_ike_sa_job_create(ike_sa_id_t *ike_sa_id); - -#endif /*DELETE_HALF_OPEN_IKE_SA_JOB_H_*/ diff --git a/Source/charon/queues/jobs/incoming_packet_job.c b/Source/charon/queues/jobs/incoming_packet_job.c deleted file mode 100644 index fc71f63ea..000000000 --- a/Source/charon/queues/jobs/incoming_packet_job.c +++ /dev/null @@ -1,102 +0,0 @@ -/** - * @file incoming_packet_job.h - * - * @brief Implementation of incoming_packet_job_t. - * - */ - -/* - * Copyright (C) 2005 Jan Hutter, Martin Willi - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - - -#include "incoming_packet_job.h" - - - -typedef struct private_incoming_packet_job_t private_incoming_packet_job_t; - -/** - * Private data of an incoming_packet_job_t Object - */ -struct private_incoming_packet_job_t { - /** - * public incoming_packet_job_t interface - */ - incoming_packet_job_t public; - - /** - * Assigned packet - */ - packet_t *packet; -}; - -/** - * Implements job_t.get_type. - */ -static job_type_t get_type(private_incoming_packet_job_t *this) -{ - return INCOMING_PACKET; -} - -/** - * Implements incoming_packet_job_t.get_packet. - */ -static packet_t *get_packet(private_incoming_packet_job_t *this) -{ - return this->packet; -} - -/** - * Implements job_t.destroy_all. - */ -static void destroy_all(private_incoming_packet_job_t *this) -{ - if (this->packet != NULL) - { - this->packet->destroy(this->packet); - } - free(this); -} - -/** - * Implements job_t.destroy. - */ -static void destroy(job_t *job) -{ - private_incoming_packet_job_t *this = (private_incoming_packet_job_t *) job; - free(this); -} - -/* - * Described in header - */ -incoming_packet_job_t *incoming_packet_job_create(packet_t *packet) -{ - 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; - this->public.job_interface.destroy_all = (void (*) (job_t *)) destroy_all; - this->public.job_interface.destroy = destroy; - - /* public functions */ - this->public.get_packet = (packet_t * (*)(incoming_packet_job_t *)) get_packet; - this->public.destroy = (void (*)(incoming_packet_job_t *)) destroy; - - /* private variables */ - this->packet = packet; - - return &(this->public); -} diff --git a/Source/charon/queues/jobs/incoming_packet_job.h b/Source/charon/queues/jobs/incoming_packet_job.h deleted file mode 100644 index e3fb5797e..000000000 --- a/Source/charon/queues/jobs/incoming_packet_job.h +++ /dev/null @@ -1,78 +0,0 @@ -/** - * @file incoming_packet_job.h - * - * @brief Interface of incoming_packet_job_t. - * - */ - -/* - * Copyright (C) 2005 Jan Hutter, Martin Willi - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#ifndef INCOMING_PACKET_JOB_H_ -#define INCOMING_PACKET_JOB_H_ - -#include <types.h> -#include <network/packet.h> -#include <queues/jobs/job.h> - - -typedef struct incoming_packet_job_t incoming_packet_job_t; - -/** - * @brief Class representing an INCOMING_PACKET Job. - * - * An incoming pack job is created from the receiver, which has - * read a packet to process from the socket. - * - * @b Constructors: - * - incoming_packet_job_create() - * - * @ingroup jobs - */ -struct incoming_packet_job_t { - /** - * implements job_t interface - */ - job_t job_interface; - - /** - * @brief Returns the assigned packet_t object - * - * @warning Returned packet is not cloned and has to get destroyed by the caller. - * - * @param this calling incoming_packet_job_t object - * @return assigned packet - */ - packet_t *(*get_packet) (incoming_packet_job_t *this); - - /** - * @brief Destroys an incoming_packet_job_t object. - * - * @param this incoming_packet_job_t object to destroy - */ - void (*destroy) (incoming_packet_job_t *this); -}; - -/** - * @brief Creates a job of type INCOMING_PACKET - * - * @param[in] packet packet to assign with this job - * @return created incoming_packet_job_t object - * - * @ingroup jobs - */ -incoming_packet_job_t *incoming_packet_job_create(packet_t *packet); - -#endif /*INCOMING_PACKET_JOB_H_*/ diff --git a/Source/charon/queues/jobs/initiate_ike_sa_job.c b/Source/charon/queues/jobs/initiate_ike_sa_job.c deleted file mode 100644 index ac9ace36c..000000000 --- a/Source/charon/queues/jobs/initiate_ike_sa_job.c +++ /dev/null @@ -1,101 +0,0 @@ -/** - * @file initiate_ike_sa_job.c - * - * @brief Implementation of initiate_ike_sa_job_t. - * - */ - -/* - * Copyright (C) 2005 Jan Hutter, Martin Willi - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - - -#include <stdlib.h> - -#include "initiate_ike_sa_job.h" - - - -typedef struct private_initiate_ike_sa_job_t private_initiate_ike_sa_job_t; - -/** - * Private data of an initiate_ike_sa_job_t Object - */ -struct private_initiate_ike_sa_job_t { - /** - * public initiate_ike_sa_job_t interface - */ - initiate_ike_sa_job_t public; - - /** - * associated connection object to initiate - */ - connection_t *connection; -}; - - -/** - * Implements initiate_ike_sa_job_t.get_type. - */ -static job_type_t get_type(private_initiate_ike_sa_job_t *this) -{ - return INITIATE_IKE_SA; -} - -/** - * Implements initiate_ike_sa_job_t.get_configuration_name. - */ -static connection_t *get_connection(private_initiate_ike_sa_job_t *this) -{ - return this->connection; -} - -/** - * Implements job_t.destroy. - */ -static void destroy_all(private_initiate_ike_sa_job_t *this) -{ - this->connection->destroy(this->connection); - free(this); -} - -/** - * Implements job_t.destroy. - */ -static void destroy(private_initiate_ike_sa_job_t *this) -{ - free(this); -} - -/* - * Described in header - */ -initiate_ike_sa_job_t *initiate_ike_sa_job_create(connection_t *connection) -{ - 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; - this->public.job_interface.destroy_all = (void (*) (job_t *)) destroy_all; - this->public.job_interface.destroy = (void (*) (job_t *)) destroy; - - /* public functions */ - this->public.get_connection = (connection_t* (*)(initiate_ike_sa_job_t *)) get_connection; - this->public.destroy = (void (*)(initiate_ike_sa_job_t *)) destroy; - - /* private variables */ - this->connection = connection; - - return &(this->public); -} diff --git a/Source/charon/queues/jobs/initiate_ike_sa_job.h b/Source/charon/queues/jobs/initiate_ike_sa_job.h deleted file mode 100644 index cee31f07b..000000000 --- a/Source/charon/queues/jobs/initiate_ike_sa_job.h +++ /dev/null @@ -1,75 +0,0 @@ -/** - * @file initiate_ike_sa_job.h - * - * @brief Interface of initiate_ike_sa_job_t. - */ - -/* - * Copyright (C) 2005 Jan Hutter, Martin Willi - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#ifndef INITIATE_IKE_SA_JOB_H_ -#define INITIATE_IKE_SA_JOB_H_ - -#include <types.h> -#include <queues/jobs/job.h> -#include <config/connections/connection.h> - - -typedef struct initiate_ike_sa_job_t initiate_ike_sa_job_t; - -/** - * @brief Class representing an INITIATE_IKE_SA Job. - * - * This job is created if an IKE_SA should be iniated. This - * happens via a user request, or via the kernel interface. - * - * @b Constructors: - * - initiate_ike_sa_job_create() - * - * @ingroup jobs - */ -struct initiate_ike_sa_job_t { - /** - * implements job_t interface - */ - job_t job_interface; - - /** - * @brief Returns the connection_t to initialize - * - * @param this calling initiate_ike_sa_job_t object - * @return connection_t - */ - connection_t *(*get_connection) (initiate_ike_sa_job_t *this); - - /** - * @brief Destroys an initiate_ike_sa_job_t object. - * - * @param this initiate_ike_sa_job_t object to destroy - */ - void (*destroy) (initiate_ike_sa_job_t *this); -}; - -/** - * @brief Creates a job of type INITIATE_IKE_SA. - * - * @param connection connection_t to initializes - * @return initiate_ike_sa_job_t object - * - * @ingroup jobs - */ -initiate_ike_sa_job_t *initiate_ike_sa_job_create(connection_t *connection); - -#endif /*INITIATE_IKE_SA_JOB_H_*/ diff --git a/Source/charon/queues/jobs/job.c b/Source/charon/queues/jobs/job.c deleted file mode 100644 index df739f9e5..000000000 --- a/Source/charon/queues/jobs/job.c +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @file job.c - * - * @brief Interface additions to job_t. - * - */ - -/* - * Copyright (C) 2005 Jan Hutter, Martin Willi - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - - -#include "job.h" - - -mapping_t job_type_m[] = { - {INCOMING_PACKET, "INCOMING_PACKET"}, - {RETRANSMIT_REQUEST, "RETRANSMIT_REQUEST"}, - {INITIATE_IKE_SA, "INITIATE_IKE_SA"}, - {DELETE_HALF_OPEN_IKE_SA, "DELETE_HALF_OPEN_IKE_SA"}, - {DELETE_ESTABLISHED_IKE_SA, "DELETE_ESTABLISHED_IKE_SA"}, - {MAPPING_END, NULL} -}; diff --git a/Source/charon/queues/jobs/job.h b/Source/charon/queues/jobs/job.h deleted file mode 100644 index eea4da09e..000000000 --- a/Source/charon/queues/jobs/job.h +++ /dev/null @@ -1,120 +0,0 @@ -/** - * @file job.h - * - * @brief Interface job_t. - * - */ - -/* - * Copyright (C) 2005 Jan Hutter, Martin Willi - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#ifndef JOB_H_ -#define JOB_H_ - -#include <types.h> -#include <definitions.h> - - -typedef enum job_type_t job_type_t; - -/** - * @brief Definition of the various job types. - * - * @todo add more jobs, such as rekeying. - * - * @ingroup jobs - */ -enum job_type_t { - /** - * Process an incoming IKEv2-Message. - * - * Job is implemented in class type incoming_packet_job_t - */ - INCOMING_PACKET, - - /** - * Retransmit an IKEv2-Message. - */ - RETRANSMIT_REQUEST, - - /** - * Establish an ike sa as initiator. - * - * Job is implemented in class type initiate_ike_sa_job_t - */ - INITIATE_IKE_SA, - - /** - * Delete an ike sa which is still not established. - * - * Job is implemented in class type delete_half_open_ike_sa_job_t - */ - DELETE_HALF_OPEN_IKE_SA, - - /** - * Delete an ike sa which is established. - * - * Job is implemented in class type delete_established_ike_sa_job_t - */ - DELETE_ESTABLISHED_IKE_SA -}; - -/** - * string mappings for job_type_t - * - * @ingroup jobs - */ -extern mapping_t job_type_m[]; - - -typedef struct job_t job_t; - -/** - * @brief Job-Interface as it is stored in the job queue. - * - * A job consists of a job-type and one or more assigned values. - * - * @b Constructors: - * - None, use specific implementation of the interface. - * - * @ingroup jobs - */ -struct job_t { - - /** - * @brief get type of job. - * - * @param this calling object - * @return type of this job - */ - job_type_t (*get_type) (job_t *this); - - /** - * @brief Destroys a job_t object and all assigned data! - * - * @param job_t calling object - */ - void (*destroy_all) (job_t *job); - - /** - * @brief Destroys a job_t object - * - * @param job_t calling object - */ - void (*destroy) (job_t *job); -}; - - -#endif /*JOB_H_*/ diff --git a/Source/charon/queues/jobs/retransmit_request_job.c b/Source/charon/queues/jobs/retransmit_request_job.c deleted file mode 100644 index e171df5bd..000000000 --- a/Source/charon/queues/jobs/retransmit_request_job.c +++ /dev/null @@ -1,132 +0,0 @@ -/** - * @file retransmit_request_job.c - * - * @brief Implementation of retransmit_request_job_t. - * - */ - -/* - * Copyright (C) 2005 Jan Hutter, Martin Willi - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#include "retransmit_request_job.h" - - - - -typedef struct private_retransmit_request_job_t private_retransmit_request_job_t; - -/** - * Private data of an retransmit_request_job_t Object. - */ -struct private_retransmit_request_job_t { - /** - * Public retransmit_request_job_t interface. - */ - retransmit_request_job_t public; - - /** - * Message ID of the request to resend. - */ - u_int32_t message_id; - - /** - * ID of the IKE_SA which the message belongs to. - */ - ike_sa_id_t *ike_sa_id; - - /** - * Number of times a request was retransmitted - */ - u_int32_t retransmit_count; -}; - - -/** - * Implements job_t.get_type. - */ -static job_type_t get_type(private_retransmit_request_job_t *this) -{ - return RETRANSMIT_REQUEST; -} - -/** - * Implements retransmit_request_job_t.get_ike_sa_id. - */ -static ike_sa_id_t *get_ike_sa_id(private_retransmit_request_job_t *this) -{ - return this->ike_sa_id; -} - -/** - * Implements retransmit_request_job_t.get_retransmit_count. - */ -static u_int32_t get_retransmit_count(private_retransmit_request_job_t *this) -{ - return this->retransmit_count; -} - -/** - * Implements retransmit_request_job_t.increase_retransmit_count. - */ -static void increase_retransmit_count(private_retransmit_request_job_t *this) -{ - this->retransmit_count++; -} - -/** - * Implements retransmit_request_job_t.get_message_id. - */ -static u_int32_t get_message_id(private_retransmit_request_job_t *this) -{ - return this->message_id; -} - - -/** - * Implements job_t.destroy. - */ -static void destroy(private_retransmit_request_job_t *this) -{ - this->ike_sa_id->destroy(this->ike_sa_id); - free(this); -} - -/* - * Described in header. - */ -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 = malloc_thing(private_retransmit_request_job_t); - - /* interface functions */ - this->public.job_interface.get_type = (job_type_t (*) (job_t *)) get_type; - /* same as destroy */ - this->public.job_interface.destroy_all = (void (*) (job_t *)) destroy; - this->public.job_interface.destroy = (void (*) (job_t *)) destroy; - - /* public functions */ - this->public.get_ike_sa_id = (ike_sa_id_t * (*)(retransmit_request_job_t *)) get_ike_sa_id; - this->public.get_message_id = (u_int32_t (*)(retransmit_request_job_t *)) get_message_id; - this->public.destroy = (void (*)(retransmit_request_job_t *)) destroy; - this->public.get_retransmit_count = (u_int32_t (*)(retransmit_request_job_t *)) get_retransmit_count; - this->public.increase_retransmit_count = (void (*)(retransmit_request_job_t *)) increase_retransmit_count; - - /* private variables */ - this->message_id = message_id; - this->retransmit_count = 0; - this->ike_sa_id = ike_sa_id->clone(ike_sa_id); - - return &(this->public); -} diff --git a/Source/charon/queues/jobs/retransmit_request_job.h b/Source/charon/queues/jobs/retransmit_request_job.h deleted file mode 100644 index 2349d3f5e..000000000 --- a/Source/charon/queues/jobs/retransmit_request_job.h +++ /dev/null @@ -1,105 +0,0 @@ -/** - * @file retransmit_request_job.h - * - * @brief Interface of retransmit_request_job_t. - * - */ - -/* - * Copyright (C) 2005 Jan Hutter, Martin Willi - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#ifndef RESEND_MESSAGE_JOB_H_ -#define RESEND_MESSAGE_JOB_H_ - -#include <types.h> -#include <queues/jobs/job.h> -#include <sa/ike_sa_id.h> - - -typedef struct retransmit_request_job_t retransmit_request_job_t; - -/** - * @brief Class representing an RETRANSMIT_REQUEST Job. - * - * This job is scheduled every time a request is sent over the - * wire. If the response to the request is not received at schedule - * time, the retransmission will be initiated. - * - * @b Constructors: - * - retransmit_request_job_create() - * - * @ingroup jobs - */ -struct retransmit_request_job_t { - /** - * The job_t interface. - */ - job_t job_interface; - - /** - * @brief Returns the retransmit count for a specific request. - * - * @param this calling retransmit_request_job_t object - * @return retransmit count of request - */ - u_int32_t (*get_retransmit_count) (retransmit_request_job_t *this); - - /** - * @brief Increases number of retransmitt attemps. - * - * @param this calling retransmit_request_job_t object - */ - void (*increase_retransmit_count) (retransmit_request_job_t *this); - - /** - * @brief Returns the message_id of the request to be resent - * - * @param this calling retransmit_request_job_t object - * @return message id of the request to resend - */ - u_int32_t (*get_message_id) (retransmit_request_job_t *this); - - /** - * @brief Returns the ike_sa_id_t object of the IKE_SA - * which the request belongs to - * - * @warning returned ike_sa_id_t object is getting destroyed in - * retransmit_request_job_t.destroy. - * - * @param this calling retransmit_request_job_t object - * @return ike_sa_id_t object to identify IKE_SA (gets NOT cloned) - */ - ike_sa_id_t *(*get_ike_sa_id) (retransmit_request_job_t *this); - - /** - * @brief Destroys an retransmit_request_job_t object. - * - * @param this retransmit_request_job_t object to destroy - */ - void (*destroy) (retransmit_request_job_t *this); -}; - -/** - * @brief Creates a job of type RETRANSMIT_REQUEST. - * - * @param message_id message_id of the request to resend - * @param ike_sa_id identification of the ike_sa as ike_sa_id_t object (gets cloned) - * @return retransmit_request_job_t object - * - * @ingroup jobs - */ -retransmit_request_job_t *retransmit_request_job_create(u_int32_t message_id,ike_sa_id_t *ike_sa_id); - -#endif /* RESEND_MESSAGE_JOB_H_ */ diff --git a/Source/charon/queues/send_queue.c b/Source/charon/queues/send_queue.c deleted file mode 100644 index 0852e5303..000000000 --- a/Source/charon/queues/send_queue.c +++ /dev/null @@ -1,153 +0,0 @@ -/** - * @file send_queue.c - * - * @brief Implementation of send_queue_t. - * - */ - -/* - * Copyright (C) 2005 Jan Hutter, Martin Willi - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#include <pthread.h> - -#include "send_queue.h" - -#include <utils/linked_list.h> - - -typedef struct private_send_queue_t private_send_queue_t; - -/** - * @brief Private Variables and Functions of send_queue class - * - */ -struct private_send_queue_t { - /** - * Public part of the send_queue_t object - */ - send_queue_t public; - - /** - * The packets are stored in a linked list - */ - linked_list_t *list; - - /** - * access to linked_list is locked through this mutex - */ - pthread_mutex_t mutex; - - /** - * If the queue is empty a thread has to wait - * This condvar is used to wake up such a thread - */ - pthread_cond_t condvar; -}; - - -/** - * implements send_queue_t.get_count - */ -static int get_count(private_send_queue_t *this) -{ - int count; - pthread_mutex_lock(&(this->mutex)); - count = this->list->get_count(this->list); - pthread_mutex_unlock(&(this->mutex)); - return count; -} - -/** - * implements send_queue_t.get - */ -static packet_t *get(private_send_queue_t *this) -{ - int oldstate; - packet_t *packet; - pthread_mutex_lock(&(this->mutex)); - /* go to wait while no packets available */ - - while(this->list->get_count(this->list) == 0) - { - /* add mutex unlock handler for cancellation, enable cancellation */ - pthread_cleanup_push((void(*)(void*))pthread_mutex_unlock, (void*)&(this->mutex)); - pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate); - pthread_cond_wait( &(this->condvar), &(this->mutex)); - - /* reset cancellation, remove mutex-unlock handler (without executing) */ - pthread_setcancelstate(oldstate, NULL); - pthread_cleanup_pop(0); - } - this->list->remove_first(this->list,(void **)&packet); - pthread_mutex_unlock(&(this->mutex)); - return packet; -} - -/** - * implements send_queue_t.add - */ -static void add(private_send_queue_t *this, packet_t *packet) -{ - pthread_mutex_lock(&(this->mutex)); - this->list->insert_last(this->list,packet); - pthread_cond_signal( &(this->condvar)); - pthread_mutex_unlock(&(this->mutex)); -} - -/** - * implements send_queue_t.destroy - */ -static void destroy (private_send_queue_t *this) -{ - - /* destroy all packets in list before destroying list */ - while (this->list->get_count(this->list) > 0) - { - packet_t *packet; - if (this->list->remove_first(this->list,(void *) &packet) != SUCCESS) - { - this->list->destroy(this->list); - break; - } - packet->destroy(packet); - } - this->list->destroy(this->list); - - pthread_mutex_destroy(&(this->mutex)); - - pthread_cond_destroy(&(this->condvar)); - - free(this); -} - -/* - * - * Documented in header - */ -send_queue_t *send_queue_create() -{ - 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; - this->public.add = (void(*)(send_queue_t*, packet_t*)) add; - this->public.destroy = (void(*)(send_queue_t*)) destroy; - - this->list = linked_list_create(); - pthread_mutex_init(&(this->mutex), NULL); - pthread_cond_init(&(this->condvar), NULL); - - return (&this->public); -} diff --git a/Source/charon/queues/send_queue.h b/Source/charon/queues/send_queue.h deleted file mode 100644 index 6dc5867eb..000000000 --- a/Source/charon/queues/send_queue.h +++ /dev/null @@ -1,100 +0,0 @@ -/** - * @file send_queue.h - * - * @brief Interface of send_queue_t. - * - */ - -/* - * Copyright (C) 2005 Jan Hutter, Martin Willi - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#ifndef SEND_QUEUE_H_ -#define SEND_QUEUE_H_ - -#include <types.h> -#include <network/packet.h> - - -typedef struct send_queue_t send_queue_t; - -/** - * @brief The send queue stores packet for the sender_t instance. - * - * The sender_t will send them consequently over the wire. - * Although the send-queue is based on a linked_list_t - * all access functions are thread-save implemented. - * - * @b Constructors: - * - send_queue_create() - * - * @ingroup queues - */ -struct send_queue_t { - - /** - * @brief returns number of packets in queue - * - * @param send_queue_t calling object - * @param[out] count integer pointer to store the count in - * @returns number of items in queue - */ - int (*get_count) (send_queue_t *send_queue); - - /** - * @brief get the next packet from the queue. - * - * If the queue is empty, this function blocks until a packet can be returned. - * - * After using, the returned packet has to get destroyed by the caller. - * - * @param send_queue_t calling object - * @return next packet from the queue - */ - packet_t *(*get) (send_queue_t *send_queue); - - /** - * @brief adds a packet to the queue. - * - * This function is non blocking and adds a packet_t to the list. - * The specific packet object has to get destroyed by the thread which - * removes the packet. - * - * @param send_queue_t calling object - * @param packet packet_t to add to the queue (packet is not copied) - */ - void (*add) (send_queue_t *send_queue, packet_t *packet); - - /** - * @brief destroys a send_queue object. - * - * @warning The caller of this function has to make sure - * that no thread is going to add or get a packet from the send_queue - * after calling this function. - * - * @param send_queue_t calling object - */ - void (*destroy) (send_queue_t *send_queue); -}; - -/** - * @brief Creates an empty send_queue_t. - * - * @return send_queue_t object - * - * @ingroup queues - */ -send_queue_t *send_queue_create(); - -#endif /*SEND_QUEUE_H_*/ |