+ /* Create the listener for incoming key exchange protocol. */
+ if (!do_not_bind) {
+ session->listener = -1;
+ if (local_ip)
+ session->hostname = strdup(local_ip);
+ else
+ silc_net_check_local_by_sock(conn->sock->sock, NULL,
+ &session->hostname);
+ if (session->hostname)
+ session->listener = silc_net_create_server(local_port,
+ session->hostname);
+ if (session->listener < 0) {
+ /* Could not create listener. Do the second best thing; send empty
+ key agreement packet and let the remote client provide the point
+ for the key exchange. */
+ SILC_LOG_DEBUG(("Could not create listener"));
+ silc_free(session->hostname);
+ session->listener = 0;
+ session->hostname = NULL;
+ session->port = 0;
+ } else {
+ /* Listener ready */
+ SILC_LOG_DEBUG(("Bound listener"));
+ session->port = silc_net_get_local_port(session->listener);
+ silc_schedule_task_add(client->schedule, session->listener,
+ silc_client_ftp_process_key_agreement, session,
+ 0, 0, SILC_TASK_FD, SILC_TASK_PRI_NORMAL);
+ session->bound = TRUE;
+ }
+ }
+
+ SILC_LOG_DEBUG(("Sending key agreement for file transfer"));
+