(CFACT 86) refactor networking facts

This patch refactors the multiple calls to ioctl system call to a separate
struct. This allows us to simplify error handling, socket creation and
destruction.