Extract shared code in RAIL channel

This patch starts a code mutualisation for a RAIL server-side implementation. The file rail_common.c contains code that is shared by both client and server.