main: fix compiler errors

Something must be wrong with the build system: these shouldn't've been
able to sneak in.
Inline IsValidPort

Since it's in a header file, we need to inline this to prevent
redefinition in separate libraries.