functorise the write and listen callbacks
This MR functorise the code base in order to simplify the management (single place where you read and write packets), and separate the IDS part from the network lower part. Beware, it compiles fine, but I haven't tested it.