]> git.ipfire.org Git - people/ms/strongswan.git/blob - Source/charon/network/packet.h
- renamed get_block_size of hasher
[people/ms/strongswan.git] / Source / charon / network / packet.h
1 /**
2 * @file packet.h
3 *
4 * @brief Interface of packet_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 #ifndef PACKET_H_
24 #define PACKET_H_
25
26
27 #include <types.h>
28 #include <utils/host.h>
29
30
31 typedef struct packet_t packet_t;
32
33 /**
34 * @brief Abstraction of an UDP-Packet, contains data, sender and receiver.
35 *
36 * @b Constructors:
37 * - packet_create()
38 *
39 * @ingroup network
40 */
41 struct packet_t {
42
43 /**
44 * @brief Set the source address.
45 *
46 * Set host_t is now owned by packet_t, it will destroy
47 * it if necessary.
48 *
49 * @param this calling object
50 * @param source address to set as source
51 */
52 void (*set_source) (packet_t *packet, host_t *source);
53
54 /**
55 * @brief Set the destination address.
56 *
57 * Set host_t is now owned by packet_t, it will destroy
58 * it if necessary.
59 *
60 * @param this calling object
61 * @param source address to set as destination
62 */
63 void (*set_destination) (packet_t *packet, host_t *destination);
64
65 /**
66 * @brief Get the source address.
67 *
68 * Set host_t is still owned by packet_t, clone it
69 * if needed.
70 *
71 * @param this calling object
72 * @return source address
73 */
74 host_t *(*get_source) (packet_t *packet);
75
76 /**
77 * @brief Get the destination address.
78 *
79 * Set host_t is still owned by packet_t, clone it
80 * if needed.
81 *
82 * @param this calling object
83 * @return destination address
84 */
85 host_t *(*get_destination) (packet_t *packet);
86
87 /**
88 * @brief Get the data from the packet.
89 *
90 * The data pointed by the chunk is still owned
91 * by the packet. Clone it if needed.
92 *
93 * @param this calling object
94 * @return chunk containing the data
95 */
96 chunk_t (*get_data) (packet_t *packet);
97
98 /**
99 * @brief Set the data in the packet.
100 *
101 * Supplied chunk data is now owned by the
102 * packet. It will free it.
103 *
104 * @param this calling object
105 * @param data chunk with data to set
106 */
107 void (*set_data) (packet_t *packet, chunk_t data);
108
109 /**
110 * @brief Clones a packet_t object.
111 *
112 * @param packet calling object
113 * @param clone pointer to a packet_t object pointer where the new object is stored
114 */
115 packet_t* (*clone) (packet_t *packet);
116
117 /**
118 * @brief Destroy the packet, freeing contained data.
119 *
120 * @param packet packet to destroy
121 */
122 void (*destroy) (packet_t *packet);
123 };
124
125 /**
126 * @brief create an empty packet
127 *
128 * @return packet_t object
129 *
130 * @ingroup network
131 */
132 packet_t *packet_create();
133
134
135 #endif /*PACKET_H_*/