]>
git.ipfire.org Git - people/ms/strongswan.git/blob - Source/charon/network/packet.h
4 * @brief Interface of packet_t.
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
28 #include <utils/host.h>
31 typedef struct packet_t packet_t
;
34 * @brief Abstraction of an UDP-Packet, contains data, sender and receiver.
44 * @brief Set the source address.
46 * Set host_t is now owned by packet_t, it will destroy
49 * @param this calling object
50 * @param source address to set as source
52 void (*set_source
) (packet_t
*packet
, host_t
*source
);
55 * @brief Set the destination address.
57 * Set host_t is now owned by packet_t, it will destroy
60 * @param this calling object
61 * @param source address to set as destination
63 void (*set_destination
) (packet_t
*packet
, host_t
*destination
);
66 * @brief Get the source address.
68 * Set host_t is still owned by packet_t, clone it
71 * @param this calling object
72 * @return source address
74 host_t
*(*get_source
) (packet_t
*packet
);
77 * @brief Get the destination address.
79 * Set host_t is still owned by packet_t, clone it
82 * @param this calling object
83 * @return destination address
85 host_t
*(*get_destination
) (packet_t
*packet
);
88 * @brief Get the data from the packet.
90 * The data pointed by the chunk is still owned
91 * by the packet. Clone it if needed.
93 * @param this calling object
94 * @return chunk containing the data
96 chunk_t (*get_data
) (packet_t
*packet
);
99 * @brief Set the data in the packet.
101 * Supplied chunk data is now owned by the
102 * packet. It will free it.
104 * @param this calling object
105 * @param data chunk with data to set
107 void (*set_data
) (packet_t
*packet
, chunk_t data
);
110 * @brief Clones a packet_t object.
112 * @param packet calling object
113 * @param clone pointer to a packet_t object pointer where the new object is stored
115 packet_t
* (*clone
) (packet_t
*packet
);
118 * @brief Destroy the packet, freeing contained data.
120 * @param packet packet to destroy
122 void (*destroy
) (packet_t
*packet
);
126 * @brief create an empty packet
128 * @return packet_t object
132 packet_t
*packet_create();