Can we use extract() function to write varbit data in other data types such as bit<32>? If yes, how?

Hello Sandeep,

There is an enhancement request for the P4 specification, but it has not been approved or implemented.

Obviously, this does not prohibit individual architectures to define their own extern methods that would do the same thing (and in certain cases they would be relatively straightforward to implement), but I haven’t heard of any that would actually implement such a functionality.

As of today, the rule is very simple: use varbit only if you intend to carry a variable-length field from ingress to egress without doing any “real” processing. If you want to do any processing (lookup, modification, etc, etc.) use multiple fixed-length chunks instead, as described in @andyfingerhut’s guide or as was clearly suggested in my previous post.

Happy hacking,
Vladimir