5 Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
7 Copyright (C) 1997 - 2001 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.
21 * Server packet routines to send packets.
25 #include "serverincludes.h"
26 #include "server_internal.h"
28 /* Routine that sends packet or marks packet to be sent. This is used
29 directly only in special cases. Normal cases should use
30 silc_server_packet_send. Returns < 0 error. */
32 int silc_server_packet_send_real(SilcServer server,
33 SilcSocketConnection sock,
38 /* If rekey protocol is active we must assure that all packets are
39 sent through packet queue. */
40 if (SILC_SERVER_IS_REKEY(sock))
44 ret = silc_packet_send(sock, force_send);
48 /* Mark that there is some outgoing data available for this connection.
49 This call sets the connection both for input and output (the input
50 is set always and this call keeps the input setting, actually).
51 Actual data sending is performed by silc_server_packet_process. */
52 SILC_SET_CONNECTION_FOR_OUTPUT(sock->sock);
54 /* Mark to socket that data is pending in outgoing buffer. This flag
55 is needed if new data is added to the buffer before the earlier
56 put data is sent to the network. */
57 SILC_SET_OUTBUF_PENDING(sock);
62 /* Assembles a new packet to be sent out to network. This doesn't actually
63 send the packet but creates the packet and fills the outgoing data
64 buffer and marks the packet ready to be sent to network. However, If
65 argument force_send is TRUE the packet is sent immediately and not put
66 to queue. Normal case is that the packet is not sent immediately. */
68 void silc_server_packet_send(SilcServer server,
69 SilcSocketConnection sock,
71 SilcPacketFlags flags,
77 SilcIdType dst_id_type = SILC_ID_NONE;
82 /* Get data used in the packet sending, keys and stuff */
84 case SILC_SOCKET_TYPE_CLIENT:
85 dst_id = ((SilcClientEntry)sock->user_data)->id;
86 dst_id_type = SILC_ID_CLIENT;
88 case SILC_SOCKET_TYPE_SERVER:
89 case SILC_SOCKET_TYPE_ROUTER:
90 dst_id = ((SilcServerEntry)sock->user_data)->id;
91 dst_id_type = SILC_ID_SERVER;
97 silc_server_packet_send_dest(server, sock, type, flags, dst_id,
98 dst_id_type, data, data_len, force_send);
101 /* Assembles a new packet to be sent out to network. This doesn't actually
102 send the packet but creates the packet and fills the outgoing data
103 buffer and marks the packet ready to be sent to network. However, If
104 argument force_send is TRUE the packet is sent immediately and not put
105 to queue. Normal case is that the packet is not sent immediately.
106 Destination information is sent as argument for this function. */
108 void silc_server_packet_send_dest(SilcServer server,
109 SilcSocketConnection sock,
111 SilcPacketFlags flags,
113 SilcIdType dst_id_type,
118 SilcPacketContext packetdata;
119 SilcIDListData idata;
120 SilcCipher cipher = NULL;
121 SilcHmac hmac = NULL;
122 unsigned char *dst_id_data = NULL;
123 uint32 dst_id_len = 0;
125 SILC_LOG_DEBUG(("Sending packet, type %d", type));
127 /* Get data used in the packet sending, keys and stuff */
128 idata = (SilcIDListData)sock->user_data;
131 dst_id_data = silc_id_id2str(dst_id, dst_id_type);
132 dst_id_len = silc_id_get_len(dst_id_type);
135 /* Set the packet context pointers */
136 packetdata.type = type;
137 packetdata.flags = flags;
138 packetdata.src_id = silc_id_id2str(server->id, server->id_type);
139 packetdata.src_id_len = SILC_ID_SERVER_LEN;
140 packetdata.src_id_type = server->id_type;
141 packetdata.dst_id = dst_id_data;
142 packetdata.dst_id_len = dst_id_len;
143 packetdata.dst_id_type = dst_id_type;
144 packetdata.truelen = data_len + SILC_PACKET_HEADER_LEN +
145 packetdata.src_id_len + dst_id_len;
146 packetdata.padlen = SILC_PACKET_PADLEN(packetdata.truelen);
148 /* Prepare outgoing data buffer for packet sending */
149 silc_packet_send_prepare(sock,
150 SILC_PACKET_HEADER_LEN +
151 packetdata.src_id_len +
152 packetdata.dst_id_len,
156 SILC_LOG_DEBUG(("Putting data to outgoing buffer, len %d", data_len));
158 packetdata.buffer = sock->outbuf;
160 /* Put the data to the buffer */
161 if (data && data_len)
162 silc_buffer_put(sock->outbuf, data, data_len);
164 /* Create the outgoing packet */
165 silc_packet_assemble(&packetdata);
168 cipher = idata->send_key;
172 /* Encrypt the packet */
173 silc_packet_encrypt(cipher, hmac, sock->outbuf, sock->outbuf->len);
175 SILC_LOG_HEXDUMP(("Outgoing packet, len %d", sock->outbuf->len),
176 sock->outbuf->data, sock->outbuf->len);
178 /* Now actually send the packet */
179 silc_server_packet_send_real(server, sock, force_send);
181 if (packetdata.src_id)
182 silc_free(packetdata.src_id);
183 if (packetdata.dst_id)
184 silc_free(packetdata.dst_id);
187 /* Assembles a new packet to be sent out to network. This doesn't actually
188 send the packet but creates the packet and fills the outgoing data
189 buffer and marks the packet ready to be sent to network. However, If
190 argument force_send is TRUE the packet is sent immediately and not put
191 to queue. Normal case is that the packet is not sent immediately.
192 The source and destination information is sent as argument for this
195 void silc_server_packet_send_srcdest(SilcServer server,
196 SilcSocketConnection sock,
198 SilcPacketFlags flags,
200 SilcIdType src_id_type,
202 SilcIdType dst_id_type,
207 SilcPacketContext packetdata;
208 SilcIDListData idata;
209 SilcCipher cipher = NULL;
210 SilcHmac hmac = NULL;
211 unsigned char *dst_id_data = NULL;
212 uint32 dst_id_len = 0;
213 unsigned char *src_id_data = NULL;
214 uint32 src_id_len = 0;
216 SILC_LOG_DEBUG(("Sending packet, type %d", type));
218 /* Get data used in the packet sending, keys and stuff */
219 idata = (SilcIDListData)sock->user_data;
222 dst_id_data = silc_id_id2str(dst_id, dst_id_type);
223 dst_id_len = silc_id_get_len(dst_id_type);
227 src_id_data = silc_id_id2str(src_id, src_id_type);
228 src_id_len = silc_id_get_len(src_id_type);
231 /* Set the packet context pointers */
232 packetdata.type = type;
233 packetdata.flags = flags;
234 packetdata.src_id = src_id_data;
235 packetdata.src_id_len = src_id_len;
236 packetdata.src_id_type = src_id_type;
237 packetdata.dst_id = dst_id_data;
238 packetdata.dst_id_len = dst_id_len;
239 packetdata.dst_id_type = dst_id_type;
240 packetdata.truelen = data_len + SILC_PACKET_HEADER_LEN +
241 packetdata.src_id_len + dst_id_len;
242 packetdata.padlen = SILC_PACKET_PADLEN(packetdata.truelen);
244 /* Prepare outgoing data buffer for packet sending */
245 silc_packet_send_prepare(sock,
246 SILC_PACKET_HEADER_LEN +
247 packetdata.src_id_len +
248 packetdata.dst_id_len,
252 SILC_LOG_DEBUG(("Putting data to outgoing buffer, len %d", data_len));
254 packetdata.buffer = sock->outbuf;
256 /* Put the data to the buffer */
257 if (data && data_len)
258 silc_buffer_put(sock->outbuf, data, data_len);
260 /* Create the outgoing packet */
261 silc_packet_assemble(&packetdata);
264 cipher = idata->send_key;
268 /* Encrypt the packet */
269 silc_packet_encrypt(cipher, hmac, sock->outbuf, sock->outbuf->len);
271 SILC_LOG_HEXDUMP(("Outgoing packet, len %d", sock->outbuf->len),
272 sock->outbuf->data, sock->outbuf->len);
274 /* Now actually send the packet */
275 silc_server_packet_send_real(server, sock, force_send);
277 if (packetdata.src_id)
278 silc_free(packetdata.src_id);
279 if (packetdata.dst_id)
280 silc_free(packetdata.dst_id);
283 /* Broadcast received packet to our primary route. This function is used
284 by router to further route received broadcast packet. It is expected
285 that the broadcast flag from the packet is checked before calling this
286 function. This does not test or set the broadcast flag. */
288 void silc_server_packet_broadcast(SilcServer server,
289 SilcSocketConnection sock,
290 SilcPacketContext *packet)
292 SilcBuffer buffer = packet->buffer;
293 SilcIDListData idata;
296 SILC_LOG_DEBUG(("Broadcasting received broadcast packet"));
298 /* If the packet is originated from our primary route we are
299 not allowed to send the packet. */
300 id = silc_id_str2id(packet->src_id, packet->src_id_len, packet->src_id_type);
301 if (id && SILC_ID_SERVER_COMPARE(id, server->router->id)) {
302 idata = (SilcIDListData)sock->user_data;
304 silc_buffer_push(buffer, buffer->data - buffer->head);
305 silc_packet_send_prepare(sock, 0, 0, buffer->len);
306 silc_buffer_put(sock->outbuf, buffer->data, buffer->len);
307 silc_packet_encrypt(idata->send_key, idata->hmac,
308 sock->outbuf, sock->outbuf->len);
310 SILC_LOG_HEXDUMP(("Broadcasted packet, len %d", sock->outbuf->len),
311 sock->outbuf->data, sock->outbuf->len);
313 /* Now actually send the packet */
314 silc_server_packet_send_real(server, sock, TRUE);
319 SILC_LOG_DEBUG(("Will not broadcast to primary route since it is the "
320 "original sender of this packet"));
324 /* Routes received packet to `sock'. This is used to route the packets that
325 router receives but are not destined to it. */
327 void silc_server_packet_route(SilcServer server,
328 SilcSocketConnection sock,
329 SilcPacketContext *packet)
331 SilcBuffer buffer = packet->buffer;
332 SilcIDListData idata;
334 SILC_LOG_DEBUG(("Routing received packet"));
336 idata = (SilcIDListData)sock->user_data;
338 silc_buffer_push(buffer, buffer->data - buffer->head);
339 silc_packet_send_prepare(sock, 0, 0, buffer->len);
340 silc_buffer_put(sock->outbuf, buffer->data, buffer->len);
341 silc_packet_encrypt(idata->send_key, idata->hmac,
342 sock->outbuf, sock->outbuf->len);
344 SILC_LOG_HEXDUMP(("Routed packet, len %d", sock->outbuf->len),
345 sock->outbuf->data, sock->outbuf->len);
347 /* Now actually send the packet */
348 silc_server_packet_send_real(server, sock, TRUE);
351 /* Internal routine to actually create the channel packet and send it
352 to network. This is common function in channel message sending. If
353 `channel_message' is TRUE this encrypts the message as it is strictly
354 a channel message. If FALSE normal encryption process is used. */
357 silc_server_packet_send_to_channel_real(SilcServer server,
358 SilcSocketConnection sock,
359 SilcPacketContext *packet,
367 packet->truelen = data_len + SILC_PACKET_HEADER_LEN +
368 packet->src_id_len + packet->dst_id_len;
370 /* Prepare outgoing data buffer for packet sending */
371 silc_packet_send_prepare(sock,
372 SILC_PACKET_HEADER_LEN +
378 packet->buffer = sock->outbuf;
380 /* Put the data to buffer, assemble and encrypt the packet. The packet
381 is encrypted with normal session key shared with the client. */
382 silc_buffer_put(sock->outbuf, data, data_len);
383 silc_packet_assemble(packet);
385 silc_packet_encrypt(cipher, hmac, sock->outbuf, SILC_PACKET_HEADER_LEN +
386 packet->src_id_len + packet->dst_id_len +
389 silc_packet_encrypt(cipher, hmac, sock->outbuf, sock->outbuf->len);
391 SILC_LOG_HEXDUMP(("Channel packet, len %d", sock->outbuf->len),
392 sock->outbuf->data, sock->outbuf->len);
394 /* Now actually send the packet */
395 silc_server_packet_send_real(server, sock, force_send);
398 /* This routine is used by the server to send packets to channel. The
399 packet sent with this function is distributed to all clients on
400 the channel. Usually this is used to send notify messages to the
401 channel, things like notify about new user joining to the channel.
402 If `route' is FALSE then the packet is sent only locally and will not
403 be routed anywhere (for router locally means cell wide). If `sender'
404 is provided then the packet is not sent to that connection since it
405 originally came from it. */
407 void silc_server_packet_send_to_channel(SilcServer server,
408 SilcSocketConnection sender,
409 SilcChannelEntry channel,
416 SilcSocketConnection sock = NULL;
417 SilcPacketContext packetdata;
418 SilcClientEntry client = NULL;
419 SilcServerEntry *routed = NULL;
420 SilcChannelClientEntry chl;
421 SilcIDListData idata;
422 uint32 routed_count = 0;
424 /* This doesn't send channel message packets */
425 if (type == SILC_PACKET_CHANNEL_MESSAGE)
428 SILC_LOG_DEBUG(("Sending packet to channel"));
430 /* Set the packet context pointers. */
431 packetdata.flags = 0;
432 packetdata.type = type;
433 packetdata.src_id = silc_id_id2str(server->id, SILC_ID_SERVER);
434 packetdata.src_id_len = SILC_ID_SERVER_LEN;
435 packetdata.src_id_type = SILC_ID_SERVER;
436 packetdata.dst_id = silc_id_id2str(channel->id, SILC_ID_CHANNEL);
437 packetdata.dst_id_len = SILC_ID_CHANNEL_LEN;
438 packetdata.dst_id_type = SILC_ID_CHANNEL;
439 packetdata.truelen = data_len + SILC_PACKET_HEADER_LEN +
440 packetdata.src_id_len + packetdata.dst_id_len;
441 packetdata.padlen = SILC_PACKET_PADLEN(packetdata.truelen);
443 /* If there are global users in the channel we will send the message
444 first to our router for further routing. */
445 if (route && server->server_type == SILC_SERVER && !server->standalone &&
446 channel->global_users) {
447 SilcServerEntry router;
449 /* Get data used in packet header encryption, keys and stuff. */
450 router = server->router;
451 sock = (SilcSocketConnection)router->connection;
452 idata = (SilcIDListData)router;
454 if (sock != sender) {
455 SILC_LOG_DEBUG(("Sending channel message to router for routing"));
457 silc_server_packet_send_to_channel_real(server, sock, &packetdata,
458 idata->send_key, idata->hmac,
459 data, data_len, FALSE,
464 /* Send the message to clients on the channel's client list. */
465 silc_list_start(channel->user_list);
466 while ((chl = silc_list_get(channel->user_list)) != SILC_LIST_END) {
467 client = chl->client;
469 /* If client has router set it is not locally connected client and
470 we will route the message to the router set in the client. Though,
471 send locally connected server in all cases. */
472 if (server->server_type == SILC_ROUTER && client && client->router &&
473 ((!route && client->router->router == server->id_entry) || route)) {
476 /* Check if we have sent the packet to this route already */
477 for (k = 0; k < routed_count; k++)
478 if (routed[k] == client->router)
480 if (k < routed_count)
483 /* Get data used in packet header encryption, keys and stuff. */
484 sock = (SilcSocketConnection)client->router->connection;
485 idata = (SilcIDListData)client->router;
487 if (sender && sock == sender)
490 /* Send the packet */
491 silc_server_packet_send_to_channel_real(server, sock, &packetdata,
492 idata->send_key, idata->hmac,
493 data, data_len, FALSE,
496 /* We want to make sure that the packet is routed to same router
497 only once. Mark this route as sent route. */
499 routed = silc_realloc(routed, sizeof(*routed) * (k + 1));
500 routed[k] = client->router;
506 if (client && client->router)
509 /* Send to locally connected client */
512 /* Get data used in packet header encryption, keys and stuff. */
513 sock = (SilcSocketConnection)client->connection;
514 idata = (SilcIDListData)client;
516 if (sender && sock == sender)
519 /* Send the packet */
520 silc_server_packet_send_to_channel_real(server, sock, &packetdata,
521 idata->send_key, idata->hmac,
522 data, data_len, FALSE,
529 silc_free(packetdata.src_id);
530 silc_free(packetdata.dst_id);
533 /* This routine is explicitly used to relay messages to some channel.
534 Packets sent with this function we have received earlier and are
535 totally encrypted. This just sends the packet to all clients on
536 the channel. If the sender of the packet is someone on the channel
537 the message will not be sent to that client. The SILC Packet header
538 is encrypted with the session key shared between us and the client.
539 MAC is also computed before encrypting the header. Rest of the
540 packet will be untouched. */
542 void silc_server_packet_relay_to_channel(SilcServer server,
543 SilcSocketConnection sender_sock,
544 SilcChannelEntry channel,
546 SilcIdType sender_type,
552 SilcSocketConnection sock = NULL;
553 SilcPacketContext packetdata;
554 SilcClientEntry client = NULL;
555 SilcServerEntry *routed = NULL;
556 SilcChannelClientEntry chl;
557 uint32 routed_count = 0;
558 SilcIDListData idata;
560 SILC_LOG_DEBUG(("Relaying packet to channel"));
562 /* Set the packet context pointers. */
563 packetdata.flags = 0;
564 packetdata.type = SILC_PACKET_CHANNEL_MESSAGE;
565 packetdata.src_id = silc_id_id2str(sender, sender_type);
566 packetdata.src_id_len = silc_id_get_len(sender_type);
567 packetdata.src_id_type = sender_type;
568 packetdata.dst_id = silc_id_id2str(channel->id, SILC_ID_CHANNEL);
569 packetdata.dst_id_len = SILC_ID_CHANNEL_LEN;
570 packetdata.dst_id_type = SILC_ID_CHANNEL;
571 packetdata.padlen = SILC_PACKET_PADLEN((SILC_PACKET_HEADER_LEN +
572 packetdata.src_id_len +
573 packetdata.dst_id_len));
575 /* If there are global users in the channel we will send the message
576 first to our router for further routing. */
577 if (server->server_type == SILC_SERVER && !server->standalone &&
578 channel->global_users) {
579 SilcServerEntry router;
581 router = server->router;
583 /* Check that the sender is not our router. */
584 if (sender_sock != (SilcSocketConnection)router->connection) {
586 /* Get data used in packet header encryption, keys and stuff. */
587 sock = (SilcSocketConnection)router->connection;
588 idata = (SilcIDListData)router;
590 SILC_LOG_DEBUG(("Sending channel message to router for routing"));
592 silc_server_packet_send_to_channel_real(server, sock, &packetdata,
593 idata->send_key, idata->hmac,
594 data, data_len, TRUE,
599 /* Send the message to clients on the channel's client list. */
600 silc_list_start(channel->user_list);
601 while ((chl = silc_list_get(channel->user_list)) != SILC_LIST_END) {
602 client = chl->client;
606 /* If sender is one on the channel do not send it the packet. */
607 if (!found && !SILC_ID_CLIENT_COMPARE(client->id, sender)) {
612 /* If the client has set router it means that it is not locally
613 connected client and we will route the packet further. */
614 if (server->server_type == SILC_ROUTER && client->router) {
617 /* Sender maybe server as well so we want to make sure that
618 we won't send the message to the server it came from. */
619 if (!found && !SILC_ID_SERVER_COMPARE(client->router->id, sender)) {
624 /* Check if we have sent the packet to this route already */
625 for (k = 0; k < routed_count; k++)
626 if (routed[k] == client->router)
628 if (k < routed_count)
631 /* Get data used in packet header encryption, keys and stuff. */
632 sock = (SilcSocketConnection)client->router->connection;
633 idata = (SilcIDListData)client->router;
635 if (sender_sock && sock == sender_sock)
638 SILC_LOG_DEBUG(("Relaying packet to client ID(%s) %s (%s)",
639 silc_id_render(client->id, SILC_ID_CLIENT),
640 sock->hostname, sock->ip));
642 /* We want to make sure that the packet is routed to same router
643 only once. Mark this route as sent route. */
645 routed = silc_realloc(routed, sizeof(*routed) * (k + 1));
646 routed[k] = client->router;
649 /* If the remote connection is router then we'll decrypt the
650 channel message and re-encrypt it with the session key shared
651 between us and the remote router. This is done because the
652 channel keys are cell specific and we have different channel
653 key than the remote router has. */
654 if (sock->type == SILC_SOCKET_TYPE_ROUTER) {
656 /* If private key mode is not set then decrypt the packet
658 if (!(channel->mode & SILC_CHANNEL_MODE_PRIVKEY)) {
659 unsigned char *tmp = silc_calloc(data_len, sizeof(*data));
660 memcpy(tmp, data, data_len);
662 /* Decrypt the channel message (we don't check the MAC) */
663 if (!silc_channel_message_payload_decrypt(tmp, data_len,
664 channel->channel_key,
666 memset(tmp, 0, data_len);
671 /* Now re-encrypt and send it to the router */
672 silc_server_packet_send_srcdest(server, sock,
673 SILC_PACKET_CHANNEL_MESSAGE, 0,
675 channel->id, SILC_ID_CHANNEL,
676 tmp, data_len, force_send);
678 /* Free the copy of the channel message */
679 memset(tmp, 0, data_len);
682 /* Private key mode is set, we don't have the channel key, so
683 just re-encrypt the entire packet and send it to the router. */
684 silc_server_packet_send_srcdest(server, sock,
685 SILC_PACKET_CHANNEL_MESSAGE, 0,
687 channel->id, SILC_ID_CHANNEL,
688 data, data_len, force_send);
693 /* Send the packet (to normal server) */
694 silc_server_packet_send_to_channel_real(server, sock, &packetdata,
695 idata->send_key, idata->hmac,
696 data, data_len, TRUE,
702 if (client && client->router)
705 /* Get data used in packet header encryption, keys and stuff. */
706 sock = (SilcSocketConnection)client->connection;
707 idata = (SilcIDListData)client;
709 if (sender_sock && sock == sender_sock)
712 SILC_LOG_DEBUG(("Sending packet to client ID(%s) %s (%s)",
713 silc_id_render(client->id, SILC_ID_CLIENT),
714 sock->hostname, sock->ip));
716 /* Send the packet */
717 silc_server_packet_send_to_channel_real(server, sock, &packetdata,
718 idata->send_key, idata->hmac,
719 data, data_len, TRUE,
724 silc_free(packetdata.src_id);
725 silc_free(packetdata.dst_id);
728 /* This function is used to send packets strictly to all local clients
729 on a particular channel. This is used for example to distribute new
730 channel key to all our locally connected clients on the channel.
731 The packets are always encrypted with the session key shared between
732 the client, this means these are not _to the channel_ but _to the client_
735 void silc_server_packet_send_local_channel(SilcServer server,
736 SilcChannelEntry channel,
738 SilcPacketFlags flags,
743 SilcChannelClientEntry chl;
744 SilcSocketConnection sock = NULL;
746 SILC_LOG_DEBUG(("Start"));
748 /* Send the message to clients on the channel's client list. */
749 silc_list_start(channel->user_list);
750 while ((chl = silc_list_get(channel->user_list)) != SILC_LIST_END) {
751 if (chl->client && !chl->client->router) {
752 sock = (SilcSocketConnection)chl->client->connection;
754 /* Send the packet to the client */
755 silc_server_packet_send_dest(server, sock, type, flags, chl->client->id,
756 SILC_ID_CLIENT, data, data_len,
762 /* Routine used to send (relay, route) private messages to some destination.
763 If the private message key does not exist then the message is re-encrypted,
764 otherwise we just pass it along. This really is not used to send new
765 private messages (as server does not send them) but to relay received
768 void silc_server_send_private_message(SilcServer server,
769 SilcSocketConnection dst_sock,
772 SilcPacketContext *packet)
774 SilcBuffer buffer = packet->buffer;
776 /* Re-encrypt and send if private messge key does not exist */
777 if ((packet->flags & SILC_PACKET_FLAG_PRIVMSG_KEY) == FALSE) {
779 silc_buffer_push(buffer, SILC_PACKET_HEADER_LEN + packet->src_id_len
780 + packet->dst_id_len + packet->padlen);
781 silc_packet_send_prepare(dst_sock, 0, 0, buffer->len);
782 silc_buffer_put(dst_sock->outbuf, buffer->data, buffer->len);
784 /* Re-encrypt packet */
785 silc_packet_encrypt(cipher, hmac, dst_sock->outbuf, buffer->len);
787 /* Send the packet */
788 silc_server_packet_send_real(server, dst_sock, FALSE);
791 /* Key exist so encrypt just header and send it */
792 silc_buffer_push(buffer, SILC_PACKET_HEADER_LEN + packet->src_id_len
793 + packet->dst_id_len + packet->padlen);
794 silc_packet_send_prepare(dst_sock, 0, 0, buffer->len);
795 silc_buffer_put(dst_sock->outbuf, buffer->data, buffer->len);
798 silc_packet_encrypt(cipher, hmac, dst_sock->outbuf,
799 SILC_PACKET_HEADER_LEN + packet->src_id_len +
800 packet->dst_id_len + packet->padlen);
802 silc_server_packet_send_real(server, dst_sock, FALSE);
806 /* Sends current motd to client */
808 void silc_server_send_motd(SilcServer server,
809 SilcSocketConnection sock)
814 if (server->config && server->config->motd &&
815 server->config->motd->motd_file) {
817 motd = silc_file_read(server->config->motd->motd_file, &motd_len);
821 silc_server_send_notify(server, sock, FALSE, SILC_NOTIFY_TYPE_MOTD, 1,
827 /* Sends error message. Error messages may or may not have any
830 void silc_server_send_error(SilcServer server,
831 SilcSocketConnection sock,
832 const char *fmt, ...)
835 unsigned char buf[4096];
837 memset(buf, 0, sizeof(buf));
839 vsprintf(buf, fmt, ap);
842 silc_server_packet_send(server, sock, SILC_PACKET_ERROR, 0,
843 buf, strlen(buf), FALSE);
846 /* Sends notify message. If format is TRUE the variable arguments are
847 formatted and the formatted string is sent as argument payload. If it is
848 FALSE then each argument is sent as separate argument and their format
849 in the argument list must be { argument data, argument length }. */
851 void silc_server_send_notify(SilcServer server,
852 SilcSocketConnection sock,
862 packet = silc_notify_payload_encode(type, argc, ap);
863 silc_server_packet_send(server, sock, SILC_PACKET_NOTIFY, 0,
864 packet->data, packet->len, FALSE);
865 silc_buffer_free(packet);
868 /* Sends notify message and gets the arguments from the `args' Argument
871 void silc_server_send_notify_args(SilcServer server,
872 SilcSocketConnection sock,
880 packet = silc_notify_payload_encode_args(type, argc, args);
881 silc_server_packet_send(server, sock, SILC_PACKET_NOTIFY, 0,
882 packet->data, packet->len, FALSE);
883 silc_buffer_free(packet);
886 /* Send CHANNEL_CHANGE notify type. This tells the receiver to replace the
887 `old_id' with the `new_id'. */
889 void silc_server_send_notify_channel_change(SilcServer server,
890 SilcSocketConnection sock,
892 SilcChannelID *old_id,
893 SilcChannelID *new_id,
896 SilcBuffer idp1, idp2;
898 idp1 = silc_id_payload_encode((void *)old_id, SILC_ID_CHANNEL);
899 idp2 = silc_id_payload_encode((void *)new_id, SILC_ID_CHANNEL);
901 silc_server_send_notify(server, sock, broadcast,
902 SILC_NOTIFY_TYPE_CHANNEL_CHANGE,
903 2, idp1->data, idp1->len, idp2->data, idp2->len);
904 silc_buffer_free(idp1);
905 silc_buffer_free(idp2);
908 /* Send NICK_CHANGE notify type. This tells the receiver to replace the
909 `old_id' with the `new_id'. */
911 void silc_server_send_notify_nick_change(SilcServer server,
912 SilcSocketConnection sock,
914 SilcClientID *old_id,
915 SilcClientID *new_id,
918 SilcBuffer idp1, idp2;
920 idp1 = silc_id_payload_encode((void *)old_id, SILC_ID_CLIENT);
921 idp2 = silc_id_payload_encode((void *)new_id, SILC_ID_CLIENT);
923 silc_server_send_notify(server, sock, broadcast,
924 SILC_NOTIFY_TYPE_NICK_CHANGE,
925 2, idp1->data, idp1->len, idp2->data, idp2->len);
926 silc_buffer_free(idp1);
927 silc_buffer_free(idp2);
930 /* Sends JOIN notify type. This tells that new client by `client_id' ID
931 has joined to the `channel'. */
933 void silc_server_send_notify_join(SilcServer server,
934 SilcSocketConnection sock,
936 SilcChannelEntry channel,
937 SilcClientID *client_id,
938 uint32 client_id_len)
940 SilcBuffer idp1, idp2;
942 idp1 = silc_id_payload_encode((void *)client_id, SILC_ID_CLIENT);
943 idp2 = silc_id_payload_encode((void *)channel->id, SILC_ID_CHANNEL);
944 silc_server_send_notify(server, sock, broadcast, SILC_NOTIFY_TYPE_JOIN,
945 2, idp1->data, idp1->len,
946 idp2->data, idp2->len);
947 silc_buffer_free(idp1);
948 silc_buffer_free(idp2);
951 /* Sends LEAVE notify type. This tells that `client_id' has left the
952 `channel'. The Notify packet is always destined to the channel. */
954 void silc_server_send_notify_leave(SilcServer server,
955 SilcSocketConnection sock,
957 SilcChannelEntry channel,
958 SilcClientID *client_id,
959 uint32 client_id_len)
963 idp = silc_id_payload_encode((void *)client_id, SILC_ID_CLIENT);
964 silc_server_send_notify_dest(server, sock, broadcast, (void *)channel->id,
965 SILC_ID_CHANNEL, SILC_NOTIFY_TYPE_LEAVE,
966 1, idp->data, idp->len);
967 silc_buffer_free(idp);
970 /* Sends CMODE_CHANGE notify type. This tells that `client_id' changed the
971 `channel' mode to `mode. The Notify packet is always destined to
974 void silc_server_send_notify_cmode(SilcServer server,
975 SilcSocketConnection sock,
977 SilcChannelEntry channel,
979 void *id, SilcIdType id_type,
981 char *cipher, char *hmac)
984 unsigned char mode[4];
986 idp = silc_id_payload_encode((void *)id, id_type);
987 SILC_PUT32_MSB(mode_mask, mode);
989 silc_server_send_notify_dest(server, sock, broadcast, (void *)channel->id,
990 SILC_ID_CHANNEL, SILC_NOTIFY_TYPE_CMODE_CHANGE,
991 4, idp->data, idp->len,
993 cipher, cipher ? strlen(cipher) : 0,
994 hmac, hmac ? strlen(hmac) : 0);
995 silc_buffer_free(idp);
998 /* Sends CUMODE_CHANGE notify type. This tells that `client_id' changed the
999 `target' client's mode on `channel'. The Notify packet is always
1000 destined to the channel. */
1002 void silc_server_send_notify_cumode(SilcServer server,
1003 SilcSocketConnection sock,
1005 SilcChannelEntry channel,
1007 SilcClientID *client_id,
1008 uint32 client_id_len,
1009 SilcClientID *target,
1012 SilcBuffer idp1, idp2;
1013 unsigned char mode[4];
1015 idp1 = silc_id_payload_encode((void *)client_id, SILC_ID_CLIENT);
1016 idp2 = silc_id_payload_encode((void *)target, SILC_ID_CLIENT);
1017 SILC_PUT32_MSB(mode_mask, mode);
1019 silc_server_send_notify_dest(server, sock, broadcast, (void *)channel->id,
1021 SILC_NOTIFY_TYPE_CUMODE_CHANGE, 3,
1022 idp1->data, idp1->len,
1024 idp2->data, idp2->len);
1025 silc_buffer_free(idp1);
1026 silc_buffer_free(idp2);
1029 /* Sends SIGNOFF notify type. This tells that `client_id' client has
1030 left SILC network. This function is used only between server and router
1031 traffic. This is not used to send the notify to the channel for
1032 client. The `message may be NULL. */
1034 void silc_server_send_notify_signoff(SilcServer server,
1035 SilcSocketConnection sock,
1037 SilcClientID *client_id,
1038 uint32 client_id_len,
1043 idp = silc_id_payload_encode((void *)client_id, SILC_ID_CLIENT);
1044 silc_server_send_notify(server, sock, broadcast,
1045 SILC_NOTIFY_TYPE_SIGNOFF,
1046 message ? 2 : 1, idp->data, idp->len,
1047 message, message ? strlen(message): 0);
1048 silc_buffer_free(idp);
1051 /* Sends TOPIC_SET notify type. This tells that `client_id' changed
1052 the `channel's topic to `topic'. The Notify packet is always destined
1053 to the channel. This function is used to send the topic set notifies
1056 void silc_server_send_notify_topic_set(SilcServer server,
1057 SilcSocketConnection sock,
1059 SilcChannelEntry channel,
1060 SilcClientID *client_id,
1061 uint32 client_id_len,
1066 idp = silc_id_payload_encode((void *)client_id, SILC_ID_CLIENT);
1067 silc_server_send_notify(server, sock, broadcast,
1068 SILC_NOTIFY_TYPE_SERVER_SIGNOFF,
1070 idp->data, idp->len,
1071 topic, topic ? strlen(topic) : 0);
1072 silc_buffer_free(idp);
1075 /* Send KICKED notify type. This tells that the `client_id' on `channel'
1076 was kicked off the channel. The `comment' may indicate the reason
1077 for the kicking. This function is used only between server and router
1080 void silc_server_send_notify_kicked(SilcServer server,
1081 SilcSocketConnection sock,
1083 SilcChannelEntry channel,
1084 SilcClientID *client_id,
1085 uint32 client_id_len,
1090 idp = silc_id_payload_encode((void *)client_id, SILC_ID_CLIENT);
1091 silc_server_send_notify_dest(server, sock, broadcast, (void *)channel->id,
1092 SILC_ID_CHANNEL, SILC_NOTIFY_TYPE_KICKED,
1093 comment ? 2 : 1, idp->data, idp->len,
1094 comment, comment ? strlen(comment) : 0);
1095 silc_buffer_free(idp);
1098 /* Send KILLED notify type. This tells that the `client_id' client was
1099 killed from the network. The `comment' may indicate the reason
1102 void silc_server_send_notify_killed(SilcServer server,
1103 SilcSocketConnection sock,
1105 SilcClientID *client_id,
1106 uint32 client_id_len,
1111 idp = silc_id_payload_encode((void *)client_id, SILC_ID_CLIENT);
1112 silc_server_send_notify_dest(server, sock, broadcast, (void *)client_id,
1113 SILC_ID_CLIENT, SILC_NOTIFY_TYPE_KILLED,
1114 comment ? 2 : 1, idp->data, idp->len,
1115 comment, comment ? strlen(comment) : 0);
1116 silc_buffer_free(idp);
1119 /* Sends UMODE_CHANGE notify type. This tells that `client_id' client's
1120 user mode in the SILC Network was changed. This function is used to
1121 send the packet between routers as broadcast packet. */
1123 void silc_server_send_notify_umode(SilcServer server,
1124 SilcSocketConnection sock,
1126 SilcClientID *client_id,
1127 uint32 client_id_len,
1131 unsigned char mode[4];
1133 idp = silc_id_payload_encode((void *)client_id, SILC_ID_CLIENT);
1134 SILC_PUT32_MSB(mode_mask, mode);
1136 silc_server_send_notify(server, sock, broadcast,
1137 SILC_NOTIFY_TYPE_UMODE_CHANGE, 2,
1138 idp->data, idp->len,
1140 silc_buffer_free(idp);
1143 /* Sends BAN notify type. This tells that ban has been either `add'ed
1144 or `del'eted on the `channel. This function is used to send the packet
1145 between routers as broadcast packet. */
1147 void silc_server_send_notify_ban(SilcServer server,
1148 SilcSocketConnection sock,
1150 SilcChannelEntry channel,
1151 char *add, char *del)
1155 idp = silc_id_payload_encode((void *)channel->id, SILC_ID_CHANNEL);
1156 silc_server_send_notify(server, sock, broadcast,
1157 SILC_NOTIFY_TYPE_BAN, 3,
1158 idp->data, idp->len,
1159 add, add ? strlen(add) : 0,
1160 del, del ? strlen(del) : 0);
1161 silc_buffer_free(idp);
1164 /* Sends INVITE notify type. This tells that invite has been either `add'ed
1165 or `del'eted on the `channel. The sender of the invite is the `client_id'.
1166 This function is used to send the packet between routers as broadcast
1169 void silc_server_send_notify_invite(SilcServer server,
1170 SilcSocketConnection sock,
1172 SilcChannelEntry channel,
1173 SilcClientID *client_id,
1174 uint32 client_id_len,
1175 char *add, char *del)
1177 SilcBuffer idp, idp2;
1179 idp = silc_id_payload_encode((void *)channel->id, SILC_ID_CHANNEL);
1180 idp2 = silc_id_payload_encode((void *)client_id, SILC_ID_CLIENT);
1181 silc_server_send_notify(server, sock, broadcast,
1182 SILC_NOTIFY_TYPE_INVITE, 5,
1183 idp->data, idp->len,
1184 channel->channel_name, strlen(channel->channel_name),
1185 idp2->data, idp2->len,
1186 add, add ? strlen(add) : 0,
1187 del, del ? strlen(del) : 0);
1188 silc_buffer_free(idp);
1189 silc_buffer_free(idp2);
1192 /* Sends notify message destined to specific entity. */
1194 void silc_server_send_notify_dest(SilcServer server,
1195 SilcSocketConnection sock,
1198 SilcIdType dest_id_type,
1199 SilcNotifyType type,
1207 packet = silc_notify_payload_encode(type, argc, ap);
1208 silc_server_packet_send_dest(server, sock, SILC_PACKET_NOTIFY, 0,
1209 dest_id, dest_id_type,
1210 packet->data, packet->len, FALSE);
1211 silc_buffer_free(packet);
1214 /* Sends notify message to a channel. The notify message sent is
1215 distributed to all clients on the channel. If `route_notify' is TRUE
1216 then the notify may be routed to primary route or to some other routers.
1217 If FALSE it is assured that the notify is sent only locally. If `sender'
1218 is provided then the packet is not sent to that connection since it
1219 originally came from it. */
1221 void silc_server_send_notify_to_channel(SilcServer server,
1222 SilcSocketConnection sender,
1223 SilcChannelEntry channel,
1224 unsigned char route_notify,
1225 SilcNotifyType type,
1233 packet = silc_notify_payload_encode(type, argc, ap);
1234 silc_server_packet_send_to_channel(server, sender, channel,
1235 SILC_PACKET_NOTIFY, route_notify,
1236 packet->data, packet->len, FALSE);
1237 silc_buffer_free(packet);
1240 /* Send notify message to all channels the client has joined. It is quaranteed
1241 that the message is sent only once to a client (ie. if a client is joined
1242 on two same channel it will receive only one notify message). Also, this
1243 sends only to local clients (locally connected if we are server, and to
1244 local servers if we are router). If `sender' is provided the packet is
1245 not sent to that client at all. */
1247 void silc_server_send_notify_on_channels(SilcServer server,
1248 SilcClientEntry sender,
1249 SilcClientEntry client,
1250 SilcNotifyType type,
1254 SilcSocketConnection sock = NULL;
1255 SilcPacketContext packetdata;
1257 SilcClientEntry *sent_clients = NULL;
1258 uint32 sent_clients_count = 0;
1259 SilcServerEntry *routed = NULL;
1260 uint32 routed_count = 0;
1261 SilcChannelEntry channel;
1262 SilcChannelClientEntry chl, chl2;
1263 SilcIDListData idata;
1265 unsigned char *data;
1267 int force_send = FALSE;
1270 SILC_LOG_DEBUG(("Start"));
1272 if (!silc_list_count(client->channels))
1276 packet = silc_notify_payload_encode(type, argc, ap);
1277 data = packet->data;
1278 data_len = packet->len;
1280 /* Set the packet context pointers. */
1281 packetdata.flags = 0;
1282 packetdata.type = SILC_PACKET_NOTIFY;
1283 packetdata.src_id = silc_id_id2str(server->id, SILC_ID_SERVER);
1284 packetdata.src_id_len = SILC_ID_SERVER_LEN;
1285 packetdata.src_id_type = SILC_ID_SERVER;
1287 silc_list_start(client->channels);
1288 while ((chl = silc_list_get(client->channels)) != SILC_LIST_END) {
1289 channel = chl->channel;
1291 /* Send the message to all clients on the channel's client list. */
1292 silc_list_start(channel->user_list);
1293 while ((chl2 = silc_list_get(channel->user_list)) != SILC_LIST_END) {
1296 if (sender && c == sender)
1299 /* Check if we have sent the packet to this client already */
1300 for (k = 0; k < sent_clients_count; k++)
1301 if (sent_clients[k] == c)
1303 if (k < sent_clients_count)
1306 /* If we are router and if this client has router set it is not
1307 locally connected client and we will route the message to the
1308 router set in the client. */
1309 if (c && c->router && server->server_type == SILC_ROUTER) {
1310 /* Check if we have sent the packet to this route already */
1311 for (k = 0; k < routed_count; k++)
1312 if (routed[k] == c->router)
1314 if (k < routed_count)
1317 /* Get data used in packet header encryption, keys and stuff. */
1318 sock = (SilcSocketConnection)c->router->connection;
1319 idata = (SilcIDListData)c->router;
1321 packetdata.dst_id = silc_id_id2str(c->router->id, SILC_ID_SERVER);
1322 packetdata.dst_id_len = SILC_ID_SERVER_LEN;
1323 packetdata.dst_id_type = SILC_ID_SERVER;
1324 packetdata.truelen = data_len + SILC_PACKET_HEADER_LEN +
1325 packetdata.src_id_len + packetdata.dst_id_len;
1326 packetdata.padlen = SILC_PACKET_PADLEN(packetdata.truelen);
1328 /* Send the packet */
1329 silc_server_packet_send_to_channel_real(server, sock, &packetdata,
1330 idata->send_key, idata->hmac,
1331 data, data_len, FALSE,
1334 silc_free(packetdata.dst_id);
1336 /* We want to make sure that the packet is routed to same router
1337 only once. Mark this route as sent route. */
1339 routed = silc_realloc(routed, sizeof(*routed) * (k + 1));
1340 routed[k] = c->router;
1349 /* Send to locally connected client */
1352 /* Get data used in packet header encryption, keys and stuff. */
1353 sock = (SilcSocketConnection)c->connection;
1354 idata = (SilcIDListData)c;
1356 packetdata.dst_id = silc_id_id2str(c->id, SILC_ID_CLIENT);
1357 packetdata.dst_id_len = SILC_ID_CLIENT_LEN;
1358 packetdata.dst_id_type = SILC_ID_CLIENT;
1359 packetdata.truelen = data_len + SILC_PACKET_HEADER_LEN +
1360 packetdata.src_id_len + packetdata.dst_id_len;
1361 packetdata.padlen = SILC_PACKET_PADLEN(packetdata.truelen);
1363 /* Send the packet */
1364 silc_server_packet_send_to_channel_real(server, sock, &packetdata,
1365 idata->send_key, idata->hmac,
1366 data, data_len, FALSE,
1369 silc_free(packetdata.dst_id);
1371 /* Make sure that we send the notify only once per client. */
1372 sent_clients = silc_realloc(sent_clients, sizeof(*sent_clients) *
1373 (sent_clients_count + 1));
1374 sent_clients[sent_clients_count] = c;
1375 sent_clients_count++;
1382 if (sent_clients_count)
1383 silc_free(sent_clients);
1384 silc_free(packetdata.src_id);
1387 /* Sends New ID Payload to remote end. The packet is used to distribute
1388 information about new registered clients, servers, channel etc. usually
1389 to routers so that they can keep these information up to date.
1390 If the argument `broadcast' is TRUE then the packet is sent as
1391 broadcast packet. */
1393 void silc_server_send_new_id(SilcServer server,
1394 SilcSocketConnection sock,
1396 void *id, SilcIdType id_type,
1401 SILC_LOG_DEBUG(("Start"));
1403 idp = silc_id_payload_encode(id, id_type);
1404 silc_server_packet_send(server, sock, SILC_PACKET_NEW_ID,
1405 broadcast ? SILC_PACKET_FLAG_BROADCAST : 0,
1406 idp->data, idp->len, FALSE);
1407 silc_buffer_free(idp);
1410 /* Send New Channel Payload to notify about newly created channel in the
1411 SILC network. Normal server nevers sends this packet. Router uses this
1412 to notify other routers in the network about new channel. This packet
1415 void silc_server_send_new_channel(SilcServer server,
1416 SilcSocketConnection sock,
1420 uint32 channel_id_len,
1425 uint32 name_len = strlen(channel_name);
1427 SILC_LOG_DEBUG(("Start"));
1429 cid = silc_id_id2str(channel_id, SILC_ID_CHANNEL);
1433 /* Encode the channel payload */
1434 packet = silc_channel_payload_encode(channel_name, name_len,
1435 cid, channel_id_len, mode);
1437 silc_server_packet_send(server, sock, SILC_PACKET_NEW_CHANNEL,
1438 broadcast ? SILC_PACKET_FLAG_BROADCAST : 0,
1439 packet->data, packet->len, FALSE);
1442 silc_buffer_free(packet);
1445 /* Send Channel Key payload to distribute the new channel key. Normal server
1446 sends this to router when new client joins to existing channel. Router
1447 sends this to the local server who sent the join command in case where
1448 the channel did not exist yet. Both normal and router servers uses this
1449 also to send this to locally connected clients on the channel. This
1450 must not be broadcasted packet. Routers do not send this to each other.
1451 If `sender is provided then the packet is not sent to that connection since
1452 it originally came from it. */
1454 void silc_server_send_channel_key(SilcServer server,
1455 SilcSocketConnection sender,
1456 SilcChannelEntry channel,
1457 unsigned char route)
1460 unsigned char *chid;
1463 SILC_LOG_DEBUG(("Start"));
1465 chid = silc_id_id2str(channel->id, SILC_ID_CHANNEL);
1469 /* Encode channel key packet */
1470 tmp_len = strlen(channel->channel_key->cipher->name);
1471 packet = silc_channel_key_payload_encode(SILC_ID_CHANNEL_LEN, chid, tmp_len,
1472 channel->channel_key->cipher->name,
1473 channel->key_len / 8, channel->key);
1475 silc_server_packet_send_to_channel(server, sender, channel,
1476 SILC_PACKET_CHANNEL_KEY,
1477 route, packet->data, packet->len, FALSE);
1478 silc_buffer_free(packet);
1482 /* Generic function to send any command. The arguments must be sent already
1483 encoded into correct form in correct order. */
1485 void silc_server_send_command(SilcServer server,
1486 SilcSocketConnection sock,
1487 SilcCommand command,
1495 packet = silc_command_payload_encode_vap(command, 0, argc, ap);
1496 silc_server_packet_send(server, sock, SILC_PACKET_COMMAND, 0,
1497 packet->data, packet->len, TRUE);
1498 silc_buffer_free(packet);
1501 /* Send the heartbeat packet. */
1503 void silc_server_send_heartbeat(SilcServer server,
1504 SilcSocketConnection sock)
1506 silc_server_packet_send(server, sock, SILC_PACKET_HEARTBEAT, 0,
1510 /* Generic function to relay packet we've received. This is used to relay
1511 packets to a client but generally can be used to other purposes as well. */
1513 void silc_server_relay_packet(SilcServer server,
1514 SilcSocketConnection dst_sock,
1517 SilcPacketContext *packet,
1520 silc_buffer_push(packet->buffer, SILC_PACKET_HEADER_LEN + packet->src_id_len
1521 + packet->dst_id_len + packet->padlen);
1523 silc_packet_send_prepare(dst_sock, 0, 0, packet->buffer->len);
1524 silc_buffer_put(dst_sock->outbuf, packet->buffer->data, packet->buffer->len);
1526 /* Re-encrypt packet */
1527 silc_packet_encrypt(cipher, hmac, dst_sock->outbuf, packet->buffer->len);
1529 /* Send the packet */
1530 silc_server_packet_send_real(server, dst_sock, force_send);
1532 silc_buffer_pull(packet->buffer, SILC_PACKET_HEADER_LEN + packet->src_id_len
1533 + packet->dst_id_len + packet->padlen);
1536 /* Routine used to send the connection authentication packet. */
1538 void silc_server_send_connection_auth_request(SilcServer server,
1539 SilcSocketConnection sock,
1541 SilcAuthMethod auth_meth)
1545 packet = silc_buffer_alloc(4);
1546 silc_buffer_pull_tail(packet, SILC_BUFFER_END(packet));
1547 silc_buffer_format(packet,
1548 SILC_STR_UI_SHORT(conn_type),
1549 SILC_STR_UI_SHORT(auth_meth),
1552 silc_server_packet_send(server, sock, SILC_PACKET_CONNECTION_AUTH_REQUEST,
1553 0, packet->data, packet->len, FALSE);
1554 silc_buffer_free(packet);