Implement proposal 264 (protocol versioning)
This is not 100% strictly necessary for legacy/trac#15055 (moved) to work, but every time we change a protocol, we will wish that we had included this feature.
Mostly implemented in a fit of C while I was on vacation.