My personal opinion (although I understand that @kskalski agrees with me on this at least partially) is that we should move protocol at very least to one definition point.
Perhaps it could be defined in cmake level - but that's not quite a solution, rather a workaround.
A solution would be to use tools like google protocol buffers. And that's what we should research (e.g, would using them hurt the performance badly).