From f661e3a4bd0338d15a5855fbf0872cc1ddc2df92 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Thu, 7 Nov 2002 09:05:18 +0000 Subject: [PATCH] Move silc_client_packet_send back to internal, added silc_client_send_packet, a bit simpler function for application. --- apps/irssi/src/silc/core/silc-servers.c | 4 +-- lib/silcclient/client.c | 19 +++++++++++ lib/silcclient/client_internal.h | 10 ++++++ lib/silcclient/silcclient.h | 43 +++++++++---------------- 4 files changed, 47 insertions(+), 29 deletions(-) diff --git a/apps/irssi/src/silc/core/silc-servers.c b/apps/irssi/src/silc/core/silc-servers.c index f6e0403a..198926c1 100644 --- a/apps/irssi/src/silc/core/silc-servers.c +++ b/apps/irssi/src/silc/core/silc-servers.c @@ -266,8 +266,8 @@ void silc_send_heartbeat(SilcSocketConnection sock, if (server == NULL) return; - silc_client_packet_send(silc_client, sock, SILC_PACKET_HEARTBEAT, - NULL, 0, NULL, NULL, NULL, 0, FALSE); + silc_client_send_packet(silc_client, server->conn, SILC_PACKET_HEARTBEAT, + NULL, 0); } static void sig_connected(SILC_SERVER_REC *server) diff --git a/lib/silcclient/client.c b/lib/silcclient/client.c index aa729e6f..62dba28c 100644 --- a/lib/silcclient/client.c +++ b/lib/silcclient/client.c @@ -1455,6 +1455,25 @@ void silc_client_packet_send(SilcClient client, silc_client_packet_send_real(client, sock, force_send); } +/* Packet sending routine for application. This is the only routine that + is provided for application to send SILC packets. */ + +bool silc_client_send_packet(SilcClient client, + SilcClientConnection conn, + SilcPacketType type, + const unsigned char *data, + SilcUInt32 data_len) +{ + + assert(client); + if (!conn) + return FALSE; + + silc_client_packet_send(client, conn->sock, type, NULL, 0, NULL, NULL, + (unsigned char *)data, data_len, TRUE); + return TRUE; +} + void silc_client_packet_queue_purge(SilcClient client, SilcSocketConnection sock) { diff --git a/lib/silcclient/client_internal.h b/lib/silcclient/client_internal.h index d3de6db3..195f5cdf 100644 --- a/lib/silcclient/client_internal.h +++ b/lib/silcclient/client_internal.h @@ -208,6 +208,16 @@ do { \ /* Prototypes */ SILC_TASK_CALLBACK_GLOBAL(silc_client_packet_process); +void silc_client_packet_send(SilcClient client, + SilcSocketConnection sock, + SilcPacketType type, + void *dst_id, + SilcIdType dst_id_type, + SilcCipher cipher, + SilcHmac hmac, + unsigned char *data, + SilcUInt32 data_len, + bool force_send); int silc_client_packet_send_real(SilcClient client, SilcSocketConnection sock, bool force_send); diff --git a/lib/silcclient/silcclient.h b/lib/silcclient/silcclient.h index 8a7bd07d..f2b9760e 100644 --- a/lib/silcclient/silcclient.h +++ b/lib/silcclient/silcclient.h @@ -2378,42 +2378,31 @@ SilcBuffer silc_client_attributes_request(SilcAttribute attribute, ...); /* Low level packet sending functions */ -/****f* silcclient/SilcClientAPI/silc_client_packet_send +/****f* silcclient/SilcClientAPI/silc_client_send_packet * * SYNOPSIS * - * void silc_client_packet_send(SilcClient client, - * SilcSocketConnection sock, - * SilcPacketType type, - * void *dst_id, - * SilcIdType dst_id_type, - * SilcCipher cipher, - * SilcHmac hmac, - * unsigned char *data, - * SilcUInt32 data_len, - * bool force_send); + * bool silc_client_send_packet(SilcClient client, + * SilcClientConnection conn, + * SilcPacketType type, + * const unsigned char *data, + * SilcUInt32 data_len); * * DESCRIPTION * - * Constructs a Requested Attributes buffer. If the `attribute' is zero (0) - * then all attributes are requested. Alternatively, `attribute' and - * all variable arguments can each be requested attribute. In this case - * the last must be set to zero (0) to complete the variable list of - * requested attributes. See SilcAttribute for all attributes. - * You can give the returned buffer as argument to for example - * silc_client_get_client_by_id_resolve function. + * This routine can be used by application to send packets directly + * to a connection indicated by `conn'. Usually application does not + * need this routine since the Client Library handles the packet + * sending. The `type' indicates the packet type. If `data' is + * NULL then empty packet is sent. This returns FALSE if packet cannot + * be sent. * ***/ -void silc_client_packet_send(SilcClient client, - SilcSocketConnection sock, +bool silc_client_send_packet(SilcClient client, + SilcClientConnection conn, SilcPacketType type, - void *dst_id, - SilcIdType dst_id_type, - SilcCipher cipher, - SilcHmac hmac, - unsigned char *data, - SilcUInt32 data_len, - bool force_send); + const unsigned char *data, + SilcUInt32 data_len); #include "command.h" #include "command_reply.h" -- 2.24.0