5 Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
7 Copyright (C) 1997 - 2000 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
24 /* Command function callback. The actual command function pointer. */
25 typedef void (*SilcCommandCb)(void *context);
27 /* Typedefinition for SILC commands. */
28 typedef unsigned char SilcCommand;
30 /* Forward declaration for Command Payload parsed from packet. The
31 actual structure is defined in source file and is private data. */
32 typedef struct SilcCommandPayloadStruct *SilcCommandPayload;
34 /* Command flags. These set how the commands behave on different
35 situations. These can be OR'ed together to set multiple flags. */
39 /* Command may only be used once per (about) 2 seconds. Bursts up
40 to 5 commands are allowed though. */
41 SILC_CF_LAG = (1L << 1),
43 /* Command may only be used once per (about) 2 seconds. No bursts
44 are allowed at all. */
45 SILC_CF_LAG_STRICT = (1L << 2),
47 /* Command is available for registered connections (connections
48 whose ID has been created. */
49 SILC_CF_REG = (1L << 3),
51 /* Command is available only for server operators */
52 SILC_CF_OPER = (1L << 4),
54 /* Command is available only for SILC (router) operators. If this
55 is set SILC_CF_OPER is not necessary to be set. */
56 SILC_CF_SILC_OPER = (1L << 5),
60 /* All SILC commands. These are commands that have client and server
61 counterparts. These are pretty much the same as in IRC. */
62 #define SILC_COMMAND_NONE 0
63 #define SILC_COMMAND_WHOIS 1
64 #define SILC_COMMAND_WHOWAS 2
65 #define SILC_COMMAND_IDENTIFY 3
66 #define SILC_COMMAND_NICK 4
67 #define SILC_COMMAND_LIST 5
68 #define SILC_COMMAND_TOPIC 6
69 #define SILC_COMMAND_INVITE 7
70 #define SILC_COMMAND_QUIT 8
71 #define SILC_COMMAND_KILL 9
72 #define SILC_COMMAND_INFO 10
73 #define SILC_COMMAND_CONNECT 11
74 #define SILC_COMMAND_PING 12
75 #define SILC_COMMAND_OPER 13
76 #define SILC_COMMAND_JOIN 14
77 #define SILC_COMMAND_MOTD 15
78 #define SILC_COMMAND_UMODE 16
79 #define SILC_COMMAND_CMODE 17
80 #define SILC_COMMAND_CUMODE 18
81 #define SILC_COMMAND_KICK 19
82 #define SILC_COMMAND_BAN 20
83 #define SILC_COMMAND_CLOSE 21
84 #define SILC_COMMAND_SHUTDOWN 22
85 #define SILC_COMMAND_SILCOPER 23
86 #define SILC_COMMAND_LEAVE 24
87 #define SILC_COMMAND_USERS 25
90 #define SILC_COMMAND_RESERVED 255
92 /* Command Status type */
93 typedef uint16 SilcCommandStatus;
95 /* Command Status messages */
96 #define SILC_STATUS_OK 0
97 #define SILC_STATUS_LIST_START 1
98 #define SILC_STATUS_LIST_ITEM 2
99 #define SILC_STATUS_LIST_END 3
100 #define SILC_STATUS_ERR_NO_SUCH_NICK 10
101 #define SILC_STATUS_ERR_NO_SUCH_CHANNEL 11
102 #define SILC_STATUS_ERR_NO_SUCH_SERVER 12
103 #define SILC_STATUS_ERR_TOO_MANY_TARGETS 13
104 #define SILC_STATUS_ERR_NO_RECIPIENT 14
105 #define SILC_STATUS_ERR_UNKNOWN_COMMAND 15
106 #define SILC_STATUS_ERR_WILDCARDS 16
107 #define SILC_STATUS_ERR_NO_CLIENT_ID 17
108 #define SILC_STATUS_ERR_NO_CHANNEL_ID 18
109 #define SILC_STATUS_ERR_NO_SERVER_ID 19
110 #define SILC_STATUS_ERR_BAD_CLIENT_ID 20
111 #define SILC_STATUS_ERR_BAD_CHANNEL_ID 21
112 #define SILC_STATUS_ERR_NO_SUCH_CLIENT_ID 22
113 #define SILC_STATUS_ERR_NO_SUCH_CHANNEL_ID 23
114 #define SILC_STATUS_ERR_NICKNAME_IN_USE 24
115 #define SILC_STATUS_ERR_NOT_ON_CHANNEL 25
116 #define SILC_STATUS_ERR_USER_NOT_ON_CHANNEL 26
117 #define SILC_STATUS_ERR_USER_ON_CHANNEL 27
118 #define SILC_STATUS_ERR_NOT_REGISTERED 28
119 #define SILC_STATUS_ERR_NOT_ENOUGH_PARAMS 29
120 #define SILC_STATUS_ERR_TOO_MANY_PARAMS 30
121 #define SILC_STATUS_ERR_PERM_DENIED 31
122 #define SILC_STATUS_ERR_BANNED_FROM_SERVER 32
123 #define SILC_STATUS_ERR_BAD_PASSWORD 33
124 #define SILC_STATUS_ERR_CHANNEL_IS_FULL 34
125 #define SILC_STATUS_ERR_NOT_INVITED 35
126 #define SILC_STATUS_ERR_BANNED_FROM_CHANNEL 36
127 #define SILC_STATUS_ERR_UNKNOWN_MODE 37
128 #define SILC_STATUS_ERR_NOT_YOU 38
129 #define SILC_STATUS_ERR_NO_CHANNEL_PRIV 39
130 #define SILC_STATUS_ERR_NO_CHANNEL_FOPRIV 40
131 #define SILC_STATUS_ERR_NO_SERVER_PRIV 41
132 #define SILC_STATUS_ERR_NO_ROUTER_PRIV 42
133 #define SILC_STATUS_ERR_BAD_NICKNAME 43
134 #define SILC_STATUS_ERR_BAD_CHANNEL 44
135 #define SILC_STATUS_ERR_AUTH_FAILED 45
136 #define SILC_STATUS_ERR_UNKNOWN_ALGORITHM 46
139 SilcCommandPayload silc_command_payload_parse(SilcBuffer buffer);
140 SilcBuffer silc_command_payload_encode(SilcCommand cmd,
142 unsigned char **argv,
146 SilcBuffer silc_command_payload_encode_payload(SilcCommandPayload payload);
147 SilcBuffer silc_command_payload_encode_va(SilcCommand cmd,
150 SilcBuffer silc_command_payload_encode_vap(SilcCommand cmd,
152 uint32 argc, va_list ap);
154 silc_command_reply_payload_encode_va(SilcCommand cmd,
155 SilcCommandStatus status,
158 void silc_command_free_payload(SilcCommandPayload payload);
159 SilcCommand silc_command_get(SilcCommandPayload payload);
160 SilcArgumentPayload silc_command_get_args(SilcCommandPayload payload);
161 uint16 silc_command_get_ident(SilcCommandPayload payload);
162 void silc_command_set_ident(SilcCommandPayload payload, uint16 ident);
163 void silc_command_set_command(SilcCommandPayload payload, SilcCommand command);