master: put send/receive protocol code in protocol.hh

Still a bit ugly (e.g. no gather-scatter) but at least all ugliness is
now in one place.

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>