Sure thing, I can move them. I also prefer pointers, deep structures, etc at the beginning and initialized/blanked, in order to make cleanups meaningful. About the initialization in for I didn't know it happens, interesting! Might be some C-standards thingy.
(Was declaring the `port_len` locally just because it is only calculated and used in that block, not for IPv4 for example; so arguable readability benefit.)