2 * @file incoming_packet_job.h
4 * @brief Job of type INCOMING_PACKET
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
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>.
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
24 #include "incoming_packet_job.h"
26 #include <utils/allocator.h>
29 * Private data of an incoming_packet_job_t Object
32 typedef struct private_incoming_packet_job_s private_incoming_packet_job_t
;
34 struct private_incoming_packet_job_s
{
36 * public incoming_packet_job_t interface
38 incoming_packet_job_t
public;
48 * Implements incoming_packet_job_t's get_type function.
49 * See #incoming_packet_job_t.get_type for description.
51 static job_type_t
get_type(private_incoming_packet_job_t
*this)
53 return INCOMING_PACKET
;
57 * Implements incoming_packet_job_t's get_configuration_name function.
58 * See #incoming_packet_job_t.get_configuration_name for description.
60 static status_t
get_packet(private_incoming_packet_job_t
*this,packet_t
**packet
)
62 if (this->packet
== NULL
)
66 *packet
= this->packet
;
73 * Implements job_t's and destroy_all function.
74 * See #job_t.destroy_all description.
76 static status_t
destroy_all(private_incoming_packet_job_t
*this)
78 if (this->packet
!= NULL
)
80 this->packet
->destroy(this->packet
);
87 * Implements job_t's and incoming_packet_job_t's destroy function.
88 * See #job_t.destroy or #incoming_packet_job_t.destroy for description.
90 static status_t
destroy(job_t
*job
)
92 private_incoming_packet_job_t
*this = (private_incoming_packet_job_t
*) job
;
101 incoming_packet_job_t
*incoming_packet_job_create(packet_t
*packet
)
103 private_incoming_packet_job_t
*this = allocator_alloc_thing(private_incoming_packet_job_t
);
109 /* interface functions */
110 this->public.job_interface
.get_type
= (job_type_t (*) (job_t
*)) get_type
;
111 this->public.job_interface
.destroy_all
= (status_t (*) (job_t
*)) destroy_all
;
112 this->public.job_interface
.destroy
= destroy
;
114 /* public functions */
115 this->public.get_packet
= (status_t (*)(incoming_packet_job_t
*,packet_t
**)) get_packet
;
116 this->public.destroy
= (status_t (*)(incoming_packet_job_t
*)) destroy
;
118 /* private variables */
119 this->packet
= packet
;
121 return &(this->public);