Does P4 support existed network protocols? For example, suppose I want to use P4 to implement ICMP protocol, do I need to rewrite all packet forwarding logic? Or I can just use built-in library?
If you find someone else who has written and published P4 code for what you want to do, then subject to the license under which that code was release, and/or other agreements you might make for using their code, you can use it.
But no, there is no built-in support for “do the right thing with ICMP packets” in P4, nor for any other protocol or header.