]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
Add support to create IKE fragments
authorTobias Brunner <tobias@strongswan.org>
Thu, 20 Dec 2012 15:04:38 +0000 (16:04 +0100)
committerTobias Brunner <tobias@strongswan.org>
Mon, 24 Dec 2012 11:29:30 +0000 (12:29 +0100)
All fragments currently use the same fragment ID (1) as that's what
other implementations are doing.

src/libcharon/encoding/payloads/fragment_payload.c
src/libcharon/encoding/payloads/fragment_payload.h

index 2e7e061988bdeb34acb1891e32f0e7b9864b7731..1a6b3234b7b4b67699b6fd686212ee1fa02c2360 100644 (file)
@@ -206,3 +206,20 @@ fragment_payload_t *fragment_payload_create()
        this->payload_length = get_header_length(this);
        return &this->public;
 }
+
+/*
+ * Described in header
+ */
+fragment_payload_t *fragment_payload_create_from_data(u_int8_t num, bool last,
+                                                                                                         chunk_t data)
+{
+       private_fragment_payload_t *this;
+
+       this = (private_fragment_payload_t*)fragment_payload_create();
+       this->fragment_id = 1;
+       this->fragment_number = num;
+       this->flags |= (last ? LAST_FRAGMENT : 0);
+       this->data = chunk_clone(data);
+       this->payload_length = get_header_length(this) + data.len;
+       return &this->public;
+}
\ No newline at end of file
index 60358abb99f7995e5e6ca32e384f84405c4496f5..a49cf32ddfbf87f70f12c132c9407ae84d429679 100644 (file)
@@ -78,4 +78,17 @@ struct fragment_payload_t {
  */
 fragment_payload_t *fragment_payload_create();
 
+/**
+ * Creates a fragment payload from the given data.  All fragments currently
+ * have the same fragment ID (1), which seems what other implementations are
+ * doing.
+ *
+ * @param num          fragment number (first one should be 1)
+ * @param last         TRUE to indicate that this is the last fragment
+ * @param data         fragment data (gets cloned)
+ * @return                     fragment_payload_t object
+ */
+fragment_payload_t *fragment_payload_create_from_data(u_int8_t num, bool last,
+                                                                                                         chunk_t data);
+
 #endif /** FRAGMENT_PAYLOAD_H_ @}*/