Service and filter API made more generic.

This removes duplication between different protocols.