SILC_LOG_DEBUG(("Initializing client"));
/* Initialize hash functions for client to use */
- silc_hash_alloc("md5", &client->internal->md5hash);
- silc_hash_alloc("sha1", &client->internal->sha1hash);
+ silc_hash_alloc("md5", &client->md5hash);
+ silc_hash_alloc("sha1", &client->sha1hash);
/* Initialize none cipher */
silc_cipher_alloc("none", &client->internal->none_cipher);
SILC_LOG_DEBUG(("Start"));
- /* XXX We should most likely use the resolved host name instead of the
- one user provided for us. */
- silc_free(conn->sock->hostname);
- conn->sock->hostname = strdup(conn->remote_host);
+ if (conn->sock->hostname) {
+ silc_free(conn->remote_host);
+ conn->remote_host = strdup(conn->sock->hostname);
+ } else {
+ conn->sock->hostname = strdup(conn->remote_host);
+ }
if (!conn->sock->ip)
- conn->sock->ip = strdup(conn->remote_host);
+ conn->sock->ip = strdup(conn->sock->hostname);
conn->sock->port = conn->remote_port;
/* Allocate internal Key Exchange context. This is sent to the
SilcBuffer buffer = packet->buffer;
SilcPacketType type = packet->type;
- SILC_LOG_DEBUG(("Parsing packet type %d", type));
+ SILC_LOG_DEBUG(("Parsing %s packet", silc_get_packet_name(type)));
/* Parse the packet type */
switch(type) {
+
case SILC_PACKET_DISCONNECT:
silc_client_disconnected_by_server(client, sock, buffer);
break;
+
case SILC_PACKET_SUCCESS:
/*
* Success received for something. For now we can have only
if (sock->protocol)
silc_protocol_execute(sock->protocol, client->schedule, 0, 0);
break;
+
case SILC_PACKET_FAILURE:
/*
* Failure received for some protocol. Set the protocol state to
*/
silc_client_process_failure(client, sock, packet);
break;
+
case SILC_PACKET_REJECT:
break;
*/
silc_client_channel_message(client, sock, packet);
break;
+
case SILC_PACKET_CHANNEL_KEY:
/*
* Received key for a channel. By receiving this key the client will be
*/
silc_client_private_message(client, sock, packet);
break;
+
case SILC_PACKET_PRIVATE_MESSAGE_KEY:
/*
* Received private message key
*/
break;
+ case SILC_PACKET_COMMAND:
+ /*
+ * Received command packet, a special case since normally client
+ * does not receive commands.
+ */
+ silc_client_command_process(client, sock, packet);
+ break;
+
case SILC_PACKET_COMMAND_REPLY:
/*
* Recived reply for a command
"protocol active, packet dropped."));
}
break;
+
case SILC_PACKET_KEY_EXCHANGE_2:
if (sock->protocol && sock->protocol->protocol &&
(sock->protocol->protocol->type == SILC_PROTOCOL_CLIENT_KEY_EXCHANGE ||