/*
* Created: Tue Nov 25 19:25:33 GMT+0200 1997
*/
-/*
- * $Id$
- * $Log$
- * Revision 1.3 2000/07/20 10:17:25 priikone
- * Added dynamic protocol registering/unregistering support. The
- * patch was provided by cras.
- *
- * Revision 1.2 2000/07/05 06:06:35 priikone
- * Global cosmetic change.
- *
- * Revision 1.1.1.1 2000/06/27 11:36:55 priikone
- * Imported from internal CVS/Added Log headers.
- *
- *
- */
+/* $Id$ */
#include "silcincludes.h"
#include "silcprotocol.h"
if (!protocol) {
SILC_LOG_ERROR(("Requested protocol does not exists"));
+ *new_protocol = NULL;
return;
}
(*new_protocol)->protocol = protocol;
(*new_protocol)->state = SILC_PROTOCOL_STATE_UNKNOWN;
(*new_protocol)->context = context;
- (*new_protocol)->execute = silc_protocol_execute;
- (*new_protocol)->execute_final = silc_protocol_execute_final;
(*new_protocol)->final_callback = callback;
}
-/* Free's a protocol object. */
+/* Frees a protocol object. */
void silc_protocol_free(SilcProtocol protocol)
{
/* Executes next state of the protocol. The state must be set before
calling this function. */
-void silc_protocol_execute(void *qptr, int type,
- void *context, int fd,
+void silc_protocol_execute(SilcProtocol protocol, SilcSchedule schedule,
long secs, long usecs)
{
- SilcProtocol protocol = (SilcProtocol)context;
-
- SILC_LOG_DEBUG(("Start"));
-
if (secs + usecs)
- silc_task_register(qptr, fd, protocol->protocol->callback, context,
- secs, usecs,
- SILC_TASK_TIMEOUT,
- SILC_TASK_PRI_NORMAL);
+ silc_schedule_task_add(schedule, 0,
+ protocol->protocol->callback, (void *)protocol,
+ secs, usecs,
+ SILC_TASK_TIMEOUT,
+ SILC_TASK_PRI_NORMAL);
else
- protocol->protocol->callback(qptr, 0, context, fd);
+ protocol->protocol->callback(schedule, 0, 0, (void *)protocol);
}
/* Executes the final callback of the protocol. */
-void silc_protocol_execute_final(void *qptr, int type,
- void *context, int fd)
+void silc_protocol_execute_final(SilcProtocol protocol, SilcSchedule schedule)
{
- SilcProtocol protocol = (SilcProtocol)context;
-
- SILC_LOG_DEBUG(("Start, state=%d", protocol->state));
+ protocol->final_callback(schedule, 0, 0, (void *)protocol);
+}
+
+/* Cancels the execution of the next state of the protocol. */
- protocol->final_callback(qptr, 0, context, fd);
+void silc_protocol_cancel(SilcProtocol protocol, SilcSchedule schedule)
+{
+ silc_schedule_task_del_by_context(schedule, protocol);
}