From: Tobias Brunner Date: Sat, 7 Jul 2012 10:46:28 +0000 (+0200) Subject: Extended constructor for packet_t added (takes src, dst and data) X-Git-Tag: 5.0.1~210^2~109 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ec486e9433320c425f6a31c7290ad7a806818ec2;p=thirdparty%2Fstrongswan.git Extended constructor for packet_t added (takes src, dst and data) --- diff --git a/src/libstrongswan/utils/packet.c b/src/libstrongswan/utils/packet.c index b5716fc4bc..a2c329d604 100644 --- a/src/libstrongswan/utils/packet.c +++ b/src/libstrongswan/utils/packet.c @@ -126,10 +126,10 @@ METHOD(packet_t, clone_, packet_t*, return other; } -/* - * Documented in header +/** + * Described in header. */ -packet_t *packet_create() +packet_t *packet_create_from_data(host_t *src, host_t *dst, chunk_t data) { private_packet_t *this; @@ -145,8 +145,19 @@ packet_t *packet_create() .clone = _clone_, .destroy = _destroy, }, + .source = src, + .destination = dst, + .adjusted_data = data, + .data = data, ); return &this->public; } +/* + * Described in header. + */ +packet_t *packet_create() +{ + return packet_create_from_data(NULL, NULL, chunk_empty); +} diff --git a/src/libstrongswan/utils/packet.h b/src/libstrongswan/utils/packet.h index 9106bbef50..5c4440115f 100644 --- a/src/libstrongswan/utils/packet.h +++ b/src/libstrongswan/utils/packet.h @@ -108,4 +108,14 @@ struct packet_t { */ packet_t *packet_create(); +/** + * Create a packet from the supplied data + * + * @param src source address (gets owned) + * @param dst destination address (gets owned) + * @param data packet data (gets owned) + * @return packet_t object + */ +packet_t *packet_create_from_data(host_t *src, host_t *dst, chunk_t data); + #endif /** PACKET_H_ @}*/