summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarrell Ball <dlu998@gmail.com>2019-02-13 17:33:22 -0800
committerBen Pfaff <blp@ovn.org>2019-02-14 11:31:46 -0800
commit6eee2dc11e70d378dfaad9f28a57522f06017af2 (patch)
tree31e353cc6c0795f4fecdb7c7b465a9c5e4f34061
parentc4cc16bd4b31b0c4a4a89064b1f5ea429c312860 (diff)
downloadopenvswitch-6eee2dc11e70d378dfaad9f28a57522f06017af2.tar.gz
dp-packet: Add 'dp_packet_l3_size()'.
The new api will be used in a subsequent patch. Signed-off-by: Darrell Ball <dlu998@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
-rw-r--r--lib/dp-packet.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/dp-packet.h b/lib/dp-packet.h
index 980ef7852..ea39eeba6 100644
--- a/lib/dp-packet.h
+++ b/lib/dp-packet.h
@@ -348,10 +348,24 @@ dp_packet_set_l4(struct dp_packet *b, void *l4)
b->l4_ofs = l4 ? (char *) l4 - (char *) dp_packet_data(b) : UINT16_MAX;
}
+/* Returns the size of the packet from the beginning of the L3 header to the
+ * end of the L3 payload. Hence L2 padding is not included. */
+static inline size_t
+dp_packet_l3_size(const struct dp_packet *b)
+{
+ return OVS_LIKELY(b->l3_ofs != UINT16_MAX)
+ ? (const char *)dp_packet_tail(b) - (const char *)dp_packet_l3(b)
+ - dp_packet_l2_pad_size(b)
+ : 0;
+}
+
+/* Returns the size of the packet from the beginning of the L4 header to the
+ * end of the L4 payload. Hence L2 padding is not included. */
+
static inline size_t
dp_packet_l4_size(const struct dp_packet *b)
{
- return b->l4_ofs != UINT16_MAX
+ return OVS_LIKELY(b->l4_ofs != UINT16_MAX)
? (const char *)dp_packet_tail(b) - (const char *)dp_packet_l4(b)
- dp_packet_l2_pad_size(b)
: 0;