updated Doxyfile
[strongswan.git] / src / charon / network / packet.h
1 /*
2 * Copyright (C) 2005-2006 Martin Willi
3 * Copyright (C) 2005 Jan Hutter
4 * Hochschule fuer Technik Rapperswil
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 *
16 * $Id$
17 */
18
19 /**
20 * @defgroup packet packet
21 * @{ @ingroup network
22 */
23
24 #ifndef PACKET_H_
25 #define PACKET_H_
26
27 typedef struct packet_t packet_t;
28
29 #include <library.h>
30 #include <utils/host.h>
31
32 /**
33 * Abstraction of an UDP-Packet, contains data, sender and receiver.
34 */
35 struct packet_t {
36
37 /**
38 * Set the source address.
39 *
40 * Set host_t is now owned by packet_t, it will destroy
41 * it if necessary.
42 *
43 * @param source address to set as source
44 */
45 void (*set_source) (packet_t *packet, host_t *source);
46
47 /**
48 * Set the destination address.
49 *
50 * Set host_t is now owned by packet_t, it will destroy
51 * it if necessary.
52 *
53 * @param source address to set as destination
54 */
55 void (*set_destination) (packet_t *packet, host_t *destination);
56
57 /**
58 * Get the source address.
59 *
60 * Set host_t is still owned by packet_t, clone it
61 * if needed.
62 *
63 * @return source address
64 */
65 host_t *(*get_source) (packet_t *packet);
66
67 /**
68 * Get the destination address.
69 *
70 * Set host_t is still owned by packet_t, clone it
71 * if needed.
72 *
73 * @return destination address
74 */
75 host_t *(*get_destination) (packet_t *packet);
76
77 /**
78 * Get the data from the packet.
79 *
80 * The data pointed by the chunk is still owned
81 * by the packet. Clone it if needed.
82 *
83 * @return chunk containing the data
84 */
85 chunk_t (*get_data) (packet_t *packet);
86
87 /**
88 * Set the data in the packet.
89 *
90 * Supplied chunk data is now owned by the
91 * packet. It will free it.
92 *
93 * @param data chunk with data to set
94 */
95 void (*set_data) (packet_t *packet, chunk_t data);
96
97 /**
98 * Clones a packet_t object.
99 *
100 * @param clone clone of the packet
101 */
102 packet_t* (*clone) (packet_t *packet);
103
104 /**
105 * Destroy the packet, freeing contained data.
106 */
107 void (*destroy) (packet_t *packet);
108 };
109
110 /**
111 * create an empty packet
112 *
113 * @return packet_t object
114 */
115 packet_t *packet_create(void);
116
117 #endif /** PACKET_H_ @}*/