@@ -445,15 +445,16 @@ void odp_packet_user_u64_set(odp_packet_t pkt, uint64_t ctx);
* Layer 2 start pointer
*
* Returns pointer to the start of the layer 2 header. Optionally, outputs
- * number of data bytes in the segment following the pointer.
+ * number of data bytes in the segment following the pointer. The return value
+ * is unspecified when odp_packet_has_l2() returns 0.
*
* @param pkt Packet handle
* @param[out] len Number of data bytes remaining in the segment (output).
* Ignored when NULL.
*
- * @return Layer 2 start pointer, or offset 0 by default
+ * @return Layer 2 start pointer
*
- * @see odp_packet_l2_offset(), odp_packet_l2_offset_set()
+ * @see odp_packet_l2_offset(), odp_packet_l2_offset_set(), odp_packet_has_l2()
*/
void *odp_packet_l2_ptr(odp_packet_t pkt, uint32_t *len);
@@ -461,7 +462,8 @@ void *odp_packet_l2_ptr(odp_packet_t pkt, uint32_t *len);
* Layer 2 start offset
*
* Returns offset to the start of the layer 2 header. The offset is calculated
- * from the current odp_packet_data() position in bytes.
+ * from the current odp_packet_data() position in bytes. The return value
+ * is unspecified when odp_packet_has_l2() returns 0.
*
* User is responsible to update the offset when modifying the packet data
* pointer position.
@@ -491,15 +493,16 @@ int odp_packet_l2_offset_set(odp_packet_t pkt, uint32_t offset);
* Layer 3 start pointer
*
* Returns pointer to the start of the layer 3 header. Optionally, outputs
- * number of data bytes in the segment following the pointer.
+ * number of data bytes in the segment following the pointer. The return value
+ * is unspecified when odp_packet_has_l3() returns 0.
*
* @param pkt Packet handle
* @param[out] len Number of data bytes remaining in the segment (output).
* Ignored when NULL.
*
- * @return Layer 3 start pointer, or NULL
+ * @return Layer 3 start pointer
*
- * @see odp_packet_l3_offset(), odp_packet_l3_offset_set()
+ * @see odp_packet_l3_offset(), odp_packet_l3_offset_set(), odp_packet_has_l3()
*/
void *odp_packet_l3_ptr(odp_packet_t pkt, uint32_t *len);
@@ -507,14 +510,15 @@ void *odp_packet_l3_ptr(odp_packet_t pkt, uint32_t *len);
* Layer 3 start offset
*
* Returns offset to the start of the layer 3 header. The offset is calculated
- * from the current odp_packet_data() position in bytes.
+ * from the current odp_packet_data() position in bytes. The return value
+ * is unspecified when odp_packet_has_l3() returns 0.
*
* User is responsible to update the offset when modifying the packet data
* pointer position.
*
* @param pkt Packet handle
*
- * @return Layer 3 start offset or ODP_PACKET_OFFSET_INVALID if not found
+ * @return Layer 3 start offset
*/
uint32_t odp_packet_l3_offset(odp_packet_t pkt);
@@ -537,7 +541,8 @@ int odp_packet_l3_offset_set(odp_packet_t pkt, uint32_t offset);
* Layer 4 start pointer
*
* Returns pointer to the start of the layer 4 header. Optionally, outputs
- * number of data bytes in the segment following the pointer.
+ * number of data bytes in the segment following the pointer. The return value
+ * is unspecified when odp_packet_has_l4() returns 0.
*
* @param pkt Packet handle
* @param[out] len Number of data bytes remaining in the segment (output).
@@ -545,7 +550,7 @@ int odp_packet_l3_offset_set(odp_packet_t pkt, uint32_t offset);
*
* @return Layer 4 start pointer, or NULL
*
- * @see odp_packet_l4_offset(), odp_packet_l4_offset_set()
+ * @see odp_packet_l4_offset(), odp_packet_l4_offset_set(), odp_packet_has_l4()
*/
void *odp_packet_l4_ptr(odp_packet_t pkt, uint32_t *len);
@@ -553,14 +558,15 @@ void *odp_packet_l4_ptr(odp_packet_t pkt, uint32_t *len);
* Layer 4 start offset
*
* Returns offset to the start of the layer 4 header. The offset is calculated
- * from the current odp_packet_data() position in bytes.
+ * from the current odp_packet_data() position in bytes. The return value
+ * is unspecified when odp_packet_has_l4() returns 0.
*
* User is responsible to update the offset when modifying the packet data
* pointer position.
*
* @param pkt Packet handle
*
- * @return Layer 4 start offset or ODP_PACKET_OFFSET_INVALID if not found
+ * @return Layer 4 start offset
*/
uint32_t odp_packet_l4_offset(odp_packet_t pkt);
Application must check L2/L3/L4 pointer and offset validity with corresponding odp_packet_has_l2/l3/l4() call. Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org> --- platform/linux-generic/include/api/odp_packet.h | 32 +++++++++++++++---------- 1 file changed, 19 insertions(+), 13 deletions(-)