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 /* Internal context that holds the packet data and packet sending function
29 callbacks when the packet is sent with timeout. This is used when
30 the server is performing re-key protocol. During re-key we will prevent
31 sending of any other than re-key packets so that the packets would not
32 be encrypted with wrong keys. Other than that, this is not used at all. */
35 } *SilcServerSendPacket;
37 /* Routine that sends packet or marks packet to be sent. This is used
38 directly only in special cases. Normal cases should use
39 silc_server_packet_send. Returns < 0 error. */
41 int silc_server_packet_send_real(SilcServer server,
42 SilcSocketConnection sock,
48 ret = silc_packet_send(sock, force_send);
52 /* Mark that there is some outgoing data available for this connection.
53 This call sets the connection both for input and output (the input
54 is set always and this call keeps the input setting, actually).
55 Actual data sending is performed by silc_server_packet_process. */
56 SILC_SET_CONNECTION_FOR_OUTPUT(sock->sock);
58 /* Mark to socket that data is pending in outgoing buffer. This flag
59 is needed if new data is added to the buffer before the earlier
60 put data is sent to the network. */
61 SILC_SET_OUTBUF_PENDING(sock);
66 /* Assembles a new packet to be sent out to network. This doesn't actually
67 send the packet but creates the packet and fills the outgoing data
68 buffer and marks the packet ready to be sent to network. However, If
69 argument force_send is TRUE the packet is sent immediately and not put
70 to queue. Normal case is that the packet is not sent immediately. */
72 void silc_server_packet_send(SilcServer server,
73 SilcSocketConnection sock,
75 SilcPacketFlags flags,
81 SilcIdType dst_id_type = SILC_ID_NONE;
86 /* Get data used in the packet sending, keys and stuff */
88 case SILC_SOCKET_TYPE_CLIENT:
89 dst_id = ((SilcClientEntry)sock->user_data)->id;
90 dst_id_type = SILC_ID_CLIENT;
92 case SILC_SOCKET_TYPE_SERVER:
93 case SILC_SOCKET_TYPE_ROUTER:
94 dst_id = ((SilcServerEntry)sock->user_data)->id;
95 dst_id_type = SILC_ID_SERVER;
101 silc_server_packet_send_dest(server, sock, type, flags, dst_id,
102 dst_id_type, data, data_len, force_send);
105 /* Assembles a new packet to be sent out to network. This doesn't actually
106 send the packet but creates the packet and fills the outgoing data
107 buffer and marks the packet ready to be sent to network. However, If
108 argument force_send is TRUE the packet is sent immediately and not put
109 to queue. Normal case is that the packet is not sent immediately.
110 Destination information is sent as argument for this function. */
112 void silc_server_packet_send_dest(SilcServer server,
113 SilcSocketConnection sock,
115 SilcPacketFlags flags,
117 SilcIdType dst_id_type,
122 SilcPacketContext packetdata;
123 SilcIDListData idata;
124 SilcCipher cipher = NULL;
125 SilcHmac hmac = NULL;
126 unsigned char *dst_id_data = NULL;
127 uint32 dst_id_len = 0;
129 SILC_LOG_DEBUG(("Sending packet, type %d", type));
131 /* Get data used in the packet sending, keys and stuff */
132 idata = (SilcIDListData)sock->user_data;
135 dst_id_data = silc_id_id2str(dst_id, dst_id_type);
136 dst_id_len = silc_id_get_len(dst_id_type);
139 /* Set the packet context pointers */
140 packetdata.type = type;
141 packetdata.flags = flags;
142 packetdata.src_id = silc_id_id2str(server->id, server->id_type);
143 packetdata.src_id_len = SILC_ID_SERVER_LEN;
144 packetdata.src_id_type = server->id_type;
145 packetdata.dst_id = dst_id_data;
146 packetdata.dst_id_len = dst_id_len;
147 packetdata.dst_id_type = dst_id_type;
148 packetdata.truelen = data_len + SILC_PACKET_HEADER_LEN +
149 packetdata.src_id_len + dst_id_len;
150 packetdata.padlen = SILC_PACKET_PADLEN(packetdata.truelen);
152 /* Prepare outgoing data buffer for packet sending */
153 silc_packet_send_prepare(sock,
154 SILC_PACKET_HEADER_LEN +
155 packetdata.src_id_len +
156 packetdata.dst_id_len,
160 SILC_LOG_DEBUG(("Putting data to outgoing buffer, len %d", data_len));
162 packetdata.buffer = sock->outbuf;
164 /* Put the data to the buffer */
165 if (data && data_len)
166 silc_buffer_put(sock->outbuf, data, data_len);
168 /* Create the outgoing packet */
169 silc_packet_assemble(&packetdata);
172 cipher = idata->send_key;
176 /* Encrypt the packet */
177 silc_packet_encrypt(cipher, hmac, sock->outbuf, sock->outbuf->len);
179 SILC_LOG_HEXDUMP(("Outgoing packet, len %d", sock->outbuf->len),
180 sock->outbuf->data, sock->outbuf->len);
182 /* Now actually send the packet */
183 silc_server_packet_send_real(server, sock, force_send);
185 if (packetdata.src_id)
186 silc_free(packetdata.src_id);
187 if (packetdata.dst_id)
188 silc_free(packetdata.dst_id);
191 /* Assembles a new packet to be sent out to network. This doesn't actually
192 send the packet but creates the packet and fills the outgoing data
193 buffer and marks the packet ready to be sent to network. However, If
194 argument force_send is TRUE the packet is sent immediately and not put
195 to queue. Normal case is that the packet is not sent immediately.
196 The source and destination information is sent as argument for this
199 void silc_server_packet_send_srcdest(SilcServer server,
200 SilcSocketConnection sock,
202 SilcPacketFlags flags,
204 SilcIdType src_id_type,
206 SilcIdType dst_id_type,
211 SilcPacketContext packetdata;
212 SilcIDListData idata;
213 SilcCipher cipher = NULL;
214 SilcHmac hmac = NULL;
215 unsigned char *dst_id_data = NULL;
216 uint32 dst_id_len = 0;
217 unsigned char *src_id_data = NULL;
218 uint32 src_id_len = 0;
220 SILC_LOG_DEBUG(("Sending packet, type %d", type));
222 /* Get data used in the packet sending, keys and stuff */
223 idata = (SilcIDListData)sock->user_data;
226 dst_id_data = silc_id_id2str(dst_id, dst_id_type);
227 dst_id_len = silc_id_get_len(dst_id_type);
231 src_id_data = silc_id_id2str(src_id, src_id_type);
232 src_id_len = silc_id_get_len(src_id_type);
235 /* Set the packet context pointers */
236 packetdata.type = type;
237 packetdata.flags = flags;
238 packetdata.src_id = src_id_data;
239 packetdata.src_id_len = src_id_len;
240 packetdata.src_id_type = src_id_type;
241 packetdata.dst_id = dst_id_data;
242 packetdata.dst_id_len = dst_id_len;
243 packetdata.dst_id_type = dst_id_type;
244 packetdata.truelen = data_len + SILC_PACKET_HEADER_LEN +
245 packetdata.src_id_len + dst_id_len;
246 packetdata.padlen = SILC_PACKET_PADLEN(packetdata.truelen);
248 /* Prepare outgoing data buffer for packet sending */
249 silc_packet_send_prepare(sock,
250 SILC_PACKET_HEADER_LEN +
251 packetdata.src_id_len +
252 packetdata.dst_id_len,
256 SILC_LOG_DEBUG(("Putting data to outgoing buffer, len %d", data_len));
258 packetdata.buffer = sock->outbuf;
260 /* Put the data to the buffer */
261 if (data && data_len)
262 silc_buffer_put(sock->outbuf, data, data_len);
264 /* Create the outgoing packet */
265 silc_packet_assemble(&packetdata);
268 cipher = idata->send_key;
272 /* Encrypt the packet */
273 silc_packet_encrypt(cipher, hmac, sock->outbuf, sock->outbuf->len);
275 SILC_LOG_HEXDUMP(("Outgoing packet, len %d", sock->outbuf->len),
276 sock->outbuf->data, sock->outbuf->len);
278 /* Now actually send the packet */
279 silc_server_packet_send_real(server, sock, force_send);
281 if (packetdata.src_id)
282 silc_free(packetdata.src_id);
283 if (packetdata.dst_id)
284 silc_free(packetdata.dst_id);
287 /* Broadcast received packet to our primary route. This function is used
288 by router to further route received broadcast packet. It is expected
289 that the broadcast flag from the packet is checked before calling this
290 function. This does not test or set the broadcast flag. */
292 void silc_server_packet_broadcast(SilcServer server,
293 SilcSocketConnection sock,
294 SilcPacketContext *packet)
296 SilcBuffer buffer = packet->buffer;
297 SilcIDListData idata;
300 SILC_LOG_DEBUG(("Broadcasting received broadcast packet"));
302 /* If the packet is originated from our primary route we are
303 not allowed to send the packet. */
304 id = silc_id_str2id(packet->src_id, packet->src_id_len, packet->src_id_type);
305 if (id && SILC_ID_SERVER_COMPARE(id, server->router->id)) {
306 idata = (SilcIDListData)sock->user_data;
308 silc_buffer_push(buffer, buffer->data - buffer->head);
309 silc_packet_send_prepare(sock, 0, 0, buffer->len);
310 silc_buffer_put(sock->outbuf, buffer->data, buffer->len);
311 silc_packet_encrypt(idata->send_key, idata->hmac,
312 sock->outbuf, sock->outbuf->len);
314 SILC_LOG_HEXDUMP(("Broadcasted packet, len %d", sock->outbuf->len),
315 sock->outbuf->data, sock->outbuf->len);
317 /* Now actually send the packet */
318 silc_server_packet_send_real(server, sock, TRUE);
323 SILC_LOG_DEBUG(("Will not broadcast to primary route since it is the "
324 "original sender of this packet"));
328 /* Routes received packet to `sock'. This is used to route the packets that
329 router receives but are not destined to it. */
331 void silc_server_packet_route(SilcServer server,
332 SilcSocketConnection sock,
333 SilcPacketContext *packet)
335 SilcBuffer buffer = packet->buffer;
336 SilcIDListData idata;
338 SILC_LOG_DEBUG(("Routing received packet"));
340 idata = (SilcIDListData)sock->user_data;
342 silc_buffer_push(buffer, buffer->data - buffer->head);
343 silc_packet_send_prepare(sock, 0, 0, buffer->len);
344 silc_buffer_put(sock->outbuf, buffer->data, buffer->len);
345 silc_packet_encrypt(idata->send_key, idata->hmac,
346 sock->outbuf, sock->outbuf->len);
348 SILC_LOG_HEXDUMP(("Routed packet, len %d", sock->outbuf->len),
349 sock->outbuf->data, sock->outbuf->len);
351 /* Now actually send the packet */
352 silc_server_packet_send_real(server, sock, TRUE);
355 /* Internal routine to actually create the channel packet and send it
356 to network. This is common function in channel message sending. If
357 `channel_message' is TRUE this encrypts the message as it is strictly
358 a channel message. If FALSE normal encryption process is used. */
361 silc_server_packet_send_to_channel_real(SilcServer server,
362 SilcSocketConnection sock,
363 SilcPacketContext *packet,
371 packet->truelen = data_len + SILC_PACKET_HEADER_LEN +
372 packet->src_id_len + packet->dst_id_len;
374 /* Prepare outgoing data buffer for packet sending */
375 silc_packet_send_prepare(sock,
376 SILC_PACKET_HEADER_LEN +
382 packet->buffer = sock->outbuf;
384 /* Put the data to buffer, assemble and encrypt the packet. The packet
385 is encrypted with normal session key shared with the client. */
386 silc_buffer_put(sock->outbuf, data, data_len);
387 silc_packet_assemble(packet);
389 silc_packet_encrypt(cipher, hmac, sock->outbuf, SILC_PACKET_HEADER_LEN +
390 packet->src_id_len + packet->dst_id_len +
393 silc_packet_encrypt(cipher, hmac, sock->outbuf, sock->outbuf->len);
395 SILC_LOG_HEXDUMP(("Channel packet, len %d", sock->outbuf->len),
396 sock->outbuf->data, sock->outbuf->len);
398 /* Now actually send the packet */
399 silc_server_packet_send_real(server, sock, force_send);
402 /* This routine is used by the server to send packets to channel. The
403 packet sent with this function is distributed to all clients on
404 the channel. Usually this is used to send notify messages to the
405 channel, things like notify about new user joining to the channel.
406 If `route' is FALSE then the packet is sent only locally and will not
407 be routed anywhere (for router locally means cell wide). If `sender'
408 is provided then the packet is not sent to that connection since it
409 originally came from it. */
411 void silc_server_packet_send_to_channel(SilcServer server,
412 SilcSocketConnection sender,
413 SilcChannelEntry channel,
420 SilcSocketConnection sock = NULL;
421 SilcPacketContext packetdata;
422 SilcClientEntry client = NULL;
423 SilcServerEntry *routed = NULL;
424 SilcChannelClientEntry chl;
425 SilcIDListData idata;
426 uint32 routed_count = 0;
428 /* This doesn't send channel message packets */
429 if (type == SILC_PACKET_CHANNEL_MESSAGE)
432 SILC_LOG_DEBUG(("Sending packet to channel"));
434 /* Set the packet context pointers. */
435 packetdata.flags = 0;
436 packetdata.type = type;
437 packetdata.src_id = silc_id_id2str(server->id, SILC_ID_SERVER);
438 packetdata.src_id_len = SILC_ID_SERVER_LEN;
439 packetdata.src_id_type = SILC_ID_SERVER;
440 packetdata.dst_id = silc_id_id2str(channel->id, SILC_ID_CHANNEL);
441 packetdata.dst_id_len = SILC_ID_CHANNEL_LEN;
442 packetdata.dst_id_type = SILC_ID_CHANNEL;
443 packetdata.truelen = data_len + SILC_PACKET_HEADER_LEN +
444 packetdata.src_id_len + packetdata.dst_id_len;
445 packetdata.padlen = SILC_PACKET_PADLEN(packetdata.truelen);
447 /* If there are global users in the channel we will send the message
448 first to our router for further routing. */
449 if (route && server->server_type == SILC_SERVER && !server->standalone &&
450 channel->global_users) {
451 SilcServerEntry router;
453 /* Get data used in packet header encryption, keys and stuff. */
454 router = server->router;
455 sock = (SilcSocketConnection)router->connection;
456 idata = (SilcIDListData)router;
458 if (sock != sender) {
459 SILC_LOG_DEBUG(("Sending channel message to router for routing"));
461 silc_server_packet_send_to_channel_real(server, sock, &packetdata,
462 idata->send_key, idata->hmac,
463 data, data_len, FALSE,
468 /* Send the message to clients on the channel's client list. */
469 silc_list_start(channel->user_list);
470 while ((chl = silc_list_get(channel->user_list)) != SILC_LIST_END) {
471 client = chl->client;
473 /* If client has router set it is not locally connected client and
474 we will route the message to the router set in the client. Though,
475 send locally connected server in all cases. */
476 if (server->server_type == SILC_ROUTER && client && client->router &&
477 ((!route && client->router->router == server->id_entry) || route)) {
480 /* Check if we have sent the packet to this route already */
481 for (k = 0; k < routed_count; k++)
482 if (routed[k] == client->router)
484 if (k < routed_count)
487 /* Get data used in packet header encryption, keys and stuff. */
488 sock = (SilcSocketConnection)client->router->connection;
489 idata = (SilcIDListData)client->router;
491 if (sender && sock == sender)
494 /* Send the packet */
495 silc_server_packet_send_to_channel_real(server, sock, &packetdata,
496 idata->send_key, idata->hmac,
497 data, data_len, FALSE,
500 /* We want to make sure that the packet is routed to same router
501 only once. Mark this route as sent route. */
503 routed = silc_realloc(routed, sizeof(*routed) * (k + 1));
504 routed[k] = client->router;
510 if (client && client->router)
513 /* Send to locally connected client */
516 /* Get data used in packet header encryption, keys and stuff. */
517 sock = (SilcSocketConnection)client->connection;
518 idata = (SilcIDListData)client;
520 if (sender && sock == sender)
523 /* Send the packet */
524 silc_server_packet_send_to_channel_real(server, sock, &packetdata,
525 idata->send_key, idata->hmac,
526 data, data_len, FALSE,
533 silc_free(packetdata.src_id);
534 silc_free(packetdata.dst_id);
537 /* This routine is explicitly used to relay messages to some channel.
538 Packets sent with this function we have received earlier and are
539 totally encrypted. This just sends the packet to all clients on
540 the channel. If the sender of the packet is someone on the channel
541 the message will not be sent to that client. The SILC Packet header
542 is encrypted with the session key shared between us and the client.
543 MAC is also computed before encrypting the header. Rest of the
544 packet will be untouched. */
546 void silc_server_packet_relay_to_channel(SilcServer server,
547 SilcSocketConnection sender_sock,
548 SilcChannelEntry channel,
550 SilcIdType sender_type,
556 SilcSocketConnection sock = NULL;
557 SilcPacketContext packetdata;
558 SilcClientEntry client = NULL;
559 SilcServerEntry *routed = NULL;
560 SilcChannelClientEntry chl;
561 uint32 routed_count = 0;
562 SilcIDListData idata;
564 SILC_LOG_DEBUG(("Relaying packet to channel"));
566 /* Set the packet context pointers. */
567 packetdata.flags = 0;
568 packetdata.type = SILC_PACKET_CHANNEL_MESSAGE;
569 packetdata.src_id = silc_id_id2str(sender, sender_type);
570 packetdata.src_id_len = silc_id_get_len(sender_type);
571 packetdata.src_id_type = sender_type;
572 packetdata.dst_id = silc_id_id2str(channel->id, SILC_ID_CHANNEL);
573 packetdata.dst_id_len = SILC_ID_CHANNEL_LEN;
574 packetdata.dst_id_type = SILC_ID_CHANNEL;
575 packetdata.padlen = SILC_PACKET_PADLEN((SILC_PACKET_HEADER_LEN +
576 packetdata.src_id_len +
577 packetdata.dst_id_len));
579 /* If there are global users in the channel we will send the message
580 first to our router for further routing. */
581 if (server->server_type == SILC_SERVER && !server->standalone &&
582 channel->global_users) {
583 SilcServerEntry router;
585 router = server->router;
587 /* Check that the sender is not our router. */
588 if (sender_sock != (SilcSocketConnection)router->connection) {
590 /* Get data used in packet header encryption, keys and stuff. */
591 sock = (SilcSocketConnection)router->connection;
592 idata = (SilcIDListData)router;
594 SILC_LOG_DEBUG(("Sending channel message to router for routing"));
596 silc_server_packet_send_to_channel_real(server, sock, &packetdata,
597 idata->send_key, idata->hmac,
598 data, data_len, TRUE,
603 /* Send the message to clients on the channel's client list. */
604 silc_list_start(channel->user_list);
605 while ((chl = silc_list_get(channel->user_list)) != SILC_LIST_END) {
606 client = chl->client;
610 /* If sender is one on the channel do not send it the packet. */
611 if (!found && !SILC_ID_CLIENT_COMPARE(client->id, sender)) {
616 /* If the client has set router it means that it is not locally
617 connected client and we will route the packet further. */
618 if (server->server_type == SILC_ROUTER && client->router) {
621 /* Sender maybe server as well so we want to make sure that
622 we won't send the message to the server it came from. */
623 if (!found && !SILC_ID_SERVER_COMPARE(client->router->id, sender)) {
628 /* Check if we have sent the packet to this route already */
629 for (k = 0; k < routed_count; k++)
630 if (routed[k] == client->router)
632 if (k < routed_count)
635 /* Get data used in packet header encryption, keys and stuff. */
636 sock = (SilcSocketConnection)client->router->connection;
637 idata = (SilcIDListData)client->router;
639 if (sender_sock && sock == sender_sock)
642 SILC_LOG_DEBUG(("Relaying packet to client ID(%s) %s (%s)",
643 silc_id_render(client->id, SILC_ID_CLIENT),
644 sock->hostname, sock->ip));
646 /* We want to make sure that the packet is routed to same router
647 only once. Mark this route as sent route. */
649 routed = silc_realloc(routed, sizeof(*routed) * (k + 1));
650 routed[k] = client->router;
653 /* If the remote connection is router then we'll decrypt the
654 channel message and re-encrypt it with the session key shared
655 between us and the remote router. This is done because the
656 channel keys are cell specific and we have different channel
657 key than the remote router has. */
658 if (sock->type == SILC_SOCKET_TYPE_ROUTER) {
660 /* If private key mode is not set then decrypt the packet
662 if (!(channel->mode & SILC_CHANNEL_MODE_PRIVKEY)) {
663 unsigned char *tmp = silc_calloc(data_len, sizeof(*data));
664 memcpy(tmp, data, data_len);
666 /* Decrypt the channel message (we don't check the MAC) */
667 if (!silc_channel_message_payload_decrypt(tmp, data_len,
668 channel->channel_key,
670 memset(tmp, 0, data_len);
675 /* Now re-encrypt and send it to the router */
676 silc_server_packet_send_srcdest(server, sock,
677 SILC_PACKET_CHANNEL_MESSAGE, 0,
679 channel->id, SILC_ID_CHANNEL,
680 tmp, data_len, force_send);
682 /* Free the copy of the channel message */
683 memset(tmp, 0, data_len);
686 /* Private key mode is set, we don't have the channel key, so
687 just re-encrypt the entire packet and send it to the router. */
688 silc_server_packet_send_srcdest(server, sock,
689 SILC_PACKET_CHANNEL_MESSAGE, 0,
691 channel->id, SILC_ID_CHANNEL,
692 data, data_len, force_send);
697 /* Send the packet (to normal server) */
698 silc_server_packet_send_to_channel_real(server, sock, &packetdata,
699 idata->send_key, idata->hmac,
700 data, data_len, TRUE,
706 if (client && client->router)
709 /* Get data used in packet header encryption, keys and stuff. */
710 sock = (SilcSocketConnection)client->connection;
711 idata = (SilcIDListData)client;
713 if (sender_sock && sock == sender_sock)
716 SILC_LOG_DEBUG(("Sending packet to client ID(%s) %s (%s)",
717 silc_id_render(client->id, SILC_ID_CLIENT),
718 sock->hostname, sock->ip));
720 /* Send the packet */
721 silc_server_packet_send_to_channel_real(server, sock, &packetdata,
722 idata->send_key, idata->hmac,
723 data, data_len, TRUE,
728 silc_free(packetdata.src_id);
729 silc_free(packetdata.dst_id);
732 /* This function is used to send packets strictly to all local clients
733 on a particular channel. This is used for example to distribute new
734 channel key to all our locally connected clients on the channel.
735 The packets are always encrypted with the session key shared between
736 the client, this means these are not _to the channel_ but _to the client_
739 void silc_server_packet_send_local_channel(SilcServer server,
740 SilcChannelEntry channel,
742 SilcPacketFlags flags,
747 SilcChannelClientEntry chl;
748 SilcSocketConnection sock = NULL;
750 SILC_LOG_DEBUG(("Start"));
752 /* Send the message to clients on the channel's client list. */
753 silc_list_start(channel->user_list);
754 while ((chl = silc_list_get(channel->user_list)) != SILC_LIST_END) {
755 if (chl->client && !chl->client->router) {
756 sock = (SilcSocketConnection)chl->client->connection;
758 /* Send the packet to the client */
759 silc_server_packet_send_dest(server, sock, type, flags, chl->client->id,
760 SILC_ID_CLIENT, data, data_len,
766 /* Routine used to send (relay, route) private messages to some destination.
767 If the private message key does not exist then the message is re-encrypted,
768 otherwise we just pass it along. This really is not used to send new
769 private messages (as server does not send them) but to relay received
772 void silc_server_send_private_message(SilcServer server,
773 SilcSocketConnection dst_sock,
776 SilcPacketContext *packet)
778 SilcBuffer buffer = packet->buffer;
780 /* Re-encrypt and send if private messge key does not exist */
781 if ((packet->flags & SILC_PACKET_FLAG_PRIVMSG_KEY) == FALSE) {
783 silc_buffer_push(buffer, SILC_PACKET_HEADER_LEN + packet->src_id_len
784 + packet->dst_id_len + packet->padlen);
785 silc_packet_send_prepare(dst_sock, 0, 0, buffer->len);
786 silc_buffer_put(dst_sock->outbuf, buffer->data, buffer->len);
788 /* Re-encrypt packet */
789 silc_packet_encrypt(cipher, hmac, dst_sock->outbuf, buffer->len);
791 /* Send the packet */
792 silc_server_packet_send_real(server, dst_sock, FALSE);
795 /* Key exist so encrypt just header and send it */
796 silc_buffer_push(buffer, SILC_PACKET_HEADER_LEN + packet->src_id_len
797 + packet->dst_id_len + packet->padlen);
798 silc_packet_send_prepare(dst_sock, 0, 0, buffer->len);
799 silc_buffer_put(dst_sock->outbuf, buffer->data, buffer->len);
802 silc_packet_encrypt(cipher, hmac, dst_sock->outbuf,
803 SILC_PACKET_HEADER_LEN + packet->src_id_len +
804 packet->dst_id_len + packet->padlen);
806 silc_server_packet_send_real(server, dst_sock, FALSE);
810 /* Sends current motd to client */
812 void silc_server_send_motd(SilcServer server,
813 SilcSocketConnection sock)
818 if (server->config && server->config->motd &&
819 server->config->motd->motd_file) {
821 motd = silc_file_read(server->config->motd->motd_file, &motd_len);
825 silc_server_send_notify(server, sock, FALSE, SILC_NOTIFY_TYPE_MOTD, 1,
831 /* Sends error message. Error messages may or may not have any
834 void silc_server_send_error(SilcServer server,
835 SilcSocketConnection sock,
836 const char *fmt, ...)
839 unsigned char buf[4096];
841 memset(buf, 0, sizeof(buf));
843 vsprintf(buf, fmt, ap);
846 silc_server_packet_send(server, sock, SILC_PACKET_ERROR, 0,
847 buf, strlen(buf), FALSE);
850 /* Sends notify message. If format is TRUE the variable arguments are
851 formatted and the formatted string is sent as argument payload. If it is
852 FALSE then each argument is sent as separate argument and their format
853 in the argument list must be { argument data, argument length }. */
855 void silc_server_send_notify(SilcServer server,
856 SilcSocketConnection sock,
866 packet = silc_notify_payload_encode(type, argc, ap);
867 silc_server_packet_send(server, sock, SILC_PACKET_NOTIFY, 0,
868 packet->data, packet->len, FALSE);
869 silc_buffer_free(packet);
872 /* Sends notify message and gets the arguments from the `args' Argument
875 void silc_server_send_notify_args(SilcServer server,
876 SilcSocketConnection sock,
884 packet = silc_notify_payload_encode_args(type, argc, args);
885 silc_server_packet_send(server, sock, SILC_PACKET_NOTIFY, 0,
886 packet->data, packet->len, FALSE);
887 silc_buffer_free(packet);
890 /* Send CHANNEL_CHANGE notify type. This tells the receiver to replace the
891 `old_id' with the `new_id'. */
893 void silc_server_send_notify_channel_change(SilcServer server,
894 SilcSocketConnection sock,
896 SilcChannelID *old_id,
897 SilcChannelID *new_id,
900 SilcBuffer idp1, idp2;
902 idp1 = silc_id_payload_encode((void *)old_id, SILC_ID_CHANNEL);
903 idp2 = silc_id_payload_encode((void *)new_id, SILC_ID_CHANNEL);
905 silc_server_send_notify(server, sock, broadcast,
906 SILC_NOTIFY_TYPE_CHANNEL_CHANGE,
907 2, idp1->data, idp1->len, idp2->data, idp2->len);
908 silc_buffer_free(idp1);
909 silc_buffer_free(idp2);
912 /* Send NICK_CHANGE notify type. This tells the receiver to replace the
913 `old_id' with the `new_id'. */
915 void silc_server_send_notify_nick_change(SilcServer server,
916 SilcSocketConnection sock,
918 SilcClientID *old_id,
919 SilcClientID *new_id,
922 SilcBuffer idp1, idp2;
924 idp1 = silc_id_payload_encode((void *)old_id, SILC_ID_CLIENT);
925 idp2 = silc_id_payload_encode((void *)new_id, SILC_ID_CLIENT);
927 silc_server_send_notify(server, sock, broadcast,
928 SILC_NOTIFY_TYPE_NICK_CHANGE,
929 2, idp1->data, idp1->len, idp2->data, idp2->len);
930 silc_buffer_free(idp1);
931 silc_buffer_free(idp2);
934 /* Sends JOIN notify type. This tells that new client by `client_id' ID
935 has joined to the `channel'. */
937 void silc_server_send_notify_join(SilcServer server,
938 SilcSocketConnection sock,
940 SilcChannelEntry channel,
941 SilcClientID *client_id,
942 uint32 client_id_len)
944 SilcBuffer idp1, idp2;
946 idp1 = silc_id_payload_encode((void *)client_id, SILC_ID_CLIENT);
947 idp2 = silc_id_payload_encode((void *)channel->id, SILC_ID_CHANNEL);
948 silc_server_send_notify(server, sock, broadcast, SILC_NOTIFY_TYPE_JOIN,
949 2, idp1->data, idp1->len,
950 idp2->data, idp2->len);
951 silc_buffer_free(idp1);
952 silc_buffer_free(idp2);
955 /* Sends LEAVE notify type. This tells that `client_id' has left the
956 `channel'. The Notify packet is always destined to the channel. */
958 void silc_server_send_notify_leave(SilcServer server,
959 SilcSocketConnection sock,
961 SilcChannelEntry channel,
962 SilcClientID *client_id,
963 uint32 client_id_len)
967 idp = silc_id_payload_encode((void *)client_id, SILC_ID_CLIENT);
968 silc_server_send_notify_dest(server, sock, broadcast, (void *)channel->id,
969 SILC_ID_CHANNEL, SILC_NOTIFY_TYPE_LEAVE,
970 1, idp->data, idp->len);
971 silc_buffer_free(idp);
974 /* Sends CMODE_CHANGE notify type. This tells that `client_id' changed the
975 `channel' mode to `mode. The Notify packet is always destined to
978 void silc_server_send_notify_cmode(SilcServer server,
979 SilcSocketConnection sock,
981 SilcChannelEntry channel,
983 void *id, SilcIdType id_type,
985 char *cipher, char *hmac)
988 unsigned char mode[4];
990 idp = silc_id_payload_encode((void *)id, id_type);
991 SILC_PUT32_MSB(mode_mask, mode);
993 silc_server_send_notify_dest(server, sock, broadcast, (void *)channel->id,
994 SILC_ID_CHANNEL, SILC_NOTIFY_TYPE_CMODE_CHANGE,
995 4, idp->data, idp->len,
997 cipher, cipher ? strlen(cipher) : 0,
998 hmac, hmac ? strlen(hmac) : 0);
999 silc_buffer_free(idp);
1002 /* Sends CUMODE_CHANGE notify type. This tells that `client_id' changed the
1003 `target' client's mode on `channel'. The Notify packet is always
1004 destined to the channel. */
1006 void silc_server_send_notify_cumode(SilcServer server,
1007 SilcSocketConnection sock,
1009 SilcChannelEntry channel,
1011 SilcClientID *client_id,
1012 uint32 client_id_len,
1013 SilcClientID *target,
1016 SilcBuffer idp1, idp2;
1017 unsigned char mode[4];
1019 idp1 = silc_id_payload_encode((void *)client_id, SILC_ID_CLIENT);
1020 idp2 = silc_id_payload_encode((void *)target, SILC_ID_CLIENT);
1021 SILC_PUT32_MSB(mode_mask, mode);
1023 silc_server_send_notify_dest(server, sock, broadcast, (void *)channel->id,
1025 SILC_NOTIFY_TYPE_CUMODE_CHANGE, 3,
1026 idp1->data, idp1->len,
1028 idp2->data, idp2->len);
1029 silc_buffer_free(idp1);
1030 silc_buffer_free(idp2);
1033 /* Sends SIGNOFF notify type. This tells that `client_id' client has
1034 left SILC network. This function is used only between server and router
1035 traffic. This is not used to send the notify to the channel for
1036 client. The `message may be NULL. */
1038 void silc_server_send_notify_signoff(SilcServer server,
1039 SilcSocketConnection sock,
1041 SilcClientID *client_id,
1042 uint32 client_id_len,
1047 idp = silc_id_payload_encode((void *)client_id, SILC_ID_CLIENT);
1048 silc_server_send_notify(server, sock, broadcast,
1049 SILC_NOTIFY_TYPE_SIGNOFF,
1050 message ? 2 : 1, idp->data, idp->len,
1051 message, message ? strlen(message): 0);
1052 silc_buffer_free(idp);
1055 /* Sends TOPIC_SET notify type. This tells that `client_id' changed
1056 the `channel's topic to `topic'. The Notify packet is always destined
1057 to the channel. This function is used to send the topic set notifies
1060 void silc_server_send_notify_topic_set(SilcServer server,
1061 SilcSocketConnection sock,
1063 SilcChannelEntry channel,
1064 SilcClientID *client_id,
1065 uint32 client_id_len,
1070 idp = silc_id_payload_encode((void *)client_id, SILC_ID_CLIENT);
1071 silc_server_send_notify(server, sock, broadcast,
1072 SILC_NOTIFY_TYPE_SERVER_SIGNOFF,
1074 idp->data, idp->len,
1075 topic, topic ? strlen(topic) : 0);
1076 silc_buffer_free(idp);
1079 /* Send KICKED notify type. This tells that the `client_id' on `channel'
1080 was kicked off the channel. The `comment' may indicate the reason
1081 for the kicking. This function is used only between server and router
1084 void silc_server_send_notify_kicked(SilcServer server,
1085 SilcSocketConnection sock,
1087 SilcChannelEntry channel,
1088 SilcClientID *client_id,
1089 uint32 client_id_len,
1094 idp = silc_id_payload_encode((void *)client_id, SILC_ID_CLIENT);
1095 silc_server_send_notify_dest(server, sock, broadcast, (void *)channel->id,
1096 SILC_ID_CHANNEL, SILC_NOTIFY_TYPE_KICKED,
1097 comment ? 2 : 1, idp->data, idp->len,
1098 comment, comment ? strlen(comment) : 0);
1099 silc_buffer_free(idp);
1102 /* Send KILLED notify type. This tells that the `client_id' client was
1103 killed from the network. The `comment' may indicate the reason
1106 void silc_server_send_notify_killed(SilcServer server,
1107 SilcSocketConnection sock,
1109 SilcClientID *client_id,
1110 uint32 client_id_len,
1115 idp = silc_id_payload_encode((void *)client_id, SILC_ID_CLIENT);
1116 silc_server_send_notify_dest(server, sock, broadcast, (void *)client_id,
1117 SILC_ID_CLIENT, SILC_NOTIFY_TYPE_KILLED,
1118 comment ? 2 : 1, idp->data, idp->len,
1119 comment, comment ? strlen(comment) : 0);
1120 silc_buffer_free(idp);
1123 /* Sends UMODE_CHANGE notify type. This tells that `client_id' client's
1124 user mode in the SILC Network was changed. This function is used to
1125 send the packet between routers as broadcast packet. */
1127 void silc_server_send_notify_umode(SilcServer server,
1128 SilcSocketConnection sock,
1130 SilcClientID *client_id,
1131 uint32 client_id_len,
1135 unsigned char mode[4];
1137 idp = silc_id_payload_encode((void *)client_id, SILC_ID_CLIENT);
1138 SILC_PUT32_MSB(mode_mask, mode);
1140 silc_server_send_notify(server, sock, broadcast,
1141 SILC_NOTIFY_TYPE_UMODE_CHANGE, 2,
1142 idp->data, idp->len,
1144 silc_buffer_free(idp);
1147 /* Sends BAN notify type. This tells that ban has been either `add'ed
1148 or `del'eted on the `channel. This function is used to send the packet
1149 between routers as broadcast packet. */
1151 void silc_server_send_notify_ban(SilcServer server,
1152 SilcSocketConnection sock,
1154 SilcChannelEntry channel,
1155 char *add, char *del)
1159 idp = silc_id_payload_encode((void *)channel->id, SILC_ID_CHANNEL);
1160 silc_server_send_notify(server, sock, broadcast,
1161 SILC_NOTIFY_TYPE_BAN, 3,
1162 idp->data, idp->len,
1163 add, add ? strlen(add) : 0,
1164 del, del ? strlen(del) : 0);
1165 silc_buffer_free(idp);
1168 /* Sends INVITE notify type. This tells that invite has been either `add'ed
1169 or `del'eted on the `channel. The sender of the invite is the `client_id'.
1170 This function is used to send the packet between routers as broadcast
1173 void silc_server_send_notify_invite(SilcServer server,
1174 SilcSocketConnection sock,
1176 SilcChannelEntry channel,
1177 SilcClientID *client_id,
1178 uint32 client_id_len,
1179 char *add, char *del)
1181 SilcBuffer idp, idp2;
1183 idp = silc_id_payload_encode((void *)channel->id, SILC_ID_CHANNEL);
1184 idp2 = silc_id_payload_encode((void *)client_id, SILC_ID_CLIENT);
1185 silc_server_send_notify(server, sock, broadcast,
1186 SILC_NOTIFY_TYPE_INVITE, 5,
1187 idp->data, idp->len,
1188 channel->channel_name, strlen(channel->channel_name),
1189 idp2->data, idp2->len,
1190 add, add ? strlen(add) : 0,
1191 del, del ? strlen(del) : 0);
1192 silc_buffer_free(idp);
1193 silc_buffer_free(idp2);
1196 /* Sends notify message destined to specific entity. */
1198 void silc_server_send_notify_dest(SilcServer server,
1199 SilcSocketConnection sock,
1202 SilcIdType dest_id_type,
1203 SilcNotifyType type,
1211 packet = silc_notify_payload_encode(type, argc, ap);
1212 silc_server_packet_send_dest(server, sock, SILC_PACKET_NOTIFY, 0,
1213 dest_id, dest_id_type,
1214 packet->data, packet->len, FALSE);
1215 silc_buffer_free(packet);
1218 /* Sends notify message to a channel. The notify message sent is
1219 distributed to all clients on the channel. If `route_notify' is TRUE
1220 then the notify may be routed to primary route or to some other routers.
1221 If FALSE it is assured that the notify is sent only locally. If `sender'
1222 is provided then the packet is not sent to that connection since it
1223 originally came from it. */
1225 void silc_server_send_notify_to_channel(SilcServer server,
1226 SilcSocketConnection sender,
1227 SilcChannelEntry channel,
1228 unsigned char route_notify,
1229 SilcNotifyType type,
1237 packet = silc_notify_payload_encode(type, argc, ap);
1238 silc_server_packet_send_to_channel(server, sender, channel,
1239 SILC_PACKET_NOTIFY, route_notify,
1240 packet->data, packet->len, FALSE);
1241 silc_buffer_free(packet);
1244 /* Send notify message to all channels the client has joined. It is quaranteed
1245 that the message is sent only once to a client (ie. if a client is joined
1246 on two same channel it will receive only one notify message). Also, this
1247 sends only to local clients (locally connected if we are server, and to
1248 local servers if we are router). If `sender' is provided the packet is
1249 not sent to that client at all. */
1251 void silc_server_send_notify_on_channels(SilcServer server,
1252 SilcClientEntry sender,
1253 SilcClientEntry client,
1254 SilcNotifyType type,
1258 SilcSocketConnection sock = NULL;
1259 SilcPacketContext packetdata;
1261 SilcClientEntry *sent_clients = NULL;
1262 uint32 sent_clients_count = 0;
1263 SilcServerEntry *routed = NULL;
1264 uint32 routed_count = 0;
1265 SilcChannelEntry channel;
1266 SilcChannelClientEntry chl, chl2;
1267 SilcIDListData idata;
1269 unsigned char *data;
1271 int force_send = FALSE;
1274 SILC_LOG_DEBUG(("Start"));
1276 if (!silc_list_count(client->channels))
1280 packet = silc_notify_payload_encode(type, argc, ap);
1281 data = packet->data;
1282 data_len = packet->len;
1284 /* Set the packet context pointers. */
1285 packetdata.flags = 0;
1286 packetdata.type = SILC_PACKET_NOTIFY;
1287 packetdata.src_id = silc_id_id2str(server->id, SILC_ID_SERVER);
1288 packetdata.src_id_len = SILC_ID_SERVER_LEN;
1289 packetdata.src_id_type = SILC_ID_SERVER;
1291 silc_list_start(client->channels);
1292 while ((chl = silc_list_get(client->channels)) != SILC_LIST_END) {
1293 channel = chl->channel;
1295 /* Send the message to all clients on the channel's client list. */
1296 silc_list_start(channel->user_list);
1297 while ((chl2 = silc_list_get(channel->user_list)) != SILC_LIST_END) {
1300 if (sender && c == sender)
1303 /* Check if we have sent the packet to this client already */
1304 for (k = 0; k < sent_clients_count; k++)
1305 if (sent_clients[k] == c)
1307 if (k < sent_clients_count)
1310 /* If we are router and if this client has router set it is not
1311 locally connected client and we will route the message to the
1312 router set in the client. */
1313 if (c && c->router && server->server_type == SILC_ROUTER) {
1314 /* Check if we have sent the packet to this route already */
1315 for (k = 0; k < routed_count; k++)
1316 if (routed[k] == c->router)
1318 if (k < routed_count)
1321 /* Get data used in packet header encryption, keys and stuff. */
1322 sock = (SilcSocketConnection)c->router->connection;
1323 idata = (SilcIDListData)c->router;
1325 packetdata.dst_id = silc_id_id2str(c->router->id, SILC_ID_SERVER);
1326 packetdata.dst_id_len = SILC_ID_SERVER_LEN;
1327 packetdata.dst_id_type = SILC_ID_SERVER;
1328 packetdata.truelen = data_len + SILC_PACKET_HEADER_LEN +
1329 packetdata.src_id_len + packetdata.dst_id_len;
1330 packetdata.padlen = SILC_PACKET_PADLEN(packetdata.truelen);
1332 /* Send the packet */
1333 silc_server_packet_send_to_channel_real(server, sock, &packetdata,
1334 idata->send_key, idata->hmac,
1335 data, data_len, FALSE,
1338 silc_free(packetdata.dst_id);
1340 /* We want to make sure that the packet is routed to same router
1341 only once. Mark this route as sent route. */
1343 routed = silc_realloc(routed, sizeof(*routed) * (k + 1));
1344 routed[k] = c->router;
1353 /* Send to locally connected client */
1356 /* Get data used in packet header encryption, keys and stuff. */
1357 sock = (SilcSocketConnection)c->connection;
1358 idata = (SilcIDListData)c;
1360 packetdata.dst_id = silc_id_id2str(c->id, SILC_ID_CLIENT);
1361 packetdata.dst_id_len = SILC_ID_CLIENT_LEN;
1362 packetdata.dst_id_type = SILC_ID_CLIENT;
1363 packetdata.truelen = data_len + SILC_PACKET_HEADER_LEN +
1364 packetdata.src_id_len + packetdata.dst_id_len;
1365 packetdata.padlen = SILC_PACKET_PADLEN(packetdata.truelen);
1367 /* Send the packet */
1368 silc_server_packet_send_to_channel_real(server, sock, &packetdata,
1369 idata->send_key, idata->hmac,
1370 data, data_len, FALSE,
1373 silc_free(packetdata.dst_id);
1375 /* Make sure that we send the notify only once per client. */
1376 sent_clients = silc_realloc(sent_clients, sizeof(*sent_clients) *
1377 (sent_clients_count + 1));
1378 sent_clients[sent_clients_count] = c;
1379 sent_clients_count++;
1386 if (sent_clients_count)
1387 silc_free(sent_clients);
1388 silc_free(packetdata.src_id);
1391 /* Sends New ID Payload to remote end. The packet is used to distribute
1392 information about new registered clients, servers, channel etc. usually
1393 to routers so that they can keep these information up to date.
1394 If the argument `broadcast' is TRUE then the packet is sent as
1395 broadcast packet. */
1397 void silc_server_send_new_id(SilcServer server,
1398 SilcSocketConnection sock,
1400 void *id, SilcIdType id_type,
1405 SILC_LOG_DEBUG(("Start"));
1407 idp = silc_id_payload_encode(id, id_type);
1408 silc_server_packet_send(server, sock, SILC_PACKET_NEW_ID,
1409 broadcast ? SILC_PACKET_FLAG_BROADCAST : 0,
1410 idp->data, idp->len, FALSE);
1411 silc_buffer_free(idp);
1414 /* Send New Channel Payload to notify about newly created channel in the
1415 SILC network. Normal server nevers sends this packet. Router uses this
1416 to notify other routers in the network about new channel. This packet
1419 void silc_server_send_new_channel(SilcServer server,
1420 SilcSocketConnection sock,
1424 uint32 channel_id_len,
1429 uint32 name_len = strlen(channel_name);
1431 SILC_LOG_DEBUG(("Start"));
1433 cid = silc_id_id2str(channel_id, SILC_ID_CHANNEL);
1437 /* Encode the channel payload */
1438 packet = silc_channel_payload_encode(channel_name, name_len,
1439 cid, channel_id_len, mode);
1441 silc_server_packet_send(server, sock, SILC_PACKET_NEW_CHANNEL,
1442 broadcast ? SILC_PACKET_FLAG_BROADCAST : 0,
1443 packet->data, packet->len, FALSE);
1446 silc_buffer_free(packet);
1449 /* Send Channel Key payload to distribute the new channel key. Normal server
1450 sends this to router when new client joins to existing channel. Router
1451 sends this to the local server who sent the join command in case where
1452 the channel did not exist yet. Both normal and router servers uses this
1453 also to send this to locally connected clients on the channel. This
1454 must not be broadcasted packet. Routers do not send this to each other.
1455 If `sender is provided then the packet is not sent to that connection since
1456 it originally came from it. */
1458 void silc_server_send_channel_key(SilcServer server,
1459 SilcSocketConnection sender,
1460 SilcChannelEntry channel,
1461 unsigned char route)
1464 unsigned char *chid;
1467 SILC_LOG_DEBUG(("Start"));
1469 chid = silc_id_id2str(channel->id, SILC_ID_CHANNEL);
1473 /* Encode channel key packet */
1474 tmp_len = strlen(channel->channel_key->cipher->name);
1475 packet = silc_channel_key_payload_encode(SILC_ID_CHANNEL_LEN, chid, tmp_len,
1476 channel->channel_key->cipher->name,
1477 channel->key_len / 8, channel->key);
1479 silc_server_packet_send_to_channel(server, sender, channel,
1480 SILC_PACKET_CHANNEL_KEY,
1481 route, packet->data, packet->len, FALSE);
1482 silc_buffer_free(packet);
1486 /* Generic function to send any command. The arguments must be sent already
1487 encoded into correct form in correct order. */
1489 void silc_server_send_command(SilcServer server,
1490 SilcSocketConnection sock,
1491 SilcCommand command,
1499 packet = silc_command_payload_encode_vap(command, 0, argc, ap);
1500 silc_server_packet_send(server, sock, SILC_PACKET_COMMAND, 0,
1501 packet->data, packet->len, TRUE);
1502 silc_buffer_free(packet);
1505 /* Send the heartbeat packet. */
1507 void silc_server_send_heartbeat(SilcServer server,
1508 SilcSocketConnection sock)
1510 silc_server_packet_send(server, sock, SILC_PACKET_HEARTBEAT, 0,
1514 /* Generic function to relay packet we've received. This is used to relay
1515 packets to a client but generally can be used to other purposes as well. */
1517 void silc_server_relay_packet(SilcServer server,
1518 SilcSocketConnection dst_sock,
1521 SilcPacketContext *packet,
1524 silc_buffer_push(packet->buffer, SILC_PACKET_HEADER_LEN + packet->src_id_len
1525 + packet->dst_id_len + packet->padlen);
1527 silc_packet_send_prepare(dst_sock, 0, 0, packet->buffer->len);
1528 silc_buffer_put(dst_sock->outbuf, packet->buffer->data, packet->buffer->len);
1530 /* Re-encrypt packet */
1531 silc_packet_encrypt(cipher, hmac, dst_sock->outbuf, packet->buffer->len);
1533 /* Send the packet */
1534 silc_server_packet_send_real(server, dst_sock, force_send);
1536 silc_buffer_pull(packet->buffer, SILC_PACKET_HEADER_LEN + packet->src_id_len
1537 + packet->dst_id_len + packet->padlen);
1540 /* Routine used to send the connection authentication packet. */
1542 void silc_server_send_connection_auth_request(SilcServer server,
1543 SilcSocketConnection sock,
1545 SilcAuthMethod auth_meth)
1549 packet = silc_buffer_alloc(4);
1550 silc_buffer_pull_tail(packet, SILC_BUFFER_END(packet));
1551 silc_buffer_format(packet,
1552 SILC_STR_UI_SHORT(conn_type),
1553 SILC_STR_UI_SHORT(auth_meth),
1556 silc_server_packet_send(server, sock, SILC_PACKET_CONNECTION_AUTH_REQUEST,
1557 0, packet->data, packet->len, FALSE);
1558 silc_buffer_free(packet);