client: If we have a pre-connected FD, set state to SOCKET_CONNECTED

Otherwise applications providing their own fd end up tripping an
assertion, since the session is just in _CONNECTING.

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Add ssh_get_poll_flags()

For integration with an external mainloop, we need to know how to
replicate libssh's internal poll() calls.  We originally through
ssh_get_status() was that API, but it's not really - those flags only
get updated from the *result* of a poll(), where what we really need
is to know how libssh would *start* a poll().

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
session: Always request POLLIN

The assumption is that if libssh functions are being invoked, we want
to read data.

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
server: Fix malloc call.
packet: Refactor ssh_packet_socket_callback().

Make error checking more readable and add additional NULL checks.
dh: Avoid possible memory leaks with realloc.
poll: Fix realloc in ssh_poll_ctx_resize().