Refactor protocol-specific packet construction into plugins.

I did a bit of refactoring to make gencfg.sh a bit more wieldy.