From ce55165b6952f9325c34b0008b5116b16736c4cb Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Fri, 10 May 2024 19:49:06 +0200 Subject: server support for fragmented dir reply; fixed shadow reply messages accordingly --- ecp/server/server.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'ecp/server/server.c') diff --git a/ecp/server/server.c b/ecp/server/server.c index eeb5f2d..5493762 100644 --- a/ecp/server/server.c +++ b/ecp/server/server.c @@ -33,7 +33,7 @@ SRVConfig *srv_get_config(void) { } static void usage(char *arg) { - fprintf(stderr, "Usage: %s [ ] [ ]\n", arg); + fprintf(stderr, "Usage: %s [ ] [ ]\n", arg); exit(1); } @@ -55,7 +55,7 @@ static ECPConnection *conn_new(ECPSocket *sock, ECPConnection *parent, unsigned switch (ctype) { case CTYPE_DIR: { - if (!(srv_config.capabilities & ECP_DIR_CAP_DIR)) return NULL; + if (!(srv_config.roles & ECP_ROLE_DIR)) return NULL; conn = malloc(sizeof(ECPConnection)); if (conn) { @@ -66,7 +66,7 @@ static ECPConnection *conn_new(ECPSocket *sock, ECPConnection *parent, unsigned } case ECP_CTYPE_DIR: { - if (!(srv_config.capabilities & ECP_DIR_CAP_DIR)) return NULL; + if (!(srv_config.roles & ECP_ROLE_DIR)) return NULL; conn = malloc(sizeof(ECPConnection)); if (conn) ecp_conn_init(conn, sock, ctype); @@ -76,7 +76,7 @@ static ECPConnection *conn_new(ECPSocket *sock, ECPConnection *parent, unsigned case ECP_CTYPE_VCONN: { ECPVConnInb *_conn; - if (!(srv_config.capabilities & ECP_DIR_CAP_VCONN)) return NULL; + if (!(srv_config.roles & ECP_ROLE_VCONN)) return NULL; _conn = malloc(sizeof(ECPVConnInb)); if (_conn) { @@ -87,7 +87,7 @@ static ECPConnection *conn_new(ECPSocket *sock, ECPConnection *parent, unsigned } case ECP_CTYPE_VLINK: { - if (!(srv_config.capabilities & ECP_DIR_CAP_VCONN)) return NULL; + if (!(srv_config.roles & ECP_ROLE_VCONN)) return NULL; conn = malloc(sizeof(ECPConnection)); if (conn) ecp_vlink_init(conn, sock); @@ -116,8 +116,12 @@ static int key_check(ECPSocket *sock, ECPConnection *parent, unsigned char ctype return 1; } - default: + case ECP_CTYPE_DIR: + case ECP_CTYPE_VCONN: return 1; + + default: + return 0; } } @@ -174,11 +178,11 @@ int main(int argc, char *argv[]) { if (srv_config.region >= MAX_REGION) fail("Bad region\n"); _argc++; - srv_config.capabilities = (uint8_t)strtol(argv[_argc], &endptr, 16); - if (endptr[0] != '\0') fail("Bad capabilities\n"); + srv_config.roles = (uint8_t)strtol(argv[_argc], &endptr, 16); + if (endptr[0] != '\0') fail("Bad roles\n"); _argc++; - if (srv_config.capabilities & ECP_DIR_CAP_DIR) { + if (srv_config.roles & ECP_ROLE_DIR) { if (argc < 7) usage(argv[0]); } else { if (argc < 5) usage(argv[0]); @@ -213,7 +217,7 @@ int main(int argc, char *argv[]) { rv = acl_init(); if (rv) fail("acl_init err:%d\n", rv); - if (srv_config.capabilities & ECP_DIR_CAP_DIR) { + if (srv_config.roles & ECP_ROLE_DIR) { srv_config.acl_fn_dir = strdup(argv[_argc]); _argc++; srv_config.acl_fn = strdup(argv[_argc]); -- cgit v1.2.3