Queue IKEv1 INFORMATIONALS with higher priority to process notifies first
[strongswan.git] / src / libcharon / 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
17 /**
18 * @defgroup packet packet
19 * @{ @ingroup network
20 */
21
22 #ifndef PACKET_H_
23 #define PACKET_H_
24
25 typedef struct packet_t packet_t;
26
27 #include <library.h>
28 #include <utils/host.h>
29
30 /**
31 * Abstraction of an UDP-Packet, contains data, sender and receiver.
32 */
33 struct packet_t {
34
35 /**
36 * Set the source address.
37 *
38 * Set host_t is now owned by packet_t, it will destroy
39 * it if necessary.
40 *
41 * @param source address to set as source
42 */
43 void (*set_source) (packet_t *packet, host_t *source);
44
45 /**
46 * Set the destination address.
47 *
48 * Set host_t is now owned by packet_t, it will destroy
49 * it if necessary.
50 *
51 * @param source address to set as destination
52 */
53 void (*set_destination) (packet_t *packet, host_t *destination);
54
55 /**
56 * Get the source address.
57 *
58 * Set host_t is still owned by packet_t, clone it
59 * if needed.
60 *
61 * @return source address
62 */
63 host_t *(*get_source) (packet_t *packet);
64
65 /**
66 * Get the destination address.
67 *
68 * Set host_t is still owned by packet_t, clone it
69 * if needed.
70 *
71 * @return destination address
72 */
73 host_t *(*get_destination) (packet_t *packet);
74
75 /**
76 * Get the data from the packet.
77 *
78 * The data pointed by the chunk is still owned
79 * by the packet. Clone it if needed.
80 *
81 * @return chunk containing the data
82 */
83 chunk_t (*get_data) (packet_t *packet);
84
85 /**
86 * Set the data in the packet.
87 *
88 * Supplied chunk data is now owned by the
89 * packet. It will free it.
90 *
91 * @param data chunk with data to set
92 */
93 void (*set_data) (packet_t *packet, chunk_t data);
94
95 /**
96 * Clones a packet_t object.
97 *
98 * @param clone clone of the packet
99 */
100 packet_t* (*clone) (packet_t *packet);
101
102 /**
103 * Destroy the packet, freeing contained data.
104 */
105 void (*destroy) (packet_t *packet);
106 };
107
108 /**
109 * create an empty packet
110 *
111 * @return packet_t object
112 */
113 packet_t *packet_create(void);
114
115 #endif /** PACKET_H_ @}*/