This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
# 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 $@ $<
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* @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_*/
|
||||
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* @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_*/
|
||||
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* @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_*/
|
||||
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* @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_*/
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @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}
|
||||
};
|
||||
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* @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_*/
|
||||
@@ -0,0 +1,132 @@
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* @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_ */
|
||||
Reference in New Issue
Block a user