summaryrefslogtreecommitdiff
path: root/src/charon/queues/jobs/job.h
blob: 28632672dc0b9a77fd3d77edadcb90038bcefcde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/**
 * @file job.h
 * 
 * @brief Interface job_t.
 * 
 */

/*
 * Copyright (C) 2005-2006 Martin Willi
 * Copyright (C) 2005 Jan Hutter
 * 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_

typedef enum job_type_t job_type_t;
typedef struct job_t job_t;

#include <library.h>

/**
 * @brief Definition of the various job types.
 *
 * @ingroup jobs
 */
enum job_type_t {
	/** 
	 * Process an incoming IKEv2-Message.
	 * 
 	 * Job is implemented in class process_message_job_t
	 */
	PROCESS_MESSAGE,
	
	/** 
	 * Retransmit an IKEv2-Message.
	 * 
	 * Job is implemented in class retransmit_job_t
	 */
	RETRANSMIT,
	
	/** 
	 * Set up a CHILD_SA, optional with an IKE_SA.
	 * 
	 * Job is implemented in class initiate_job_t
	 */
	INITIATE,
	
	/** 
	 * Install SPD entries.
	 * 
	 * Job is implemented in class route_job_t
	 */
	ROUTE,
	
	/** 
	 * React on a acquire message from the kernel (e.g. setup CHILD_SA)
	 * 
	 * Job is implemented in class acquire_job_t
	 */
	ACQUIRE,
	
	/** 
	 * Delete an IKE_SA.
	 * 
	 * Job is implemented in class delete_ike_sa_job_t
	 */
	DELETE_IKE_SA,
	
	/**
	 * Delete a CHILD_SA.
	 * 
	 * Job is implemented in class delete_child_sa_job_t
	 */
	DELETE_CHILD_SA,
	
	/**
	 * Rekey a CHILD_SA.
	 * 
	 * Job is implemented in class rekey_child_sa_job_t
	 */
	REKEY_CHILD_SA,
	
	/**
	 * Rekey an IKE_SA.
	 * 
	 * Job is implemented in class rekey_ike_sa_job_t
	 */
	REKEY_IKE_SA,
	
	/**
	 * Send a keepalive packet.
	 * 
	 * Job is implemented in class type send_keepalive_job_t
	 */
	SEND_KEEPALIVE,
	
	/**
	 * Send a DPD packet.
	 * 
	 * Job is implemented in class type send_dpd_job_t
	 */
	SEND_DPD
};

/**
 * enum name  for job_type_t
 * 
 * @ingroup jobs
 */
extern enum_name_t *job_type_names;


/**
 * @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 Execute a job.
	 * 
	 * Call the internall job routine to process the
	 * job. If this method returns DESTROY_ME, the job
	 * must be destroyed by the caller.
	 *
	 * @param this 				calling object
	 * @return 					status of job execution
	 */
	status_t (*execute) (job_t *this);

	/**
	 * @brief Destroys a job_t object
	 * 
	 * @param job_t calling object
	 */
	void (*destroy) (job_t *job);
};


#endif /* JOB_H_ */