From 6334bada15107406dfd4c2cd8f60774c4307dae6 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Mon, 16 Feb 2015 09:27:05 +0100 Subject: [PATCH] renamed urlfw to kkdcp --- src/Makefile.am | 2 +- src/config.c | 36 +++++++++++++------------- src/vpn.h | 8 +++--- src/worker-http.c | 6 ++--- src/{worker-urlfw.c => worker-kkdcp.c} | 26 +++++++++---------- src/worker.h | 2 +- 6 files changed, 40 insertions(+), 40 deletions(-) rename src/{worker-urlfw.c => worker-kkdcp.c} (77%) diff --git a/src/Makefile.am b/src/Makefile.am index 6c868734..8175b8f6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -74,7 +74,7 @@ ocserv_SOURCES = main.c main-auth.c worker-vpn.c worker-auth.c tlslib.c \ main-user.c worker-misc.c route-add.c route-add.h worker-privs.c \ sec-mod.c sec-mod-db.c sec-mod-auth.c sec-mod-auth.h sec-mod.h sec-mod-ban.c \ script-list.h $(COMMON_SOURCES) $(AUTH_SOURCES) \ - icmp-ping.c icmp-ping.h worker-urlfw.c \ + icmp-ping.c icmp-ping.h worker-kkdcp.c \ sec-mod-sup-config.c sec-mod-sup-config.h \ sup-config/file.c sup-config/file.h \ sup-config/radius.c sup-config/radius.h \ diff --git a/src/config.c b/src/config.c index dfa404f3..b6c81247 100644 --- a/src/config.c +++ b/src/config.c @@ -95,7 +95,7 @@ static struct cfg_options available_options[] = { { .name = "connect-script", .type = OPTION_STRING, .mandatory = 0 }, { .name = "disconnect-script", .type = OPTION_STRING, .mandatory = 0 }, { .name = "pid-file", .type = OPTION_STRING, .mandatory = 0 }, - { .name = "url-fw", .type = OPTION_STRING, .mandatory = 0 }, + { .name = "kkdcp", .type = OPTION_STRING, .mandatory = 0 }, { .name = "socket-file", .type = OPTION_STRING, .mandatory = 1 }, { .name = "listen-clear-file", .type = OPTION_STRING, .mandatory = 0 }, { .name = "occtl-socket-file", .type = OPTION_STRING, .mandatory = 0 }, @@ -525,15 +525,15 @@ static void figure_auth_funcs(struct cfg_st *config, char **auth, unsigned auth_ talloc_free(auth); } -static void parse_urlfw(struct cfg_st *config, char **urlfw, unsigned urlfw_size) +static void parse_kkdcp(struct cfg_st *config, char **urlfw, unsigned urlfw_size) { unsigned i; char *p, *p2, *p3, *cont_type; struct addrinfo hints, *res; int ret; - config->urlfw = talloc_size(config, urlfw_size*sizeof(urlfw_st)); - if (config->urlfw == NULL) { + config->kkdcp = talloc_size(config, urlfw_size*sizeof(kkdcp_st)); + if (config->kkdcp == NULL) { fprintf(stderr, "memory error\n"); exit(1); } @@ -542,7 +542,7 @@ static void parse_urlfw(struct cfg_st *config, char **urlfw, unsigned urlfw_size p = urlfw[i]; p2 = strchr(p, ' '); if (p2 == NULL) { - fprintf(stderr, "Cannot parse url-fw string: %s\n", p); + fprintf(stderr, "Cannot parse kkdcp string: %s\n", p); exit(1); } *p2 = 0; @@ -563,7 +563,7 @@ static void parse_urlfw(struct cfg_st *config, char **urlfw, unsigned urlfw_size if (cont_type != NULL) { *cont_type = 0; cont_type++; - config->urlfw[i].content_type = talloc_strdup(config->urlfw, cont_type); + config->kkdcp[i].content_type = talloc_strdup(config->kkdcp, cont_type); } p3 = strchr(p2, ':'); @@ -581,17 +581,17 @@ static void parse_urlfw(struct cfg_st *config, char **urlfw, unsigned urlfw_size exit(1); } - memcpy(&config->urlfw[i].addr, res->ai_addr, res->ai_addrlen); - config->urlfw[i].addr_len = res->ai_addrlen; - config->urlfw[i].ai_family = res->ai_family; - config->urlfw[i].ai_socktype = res->ai_socktype; - config->urlfw[i].ai_protocol = res->ai_protocol; + memcpy(&config->kkdcp[i].addr, res->ai_addr, res->ai_addrlen); + config->kkdcp[i].addr_len = res->ai_addrlen; + config->kkdcp[i].ai_family = res->ai_family; + config->kkdcp[i].ai_socktype = res->ai_socktype; + config->kkdcp[i].ai_protocol = res->ai_protocol; - config->urlfw[i].url = talloc_strdup(config->urlfw, p); + config->kkdcp[i].url = talloc_strdup(config->kkdcp, p); freeaddrinfo(res); } - config->urlfw_size = urlfw_size; + config->kkdcp_size = urlfw_size; } static void parse_cfg_file(const char* file, struct cfg_st *config, unsigned reload) @@ -656,9 +656,9 @@ unsigned urlfw_size = 0; READ_TF("listen-host-is-dyndns", config->is_dyndns, 0); READ_STRING("listen-clear-file", config->unix_conn_file); - READ_MULTI_LINE("url-fw", urlfw, urlfw_size); + READ_MULTI_LINE("kkdcp", urlfw, urlfw_size); if (urlfw_size > 0) { - parse_urlfw(config, urlfw, urlfw_size); + parse_kkdcp(config, urlfw, urlfw_size); talloc_free(urlfw); } @@ -1074,9 +1074,9 @@ unsigned i; DEL(config->disconnect_script); DEL(config->proxy_url); - for (i=0;iurlfw_size;i++) - DEL(config->urlfw[i].url); - DEL(config->urlfw); + for (i=0;ikkdcp_size;i++) + DEL(config->kkdcp[i].url); + DEL(config->kkdcp); DEL(config->network.ipv4); DEL(config->network.ipv4_netmask); diff --git a/src/vpn.h b/src/vpn.h index 4ec57da0..9dc1c0e8 100644 --- a/src/vpn.h +++ b/src/vpn.h @@ -217,7 +217,7 @@ typedef struct auth_struct_st { bool enabled; } auth_struct_st; -typedef struct urlfw_st { +typedef struct kkdcp_st { char *url; char *content_type; /* Content-Type */ struct sockaddr_storage addr; @@ -225,7 +225,7 @@ typedef struct urlfw_st { int ai_family; int ai_socktype; int ai_protocol; -} urlfw_st; +} kkdcp_st; struct cfg_st { char *name; /* server name */ @@ -236,8 +236,8 @@ struct cfg_st { unsigned int sup_config_type; /* one of SUP_CONFIG_ */ unsigned int stats_report_time; - urlfw_st *urlfw; - unsigned int urlfw_size; + kkdcp_st *kkdcp; + unsigned int kkdcp_size; char *pin_file; char *srk_pin_file; diff --git a/src/worker-http.c b/src/worker-http.c index f5588959..abd58c7e 100644 --- a/src/worker-http.c +++ b/src/worker-http.c @@ -420,9 +420,9 @@ url_handler_fn http_post_url_handler(struct worker_st *ws, const char *url) p++; } while (p->url != NULL); - for (i=0;iconfig->urlfw_size;i++) { - if (ws->config->urlfw[i].url && strcmp(ws->config->urlfw[i].url, url) == 0) - return post_urlfw_handler; + for (i=0;iconfig->kkdcp_size;i++) { + if (ws->config->kkdcp[i].url && strcmp(ws->config->kkdcp[i].url, url) == 0) + return post_kkdcp_handler; } return NULL; diff --git a/src/worker-urlfw.c b/src/worker-kkdcp.c similarity index 77% rename from src/worker-urlfw.c rename to src/worker-kkdcp.c index 88169d9b..87560158 100644 --- a/src/worker-urlfw.c +++ b/src/worker-kkdcp.c @@ -27,38 +27,38 @@ #include #include -int post_urlfw_handler(worker_st *ws, unsigned http_ver) +int post_kkdcp_handler(worker_st *ws, unsigned http_ver) { int ret, e, fd; struct http_req_st *req = &ws->req; unsigned i, length; - urlfw_st *handler = NULL; + kkdcp_st *handler = NULL; char buf[16*1024]; const char *reason = "Unknown"; - for (i=0;iconfig->urlfw_size;i++) { - if (ws->config->urlfw[i].url && strcmp(ws->config->urlfw[i].url, req->url) == 0) { - handler = &ws->config->urlfw[i]; + for (i=0;iconfig->kkdcp_size;i++) { + if (ws->config->kkdcp[i].url && strcmp(ws->config->kkdcp[i].url, req->url) == 0) { + handler = &ws->config->kkdcp[i]; break; } } if (handler == NULL) { - oclog(ws, LOG_HTTP_DEBUG, "could not figure urlfw handler for %s", req->url); + oclog(ws, LOG_HTTP_DEBUG, "could not figure kkdcp handler for %s", req->url); return -1; } if (req->body_length == 0) { - oclog(ws, LOG_HTTP_DEBUG, "empty body length for urlfw handler %s", req->url); + oclog(ws, LOG_HTTP_DEBUG, "empty body length for kkdcp handler %s", req->url); return -1; } - oclog(ws, LOG_HTTP_DEBUG, "POST urlfw data: %u bytes", (unsigned)req->body_length); + oclog(ws, LOG_HTTP_DEBUG, "POST kkdcp data: %u bytes", (unsigned)req->body_length); fd = socket(handler->ai_family, handler->ai_socktype, handler->ai_protocol); if (fd == -1) { e = errno; - oclog(ws, LOG_INFO, "urlfw: socket error: %s", strerror(e)); + oclog(ws, LOG_INFO, "kkdcp: socket error: %s", strerror(e)); reason = "Socket error"; goto fail; } @@ -66,7 +66,7 @@ int post_urlfw_handler(worker_st *ws, unsigned http_ver) ret = connect(fd, (struct sockaddr*)&handler->addr, handler->addr_len); if (ret == -1) { e = errno; - oclog(ws, LOG_INFO, "urlfw: connect error: %s", strerror(e)); + oclog(ws, LOG_INFO, "kkdcp: connect error: %s", strerror(e)); reason = "Connect error"; goto fail; } @@ -75,9 +75,9 @@ int post_urlfw_handler(worker_st *ws, unsigned http_ver) if (ret != req->body_length) { if (ret == -1) { e = errno; - oclog(ws, LOG_INFO, "urlfw: send error: %s", strerror(e)); + oclog(ws, LOG_INFO, "kkdcp: send error: %s", strerror(e)); } else { - oclog(ws, LOG_INFO, "urlfw: send error: only %d were sent", ret); + oclog(ws, LOG_INFO, "kkdcp: send error: only %d were sent", ret); } reason = "Send error"; goto fail; @@ -86,7 +86,7 @@ int post_urlfw_handler(worker_st *ws, unsigned http_ver) ret = recv(fd, buf, sizeof(buf), 0); if (ret == -1) { e = errno; - oclog(ws, LOG_INFO, "urlfw: recv error: %s", strerror(e)); + oclog(ws, LOG_INFO, "kkdcp: recv error: %s", strerror(e)); reason = "Recv error"; goto fail; } diff --git a/src/worker.h b/src/worker.h index 90c31795..35cdea89 100644 --- a/src/worker.h +++ b/src/worker.h @@ -269,7 +269,7 @@ int auth_user_deinit(worker_st *ws); int get_auth_handler(worker_st *server, unsigned http_ver); int post_auth_handler(worker_st *server, unsigned http_ver); -int post_urlfw_handler(worker_st *server, unsigned http_ver); +int post_kkdcp_handler(worker_st *server, unsigned http_ver); int get_empty_handler(worker_st *server, unsigned http_ver); int get_config_handler(worker_st *ws, unsigned http_ver);