Move getdefaultgateway() fallback to bottom

Transform `if/endif/.../if/endif` chain into `if/elif/.../else/endif`
and move fallback getdefaultgateway implementation to the bottom. This
also fixes compilation issues on platforms using the fallback since
its signature includes argument of `in_addr_t` type, and the type itself
is only defined in "getgateway.h" (unless provided by \<netinet/in.h\>)
which is only being included *after* the function declaration.

Also fix compilation error on Windows where \<winsock2.h\> should be
included to use inet_addr function.