diff --git a/src/channel.c b/src/channel.c index 06e0e779..eecefede 100644 --- a/src/channel.c +++ b/src/channel.c @@ -78,7 +78,7 @@ _libssh2_channel_nextid(LIBSSH2_SESSION * session) * told... */ session->next_channel = id + 1; - _libssh2_debug(session, LIBSSH2_DBG_CONN, "Allocated new channel ID#%lu", + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Allocated new channel ID#%lu", id); return id; } @@ -149,7 +149,7 @@ _libssh2_channel_open(LIBSSH2_SESSION * session, const char *channel_type, memset(&session->open_packet_requirev_state, 0, sizeof(session->open_packet_requirev_state)); - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Opening Channel - win %d pack %d", window_size, packet_size); session->open_channel = @@ -254,7 +254,7 @@ _libssh2_channel_open(LIBSSH2_SESSION * session, const char *channel_type, _libssh2_ntohu32(session->open_data + 9); session->open_channel->local.packet_size = _libssh2_ntohu32(session->open_data + 13); - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Connection Established - ID: %lu/%lu win: %lu/%lu" " pack: %lu/%lu", session->open_channel->local.id, @@ -361,7 +361,7 @@ channel_direct_tcpip(LIBSSH2_SESSION * session, const char *host, session->direct_message_len = session->direct_host_len + session->direct_shost_len + 16; - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Requesting direct-tcpip session to from %s:%d to %s:%d", shost, sport, host, port); @@ -455,7 +455,7 @@ channel_forward_listen(LIBSSH2_SESSION * session, const char *host, memset(&session->fwdLstn_packet_requirev_state, 0, sizeof(session->fwdLstn_packet_requirev_state)); - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Requesting tcpip-forward session for %s:%d", host, port); @@ -552,7 +552,7 @@ channel_forward_listen(LIBSSH2_SESSION * session, const char *host, listener->host[session->fwdLstn_host_len] = 0; if (data_len >= 5 && !port) { listener->port = _libssh2_ntohu32(data + 1); - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Dynamic tcpip-forward port allocated: %d", listener->port); } else { @@ -625,7 +625,7 @@ static int channel_forward_cancel(LIBSSH2_LISTENER *listener) int rc; if (listener->chanFwdCncl_state == libssh2_NB_state_idle) { - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Cancelling tcpip-forward session for %s:%d", listener->host, listener->port); @@ -791,7 +791,7 @@ static int channel_setenv(LIBSSH2_CHANNEL *channel, memset(&channel->setenv_packet_requirev_state, 0, sizeof(channel->setenv_packet_requirev_state)); - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Setting remote environment variable: %s=%s on " "channel %lu/%lu", varname, value, channel->local.id, channel->remote.id); @@ -922,7 +922,7 @@ static int channel_request_pty(LIBSSH2_CHANNEL *channel, memset(&channel->reqPTY_packet_requirev_state, 0, sizeof(channel->reqPTY_packet_requirev_state)); - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Allocating tty on channel %lu/%lu", channel->local.id, channel->remote.id); @@ -1049,7 +1049,7 @@ channel_request_pty_size(LIBSSH2_CHANNEL * channel, int width, memset(&channel->reqPTY_packet_requirev_state, 0, sizeof(channel->reqPTY_packet_requirev_state)); - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "changing tty size on channel %lu/%lu", channel->local.id, channel->remote.id); @@ -1153,7 +1153,7 @@ channel_x11_req(LIBSSH2_CHANNEL *channel, int single_connection, memset(&channel->reqX11_packet_requirev_state, 0, sizeof(channel->reqX11_packet_requirev_state)); - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Requesting x11-req for channel %lu/%lu: single=%d " "proto=%s cookie=%s screen=%d", channel->local.id, channel->remote.id, @@ -1303,7 +1303,7 @@ _libssh2_channel_process_startup(LIBSSH2_CHANNEL *channel, channel->process_packet_len += message_len + 4; } - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "starting request(%s) on channel %lu/%lu, message=%s", request, channel->local.id, channel->remote.id, message); @@ -1449,7 +1449,7 @@ _libssh2_channel_flush(LIBSSH2_CHANNEL *channel, int streamid) && (streamid == 0))) { int bytes_to_flush = packet->data_len - packet->data_head; - _libssh2_debug(channel->session, LIBSSH2_DBG_CONN, + _libssh2_debug(channel->session, LIBSSH2_TRACE_CONN, "Flushing %d bytes of data from stream " "%lu on channel %lu/%lu", bytes_to_flush, packet_stream_id, @@ -1533,7 +1533,7 @@ _libssh2_channel_receive_window_adjust(LIBSSH2_CHANNEL * channel, if (!force && (adjustment + channel->adjust_queue < LIBSSH2_CHANNEL_MINADJUST)) { - _libssh2_debug(channel->session, LIBSSH2_DBG_CONN, + _libssh2_debug(channel->session, LIBSSH2_TRACE_CONN, "Queueing %lu bytes for receive window adjustment " "for channel %lu/%lu", adjustment, channel->local.id, channel->remote.id); @@ -1556,7 +1556,7 @@ _libssh2_channel_receive_window_adjust(LIBSSH2_CHANNEL * channel, channel->adjust_adjust[0] = SSH_MSG_CHANNEL_WINDOW_ADJUST; _libssh2_htonu32(&channel->adjust_adjust[1], channel->remote.id); _libssh2_htonu32(&channel->adjust_adjust[5], adjustment); - _libssh2_debug(channel->session, LIBSSH2_DBG_CONN, + _libssh2_debug(channel->session, LIBSSH2_TRACE_CONN, "Adjusting window %lu bytes for data on " "channel %lu/%lu", adjustment, channel->local.id, channel->remote.id); @@ -1643,7 +1643,7 @@ int _libssh2_channel_extended_data(LIBSSH2_CHANNEL *channel, int ignore_mode) { if (channel->extData2_state == libssh2_NB_state_idle) { - _libssh2_debug(channel->session, LIBSSH2_DBG_CONN, + _libssh2_debug(channel->session, LIBSSH2_TRACE_CONN, "Setting channel %lu/%lu handle_extended_data" " mode to %d", channel->local.id, channel->remote.id, ignore_mode); @@ -1720,7 +1720,7 @@ ssize_t _libssh2_channel_read(LIBSSH2_CHANNEL *channel, int stream_id, LIBSSH2_PACKET *read_next; if (channel->read_state == libssh2_NB_state_idle) { - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "channel_read() wants %d bytes from channel %lu/%lu " "stream #%d", (int) buflen, channel->local.id, channel->remote.id, @@ -1797,7 +1797,7 @@ ssize_t _libssh2_channel_read(LIBSSH2_CHANNEL *channel, int stream_id, unlink_packet = TRUE; } - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "channel_read() got %d of data from %lu/%lu/%d%s", bytes_want, channel->local.id, channel->remote.id, stream_id, @@ -1856,7 +1856,7 @@ ssize_t _libssh2_channel_read(LIBSSH2_CHANNEL *channel, int stream_id, if (rc == PACKET_EAGAIN) return rc; - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "channel_read() filled %d adjusted %d", bytes_read, buflen); /* continue in 'created' state to drain the already read packages @@ -1966,7 +1966,7 @@ _libssh2_channel_write(LIBSSH2_CHANNEL *channel, int stream_id, if (channel->write_state == libssh2_NB_state_idle) { channel->write_bufwrote = 0; - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Writing %d bytes on channel %lu/%lu, stream #%d", (int) buflen, channel->local.id, channel->remote.id, stream_id); @@ -2030,7 +2030,7 @@ _libssh2_channel_write(LIBSSH2_CHANNEL *channel, int stream_id, /* Don't exceed the remote end's limits */ /* REMEMBER local means local as the SOURCE of the data */ if (channel->write_bufwrite > channel->local.window_size) { - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Splitting write block due to %lu byte " "window_size on %lu/%lu/%d", channel->local.window_size, channel->local.id, @@ -2038,7 +2038,7 @@ _libssh2_channel_write(LIBSSH2_CHANNEL *channel, int stream_id, channel->write_bufwrite = channel->local.window_size; } if (channel->write_bufwrite > channel->local.packet_size) { - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Splitting write block due to %lu byte " "packet_size on %lu/%lu/%d", channel->local.packet_size, channel->local.id, @@ -2050,7 +2050,7 @@ _libssh2_channel_write(LIBSSH2_CHANNEL *channel, int stream_id, memcpy(channel->write_s, buf, channel->write_bufwrite); channel->write_s += channel->write_bufwrite; - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Sending %d bytes on channel %lu/%lu, stream_id=%d", (int) channel->write_bufwrite, channel->local.id, channel->remote.id, stream_id); @@ -2122,7 +2122,7 @@ static int channel_send_eof(LIBSSH2_CHANNEL *channel) unsigned char packet[5]; /* packet_type(1) + channelno(4) */ int rc; - _libssh2_debug(session, LIBSSH2_DBG_CONN, "Sending EOF on channel %lu/%lu", + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Sending EOF on channel %lu/%lu", channel->local.id, channel->remote.id); packet[0] = SSH_MSG_CHANNEL_EOF; _libssh2_htonu32(packet + 1, channel->remote.id); @@ -2188,7 +2188,7 @@ static int channel_wait_eof(LIBSSH2_CHANNEL *channel) int rc; if (channel->wait_eof_state == libssh2_NB_state_idle) { - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Awaiting close of channel %lu/%lu", channel->local.id, channel->remote.id); @@ -2246,7 +2246,7 @@ channel_close(LIBSSH2_CHANNEL * channel) } if (channel->close_state == libssh2_NB_state_idle) { - _libssh2_debug(session, LIBSSH2_DBG_CONN, "Closing channel %lu/%lu", + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Closing channel %lu/%lu", channel->local.id, channel->remote.id); channel->close_packet[0] = SSH_MSG_CHANNEL_CLOSE; @@ -2327,7 +2327,7 @@ static int channel_wait_closed(LIBSSH2_CHANNEL *channel) } if (channel->wait_closed_state == libssh2_NB_state_idle) { - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Awaiting close of channel %lu/%lu", channel->local.id, channel->remote.id); @@ -2386,7 +2386,7 @@ int _libssh2_channel_free(LIBSSH2_CHANNEL *channel) assert(session); if (channel->free_state == libssh2_NB_state_idle) { - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Freeing channel %lu/%lu resources", channel->local.id, channel->remote.id); diff --git a/src/kex.c b/src/kex.c index edcf1b6e..08ed190f 100644 --- a/src/kex.c +++ b/src/kex.c @@ -135,7 +135,7 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session, exchange_state->e_packet + 6); } - _libssh2_debug(session, LIBSSH2_DBG_KEX, "Sending KEX packet %d", + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Sending KEX packet %d", (int) packet_type_init); exchange_state->state = libssh2_NB_state_created; } @@ -161,7 +161,7 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session, * need to silently ignore it */ int burn_type; - _libssh2_debug(session, LIBSSH2_DBG_KEX, + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Waiting for badly guessed KEX packet (to be ignored)"); burn_type = _libssh2_packet_burn(session, &exchange_state->burn_state); @@ -174,7 +174,7 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session, } session->burn_optimistic_kexinit = 0; - _libssh2_debug(session, LIBSSH2_DBG_KEX, + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Burnt packet of type: %02x", (unsigned int) burn_type); } @@ -233,7 +233,7 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session, snprintf(fprint, 4, "%02x:", session->server_hostkey_md5[i]); } *(--fprint) = '\0'; - _libssh2_debug(session, LIBSSH2_DBG_KEX, + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Server's MD5 Fingerprint: %s", fingerprint); } #endif /* LIBSSH2DEBUG */ @@ -256,7 +256,7 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session, snprintf(fprint, 4, "%02x:", session->server_hostkey_sha1[i]); } *(--fprint) = '\0'; - _libssh2_debug(session, LIBSSH2_DBG_KEX, + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Server's SHA1 Fingerprint: %s", fingerprint); } #endif /* LIBSSH2DEBUG */ @@ -410,7 +410,7 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session, goto clean_exit; } - _libssh2_debug(session, LIBSSH2_DBG_KEX, "Sending NEWKEYS message"); + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Sending NEWKEYS message"); exchange_state->c = SSH_MSG_NEWKEYS; exchange_state->state = libssh2_NB_state_sent2; @@ -444,7 +444,7 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session, /* The first key exchange has been performed, switch to active crypt/comp/mac mode */ session->state |= LIBSSH2_STATE_NEWKEYS; - _libssh2_debug(session, LIBSSH2_DBG_KEX, "Received NEWKEYS message"); + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Received NEWKEYS message"); /* This will actually end up being just packet_type(1) for this packet type anyway */ @@ -461,7 +461,7 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session, memcpy(session->session_id, exchange_state->h_sig_comp, SHA_DIGEST_LENGTH); session->session_id_len = SHA_DIGEST_LENGTH; - _libssh2_debug(session, LIBSSH2_DBG_KEX, "session_id calculated"); + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "session_id calculated"); } /* Cleanup any existing cipher */ @@ -509,7 +509,7 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session, LIBSSH2_FREE(session, secret); } } - _libssh2_debug(session, LIBSSH2_DBG_KEX, + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Client to Server IV and Key calculated"); if (session->remote.crypt->dtor) { @@ -556,7 +556,7 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session, LIBSSH2_FREE(session, secret); } } - _libssh2_debug(session, LIBSSH2_DBG_KEX, + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Server to Client IV and Key calculated"); if (session->local.mac->dtor) { @@ -582,7 +582,7 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session, LIBSSH2_FREE(session, key); } } - _libssh2_debug(session, LIBSSH2_DBG_KEX, + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Client to Server HMAC Key calculated"); if (session->remote.mac->dtor) { @@ -608,7 +608,7 @@ static int diffie_hellman_sha1(LIBSSH2_SESSION *session, LIBSSH2_FREE(session, key); } } - _libssh2_debug(session, LIBSSH2_DBG_KEX, + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Server to Client HMAC Key calculated"); } @@ -684,7 +684,7 @@ kex_method_diffie_hellman_group1_sha1_key_exchange(LIBSSH2_SESSION *session, _libssh2_bn_set_word(key_state->g, 2); _libssh2_bn_from_bin(key_state->p, 128, p_value); - _libssh2_debug(session, LIBSSH2_DBG_KEX, + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Initiating Diffie-Hellman Group1 Key Exchange"); key_state->state = libssh2_NB_state_created; @@ -760,7 +760,7 @@ kex_method_diffie_hellman_group14_sha1_key_exchange(LIBSSH2_SESSION *session, _libssh2_bn_set_word(key_state->g, 2); _libssh2_bn_from_bin(key_state->p, 256, p_value); - _libssh2_debug(session, LIBSSH2_DBG_KEX, + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Initiating Diffie-Hellman Group14 Key Exchange"); key_state->state = libssh2_NB_state_created; @@ -806,13 +806,13 @@ kex_method_diffie_hellman_group_exchange_sha1_key_exchange _libssh2_htonu32(key_state->request + 5, LIBSSH2_DH_GEX_OPTGROUP); _libssh2_htonu32(key_state->request + 9, LIBSSH2_DH_GEX_MAXGROUP); key_state->request_len = 13; - _libssh2_debug(session, LIBSSH2_DBG_KEX, + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Initiating Diffie-Hellman Group-Exchange (New Method)"); #else key_state->request[0] = SSH_MSG_KEX_DH_GEX_REQUEST_OLD; _libssh2_htonu32(key_state->request + 1, LIBSSH2_DH_GEX_OPTGROUP); key_state->request_len = 5; - _libssh2_debug(session, LIBSSH2_DBG_KEX, + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Initiating Diffie-Hellman Group-Exchange (Old Method)"); #endif @@ -1090,25 +1090,25 @@ static int kexinit(LIBSSH2_SESSION * session) /* Funnily enough, they'll all "appear" to be '\0' terminated */ unsigned char *p = data + 21; /* type(1) + cookie(16) + len(4) */ - _libssh2_debug(session, LIBSSH2_DBG_KEX, "Sent KEX: %s", p); + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Sent KEX: %s", p); p += kex_len + 4; - _libssh2_debug(session, LIBSSH2_DBG_KEX, "Sent HOSTKEY: %s", p); + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Sent HOSTKEY: %s", p); p += hostkey_len + 4; - _libssh2_debug(session, LIBSSH2_DBG_KEX, "Sent CRYPT_CS: %s", p); + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Sent CRYPT_CS: %s", p); p += crypt_cs_len + 4; - _libssh2_debug(session, LIBSSH2_DBG_KEX, "Sent CRYPT_SC: %s", p); + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Sent CRYPT_SC: %s", p); p += crypt_sc_len + 4; - _libssh2_debug(session, LIBSSH2_DBG_KEX, "Sent MAC_CS: %s", p); + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Sent MAC_CS: %s", p); p += mac_cs_len + 4; - _libssh2_debug(session, LIBSSH2_DBG_KEX, "Sent MAC_SC: %s", p); + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Sent MAC_SC: %s", p); p += mac_sc_len + 4; - _libssh2_debug(session, LIBSSH2_DBG_KEX, "Sent COMP_CS: %s", p); + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Sent COMP_CS: %s", p); p += comp_cs_len + 4; - _libssh2_debug(session, LIBSSH2_DBG_KEX, "Sent COMP_SC: %s", p); + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Sent COMP_SC: %s", p); p += comp_sc_len + 4; - _libssh2_debug(session, LIBSSH2_DBG_KEX, "Sent LANG_CS: %s", p); + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Sent LANG_CS: %s", p); p += lang_cs_len + 4; - _libssh2_debug(session, LIBSSH2_DBG_KEX, "Sent LANG_SC: %s", p); + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Sent LANG_SC: %s", p); p += lang_sc_len + 4; } #endif /* LIBSSH2DEBUG */ @@ -1607,24 +1607,24 @@ static int kex_agree_methods(LIBSSH2_SESSION * session, unsigned char *data, return -1; } - _libssh2_debug(session, LIBSSH2_DBG_KEX, "Agreed on KEX method: %s", + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Agreed on KEX method: %s", session->kex->name); - _libssh2_debug(session, LIBSSH2_DBG_KEX, "Agreed on HOSTKEY method: %s", + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Agreed on HOSTKEY method: %s", session->hostkey->name); - _libssh2_debug(session, LIBSSH2_DBG_KEX, "Agreed on CRYPT_CS method: %s", + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Agreed on CRYPT_CS method: %s", session->local.crypt->name); - _libssh2_debug(session, LIBSSH2_DBG_KEX, "Agreed on CRYPT_SC method: %s", + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Agreed on CRYPT_SC method: %s", session->remote.crypt->name); - _libssh2_debug(session, LIBSSH2_DBG_KEX, "Agreed on MAC_CS method: %s", + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Agreed on MAC_CS method: %s", session->local.mac->name); - _libssh2_debug(session, LIBSSH2_DBG_KEX, "Agreed on MAC_SC method: %s", + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Agreed on MAC_SC method: %s", session->remote.mac->name); - _libssh2_debug(session, LIBSSH2_DBG_KEX, "Agreed on COMP_CS method: %s", + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Agreed on COMP_CS method: %s", session->local.comp->name); - _libssh2_debug(session, LIBSSH2_DBG_KEX, "Agreed on COMP_SC method: %s", + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Agreed on COMP_SC method: %s", session->remote.comp->name); - _libssh2_debug(session, LIBSSH2_DBG_KEX, "Agreed on LANG_CS method:"); /* None yet */ - _libssh2_debug(session, LIBSSH2_DBG_KEX, "Agreed on LANG_SC method:"); /* None yet */ + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Agreed on LANG_CS method:"); /* None yet */ + _libssh2_debug(session, LIBSSH2_TRACE_KEX, "Agreed on LANG_SC method:"); /* None yet */ /* Initialize compression layer */ if (session->local.comp && session->local.comp->init && diff --git a/src/libssh2_priv.h b/src/libssh2_priv.h index ebea932d..1ba93549 100644 --- a/src/libssh2_priv.h +++ b/src/libssh2_priv.h @@ -1014,16 +1014,6 @@ struct _LIBSSH2_MAC_METHOD int (*dtor) (LIBSSH2_SESSION * session, void **abstract); }; -#define LIBSSH2_DBG_TRANS 1 -#define LIBSSH2_DBG_KEX 2 -#define LIBSSH2_DBG_AUTH 3 -#define LIBSSH2_DBG_CONN 4 -#define LIBSSH2_DBG_SCP 5 -#define LIBSSH2_DBG_SFTP 6 -#define LIBSSH2_DBG_ERROR 7 -#define LIBSSH2_DBG_PUBLICKEY 8 -#define LIBSSH2_DBG_SOCKET 9 - #ifdef LIBSSH2DEBUG void _libssh2_debug(LIBSSH2_SESSION * session, int context, const char *format, ...); @@ -1050,7 +1040,7 @@ _libssh2_debug(LIBSSH2_SESSION * session, int context, const char *format, ...) session->err_msglen = strlen(errmsg); \ session->err_should_free = should_free; \ session->err_code = errcode; \ - _libssh2_debug(session, LIBSSH2_DBG_ERROR, "%d - %s", session->err_code, session->err_msg); \ + _libssh2_debug(session, LIBSSH2_TRACE_ERROR, "%d - %s", session->err_code, session->err_msg); \ } #else /* ! LIBSSH2DEBUG */ diff --git a/src/misc.c b/src/misc.c index df77b974..83e6bd5e 100644 --- a/src/misc.c +++ b/src/misc.c @@ -336,7 +336,7 @@ _libssh2_debug(LIBSSH2_SESSION * session, int context, const char *format, ...) if (context < 1 || context >= (int)ARRAY_SIZE(contexts)) { context = 0; } - if (!(session->showmask & (1 << context))) { + if (!(session->showmask & context)) { /* no such output asked for */ return; } diff --git a/src/packet.c b/src/packet.c index 998c92c5..c013dfda 100644 --- a/src/packet.c +++ b/src/packet.c @@ -108,7 +108,7 @@ packet_queue_listener(LIBSSH2_SESSION * session, unsigned char *data, listen_state->sport = _libssh2_ntohu32(s); s += 4; - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Remote received connection from %s:%ld to %s:%ld", listen_state->shost, listen_state->sport, listen_state->host, listen_state->port); @@ -131,7 +131,7 @@ packet_queue_listener(LIBSSH2_SESSION * session, unsigned char *data, (listen->queue_maxsize <= listen->queue_size)) { /* Queue is full */ failure_code = 4; /* SSH_OPEN_RESOURCE_SHORTAGE */ - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Listener queue full, ignoring"); listen_state->state = libssh2_NB_state_sent; break; @@ -183,7 +183,7 @@ packet_queue_listener(LIBSSH2_SESSION * session, unsigned char *data, listen_state->initial_window_size; channel->local.packet_size = listen_state->packet_size; - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Connection queued: channel %lu/%lu win %lu/%lu packet %lu/%lu", channel->local.id, channel->remote.id, channel->local.window_size, @@ -294,7 +294,7 @@ packet_x11_open(LIBSSH2_SESSION * session, unsigned char *data, x11open_state->sport = _libssh2_ntohu32(s); s += 4; - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "X11 Connection Received from %s:%ld on channel %lu", x11open_state->shost, x11open_state->sport, x11open_state->sender_channel); @@ -342,7 +342,7 @@ packet_x11_open(LIBSSH2_SESSION * session, unsigned char *data, channel->local.window_size = x11open_state->initial_window_size; channel->local.packet_size = x11open_state->packet_size; - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "X11 Connection established: channel %lu/%lu win %lu/%lu packet %lu/%lu", channel->local.id, channel->remote.id, channel->local.window_size, @@ -446,7 +446,7 @@ _libssh2_packet_add(LIBSSH2_SESSION * session, unsigned char *data, memset(&session->packAdd_x11open_state, 0, sizeof(session->packAdd_x11open_state)); - _libssh2_debug(session, LIBSSH2_DBG_TRANS, + _libssh2_debug(session, LIBSSH2_TRACE_TRANS, "Packet type %d received, length=%d", (int) data[0], (int) datalen); if (macstate == LIBSSH2_MAC_INVALID) { @@ -520,7 +520,7 @@ _libssh2_packet_add(LIBSSH2_SESSION * session, unsigned char *data, LIBSSH2_DISCONNECT(session, reason, message, message_len, language, language_len); } - _libssh2_debug(session, LIBSSH2_DBG_TRANS, + _libssh2_debug(session, LIBSSH2_TRACE_TRANS, "Disconnect(%d): %s(%s)", reason, message, language); LIBSSH2_FREE(session, data); @@ -583,7 +583,7 @@ _libssh2_packet_add(LIBSSH2_SESSION * session, unsigned char *data, * _libssh2_debug will actually truncate this for us so * that it's not an inordinate about of data */ - _libssh2_debug(session, LIBSSH2_DBG_TRANS, + _libssh2_debug(session, LIBSSH2_TRACE_TRANS, "Debug Packet: %s", message); LIBSSH2_FREE(session, data); session->packAdd_state = libssh2_NB_state_idle; @@ -616,7 +616,7 @@ _libssh2_packet_add(LIBSSH2_SESSION * session, unsigned char *data, stream_id = _libssh2_ntohu32(data + 5); } - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "%d bytes packet_add() for %lu/%lu/%lu", (int) (datalen - session->packAdd_data_head), session->packAdd_channel->local.id, @@ -630,7 +630,7 @@ _libssh2_packet_add(LIBSSH2_SESSION * session, unsigned char *data, /* Pretend we didn't receive this */ LIBSSH2_FREE(session, data); - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Ignoring extended data and refunding %d bytes", (int) (datalen - 13)); /* Adjust the window based on the block we just freed */ @@ -713,7 +713,7 @@ _libssh2_packet_add(LIBSSH2_SESSION * session, unsigned char *data, } _libssh2_debug(session, - LIBSSH2_DBG_CONN, + LIBSSH2_TRACE_CONN, "EOF received for channel %lu/%lu", session->packAdd_channel->local.id, session->packAdd_channel->remote.id); @@ -736,7 +736,7 @@ _libssh2_packet_add(LIBSSH2_SESSION * session, unsigned char *data, if (session->packAdd_channel) { session->packAdd_channel->exit_status = _libssh2_ntohu32(data + 9 + sizeof("exit-status")); - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Exit status %lu received for channel %lu/%lu", session->packAdd_channel->exit_status, session->packAdd_channel->local.id, @@ -759,7 +759,7 @@ _libssh2_packet_add(LIBSSH2_SESSION * session, unsigned char *data, session->packAdd_state = libssh2_NB_state_idle; return 0; } - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Close received for channel %lu/%lu", session->packAdd_channel->local.id, session->packAdd_channel->remote.id); @@ -816,7 +816,7 @@ _libssh2_packet_add(LIBSSH2_SESSION * session, unsigned char *data, if (session->packAdd_channel && bytestoadd) { session->packAdd_channel->local.window_size += bytestoadd; } - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Window adjust received for channel %lu/%lu, adding %lu bytes, new window_size=%lu", session->packAdd_channel->local.id, session->packAdd_channel->remote.id, @@ -864,7 +864,7 @@ _libssh2_packet_add(LIBSSH2_SESSION * session, unsigned char *data, * Well, it's already in the brigade, * let's just call back into ourselves */ - _libssh2_debug(session, LIBSSH2_DBG_TRANS, "Renegotiating Keys"); + _libssh2_debug(session, LIBSSH2_TRACE_TRANS, "Renegotiating Keys"); session->packAdd_state = libssh2_NB_state_sent2; } @@ -915,7 +915,7 @@ _libssh2_packet_ask(LIBSSH2_SESSION * session, unsigned char packet_type, { LIBSSH2_PACKET *packet = _libssh2_list_first(&session->packets); - _libssh2_debug(session, LIBSSH2_DBG_TRANS, + _libssh2_debug(session, LIBSSH2_TRACE_TRANS, "Looking for packet of type: %d", (int) packet_type); while (packet) { @@ -1054,7 +1054,7 @@ _libssh2_packet_burn(LIBSSH2_SESSION * session, return i; } - _libssh2_debug(session, LIBSSH2_DBG_TRANS, + _libssh2_debug(session, LIBSSH2_TRACE_TRANS, "Blocking until packet becomes available to burn"); *state = libssh2_NB_state_created; } diff --git a/src/publickey.c b/src/publickey.c index 8ca499c8..68c4de76 100644 --- a/src/publickey.c +++ b/src/publickey.c @@ -353,7 +353,7 @@ libssh2_publickey_init(LIBSSH2_SESSION * session) session->pkeyInit_pkey = NULL; session->pkeyInit_channel = NULL; - _libssh2_debug(session, LIBSSH2_DBG_PUBLICKEY, + _libssh2_debug(session, LIBSSH2_TRACE_PUBLICKEY, "Initializing publickey subsystem"); session->pkeyInit_state = libssh2_NB_state_allocated; @@ -434,7 +434,7 @@ libssh2_publickey_init(LIBSSH2_SESSION * session) _libssh2_htonu32(s, LIBSSH2_PUBLICKEY_VERSION); s += 4; - _libssh2_debug(session, LIBSSH2_DBG_PUBLICKEY, + _libssh2_debug(session, LIBSSH2_TRACE_PUBLICKEY, "Sending publickey version packet advertising version %d support", (int) LIBSSH2_PUBLICKEY_VERSION); @@ -519,13 +519,13 @@ libssh2_publickey_init(LIBSSH2_SESSION * session) session->pkeyInit_pkey->version = _libssh2_ntohu32(s); if (session->pkeyInit_pkey->version > LIBSSH2_PUBLICKEY_VERSION) { - _libssh2_debug(session, LIBSSH2_DBG_PUBLICKEY, + _libssh2_debug(session, LIBSSH2_TRACE_PUBLICKEY, "Truncating remote publickey version from %lu", session->pkeyInit_pkey->version); session->pkeyInit_pkey->version = LIBSSH2_PUBLICKEY_VERSION; } - _libssh2_debug(session, LIBSSH2_DBG_PUBLICKEY, + _libssh2_debug(session, LIBSSH2_TRACE_PUBLICKEY, "Enabling publickey subsystem version %lu", session->pkeyInit_pkey->version); LIBSSH2_FREE(session, session->pkeyInit_data); @@ -590,7 +590,7 @@ libssh2_publickey_add_ex(LIBSSH2_PUBLICKEY * pkey, const unsigned char *name, if (pkey->add_state == libssh2_NB_state_idle) { pkey->add_packet = NULL; - _libssh2_debug(session, LIBSSH2_DBG_PUBLICKEY, "Adding %s publickey", + _libssh2_debug(session, LIBSSH2_TRACE_PUBLICKEY, "Adding %s publickey", name); if (pkey->version == 1) { @@ -671,7 +671,7 @@ libssh2_publickey_add_ex(LIBSSH2_PUBLICKEY * pkey, const unsigned char *name, } } - _libssh2_debug(session, LIBSSH2_DBG_PUBLICKEY, + _libssh2_debug(session, LIBSSH2_TRACE_PUBLICKEY, "Sending publickey \"add\" packet: type=%s blob_len=%ld num_attrs=%ld", name, blob_len, num_attrs); @@ -747,7 +747,7 @@ libssh2_publickey_remove_ex(LIBSSH2_PUBLICKEY * pkey, memcpy(pkey->remove_s, blob, blob_len); pkey->remove_s += blob_len; - _libssh2_debug(session, LIBSSH2_DBG_PUBLICKEY, + _libssh2_debug(session, LIBSSH2_TRACE_PUBLICKEY, "Sending publickey \"remove\" packet: type=%s blob_len=%ld", name, blob_len); @@ -809,7 +809,7 @@ libssh2_publickey_list_fetch(LIBSSH2_PUBLICKEY * pkey, unsigned long *num_keys, memcpy(pkey->listFetch_s, "list", sizeof("list") - 1); pkey->listFetch_s += sizeof("list") - 1; - _libssh2_debug(session, LIBSSH2_DBG_PUBLICKEY, + _libssh2_debug(session, LIBSSH2_TRACE_PUBLICKEY, "Sending publickey \"list\" packet"); pkey->listFetch_state = libssh2_NB_state_created; diff --git a/src/scp.c b/src/scp.c index e861bf4c..c08856c9 100644 --- a/src/scp.c +++ b/src/scp.c @@ -301,7 +301,7 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb) session->scpRecv_command_len - cmd_len); - _libssh2_debug(session, LIBSSH2_DBG_SCP, + _libssh2_debug(session, LIBSSH2_TRACE_SCP, "Opening channel for SCP receive"); session->scpRecv_state = libssh2_NB_state_created; @@ -350,7 +350,7 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb) LIBSSH2_FREE(session, session->scpRecv_command); session->scpRecv_command = NULL; - _libssh2_debug(session, LIBSSH2_DBG_SCP, "Sending initial wakeup"); + _libssh2_debug(session, LIBSSH2_TRACE_SCP, "Sending initial wakeup"); /* SCP ACK */ session->scpRecv_response[0] = '\0'; @@ -569,7 +569,7 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb) goto scp_recv_error; } - _libssh2_debug(session, LIBSSH2_DBG_SCP, + _libssh2_debug(session, LIBSSH2_TRACE_SCP, "mtime = %ld, atime = %ld", session->scpRecv_mtime, session->scpRecv_atime); @@ -731,7 +731,7 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, struct stat * sb) } else if (rc != 1) { goto scp_recv_error; } - _libssh2_debug(session, LIBSSH2_DBG_SCP, + _libssh2_debug(session, LIBSSH2_TRACE_SCP, "mode = 0%lo size = %ld", session->scpRecv_mode, session->scpRecv_size); @@ -816,7 +816,7 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode, session->scpSend_command[session->scpSend_command_len - 1] = '\0'; - _libssh2_debug(session, LIBSSH2_DBG_SCP, + _libssh2_debug(session, LIBSSH2_TRACE_SCP, "Opening channel for SCP send"); /* Allocate a channel */ @@ -892,7 +892,7 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode, snprintf((char *) session->scpSend_response, LIBSSH2_SCP_RESPONSE_BUFLEN, "T%ld 0 %ld 0\n", mtime, atime); - _libssh2_debug(session, LIBSSH2_DBG_SCP, "Sent %s", + _libssh2_debug(session, LIBSSH2_TRACE_SCP, "Sent %s", session->scpSend_response); } @@ -953,7 +953,7 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode, snprintf((char *) session->scpSend_response, LIBSSH2_SCP_RESPONSE_BUFLEN, "C0%o %lu %s\n", mode, (unsigned long) size, base); - _libssh2_debug(session, LIBSSH2_DBG_SCP, "Sent %s", + _libssh2_debug(session, LIBSSH2_TRACE_SCP, "Sent %s", session->scpSend_response); session->scpSend_state = libssh2_NB_state_sent5; diff --git a/src/session.c b/src/session.c index b929a603..28885c50 100644 --- a/src/session.c +++ b/src/session.c @@ -112,10 +112,10 @@ banner_receive(LIBSSH2_SESSION * session) ret = _libssh2_recv(session->socket_fd, &c, 1, LIBSSH2_SOCKET_RECV_FLAGS(session)); if (ret < 0) - _libssh2_debug(session, LIBSSH2_DBG_SOCKET, + _libssh2_debug(session, LIBSSH2_TRACE_SOCKET, "Error recving %d bytes to %p: %d", 1, &c, errno); else - _libssh2_debug(session, LIBSSH2_DBG_SOCKET, + _libssh2_debug(session, LIBSSH2_TRACE_SOCKET, "Recved %d bytes to %p", ret, &c); if (ret < 0) { @@ -168,7 +168,7 @@ banner_receive(LIBSSH2_SESSION * session) } memcpy(session->remote.banner, session->banner_TxRx_banner, banner_len); session->remote.banner[banner_len] = '\0'; - _libssh2_debug(session, LIBSSH2_DBG_TRANS, "Received Banner: %s", + _libssh2_debug(session, LIBSSH2_TRACE_TRANS, "Received Banner: %s", session->remote.banner); return 0; } @@ -209,7 +209,7 @@ banner_send(LIBSSH2_SESSION * session) banner[255] = '\0'; } - _libssh2_debug(session, LIBSSH2_DBG_TRANS, "Sending Banner: %s", + _libssh2_debug(session, LIBSSH2_TRACE_TRANS, "Sending Banner: %s", banner_dup); #endif @@ -224,11 +224,11 @@ banner_send(LIBSSH2_SESSION * session) banner_len - session->banner_TxRx_total_send, LIBSSH2_SOCKET_SEND_FLAGS(session)); if (ret < 0) - _libssh2_debug(session, LIBSSH2_DBG_SOCKET, + _libssh2_debug(session, LIBSSH2_TRACE_SOCKET, "Error sending %d bytes: %d", banner_len - session->banner_TxRx_total_send, errno); else - _libssh2_debug(session, LIBSSH2_DBG_SOCKET, + _libssh2_debug(session, LIBSSH2_TRACE_SOCKET, "Sent %d/%d bytes at %p+%d", ret, banner_len - session->banner_TxRx_total_send, banner, session->banner_TxRx_total_send); @@ -410,7 +410,7 @@ libssh2_banner_set(LIBSSH2_SESSION * session, const char *banner) memcpy(session->local.banner, banner, banner_len); session->local.banner[banner_len] = '\0'; - _libssh2_debug(session, LIBSSH2_DBG_TRANS, "Setting local Banner: %s", + _libssh2_debug(session, LIBSSH2_TRACE_TRANS, "Setting local Banner: %s", session->local.banner); session->local.banner[banner_len++] = '\r'; session->local.banner[banner_len++] = '\n'; @@ -456,7 +456,7 @@ libssh2_session_init_ex(LIBSSH2_ALLOC_FUNC((*my_alloc)), session->realloc = local_realloc; session->abstract = abstract; session->api_block_mode = 1; /* blocking API by default */ - _libssh2_debug(session, LIBSSH2_DBG_TRANS, + _libssh2_debug(session, LIBSSH2_TRACE_TRANS, "New session resource allocated"); libssh2_crypto_init(); } @@ -505,7 +505,7 @@ libssh2_session_callback_set(LIBSSH2_SESSION * session, return oldcb; } - _libssh2_debug(session, LIBSSH2_DBG_TRANS, "Setting Callback %d", cbtype); + _libssh2_debug(session, LIBSSH2_TRACE_TRANS, "Setting Callback %d", cbtype); return NULL; } @@ -555,7 +555,7 @@ session_startup(LIBSSH2_SESSION *session, libssh2_socket_t sock) int rc; if (session->startup_state == libssh2_NB_state_idle) { - _libssh2_debug(session, LIBSSH2_DBG_TRANS, + _libssh2_debug(session, LIBSSH2_TRACE_TRANS, "session_startup for socket %d", sock); /* FIXME: on some platforms (like win32) sockets are unsigned */ if (sock < 0) { @@ -610,7 +610,7 @@ session_startup(LIBSSH2_SESSION *session, libssh2_socket_t sock) } if (session->startup_state == libssh2_NB_state_sent2) { - _libssh2_debug(session, LIBSSH2_DBG_TRANS, + _libssh2_debug(session, LIBSSH2_TRACE_TRANS, "Requesting userauth service"); /* Request the userauth service */ @@ -701,7 +701,7 @@ session_free(LIBSSH2_SESSION *session) LIBSSH2_LISTENER *l; if (session->free_state == libssh2_NB_state_idle) { - _libssh2_debug(session, LIBSSH2_DBG_TRANS, "Freeing session resource", + _libssh2_debug(session, LIBSSH2_TRACE_TRANS, "Freeing session resource", session->remote.banner); session->state = libssh2_NB_state_created; @@ -961,7 +961,7 @@ session_disconnect(LIBSSH2_SESSION *session, int reason, int rc; if (session->disconnect_state == libssh2_NB_state_idle) { - _libssh2_debug(session, LIBSSH2_DBG_TRANS, + _libssh2_debug(session, LIBSSH2_TRACE_TRANS, "Disconnecting: reason=%d, desc=%s, lang=%s", reason, description, lang); if (description) { @@ -1207,7 +1207,7 @@ int _libssh2_session_set_blocking(LIBSSH2_SESSION *session, int blocking) { int bl = session->api_block_mode; - _libssh2_debug(session, LIBSSH2_DBG_CONN, + _libssh2_debug(session, LIBSSH2_TRACE_CONN, "Setting blocking mode %s", blocking?"ON":"OFF"); session->api_block_mode = blocking; diff --git a/src/sftp.c b/src/sftp.c index e834b4df..f7f04538 100644 --- a/src/sftp.c +++ b/src/sftp.c @@ -118,7 +118,7 @@ sftp_packet_add(LIBSSH2_SFTP *sftp, unsigned char *data, LIBSSH2_SESSION *session = sftp->channel->session; LIBSSH2_PACKET *packet; - _libssh2_debug(session, LIBSSH2_DBG_SFTP, "Received packet %d (len %d)", + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Received packet %d (len %d)", (int) data[0], data_len); packet = LIBSSH2_ALLOC(session, sizeof(LIBSSH2_PACKET)); if (!packet) { @@ -153,7 +153,7 @@ sftp_packet_read(LIBSSH2_SFTP *sftp) ssize_t bytes_received; int rc; - _libssh2_debug(session, LIBSSH2_DBG_SFTP, "recv packet"); + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "recv packet"); /* If there was a previous partial, start using it */ if (sftp->partial_packet) { @@ -163,7 +163,7 @@ sftp_packet_read(LIBSSH2_SFTP *sftp) packet_received = sftp->partial_received; sftp->partial_packet = NULL; - _libssh2_debug(session, LIBSSH2_DBG_SFTP, + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "partial read cont, len: %lu", packet_len); } else { @@ -181,7 +181,7 @@ sftp_packet_read(LIBSSH2_SFTP *sftp) } packet_len = _libssh2_ntohu32(buffer); - _libssh2_debug(session, LIBSSH2_DBG_SFTP, + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Data begin - Packet Length: %lu", packet_len); if (packet_len > LIBSSH2_SFTP_PACKET_MAXLEN) { libssh2_error(session, LIBSSH2_ERROR_CHANNEL_PACKET_EXCEEDED, @@ -251,7 +251,7 @@ sftp_packet_ask(LIBSSH2_SFTP *sftp, unsigned char packet_type, unsigned char match_buf[5]; int match_len; - _libssh2_debug(session, LIBSSH2_DBG_SFTP, "Asking for %d packet", + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Asking for %d packet", (int) packet_type); match_buf[0] = packet_type; @@ -293,12 +293,12 @@ sftp_packet_require(LIBSSH2_SFTP *sftp, unsigned char packet_type, LIBSSH2_SESSION *session = sftp->channel->session; int ret; - _libssh2_debug(session, LIBSSH2_DBG_SFTP, "Requiring packet %d id %ld", + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Requiring packet %d id %ld", (int) packet_type, request_id); if (sftp_packet_ask(sftp, packet_type, request_id, data, data_len) == 0) { /* The right packet was available in the packet brigade */ - _libssh2_debug(session, LIBSSH2_DBG_SFTP, "Got %d", + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Got %d", (int) packet_type); return 0; } @@ -314,7 +314,7 @@ sftp_packet_require(LIBSSH2_SFTP *sftp, unsigned char packet_type, /* data was read, check the queue again */ if (!sftp_packet_ask(sftp, packet_type, request_id, data, data_len)) { /* The right packet was available in the packet brigade */ - _libssh2_debug(session, LIBSSH2_DBG_SFTP, "Got %d", + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Got %d", (int) packet_type); return 0; } @@ -530,7 +530,7 @@ static LIBSSH2_SFTP *sftp_init(LIBSSH2_SESSION *session) LIBSSH2_SFTP *sftp_handle; if (session->sftpInit_state == libssh2_NB_state_idle) { - _libssh2_debug(session, LIBSSH2_DBG_SFTP, + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Initializing SFTP subsystem"); /* @@ -616,7 +616,7 @@ static LIBSSH2_SFTP *sftp_init(LIBSSH2_SESSION *session) session->sftpInit_buffer[4] = SSH_FXP_INIT; _libssh2_htonu32(session->sftpInit_buffer + 5, LIBSSH2_SFTP_VERSION); - _libssh2_debug(session, LIBSSH2_DBG_SFTP, + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Sending FXP_INIT packet advertising version %d support", (int) LIBSSH2_SFTP_VERSION); @@ -661,12 +661,12 @@ static LIBSSH2_SFTP *sftp_init(LIBSSH2_SESSION *session) sftp_handle->version = _libssh2_ntohu32(s); s += 4; if (sftp_handle->version > LIBSSH2_SFTP_VERSION) { - _libssh2_debug(session, LIBSSH2_DBG_SFTP, + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Truncating remote SFTP version from %lu", sftp_handle->version); sftp_handle->version = LIBSSH2_SFTP_VERSION; } - _libssh2_debug(session, LIBSSH2_DBG_SFTP, + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Enabling SFTP version %lu compatability", sftp_handle->version); while (s < (data + data_len)) { @@ -864,7 +864,7 @@ sftp_open(LIBSSH2_SFTP *sftp, const char *filename, s += sftp_attr2bin(s, &attrs); } - _libssh2_debug(session, LIBSSH2_DBG_SFTP, "Sending %s open request", + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Sending %s open request", (open_type == LIBSSH2_SFTP_OPENFILE) ? "file" : "directory"); @@ -925,7 +925,7 @@ sftp_open(LIBSSH2_SFTP *sftp, const char *filename, sftp->last_errno = _libssh2_ntohu32(data + 5); if(LIBSSH2_FX_OK == sftp->last_errno) { - _libssh2_debug(session, LIBSSH2_DBG_SFTP, "got HANDLE FXOK!"); + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "got HANDLE FXOK!"); /* silly situation, but check for a HANDLE */ rc = sftp_packet_require(sftp, SSH_FXP_HANDLE, @@ -943,7 +943,7 @@ sftp_open(LIBSSH2_SFTP *sftp, const char *filename, if(badness) { libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL, "Failed opening remote file", 0); - _libssh2_debug(session, LIBSSH2_DBG_SFTP, "got FXP_STATUS %d", + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "got FXP_STATUS %d", sftp->last_errno); LIBSSH2_FREE(session, data); return NULL; @@ -979,7 +979,7 @@ sftp_open(LIBSSH2_SFTP *sftp, const char *filename, fp->u.file.offset = 0; - _libssh2_debug(session, LIBSSH2_DBG_SFTP, "Open command successful"); + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Open command successful"); return fp; } @@ -1019,7 +1019,7 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer, int retcode; if (sftp->read_state == libssh2_NB_state_idle) { - _libssh2_debug(session, LIBSSH2_DBG_SFTP, + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Reading %lu bytes from SFTP handle", (unsigned long) buffer_maxlen); packet = handle->request_packet; @@ -1057,7 +1057,7 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer, bytes_requested = LIBSSH2_SFTP_PACKET_MAXLEN - 13; } #ifdef LIBSSH2_DEBUG_SFTP - _libssh2_debug(session, LIBSSH2_DBG_SFTP, + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Requesting %lu bytes from SFTP handle", (unsigned long) bytes_requested); #endif @@ -1153,7 +1153,7 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer, return -1; } #ifdef LIBSSH2_DEBUG_SFTP - _libssh2_debug(session, LIBSSH2_DBG_SFTP, "%lu bytes returned", + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "%lu bytes returned", (unsigned long) bytes_read); #endif memcpy(buffer + total_read, data + 9, bytes_read); @@ -1257,7 +1257,7 @@ static int sftp_readdir(LIBSSH2_SFTP_HANDLE *handle, char *buffer, LIBSSH2_FREE(session, handle->u.dir.names_packet); } - _libssh2_debug(session, LIBSSH2_DBG_SFTP, + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "libssh2_sftp_readdir_ex() return %d", filename_len); return filename_len; @@ -1288,7 +1288,7 @@ static int sftp_readdir(LIBSSH2_SFTP_HANDLE *handle, char *buffer, } if (sftp->readdir_state == libssh2_NB_state_created) { - _libssh2_debug(session, LIBSSH2_DBG_SFTP, + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Reading entries from directory handle"); retcode = _libssh2_channel_write(channel, 0, (char *) sftp->readdir_packet, @@ -1340,7 +1340,7 @@ static int sftp_readdir(LIBSSH2_SFTP_HANDLE *handle, char *buffer, } num_names = _libssh2_ntohu32(data + 5); - _libssh2_debug(session, LIBSSH2_DBG_SFTP, "%lu entries returned", + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "%lu entries returned", num_names); if (num_names <= 0) { LIBSSH2_FREE(session, data); @@ -1431,7 +1431,7 @@ static ssize_t sftp_write(LIBSSH2_SFTP_HANDLE *handle, const char *buffer, packet_len = handle->handle_len + count + 25; if (sftp->write_state == libssh2_NB_state_idle) { - _libssh2_debug(session, LIBSSH2_DBG_SFTP, "Writing %lu bytes", + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Writing %lu bytes", (unsigned long) count); s = sftp->write_packet = LIBSSH2_ALLOC(session, packet_len); if (!sftp->write_packet) { @@ -1541,7 +1541,7 @@ static int sftp_fstat(LIBSSH2_SFTP_HANDLE *handle, int rc; if (sftp->fstat_state == libssh2_NB_state_idle) { - _libssh2_debug(session, LIBSSH2_DBG_SFTP, "Issuing %s command", + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Issuing %s command", setstat ? "set-stat" : "stat"); s = sftp->fstat_packet = LIBSSH2_ALLOC(session, packet_len); if (!sftp->fstat_packet) { @@ -1693,7 +1693,7 @@ sftp_close_handle(LIBSSH2_SFTP_HANDLE *handle) int rc; if (handle->close_state == libssh2_NB_state_idle) { - _libssh2_debug(session, LIBSSH2_DBG_SFTP, "Closing handle"); + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Closing handle"); s = handle->close_packet = LIBSSH2_ALLOC(session, packet_len); if (!handle->close_packet) { libssh2_error(session, LIBSSH2_ERROR_ALLOC, @@ -1804,7 +1804,7 @@ static int sftp_unlink(LIBSSH2_SFTP *sftp, const char *filename, int rc; if (sftp->unlink_state == libssh2_NB_state_idle) { - _libssh2_debug(session, LIBSSH2_DBG_SFTP, "Unlinking %s", filename); + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Unlinking %s", filename); s = sftp->unlink_packet = LIBSSH2_ALLOC(session, packet_len); if (!sftp->unlink_packet) { libssh2_error(session, LIBSSH2_ERROR_ALLOC, @@ -1916,7 +1916,7 @@ static int sftp_rename(LIBSSH2_SFTP *sftp, const char *source_filename, } if (sftp->rename_state == libssh2_NB_state_idle) { - _libssh2_debug(session, LIBSSH2_DBG_SFTP, "Renaming %s to %s", + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Renaming %s to %s", source_filename, dest_filename); sftp->rename_s = sftp->rename_packet = LIBSSH2_ALLOC(session, packet_len); @@ -2052,7 +2052,7 @@ static int sftp_mkdir(LIBSSH2_SFTP *sftp, const char *path, int rc; if (sftp->mkdir_state == libssh2_NB_state_idle) { - _libssh2_debug(session, LIBSSH2_DBG_SFTP, + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Creating directory %s with mode 0%lo", path, mode); s = packet = LIBSSH2_ALLOC(session, packet_len); if (!packet) { @@ -2116,7 +2116,7 @@ static int sftp_mkdir(LIBSSH2_SFTP *sftp, const char *path, LIBSSH2_FREE(session, data); if (retcode == LIBSSH2_FX_OK) { - _libssh2_debug(session, LIBSSH2_DBG_SFTP, "OK!"); + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "OK!"); return 0; } else { libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL, @@ -2156,7 +2156,7 @@ static int sftp_rmdir(LIBSSH2_SFTP *sftp, const char *path, int rc; if (sftp->rmdir_state == libssh2_NB_state_idle) { - _libssh2_debug(session, LIBSSH2_DBG_SFTP, "Removing directory: %s", + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "Removing directory: %s", path); s = sftp->rmdir_packet = LIBSSH2_ALLOC(session, packet_len); if (!sftp->rmdir_packet) { @@ -2258,7 +2258,7 @@ static int sftp_stat(LIBSSH2_SFTP *sftp, const char *path, int rc; if (sftp->stat_state == libssh2_NB_state_idle) { - _libssh2_debug(session, LIBSSH2_DBG_SFTP, "%s %s", + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "%s %s", (stat_type == LIBSSH2_SFTP_SETSTAT) ? "Set-statting" : (stat_type == LIBSSH2_SFTP_LSTAT ? "LStatting" : "Statting"), path); @@ -2400,7 +2400,7 @@ static int sftp_symlink(LIBSSH2_SFTP *sftp, const char *path, return -1; } - _libssh2_debug(session, LIBSSH2_DBG_SFTP, "%s %s on %s", + _libssh2_debug(session, LIBSSH2_TRACE_SFTP, "%s %s on %s", (link_type == LIBSSH2_SFTP_SYMLINK) ? "Creating" : "Reading", (link_type == diff --git a/src/transport.c b/src/transport.c index b15d01da..5a2dfeb7 100644 --- a/src/transport.c +++ b/src/transport.c @@ -60,7 +60,7 @@ debugdump(LIBSSH2_SESSION * session, FILE *stream = stderr; unsigned int width = 0x10; - if (!(session->showmask & (1 << LIBSSH2_DBG_TRANS))) { + if (!(session->showmask & LIBSSH2_TRACE_TRANS)) { /* not asked for, bail out */ return; } @@ -290,7 +290,7 @@ int _libssh2_transport_read(LIBSSH2_SESSION * session) /* Whoever wants a packet won't get anything until the key re-exchange * is done! */ - _libssh2_debug(session, LIBSSH2_DBG_TRANS, "Redirecting into the" + _libssh2_debug(session, LIBSSH2_TRACE_TRANS, "Redirecting into the" " key re-exchange"); rc = libssh2_kex_exchange(session, 1, &session->startup_key_state); if (rc) @@ -356,12 +356,12 @@ int _libssh2_transport_read(LIBSSH2_SESSION * session) PACKETBUFSIZE - remainbuf, LIBSSH2_SOCKET_RECV_FLAGS(session)); if (nread < 0) - _libssh2_debug(session, LIBSSH2_DBG_SOCKET, + _libssh2_debug(session, LIBSSH2_TRACE_SOCKET, "Error recving %d bytes to %p+%d: %d", PACKETBUFSIZE - remainbuf, p->buf, remainbuf, errno); else - _libssh2_debug(session, LIBSSH2_DBG_SOCKET, + _libssh2_debug(session, LIBSSH2_TRACE_SOCKET, "Recved %d/%d bytes to %p+%d", nread, PACKETBUFSIZE - remainbuf, p->buf, remainbuf); if (nread <= 0) { @@ -612,10 +612,10 @@ send_existing(LIBSSH2_SESSION * session, unsigned char *data, rc = _libssh2_send(session->socket_fd, &p->outbuf[p->osent], length, LIBSSH2_SOCKET_SEND_FLAGS(session)); if (rc < 0) - _libssh2_debug(session, LIBSSH2_DBG_SOCKET, + _libssh2_debug(session, LIBSSH2_TRACE_SOCKET, "Error sending %d bytes: %d", length, errno); else - _libssh2_debug(session, LIBSSH2_DBG_SOCKET, + _libssh2_debug(session, LIBSSH2_TRACE_SOCKET, "Sent %d/%d bytes at %p+%d", rc, length, p->outbuf, p->osent); @@ -793,10 +793,10 @@ _libssh2_transport_write(LIBSSH2_SESSION * session, unsigned char *data, ret = _libssh2_send(session->socket_fd, p->outbuf, total_length, LIBSSH2_SOCKET_SEND_FLAGS(session)); if (ret < 0) - _libssh2_debug(session, LIBSSH2_DBG_SOCKET, + _libssh2_debug(session, LIBSSH2_TRACE_SOCKET, "Error sending %d bytes: %d", total_length, errno); else - _libssh2_debug(session, LIBSSH2_DBG_SOCKET, "Sent %d/%d bytes at %p", + _libssh2_debug(session, LIBSSH2_TRACE_SOCKET, "Sent %d/%d bytes at %p", ret, total_length, p->outbuf); if (ret != -1) { diff --git a/src/userauth.c b/src/userauth.c index 9aed20e1..3ee338e3 100644 --- a/src/userauth.c +++ b/src/userauth.c @@ -155,7 +155,7 @@ static char *userauth_list(LIBSSH2_SESSION *session, const char *username, memmove(session->userauth_list_data, session->userauth_list_data + 5, methods_len); session->userauth_list_data[methods_len] = '\0'; - _libssh2_debug(session, LIBSSH2_DBG_AUTH, "Permitted auth methods: %s", + _libssh2_debug(session, LIBSSH2_TRACE_AUTH, "Permitted auth methods: %s", session->userauth_list_data); } @@ -256,7 +256,7 @@ userauth_password(LIBSSH2_SESSION *session, const char *username, memcpy(s, password, password_len); s += password_len; - _libssh2_debug(session, LIBSSH2_DBG_AUTH, + _libssh2_debug(session, LIBSSH2_TRACE_AUTH, "Attempting to login using password authentication"); session->userauth_pswd_state = libssh2_NB_state_created; @@ -301,7 +301,7 @@ userauth_password(LIBSSH2_SESSION *session, const char *username, } if (session->userauth_pswd_data[0] == SSH_MSG_USERAUTH_SUCCESS) { - _libssh2_debug(session, LIBSSH2_DBG_AUTH, + _libssh2_debug(session, LIBSSH2_TRACE_AUTH, "Password authentication successful"); LIBSSH2_FREE(session, session->userauth_pswd_data); session->userauth_pswd_data = NULL; @@ -325,7 +325,7 @@ userauth_password(LIBSSH2_SESSION *session, const char *username, if ((session->userauth_pswd_state == libssh2_NB_state_sent1) || (session->userauth_pswd_state == libssh2_NB_state_sent2)) { if (session->userauth_pswd_state == libssh2_NB_state_sent1) { - _libssh2_debug(session, LIBSSH2_DBG_AUTH, + _libssh2_debug(session, LIBSSH2_TRACE_AUTH, "Password change required"); LIBSSH2_FREE(session, session->userauth_pswd_data); session->userauth_pswd_data = NULL; @@ -484,7 +484,7 @@ file_read_publickey(LIBSSH2_SESSION * session, unsigned char **method, size_t pubkey_len = 0; unsigned int tmp_len; - _libssh2_debug(session, LIBSSH2_DBG_AUTH, "Loading public key file: %s", + _libssh2_debug(session, LIBSSH2_TRACE_AUTH, "Loading public key file: %s", pubkeyfile); /* Read Public Key */ fd = fopen(pubkeyfile, "r"); @@ -583,7 +583,7 @@ file_read_privatekey(LIBSSH2_SESSION * session, const LIBSSH2_HOSTKEY_METHOD **hostkey_methods_avail = libssh2_hostkey_methods(); - _libssh2_debug(session, LIBSSH2_DBG_AUTH, "Loading private key file: %s", + _libssh2_debug(session, LIBSSH2_TRACE_AUTH, "Loading private key file: %s", privkeyfile); *hostkey_method = NULL; *hostkey_abstract = NULL; @@ -795,7 +795,7 @@ userauth_hostbased_fromfile(LIBSSH2_SESSION *session, session->userauth_host_s += sig_len; LIBSSH2_FREE(session, sig); - _libssh2_debug(session, LIBSSH2_DBG_AUTH, + _libssh2_debug(session, LIBSSH2_TRACE_AUTH, "Attempting hostbased authentication"); session->userauth_host_state = libssh2_NB_state_created; @@ -839,7 +839,7 @@ userauth_hostbased_fromfile(LIBSSH2_SESSION *session, return -1; if (session->userauth_host_data[0] == SSH_MSG_USERAUTH_SUCCESS) { - _libssh2_debug(session, LIBSSH2_DBG_AUTH, + _libssh2_debug(session, LIBSSH2_TRACE_AUTH, "Hostbased authentication successful"); /* We are us and we've proved it. */ LIBSSH2_FREE(session, session->userauth_host_data); @@ -977,7 +977,7 @@ userauth_publickey_fromfile(LIBSSH2_SESSION *session, session->userauth_pblc_s += pubkeydata_len; LIBSSH2_FREE(session, pubkeydata); - _libssh2_debug(session, LIBSSH2_DBG_AUTH, + _libssh2_debug(session, LIBSSH2_TRACE_AUTH, "Attempting publickey authentication"); session->userauth_pblc_state = libssh2_NB_state_created; @@ -1028,7 +1028,7 @@ userauth_publickey_fromfile(LIBSSH2_SESSION *session, } if (session->userauth_pblc_data[0] == SSH_MSG_USERAUTH_SUCCESS) { - _libssh2_debug(session, LIBSSH2_DBG_AUTH, + _libssh2_debug(session, LIBSSH2_TRACE_AUTH, "Pubkey authentication prematurely successful"); /* * God help any SSH server that allows an UNVERIFIED @@ -1152,7 +1152,7 @@ userauth_publickey_fromfile(LIBSSH2_SESSION *session, session->userauth_pblc_s += sig_len; LIBSSH2_FREE(session, sig); - _libssh2_debug(session, LIBSSH2_DBG_AUTH, + _libssh2_debug(session, LIBSSH2_TRACE_AUTH, "Attempting publickey authentication -- phase 2"); session->userauth_pblc_state = libssh2_NB_state_sent1; @@ -1193,7 +1193,7 @@ userauth_publickey_fromfile(LIBSSH2_SESSION *session, } if (session->userauth_pblc_data[0] == SSH_MSG_USERAUTH_SUCCESS) { - _libssh2_debug(session, LIBSSH2_DBG_AUTH, + _libssh2_debug(session, LIBSSH2_TRACE_AUTH, "Publickey authentication successful"); /* We are us and we've proved it. */ LIBSSH2_FREE(session, session->userauth_pblc_data); @@ -1317,7 +1317,7 @@ userauth_keyboard_interactive(LIBSSH2_SESSION * session, _libssh2_htonu32(s, 0); s += 4; - _libssh2_debug(session, LIBSSH2_DBG_AUTH, + _libssh2_debug(session, LIBSSH2_TRACE_AUTH, "Attempting keyboard-interactive authentication"); session->userauth_kybd_state = libssh2_NB_state_created; @@ -1358,7 +1358,7 @@ userauth_keyboard_interactive(LIBSSH2_SESSION * session, } if (session->userauth_kybd_data[0] == SSH_MSG_USERAUTH_SUCCESS) { - _libssh2_debug(session, LIBSSH2_DBG_AUTH, + _libssh2_debug(session, LIBSSH2_TRACE_AUTH, "Keyboard-interactive authentication successful"); LIBSSH2_FREE(session, session->userauth_kybd_data); session->userauth_kybd_data = NULL; @@ -1483,7 +1483,7 @@ userauth_keyboard_interactive(LIBSSH2_SESSION * session, session->userauth_kybd_responses, &session->abstract); - _libssh2_debug(session, LIBSSH2_DBG_AUTH, + _libssh2_debug(session, LIBSSH2_TRACE_AUTH, "Keyboard-interactive response callback function" " invoked");