[strongSwan-dev] [PATCH 3/5] packet_t: Add methods to get/set IKEv1 fragment size

Volker Rümelin vr_strongswan at t-online.de
Mon Mar 10 22:34:27 CET 2014


 src/libstrongswan/networking/packet.c | 20 ++++++++++++++++++++
 src/libstrongswan/networking/packet.h | 14 ++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/src/libstrongswan/networking/packet.c b/src/libstrongswan/networking/packet.c
index 4ff7fc4..732baf1 100644
--- a/src/libstrongswan/networking/packet.c
+++ b/src/libstrongswan/networking/packet.c
@@ -44,6 +44,11 @@ struct private_packet_t {
 	 */
 	u_int8_t dscp;
 
+	/**
+	 * IKEv1 maximum fragment data size
+	 */
+	size_t fragment_size;
+
 	 /**
 	  * message data
 	  */
@@ -105,6 +110,18 @@ METHOD(packet_t, set_dscp, void,
 	this->dscp = value;
 }
 
+METHOD(packet_t, get_fragsize, size_t,
+	private_packet_t *this)
+{
+	return this->fragment_size;
+}
+
+METHOD(packet_t, set_fragsize, void,
+	private_packet_t *this, size_t size)
+{
+	this->fragment_size = size;
+}
+
 METHOD(packet_t, skip_bytes, void,
 	private_packet_t *this, size_t bytes)
 {
@@ -140,6 +157,7 @@ METHOD(packet_t, clone_, packet_t*,
 		other->set_data(other, chunk_clone(this->adjusted_data));
 	}
 	other->set_dscp(other, this->dscp);
+	other->set_fragsize(other, this->fragment_size);
 	return other;
 }
 
@@ -160,6 +178,8 @@ packet_t *packet_create_from_data(host_t *src, host_t *dst, chunk_t data)
 			.get_destination = _get_destination,
 			.get_dscp = _get_dscp,
 			.set_dscp = _set_dscp,
+			.get_fragsize = _get_fragsize,
+			.set_fragsize = _set_fragsize,
 			.skip_bytes = _skip_bytes,
 			.clone = _clone_,
 			.destroy = _destroy,
diff --git a/src/libstrongswan/networking/packet.h b/src/libstrongswan/networking/packet.h
index a96a4b8..48f2d1e 100644
--- a/src/libstrongswan/networking/packet.h
+++ b/src/libstrongswan/networking/packet.h
@@ -90,6 +90,20 @@ struct packet_t {
 	void (*set_dscp)(packet_t *this, u_int8_t value);
 
 	/**
+	 * Get IKEv1 maximum fragment data size.
+	 *
+	 * @return			fragment size
+	 */
+	size_t (*get_fragsize)(packet_t *this);
+
+	/**
+	 * Set IKEv1 maximum fragment data size.
+	 *
+	 * @param size		fragment size
+	 */
+	void (*set_fragsize)(packet_t *this, size_t size);
+
+	/**
 	 * Increase the offset where the actual packet data starts.
 	 *
 	 * The total offset applies to future calls of get_data() and clone().
-- 
1.8.4.5




More information about the Dev mailing list