* A comma in invite/ban string is invalid, check for it.
Affected file apps/silcd/server_util.c.
+ * Added SERVICE command to the server. It parses the command
+ request but SILC Server does not support services for the
+ time being. Affected file apps/silcd/command.[ch].
+
+ * Added SERVICE command and command reply to client library.
+ It is however incomplete. Updated Toolkit documentation.
+ Affected files are lib/silcclient/command[_reply].[ch].
+
Mon Apr 25 14:25:24 EEST 2005 Pekka Riikonen <priikone@silcnet.org>
* Moved silcer/, silc/, silcd/ and irssi/ to apps/. This
SILC_SERVER_CMD(leave, LEAVE, SILC_CF_LAG_STRICT | SILC_CF_REG),
SILC_SERVER_CMD(users, USERS, SILC_CF_LAG | SILC_CF_REG),
SILC_SERVER_CMD(getkey, GETKEY, SILC_CF_LAG | SILC_CF_REG),
+ SILC_SERVER_CMD(service, SERVICE, SILC_CF_LAG_STRICT | SILC_CF_REG),
SILC_SERVER_CMD(connect, PRIV_CONNECT,
SILC_CF_LAG | SILC_CF_REG | SILC_CF_OPER),
silc_server_command_free(cmd);
}
+/* Server side of command SERVICE. */
+/* XXX currently this just sends empty reply back */
+
+SILC_SERVER_CMD_FUNC(service)
+{
+ SilcServerCommandContext cmd = (SilcServerCommandContext)context;
+ SilcServer server = cmd->server;
+ SilcUInt32 tmp_len, auth_len;
+ unsigned char *service_name, *auth;
+ bool send_list = FALSE;
+ SilcUInt16 ident = silc_command_get_ident(cmd->payload);
+
+ SILC_SERVER_COMMAND_CHECK(SILC_COMMAND_SERVICE, cmd, 0, 256);
+
+ /* Get requested service */
+ service_name = silc_argument_get_arg_type(cmd->args, 1, &tmp_len);
+ if (service_name && tmp_len) {
+ /* Verify service name */
+ if (!silc_identifier_verify(service_name, tmp_len,
+ SILC_STRING_UTF8, 256)) {
+ silc_server_command_send_status_reply(cmd, SILC_COMMAND_SERVICE,
+ SILC_STATUS_ERR_NOT_ENOUGH_PARAMS,
+ 0);
+ goto out;
+ }
+ }
+
+ /* Get authentication payload if present */
+ auth = silc_argument_get_arg_type(cmd->args, 2, &auth_len);
+ if (auth) {
+ /* XXX */
+ }
+
+
+ send_list = TRUE;
+
+ /* Send our service list back */
+ silc_server_send_command_reply(server, cmd->sock, SILC_COMMAND_SERVICE,
+ SILC_STATUS_OK, 0, ident, 0);
+
+ out:
+ silc_server_command_free(cmd);
+}
+
/* Private range commands, specific to this implementation */
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 2002 Pekka Riikonen
+ Copyright (C) 1997 - 2005 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
+ the Free Software Foundation; version 2 of the License.
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#ifndef COMMAND_H
#define COMMAND_H
-/*
- Structure holding one command and pointer to its function.
+/*
+ Structure holding one command and pointer to its function.
SilcCommandCb cb
SilcCommandFlag flags
Flags for the command. These set how command behaves on different
- situations.
+ situations.
*/
typedef struct {
{ silc_server_command_##func, SILC_COMMAND_##cmd, flags }
/* Macro used to declare command functions. The `context' will be the
- SilcServerCommandContext and the `context2' is the
+ SilcServerCommandContext and the `context2' is the
SilcServerCommandReplyContext if this function is called from the
- command reply as pending command callback. Otherwise `context2'
+ command reply as pending command callback. Otherwise `context2'
is NULL. */
#define SILC_SERVER_CMD_FUNC(func) \
void silc_server_command_##func(void *context, void *context2)
SilcPacketContext *packet);
SilcServerCommandContext silc_server_command_alloc();
void silc_server_command_free(SilcServerCommandContext ctx);
-SilcServerCommandContext
+SilcServerCommandContext
silc_server_command_dup(SilcServerCommandContext ctx);
bool silc_server_command_pending(SilcServer server,
SilcCommand reply_cmd,
SilcUInt16 ident);
SilcServerCommandPendingCallbacks
silc_server_command_pending_check(SilcServer server,
- SilcCommand command,
+ SilcCommand command,
SilcUInt16 ident,
SilcUInt32 *callbacks_count);
SILC_SERVER_CMD_FUNC(whois);
SILC_SERVER_CMD_FUNC(leave);
SILC_SERVER_CMD_FUNC(users);
SILC_SERVER_CMD_FUNC(getkey);
+SILC_SERVER_CMD_FUNC(service);
SILC_SERVER_CMD_FUNC(connect);
SILC_SERVER_CMD_FUNC(close);
</td>
</tr>
+<tr>
+<td><small>SILC_COMMAND_SERVICE</td>
+<td><small>
+Returns the service list in the server, or information on the accepted
+and authenticated service. The 'service_list' maybe NULL if server does
+not support any services. It is NULL also when 'name' is not NULL. The
+'service_list' is a comma separated list of services the server supports.
+The 'name' MAY be NULL also. The 'name' is the requested service, and it is
+non-NULL only if server accepted and authenticated client's request.
+</td>
+<td width="50%"><small>const char *server_list, const char *service_name
+</td>
+</tr>
+
</table>
<br /> <br />
silc_client_command_free(cmd);
}
+/* Command SERVICE. Negotiates service agreement with server. */
+/* XXX incomplete */
+
+SILC_CLIENT_CMD_FUNC(service)
+{
+ SilcClientCommandContext cmd = (SilcClientCommandContext)context;
+ SilcClientConnection conn = cmd->conn;
+ SilcBuffer buffer;
+ char *name;
+
+ if (!cmd->conn) {
+ SILC_NOT_CONNECTED(cmd->client, cmd->conn);
+ COMMAND_ERROR(SILC_STATUS_ERR_NOT_REGISTERED);
+ goto out;
+ }
+
+ if (cmd->argc < 2) {
+ SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO,
+ "Usage: /SERVICE [<service name>] [-pubkey]");
+ COMMAND_ERROR(SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
+ goto out;
+ }
+
+ name = cmd->argv[1];
+
+ /* Send SERVICE command to the server */
+ buffer = silc_command_payload_encode_va(SILC_COMMAND_SERVICE,
+ ++conn->cmd_ident, 1,
+ 1, name, strlen(name));
+ silc_client_packet_send(cmd->client, conn->sock, SILC_PACKET_COMMAND,
+ NULL, 0, NULL, NULL, buffer->data,
+ buffer->len, TRUE);
+ silc_buffer_free(buffer);
+
+ /* Notify application */
+ COMMAND(SILC_STATUS_OK);
+
+ out:
+ silc_client_command_free(cmd);
+}
+
/* Register a new command indicated by the `command' to the SILC client.
The `name' is optional command name. If provided the command may be
searched using the silc_client_command_find by that name. The
SILC_CLIENT_CMD(leave, LEAVE, "LEAVE", 2);
SILC_CLIENT_CMD(users, USERS, "USERS", 2);
SILC_CLIENT_CMD(getkey, GETKEY, "GETKEY", 2);
+ SILC_CLIENT_CMD(service, SERVICE, "SERVICE", 10);
SILC_CLIENT_CMD(connect, PRIV_CONNECT, "CONNECT", 3);
SILC_CLIENT_CMD(close, PRIV_CLOSE, "CLOSE", 3);
SILC_CLIENT_CMDU(leave, LEAVE, "LEAVE");
SILC_CLIENT_CMDU(users, USERS, "USERS");
SILC_CLIENT_CMDU(getkey, GETKEY, "GETKEY");
+ SILC_CLIENT_CMDU(service, SERVICE, "SERVICE");
SILC_CLIENT_CMDU(connect, PRIV_CONNECT, "CONNECT");
SILC_CLIENT_CMDU(close, PRIV_CLOSE, "CLOSE");
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 2001 Pekka Riikonen
+ Copyright (C) 1997 - 2005 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
SILC_CLIENT_CMD_FUNC(leave);
SILC_CLIENT_CMD_FUNC(users);
SILC_CLIENT_CMD_FUNC(getkey);
+SILC_CLIENT_CMD_FUNC(service);
SILC_CLIENT_CMD_FUNC(shutdown);
SILC_CLIENT_CMD_FUNC(close);
silc_client_command_reply_free(cmd);
}
+/* Reply to SERVICE command. */
+/* XXX incomplete */
+
+SILC_CLIENT_CMD_REPLY_FUNC(service)
+{
+ SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
+ SilcUInt32 tmp_len;
+ unsigned char *service_list, *name;
+
+ COMMAND_CHECK_STATUS;
+
+ /* Get service list */
+ service_list = silc_argument_get_arg_type(cmd->args, 2, &tmp_len);
+
+ /* Get requested service name */
+ name = silc_argument_get_arg_type(cmd->args, 3, &tmp_len);
+
+ /* Notify application */
+ COMMAND_REPLY((SILC_ARGS, service_list, name));
+
+ out:
+ SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_SERVICE);
+ err:
+ silc_client_command_reply_free(cmd);
+}
+
SILC_CLIENT_CMD_REPLY_FUNC(quit)
{
silc_client_command_reply_free(context);
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 2003 Pekka Riikonen
+ Copyright (C) 1997 - 2005 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
SILC_CLIENT_CMD_REPLY_FUNC(leave);
SILC_CLIENT_CMD_REPLY_FUNC(users);
SILC_CLIENT_CMD_REPLY_FUNC(getkey);
+SILC_CLIENT_CMD_REPLY_FUNC(service);
SILC_CLIENT_CMD_REPLY_FUNC(quit);
/* Internal command reply functions */