+
+/* OPER command. Used to obtain server operator privileges. */
+
+SILC_CLIENT_CMD_FUNC(oper)
+{
+ SilcClientCommandContext cmd = (SilcClientCommandContext)context;
+ SilcClientConnection conn = cmd->conn;
+
+ if (!cmd->conn) {
+ SILC_NOT_CONNECTED(cmd->client, cmd->conn);
+ COMMAND_ERROR;
+ goto out;
+ }
+
+ if (cmd->argc < 2) {
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO,
+ "Usage: /OPER <username> [-pubkey]");
+ COMMAND_ERROR;
+ goto out;
+ }
+
+ if (cmd->argc < 3) {
+ /* Get passphrase */
+ cmd->client->ops->ask_passphrase(cmd->client, conn,
+ silc_client_command_oper_send,
+ context);
+ return;
+ }
+
+ silc_client_command_oper_send(NULL, 0, context);
+
+ out:
+ silc_client_command_free(cmd);
+}
+
+static void silc_client_command_silcoper_send(unsigned char *data,
+ uint32 data_len, void *context)
+{
+ SilcClientCommandContext cmd = (SilcClientCommandContext)context;
+ SilcClientConnection conn = cmd->conn;
+ SilcBuffer buffer, auth;
+
+ if (cmd->argc >= 3) {
+ /* Encode the public key authentication payload */
+ auth = silc_auth_public_key_auth_generate(cmd->client->public_key,
+ cmd->client->private_key,
+ conn->hash,
+ conn->local_id,
+ SILC_ID_CLIENT);
+ } else {
+ /* Encode the password authentication payload */
+ auth = silc_auth_payload_encode(SILC_AUTH_PASSWORD, NULL, 0,
+ data, data_len);
+ }
+
+ buffer = silc_command_payload_encode_va(SILC_COMMAND_SILCOPER, 0, 2,
+ 1, cmd->argv[1],
+ strlen(cmd->argv[1]),
+ 2, auth->data, auth->len);
+ silc_client_packet_send(cmd->client, conn->sock, SILC_PACKET_COMMAND, NULL,
+ 0, NULL, NULL, buffer->data, buffer->len, TRUE);
+
+ silc_buffer_free(buffer);
+ silc_buffer_free(auth);
+
+ /* Notify application */
+ COMMAND;
+}
+
+/* SILCOPER command. Used to obtain router operator privileges. */
+
+SILC_CLIENT_CMD_FUNC(silcoper)
+{
+ SilcClientCommandContext cmd = (SilcClientCommandContext)context;
+ SilcClientConnection conn = cmd->conn;
+
+ if (!cmd->conn) {
+ SILC_NOT_CONNECTED(cmd->client, cmd->conn);
+ COMMAND_ERROR;
+ goto out;
+ }
+
+ if (cmd->argc < 2) {
+ cmd->client->ops->say(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO,
+ "Usage: /SILCOPER <username> [-pubkey]");
+ COMMAND_ERROR;
+ goto out;
+ }
+
+ if (cmd->argc < 3) {
+ /* Get passphrase */
+ cmd->client->ops->ask_passphrase(cmd->client, conn,
+ silc_client_command_silcoper_send,
+ context);
+ return;
+ }
+
+ silc_client_command_silcoper_send(NULL, 0, context);
+
+ out:
+ silc_client_command_free(cmd);
+}
+
+/* CONNECT command. Connects the server to another server. */
+
+SILC_CLIENT_CMD_FUNC(connect)