@@ -72,6 +72,51 @@ extern "C" {
*/
/**
+ * Protocol
+ */
+typedef enum odp_proto_t {
+ /** No protocol defined */
+ ODP_PROTO_NONE = 0,
+
+ /** Ethernet (including VLAN) */
+ ODP_PROTO_ETH,
+
+ /** IP (including IPv4 and IPv6) */
+ ODP_PROTO_IP,
+
+ /** UDP */
+ ODP_PROTO_UDP,
+
+ /** TCP */
+ ODP_PROTO_TCP,
+
+ /** SCTP */
+ ODP_PROTO_SCTP
+
+} odp_proto_t;
+
+/**
+ * Protocol layer
+ */
+typedef enum odp_proto_layer_t {
+ /** No layers */
+ ODP_PROTO_LAYER_NONE = 0,
+
+ /** Layer L2 protocols (Ethernet, VLAN, etc) */
+ ODP_PROTO_LAYER_L2,
+
+ /** Layer L3 protocols (IPv4, IPv6, ICMP, IPSEC, etc) */
+ ODP_PROTO_LAYER_L3,
+
+ /** Layer L4 protocols (UDP, TCP, SCTP) */
+ ODP_PROTO_LAYER_L4,
+
+ /** All layers */
+ ODP_PROTO_LAYER_ALL
+
+} odp_proto_layer_t;
+
+/**
* Packet API data range specifier
*/
typedef struct odp_packet_data_range {
@@ -1140,6 +1185,48 @@ int odp_packet_move_data(odp_packet_t pkt, uint32_t dst_offset,
*/
/**
+ * Parse packet
+ *
+ * Parse protocol headers in packet data. Parsing starts at 'offset', which
+ * is the first header byte of protocol 'proto'. Parameter 'layer' defines the
+ * last layer application is interested about. Use ODP_PROTO_LAYER_ALL for all
+ * layers. The operation sets or resets packet metadata for all layers from
+ * the layer of 'proto' to the application defined last layer. Metadata of
+ * other layers have undefined values.
+ *
+ * @param pkt Packet handle
+ * @param offset Byte offset into the packet
+ * @param proto Protocol of the header starting at 'offset'
+ * @param layer Continue parsing until this layer. Must be the same or higher
+ * layer than the layer of 'proto'.
+ *
+ * @retval 0 on success
+ * @retval <0 on failure
+ */
+int odp_packet_parse(odp_packet_t pkt, uint32_t offset, odp_proto_t proto,
+ odp_proto_layer_t layer);
+
+/**
+ * Parse multiple packets
+ *
+ * Otherwise like odp_packet_parse(), but parses multiple packets. Packets may
+ * have unique offsets, but must start with the same protocol. Also, packets are
+ * parsed up to the same protocol layer.
+ *
+ * @param pkt Packet handle array
+ * @param offset Byte offsets into the packets
+ * @param num Number of packets and offsets
+ * @param proto Protocol of the header starting at 'offset'
+ * @param layer Continue parsing until this layer. Must be the same or higher
+ * layer than the layer of 'proto'.
+ *
+ * @retval 0 on success
+ * @retval <0 on failure
+ */
+int odp_packet_parse_multi(const odp_packet_t pkt[], const uint32_t offset[],
+ int num, odp_proto_t proto, odp_proto_layer_t layer);
+
+/**
* Packet pool
*
* Returns handle to the packet pool where the packet was allocated from.