patch was provided by cras.
+Thu Jul 20 13:15:01 EEST 2000 Pekka Riikonen <priikone@poseidon.pspt.fi>
+
+ * Added dynamic protocol registering support. Now protocols can
+ registered and unregistered on the fly. Patch by cras.
+
Wed Jul 19 19:08:46 EEST 2000 Pekka Riikonen <priikone@poseidon.pspt.fi>
* Added lib/contrib directory to hold routines that some platforms
/*
* $Id$
* $Log$
+ * Revision 1.13 2000/07/20 10:17:25 priikone
+ * Added dynamic protocol registering/unregistering support. The
+ * patch was provided by cras.
+ *
* Revision 1.12 2000/07/19 07:07:34 priikone
* Save packet on private message's command context.
*
goto err1;
}
+ /* Register protocols */
+ silc_client_protocols_register();
+
/* Initialize the scheduler */
silc_schedule_init(client->io_queue, client->timeout_queue,
client->generic_queue, 5000);
silc_schedule_stop();
silc_schedule_uninit();
+ silc_client_protocols_unregister();
+
SILC_LOG_DEBUG(("Client client"));
}
/*
* $Id$
* $Log$
+ * Revision 1.8 2000/07/20 10:17:25 priikone
+ * Added dynamic protocol registering/unregistering support. The
+ * patch was provided by cras.
+ *
* Revision 1.7 2000/07/19 07:07:47 priikone
* Added version detection support to SKE.
*
extern char *silc_version_string;
-/* SILC client protocol list */
-const SilcProtocolObject silc_protocol_list[] =
-{
- { SILC_PROTOCOL_CLIENT_CONNECTION_AUTH,
- silc_client_protocol_connection_auth },
- { SILC_PROTOCOL_CLIENT_KEY_EXCHANGE,
- silc_client_protocol_key_exchange },
-
- { SILC_PROTOCOL_CLIENT_NONE, NULL },
-};
-
/*
* Key Exhange protocol functions
*/
}
}
+/* Registers protocols used in client */
+
+void silc_client_protocols_register(void)
+{
+ silc_protocol_register(SILC_PROTOCOL_CLIENT_CONNECTION_AUTH,
+ silc_client_protocol_connection_auth);
+ silc_protocol_register(SILC_PROTOCOL_CLIENT_KEY_EXCHANGE,
+ silc_client_protocol_key_exchange);
+}
+
+/* Unregisters protocols */
+
+void silc_client_protocols_unregister(void)
+{
+ silc_protocol_unregister(SILC_PROTOCOL_CLIENT_CONNECTION_AUTH,
+ silc_client_protocol_connection_auth);
+ silc_protocol_unregister(SILC_PROTOCOL_CLIENT_KEY_EXCHANGE,
+ silc_client_protocol_key_exchange);
+}
} SilcClientConnAuthInternalContext;
/* Prototypes */
+void silc_client_protocols_register(void);
+void silc_client_protocols_unregister(void);
#endif
/*
* $Id$
* $Log$
+ * Revision 1.9 2000/07/20 10:17:25 priikone
+ * Added dynamic protocol registering/unregistering support. The
+ * patch was provided by cras.
+ *
* Revision 1.8 2000/07/19 07:08:09 priikone
* Added version detection support to SKE.
*
extern char *silc_version_string;
-/* SILC client protocol list */
-const SilcProtocolObject silc_protocol_list[] =
-{
- { SILC_PROTOCOL_SERVER_CONNECTION_AUTH,
- silc_server_protocol_connection_auth },
- { SILC_PROTOCOL_SERVER_KEY_EXCHANGE,
- silc_server_protocol_key_exchange },
-
- { SILC_PROTOCOL_SERVER_NONE, NULL },
-};
-
/*
* Key Exhange protocol functions
*/
break;
}
}
+
+/* Registers protocols used in server. */
+
+void silc_server_protocols_register(void)
+{
+ silc_protocol_register(SILC_PROTOCOL_SERVER_CONNECTION_AUTH,
+ silc_server_protocol_connection_auth);
+ silc_protocol_register(SILC_PROTOCOL_SERVER_KEY_EXCHANGE,
+ silc_server_protocol_key_exchange);
+}
+
+/* Unregisters protocols */
+
+void silc_server_protocols_unregister(void)
+{
+ silc_protocol_unregister(SILC_PROTOCOL_SERVER_CONNECTION_AUTH,
+ silc_server_protocol_connection_auth);
+ silc_protocol_unregister(SILC_PROTOCOL_SERVER_KEY_EXCHANGE,
+ silc_server_protocol_key_exchange);
+}
} SilcServerConnAuthInternalContext;
/* Prototypes */
+void silc_server_protocols_register(void);
+void silc_server_protocols_unregister(void);
#endif
/*
* $Id$
* $Log$
+ * Revision 1.11 2000/07/20 10:17:25 priikone
+ * Added dynamic protocol registering/unregistering support. The
+ * patch was provided by cras.
+ *
* Revision 1.10 2000/07/17 11:47:30 priikone
* Added command lagging support. Added idle counting support.
*
goto err1;
}
+ /* Register protocols */
+ silc_server_protocols_register();
+
/* Initialize the scheduler */
silc_schedule_init(server->io_queue, server->timeout_queue,
server->generic_queue,
silc_schedule_stop();
silc_schedule_uninit();
+ silc_server_protocols_unregister();
+
SILC_LOG_DEBUG(("Server stopped"));
}
/*
* $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.
*
#include "silcincludes.h"
#include "silcprotocol.h"
+/* Dynamically registered protocols */
+SilcProtocolObject *silc_protocol_list = NULL;
+
+/* Dynamically registers new protocol. The protocol is added into protocol
+ list and can be unregistered with silc_protocol_unregister. */
+
+void silc_protocol_register(SilcProtocolType type,
+ SilcProtocolCallback callback)
+{
+ SilcProtocolObject *new;
+
+ new = silc_calloc(1, sizeof(*new));
+ new->type = type;
+ new->callback = callback;
+
+ if (!silc_protocol_list)
+ silc_protocol_list = new;
+ else {
+ new->next = silc_protocol_list;
+ silc_protocol_list = new;
+ }
+}
+
+/* Unregisters protocol. The unregistering is done by both protocol type
+ and the protocol callback. */
+
+void silc_protocol_unregister(SilcProtocolType type,
+ SilcProtocolCallback callback)
+{
+ SilcProtocolObject *protocol, *prev;
+
+ protocol = silc_protocol_list;
+ prev = NULL;
+ while (protocol && (protocol->type != type &&
+ protocol->callback != callback)) {
+ prev = protocol;
+ protocol = protocol->next;
+ }
+
+ if (protocol) {
+ if (prev)
+ prev->next = protocol->next;
+ else
+ silc_protocol_list = protocol->next;
+
+ silc_free(protocol);
+ }
+}
+
/* Allocates a new protocol object. The new allocated and initialized
protocol is returned to the new_protocol argument. The argument context
is the context to be sent as argument for the protocol. The callback
void silc_protocol_alloc(SilcProtocolType type, SilcProtocol *new_protocol,
void *context, SilcProtocolFinalCallback callback)
{
- int i;
+ SilcProtocolObject *protocol;
SILC_LOG_DEBUG(("Allocating new protocol type %d", type));
- for (i = 0; silc_protocol_list[i].callback; i++)
- if (silc_protocol_list[i].type == type)
- break;
+ protocol = silc_protocol_list;
+ while (protocol && protocol->type != type)
+ protocol = protocol->next;
- if (!silc_protocol_list[i].callback) {
+ if (!protocol) {
SILC_LOG_ERROR(("Requested protocol does not exists"));
return;
}
*new_protocol = silc_calloc(1, sizeof(**new_protocol));
- (*new_protocol)->protocol = (SilcProtocolObject *)&silc_protocol_list[i];
+ (*new_protocol)->protocol = protocol;
(*new_protocol)->state = SILC_PROTOCOL_STATE_UNKNOWN;
(*new_protocol)->context = context;
(*new_protocol)->execute = silc_protocol_execute;
*/
typedef SilcTaskCallback SilcProtocolCallback;
-typedef struct {
+typedef struct SilcProtocolObjectStruct {
SilcProtocolType type;
SilcProtocolCallback callback;
+
+ struct SilcProtocolObjectStruct *next;
} SilcProtocolObject;
typedef SilcTaskCallback SilcProtocolFinalCallback;
typedef SilcTaskCallback SilcProtocolExecute;
-typedef struct SilcProtocolObjectStruct {
+typedef struct SilcProtocolStruct {
SilcProtocolObject *protocol;
SilcProtocolState state;
void *context;
SilcProtocolFinalCallback final_callback;
} *SilcProtocol;
-/* Definition for SILC protocol list. This list includes all the
- protocols in the SILC. SILC server and client defined own list of
- protocols. */
-extern const SilcProtocolObject silc_protocol_list[];
-
/* Prototypes */
+void silc_protocol_register(SilcProtocolType type,
+ SilcProtocolCallback callback);
+void silc_protocol_unregister(SilcProtocolType type,
+ SilcProtocolCallback callback);
void silc_protocol_alloc(SilcProtocolType type, SilcProtocol *new_protocol,
void *context, SilcProtocolFinalCallback callback);
void silc_protocol_free(SilcProtocol protocol);