]> git.ipfire.org Git - thirdparty/strongswan.git/blob - programs/charon/charon/queues/jobs/incoming_packet_job.c
- renamed get_block_size of hasher
[thirdparty/strongswan.git] / programs / charon / charon / queues / jobs / incoming_packet_job.c
1 /**
2 * @file incoming_packet_job.h
3 *
4 * @brief Implementation of incoming_packet_job_t.
5 *
6 */
7
8 /*
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 */
22
23
24 #include "incoming_packet_job.h"
25
26
27
28 typedef struct private_incoming_packet_job_t private_incoming_packet_job_t;
29
30 /**
31 * Private data of an incoming_packet_job_t Object
32 */
33 struct private_incoming_packet_job_t {
34 /**
35 * public incoming_packet_job_t interface
36 */
37 incoming_packet_job_t public;
38
39 /**
40 * Assigned packet
41 */
42 packet_t *packet;
43 };
44
45 /**
46 * Implements job_t.get_type.
47 */
48 static job_type_t get_type(private_incoming_packet_job_t *this)
49 {
50 return INCOMING_PACKET;
51 }
52
53 /**
54 * Implements incoming_packet_job_t.get_packet.
55 */
56 static packet_t *get_packet(private_incoming_packet_job_t *this)
57 {
58 return this->packet;
59 }
60
61 /**
62 * Implements job_t.destroy_all.
63 */
64 static void destroy_all(private_incoming_packet_job_t *this)
65 {
66 if (this->packet != NULL)
67 {
68 this->packet->destroy(this->packet);
69 }
70 free(this);
71 }
72
73 /**
74 * Implements job_t.destroy.
75 */
76 static void destroy(job_t *job)
77 {
78 private_incoming_packet_job_t *this = (private_incoming_packet_job_t *) job;
79 free(this);
80 }
81
82 /*
83 * Described in header
84 */
85 incoming_packet_job_t *incoming_packet_job_create(packet_t *packet)
86 {
87 private_incoming_packet_job_t *this = malloc_thing(private_incoming_packet_job_t);
88
89 /* interface functions */
90 this->public.job_interface.get_type = (job_type_t (*) (job_t *)) get_type;
91 this->public.job_interface.destroy_all = (void (*) (job_t *)) destroy_all;
92 this->public.job_interface.destroy = destroy;
93
94 /* public functions */
95 this->public.get_packet = (packet_t * (*)(incoming_packet_job_t *)) get_packet;
96 this->public.destroy = (void (*)(incoming_packet_job_t *)) destroy;
97
98 /* private variables */
99 this->packet = packet;
100
101 return &(this->public);
102 }