]>
Commit | Line | Data |
---|---|---|
df917df7 JH |
1 | /** |
2 | * @file incoming_packet_job.h | |
3 | * | |
df3c59d0 | 4 | * @brief Implementation of incoming_packet_job_t. |
df917df7 JH |
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 | ||
df917df7 | 26 | |
95c61cb9 JH |
27 | |
28 | typedef struct private_incoming_packet_job_t private_incoming_packet_job_t; | |
29 | ||
df917df7 JH |
30 | /** |
31 | * Private data of an incoming_packet_job_t Object | |
df917df7 | 32 | */ |
95c61cb9 | 33 | struct private_incoming_packet_job_t { |
df917df7 JH |
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 | ||
df917df7 | 45 | /** |
df3c59d0 | 46 | * Implements job_t.get_type. |
df917df7 JH |
47 | */ |
48 | static job_type_t get_type(private_incoming_packet_job_t *this) | |
49 | { | |
50 | return INCOMING_PACKET; | |
51 | } | |
52 | ||
53 | /** | |
df3c59d0 | 54 | * Implements incoming_packet_job_t.get_packet. |
df917df7 | 55 | */ |
df3c59d0 | 56 | static packet_t *get_packet(private_incoming_packet_job_t *this) |
df917df7 | 57 | { |
df3c59d0 | 58 | return this->packet; |
df917df7 JH |
59 | } |
60 | ||
f07a80d1 | 61 | /** |
df3c59d0 | 62 | * Implements job_t.destroy_all. |
f07a80d1 | 63 | */ |
df3c59d0 | 64 | static void destroy_all(private_incoming_packet_job_t *this) |
f07a80d1 JH |
65 | { |
66 | if (this->packet != NULL) | |
67 | { | |
68 | this->packet->destroy(this->packet); | |
69 | } | |
5113680f | 70 | free(this); |
f07a80d1 JH |
71 | } |
72 | ||
df917df7 | 73 | /** |
df3c59d0 | 74 | * Implements job_t.destroy. |
df917df7 | 75 | */ |
df3c59d0 | 76 | static void destroy(job_t *job) |
df917df7 JH |
77 | { |
78 | private_incoming_packet_job_t *this = (private_incoming_packet_job_t *) job; | |
5113680f | 79 | free(this); |
df917df7 JH |
80 | } |
81 | ||
df917df7 JH |
82 | /* |
83 | * Described in header | |
84 | */ | |
85 | incoming_packet_job_t *incoming_packet_job_create(packet_t *packet) | |
86 | { | |
5113680f | 87 | private_incoming_packet_job_t *this = malloc_thing(private_incoming_packet_job_t); |
df3c59d0 | 88 | |
df917df7 JH |
89 | /* interface functions */ |
90 | this->public.job_interface.get_type = (job_type_t (*) (job_t *)) get_type; | |
df3c59d0 | 91 | this->public.job_interface.destroy_all = (void (*) (job_t *)) destroy_all; |
df917df7 JH |
92 | this->public.job_interface.destroy = destroy; |
93 | ||
94 | /* public functions */ | |
df3c59d0 MW |
95 | this->public.get_packet = (packet_t * (*)(incoming_packet_job_t *)) get_packet; |
96 | this->public.destroy = (void (*)(incoming_packet_job_t *)) destroy; | |
df917df7 JH |
97 | |
98 | /* private variables */ | |
99 | this->packet = packet; | |
100 | ||
101 | return &(this->public); | |
102 | } |