protocol: add some helpers to extract state of connections.