generate_packets.py: Parse packets.def in a separate function
Part of #43927. Extract the code responsible for parsing packets.def from main().
Part of #43927. Extract the code responsible for parsing packets.def from main().