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 */
40 SILC_CF_LAG = (1L << 1),
42 /* Command is available for registered connections (connections
43 whose ID has been created. */
44 SILC_CF_REG = (1L << 2),
46 /* Command is available only for server operators */
47 SILC_CF_OPER = (1L << 3),
49 /* Command is available only for SILC (router) operators. If this
50 is set SILC_CF_OPER is not necessary to be set. */
51 SILC_CF_SILC_OPER = (1L << 4),
55 /* All SILC commands. These are commands that have client and server
56 counterparts. These are pretty much the same as in IRC. */
57 #define SILC_COMMAND_NONE 0
58 #define SILC_COMMAND_WHOIS 1
59 #define SILC_COMMAND_WHOWAS 2
60 #define SILC_COMMAND_IDENTIFY 3
61 #define SILC_COMMAND_NICK 4
62 #define SILC_COMMAND_LIST 5
63 #define SILC_COMMAND_TOPIC 6
64 #define SILC_COMMAND_INVITE 7
65 #define SILC_COMMAND_QUIT 8
66 #define SILC_COMMAND_KILL 9
67 #define SILC_COMMAND_INFO 10
68 #define SILC_COMMAND_CONNECT 11
69 #define SILC_COMMAND_PING 12
70 #define SILC_COMMAND_OPER 13
71 #define SILC_COMMAND_JOIN 14
72 #define SILC_COMMAND_MOTD 15
73 #define SILC_COMMAND_UMODE 16
74 #define SILC_COMMAND_CMODE 17
75 #define SILC_COMMAND_KICK 18
76 #define SILC_COMMAND_RESTART 19
77 #define SILC_COMMAND_CLOSE 20
78 #define SILC_COMMAND_DIE 21
79 #define SILC_COMMAND_SILCOPER 22
80 #define SILC_COMMAND_LEAVE 23
81 #define SILC_COMMAND_NAMES 24
84 #define SILC_COMMAND_RESERVED 255
86 /* Command Status type */
87 typedef unsigned short SilcCommandStatus;
89 /* Command Status messages */
90 #define SILC_STATUS_OK 0
91 #define SILC_STATUS_LIST_START 1
92 #define SILC_STATUS_LIST_ITEM 2
93 #define SILC_STATUS_LIST_END 3
94 #define SILC_STATUS_ERR_NO_SUCH_NICK 10
95 #define SILC_STATUS_ERR_NO_SUCH_CHANNEL 11
96 #define SILC_STATUS_ERR_NO_SUCH_SERVER 12
97 #define SILC_STATUS_ERR_TOO_MANY_TARGETS 13
98 #define SILC_STATUS_ERR_NO_RECIPIENT 14
99 #define SILC_STATUS_ERR_UNKNOWN_COMMAND 15
100 #define SILC_STATUS_ERR_WILDCARDS 16
101 #define SILC_STATUS_ERR_NO_CLIENT_ID 17
102 #define SILC_STATUS_ERR_NO_CHANNEL_ID 18
103 #define SILC_STATUS_ERR_NO_SERVER_ID 19
104 #define SILC_STATUS_ERR_BAD_CLIENT_ID 20
105 #define SILC_STATUS_ERR_BAD_CHANNEL_ID 21
106 #define SILC_STATUS_ERR_NO_SUCH_CLIENT_ID 22
107 #define SILC_STATUS_ERR_NO_SUCH_CHANNEL_ID 23
108 #define SILC_STATUS_ERR_NICKNAME_IN_USE 24
109 #define SILC_STATUS_ERR_NOT_ON_CHANNEL 25
110 #define SILC_STATUS_ERR_USER_ON_CHANNEL 26
111 #define SILC_STATUS_ERR_NOT_REGISTERED 27
112 #define SILC_STATUS_ERR_NOT_ENOUGH_PARAMS 28
113 #define SILC_STATUS_ERR_TOO_MANY_PARAMS 29
114 #define SILC_STATUS_ERR_PERM_DENIED 30
115 #define SILC_STATUS_ERR_BANNED_FROM_SERVER 31
116 #define SILC_STATUS_ERR_BAD_PASSWORD 32
117 #define SILC_STATUS_ERR_CHANNEL_IS_FULL 33
118 #define SILC_STATUS_ERR_NOT_INVITED 34
119 #define SILC_STATUS_ERR_BANNED_FROM_CHANNEL 35
120 #define SILC_STATUS_ERR_UNKNOWN_MODE 36
121 #define SILC_STATUS_ERR_NOT_YOU 37
122 #define SILC_STATUS_ERR_NO_CHANNEL_PRIV 38
123 #define SILC_STATUS_ERR_NO_SERVER_PRIV 39
124 #define SILC_STATUS_ERR_NO_ROUTER_PRIV 40
125 #define SILC_STATUS_ERR_BAD_NICKNAME 41
126 #define SILC_STATUS_ERR_BAD_CHANNEL 42
127 #define SILC_STATUS_ERR_AUTH_FAILED 43
130 SilcCommandPayload silc_command_payload_parse(SilcBuffer buffer);
131 SilcBuffer silc_command_payload_encode(SilcCommand cmd,
133 unsigned char **argv,
134 unsigned int *argv_lens,
135 unsigned int *argv_types,
136 unsigned short ident);
137 SilcBuffer silc_command_payload_encode_va(SilcCommand cmd,
138 unsigned short ident,
139 unsigned int argc, ...);
141 silc_command_reply_payload_encode_va(SilcCommand cmd,
142 SilcCommandStatus status,
143 unsigned short ident,
144 unsigned int argc, ...);
145 void silc_command_free_payload(SilcCommandPayload payload);
146 SilcCommand silc_command_get(SilcCommandPayload payload);
147 SilcArgumentPayload silc_command_get_args(SilcCommandPayload payload);
148 unsigned short silc_command_get_ident(SilcCommandPayload payload);