summaryrefslogtreecommitdiff
path: root/ecp/server/server.c
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2024-05-10 19:49:06 +0200
committerUros Majstorovic <majstor@majstor.org>2024-05-10 19:49:06 +0200
commitce55165b6952f9325c34b0008b5116b16736c4cb (patch)
tree7c85cb58e0eff3c9a884c499ad87ba6069dbc6ce /ecp/server/server.c
parent3f814b6f30a9ae296805ebab49114fb24ab3b0d1 (diff)
server support for fragmented dir reply; fixed shadow reply messages accordingly
Diffstat (limited to 'ecp/server/server.c')
-rw-r--r--ecp/server/server.c24
1 files changed, 14 insertions, 10 deletions
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 <region> <capabilities> <private key> <addr> [ <dir acl> <vconn acl> ] [ <public key> <addr> ]\n", arg);
+ fprintf(stderr, "Usage: %s <region> <roles> <private key> <addr> [ <dir acl> <vconn acl> ] [ <public key> <addr> ]\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]);