I would prefer a memcpy with a htons - this code is hard to understand