refactor code for preparing syslog packet headers