diff options
author | Darrell Ball <dlu998@gmail.com> | 2019-02-04 16:23:06 -0800 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2019-02-11 19:30:08 -0800 |
commit | 69c45b36bc99b0de9f00c9a7201d5ead4c2db0fe (patch) | |
tree | 25e2b7739c890f1a3ac0c760d61e368d9898b01f /lib | |
parent | 78a0b2721fc8a3664d99380d55a43638847a9c8f (diff) | |
download | openvswitch-69c45b36bc99b0de9f00c9a7201d5ead4c2db0fe.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>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dp-packet.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/dp-packet.h b/lib/dp-packet.h index 7b85dd902..c297a8f50 100644 --- a/lib/dp-packet.h +++ b/lib/dp-packet.h @@ -352,10 +352,23 @@ 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; |