summaryrefslogtreecommitdiff
path: root/lib/dp-packet.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/dp-packet.h')
-rw-r--r--lib/dp-packet.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/dp-packet.h b/lib/dp-packet.h
index 8bbcb2f37..2baba3fdf 100644
--- a/lib/dp-packet.h
+++ b/lib/dp-packet.h
@@ -153,6 +153,7 @@ struct dp_packet *dp_packet_clone_data(const void *, size_t);
struct dp_packet *dp_packet_clone_data_with_headroom(const void *, size_t,
size_t headroom);
static inline void dp_packet_delete(struct dp_packet *);
+static inline void dp_packet_swap(struct dp_packet *, struct dp_packet *);
static inline void *dp_packet_at(const struct dp_packet *, size_t offset,
size_t size);
@@ -210,6 +211,18 @@ dp_packet_delete(struct dp_packet *b)
}
}
+/* Swaps content of two packets. */
+static inline void
+dp_packet_swap(struct dp_packet *a, struct dp_packet *b)
+{
+ ovs_assert(a->source == DPBUF_MALLOC || a->source == DPBUF_STUB);
+ ovs_assert(b->source == DPBUF_MALLOC || b->source == DPBUF_STUB);
+ struct dp_packet c = *a;
+
+ *a = *b;
+ *b = c;
+}
+
/* If 'b' contains at least 'offset + size' bytes of data, returns a pointer to
* byte 'offset'. Otherwise, returns a null pointer. */
static inline void *