generate_packets.py: unify all_caps-related code
Part of #43927. Multiple places need the capabilities affecting a packet, computing them separately each time ~> unify the code as a property on the Packet class, giving a set of capabilities.
This patch also includes a number of sorted() calls, to make the script more deterministic.
Part of #43927. Multiple places need the capabilities affecting a packet, computing them separately each time ~> unify the code as a property on the Packet class, giving a set of capabilities.