diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2018-04-16 01:28:02 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2018-04-16 01:28:02 +0200 |
commit | c9b2cd567ed8bbe2df36821a26a56a8d713c2c80 (patch) | |
tree | c783469615340812b5e579ed5f0101d26e6293e7 | |
parent | 2eeb2bf76240e0a4f9a94975cf59e0c6e83a0c26 (diff) |
POTD skeleton #8.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rw-r--r-- | src/server.c | 5 | ||||
-rw-r--r-- | src/server.h | 12 | ||||
-rw-r--r-- | src/server_ssh.c | 36 | ||||
-rw-r--r-- | src/server_ssh.h | 12 |
4 files changed, 11 insertions, 54 deletions
diff --git a/src/server.c b/src/server.c index 0adf9d6..8c71554 100644 --- a/src/server.c +++ b/src/server.c @@ -41,10 +41,7 @@ server_init_ctx(server_ctx *ctx, init_cb init_fn) int server_validate_ctx(const server_ctx *ctx) { assert(ctx); - assert(ctx->server_cbs.on_connect && ctx->server_cbs.on_disconnect - && ctx->server_cbs.mainloop); - assert(ctx->server_cbs.on_free && ctx->server_cbs.on_listen - && ctx->server_cbs.on_shutdown); + assert(ctx->server_cbs.on_listen && ctx->server_cbs.on_shutdown); return 0; } diff --git a/src/server.h b/src/server.h index 2851c50..32a711d 100644 --- a/src/server.h +++ b/src/server.h @@ -10,22 +10,10 @@ typedef struct server_data { void *data; } server_data; -typedef struct server_session { - void *data; -} server_session; - -typedef int (*on_connect_cb) (struct server_data *data, struct server_session *ses); -typedef int (*on_disconnect_cb) (struct server_data *data, struct server_session *ses); -typedef int (*on_data_cb) (struct server_data *data, struct server_session *ses); -typedef int (*on_free_cb) (struct server_data *data); typedef int (*on_listen_cb) (struct server_data *data); typedef int (*on_shutdown_cb) (struct server_data *data); typedef struct server_callbacks { - on_connect_cb on_connect; - on_disconnect_cb on_disconnect; - on_data_cb mainloop; - on_free_cb on_free; on_listen_cb on_listen; on_shutdown_cb on_shutdown; } server_callbacks; diff --git a/src/server_ssh.c b/src/server_ssh.c index 24fdd3e..1c72b61 100644 --- a/src/server_ssh.c +++ b/src/server_ssh.c @@ -5,33 +5,18 @@ #include "server_ssh.h" #include "server.h" +struct server_callbacks potd_ssh_callbacks = { + .on_listen = ssh_on_listen, + .on_shutdown = ssh_on_shutdown +}; + static void set_default_keys(ssh_bind sshbind, int rsa_already_set, int dsa_already_set, int ecdsa_already_set); -int ssh_on_connect(struct server_data *data, struct server_session *ses) -{ - return 0; -} - -int ssh_on_disconnect(struct server_data *data, struct server_session *ses) -{ - return 0; -} - -int ssh_mainloop_cb(struct server_data *data, struct server_session *ses) -{ - return 0; -} - int ssh_init_cb(struct server_ctx *ctx) { - ctx->server_cbs.on_connect = ssh_on_connect; - ctx->server_cbs.on_disconnect = ssh_on_disconnect; - ctx->server_cbs.mainloop = ssh_mainloop_cb; - ctx->server_cbs.on_free = ssh_free_cb; - ctx->server_cbs.on_listen = ssh_listen_cb; - ctx->server_cbs.on_shutdown = ssh_shutdown_cb; + ctx->server_cbs = potd_ssh_callbacks; ssh_init(); ssh_data *d = (ssh_data *) calloc(1, sizeof(*d)); @@ -44,17 +29,12 @@ int ssh_init_cb(struct server_ctx *ctx) return 0; } -int ssh_free_cb(struct server_data *data) -{ - return 0; -} - -int ssh_listen_cb(struct server_data *data) +int ssh_on_listen(struct server_data *data) { return 0; } -int ssh_shutdown_cb(struct server_data *data) +int ssh_on_shutdown(struct server_data *data) { return 0; } diff --git a/src/server_ssh.h b/src/server_ssh.h index dc80645..893c2e8 100644 --- a/src/server_ssh.h +++ b/src/server_ssh.h @@ -10,18 +10,10 @@ typedef struct ssh_data { } ssh_data; -int ssh_on_connect(struct server_data *data, struct server_session *ses); - -int ssh_on_disconnect(struct server_data *data, struct server_session *ses); - -int ssh_mainloop_cb(struct server_data *_data, struct server_session *ses); - int ssh_init_cb(struct server_ctx *ctx); -int ssh_free_cb(struct server_data *data); - -int ssh_listen_cb(struct server_data *data); +int ssh_on_listen(struct server_data *data); -int ssh_shutdown_cb(struct server_data *data); +int ssh_on_shutdown(struct server_data *data); #endif |