From 48599a14144725dedc45f7558d814950791d069d Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Fri, 24 Feb 2017 11:32:24 +0100 Subject: Revise CACEP API The information passed to CACEP is split between the information about the connection and the information to be used during the authentication exchange. --- src/ipcpd/normal/cdap_flow.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/ipcpd/normal/cdap_flow.c') diff --git a/src/ipcpd/normal/cdap_flow.c b/src/ipcpd/normal/cdap_flow.c index a94627c2..71ebcc03 100644 --- a/src/ipcpd/normal/cdap_flow.c +++ b/src/ipcpd/normal/cdap_flow.c @@ -38,17 +38,17 @@ static void cdap_flow_destroy(struct cdap_flow * flow) if (flow->ci != NULL) cdap_destroy(flow->ci); if (flow->info != NULL) { - cacep_info_fini(flow->info); + conn_info_fini(flow->info); free(flow->info); } free(flow); } -struct cdap_flow * cdap_flow_arr(int fd, - int resp, - enum pol_cacep pc, - const struct cacep_info * info) +struct cdap_flow * cdap_flow_arr(int fd, + int resp, + enum pol_cacep pc, + const struct conn_info * info) { struct cdap_flow * flow; @@ -69,7 +69,7 @@ struct cdap_flow * cdap_flow_arr(int fd, flow->fd = fd; flow->ci = NULL; - flow->info = cacep_auth_wait(fd, pc, info); + flow->info = cacep_auth_wait(fd, pc, info, NULL); if (flow->info == NULL) { log_err("Other side failed to authenticate."); cdap_flow_destroy(flow); @@ -86,11 +86,11 @@ struct cdap_flow * cdap_flow_arr(int fd, return flow; } -struct cdap_flow * cdap_flow_alloc(const char * dst_name, - const char * ae_name, - qosspec_t * qs, - enum pol_cacep pc, - const struct cacep_info * info) +struct cdap_flow * cdap_flow_alloc(const char * dst_name, + const char * ae_name, + qosspec_t * qs, + enum pol_cacep pc, + const struct conn_info * info) { struct cdap_flow * flow; int fd; @@ -123,7 +123,7 @@ struct cdap_flow * cdap_flow_alloc(const char * dst_name, flow->fd = fd; flow->ci = NULL; - flow->info = cacep_auth(fd, pc, info); + flow->info = cacep_auth(fd, pc, info, NULL); if (flow->info == NULL) { log_err("Failed to authenticate."); cdap_flow_dealloc(flow); -- cgit v1.2.3 From cdab533860ba69423695e1d08acc25b074a0e065 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Fri, 24 Feb 2017 16:03:28 +0100 Subject: lib: Remove application entity name The AE name should not be passed over the layer boundaries. If an application has more than one AE it should exchange this in CACEP. --- include/ouroboros/dev.h | 8 +--- include/ouroboros/ipcp-dev.h | 1 - src/ipcpd/ipcp-ops.h | 51 ---------------------- src/ipcpd/ipcp.c | 1 - src/ipcpd/ipcp.h | 1 - src/ipcpd/local/main.c | 4 +- src/ipcpd/normal/cdap_flow.c | 5 +-- src/ipcpd/normal/cdap_flow.h | 1 - src/ipcpd/normal/enroll.c | 3 +- src/ipcpd/normal/flow_alloc.proto | 5 +-- src/ipcpd/normal/fmgr.c | 5 +-- src/ipcpd/normal/fmgr.h | 1 - src/ipcpd/normal/gam.c | 20 ++------- src/ipcpd/normal/gam.h | 3 +- src/ipcpd/normal/main.c | 9 ++-- src/ipcpd/normal/pol-gam-ops.h | 2 +- src/ipcpd/normal/ribmgr.c | 2 +- src/ipcpd/shim-eth-llc/main.c | 15 ++----- src/ipcpd/shim-eth-llc/shim_eth_llc_messages.proto | 9 ++-- src/ipcpd/shim-udp/main.c | 12 +---- src/irmd/ipcp.c | 4 +- src/irmd/ipcp.h | 1 - src/irmd/main.c | 17 ++------ src/irmd/registry.c | 1 - src/irmd/registry.h | 1 - src/lib/dev.c | 24 +--------- src/lib/ipcpd_messages.proto | 13 +++--- src/lib/irmd_messages.proto | 25 +++++------ src/tools/cbr/cbr_client.c | 2 +- src/tools/cbr/cbr_server.c | 2 +- src/tools/echo/echo_client.c | 2 +- src/tools/echo/echo_server.c | 2 +- src/tools/operf/operf_client.c | 2 +- src/tools/operf/operf_server.c | 2 +- src/tools/oping/oping_client.c | 2 +- src/tools/oping/oping_server.c | 2 +- 36 files changed, 61 insertions(+), 199 deletions(-) delete mode 100644 src/ipcpd/ipcp-ops.h (limited to 'src/ipcpd/normal/cdap_flow.c') diff --git a/include/ouroboros/dev.h b/include/ouroboros/dev.h index 1d2a2533..c4d2cb16 100644 --- a/include/ouroboros/dev.h +++ b/include/ouroboros/dev.h @@ -27,16 +27,13 @@ #ifndef OUROBOROS_DEV_H #define OUROBOROS_DEV_H -#define UNKNOWN_AE "__UNKNOWN_AE__" - /* These calls should be removed once we write the ouroboros OS. */ int ap_init(const char * ap_name); void ap_fini(void); -/* Returns flow descriptor (> 0), client AE name and qos spec. */ -int flow_accept(char ** ae_name, - qosspec_t * spec); +/* Returns flow descriptor (> 0) and qos spec. */ +int flow_accept(qosspec_t * spec); int flow_alloc_resp(int fd, int response); @@ -46,7 +43,6 @@ int flow_alloc_resp(int fd, * On returning, spec will contain the actual supplied QoS. */ int flow_alloc(const char * dst_name, - const char * src_ae_name, qosspec_t * spec); int flow_alloc_res(int fd); diff --git a/include/ouroboros/ipcp-dev.h b/include/ouroboros/ipcp-dev.h index 81aca1d7..fc82f374 100644 --- a/include/ouroboros/ipcp-dev.h +++ b/include/ouroboros/ipcp-dev.h @@ -31,7 +31,6 @@ int ipcp_create_r(pid_t api, int ipcp_flow_req_arr(pid_t api, char * dst_name, - char * src_ae_name, qoscube_t cube); int ipcp_flow_alloc_reply(int fd, diff --git a/src/ipcpd/ipcp-ops.h b/src/ipcpd/ipcp-ops.h deleted file mode 100644 index 6a42ec5c..00000000 --- a/src/ipcpd/ipcp-ops.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Ouroboros - Copyright (C) 2016 - 2017 - * - * IPC process ops - * - * Dimitri Staessens - * Sander Vrijders - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef IPCPD_IPCP_OPS_H -#define IPCPD_IPCP_OPS_H - -#include -#include - -struct ipcp_ops { - int (* ipcp_bootstrap)(struct dif_config * conf); - - int (* ipcp_enroll)(char * dif_name); - - int (* ipcp_name_reg)(char * name); - - int (* ipcp_name_unreg)(char * name); - - int (* ipcp_name_query)(char * name); - - int (* ipcp_flow_alloc)(int fd, - char * dst_ap_name, - char * src_ae_name, - qoscube_t qos); - - int (* ipcp_flow_alloc_resp)(int fd, - int response); - - int (* ipcp_flow_dealloc)(int fd); -}; - -#endif /* IPCPD_IPCP_OPS_H */ diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c index 19b3a721..41b5bb48 100644 --- a/src/ipcpd/ipcp.c +++ b/src/ipcpd/ipcp.c @@ -191,7 +191,6 @@ static void * ipcp_main_loop(void * o) ret_msg.result = ipcpi.ops->ipcp_flow_alloc(fd, msg->dst_name, - msg->src_ae_name, msg->qoscube); break; case IPCP_MSG_CODE__IPCP_FLOW_ALLOC_RESP: diff --git a/src/ipcpd/ipcp.h b/src/ipcpd/ipcp.h index de7d72b0..d0b5e022 100644 --- a/src/ipcpd/ipcp.h +++ b/src/ipcpd/ipcp.h @@ -50,7 +50,6 @@ struct ipcp_ops { int (* ipcp_flow_alloc)(int fd, char * dst_ap_name, - char * src_ae_name, qoscube_t qos); int (* ipcp_flow_alloc_resp)(int fd, diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c index 8d770c94..2d995680 100644 --- a/src/ipcpd/local/main.c +++ b/src/ipcpd/local/main.c @@ -220,7 +220,6 @@ static int ipcp_local_name_query(char * name) static int ipcp_local_flow_alloc(int fd, char * dst_name, - char * src_ae_name, qoscube_t cube) { int out_fd = -1; @@ -228,7 +227,6 @@ static int ipcp_local_flow_alloc(int fd, log_dbg("Allocating flow to %s on fd %d.", dst_name, fd); assert(dst_name); - assert(src_ae_name); pthread_rwlock_rdlock(&ipcpi.state_lock); @@ -240,7 +238,7 @@ static int ipcp_local_flow_alloc(int fd, pthread_rwlock_wrlock(&local_data.lock); - out_fd = ipcp_flow_req_arr(getpid(), dst_name, src_ae_name, cube); + out_fd = ipcp_flow_req_arr(getpid(), dst_name, cube); local_data.in_out[fd] = out_fd; local_data.in_out[out_fd] = fd; diff --git a/src/ipcpd/normal/cdap_flow.c b/src/ipcpd/normal/cdap_flow.c index 71ebcc03..3d1b2b22 100644 --- a/src/ipcpd/normal/cdap_flow.c +++ b/src/ipcpd/normal/cdap_flow.c @@ -87,7 +87,6 @@ struct cdap_flow * cdap_flow_arr(int fd, } struct cdap_flow * cdap_flow_alloc(const char * dst_name, - const char * ae_name, qosspec_t * qs, enum pol_cacep pc, const struct conn_info * info) @@ -97,12 +96,12 @@ struct cdap_flow * cdap_flow_alloc(const char * dst_name, log_dbg("Allocating flow to %s.", dst_name); - if (dst_name == NULL || ae_name == NULL) { + if (dst_name == NULL) { log_err("Not enough info to establish flow."); return NULL; } - fd = flow_alloc(dst_name, ae_name, qs); + fd = flow_alloc(dst_name, qs); if (fd < 0) { log_err("Failed to allocate flow to %s.", dst_name); return NULL; diff --git a/src/ipcpd/normal/cdap_flow.h b/src/ipcpd/normal/cdap_flow.h index 14a04f02..8aa26dc0 100644 --- a/src/ipcpd/normal/cdap_flow.h +++ b/src/ipcpd/normal/cdap_flow.h @@ -39,7 +39,6 @@ struct cdap_flow * cdap_flow_arr(int fd, const struct conn_info * info); struct cdap_flow * cdap_flow_alloc(const char * dst_name, - const char * ae_name, qosspec_t * qs, enum pol_cacep pc, const struct conn_info * info); diff --git a/src/ipcpd/normal/enroll.c b/src/ipcpd/normal/enroll.c index 78bc4d51..b420533e 100644 --- a/src/ipcpd/normal/enroll.c +++ b/src/ipcpd/normal/enroll.c @@ -181,8 +181,7 @@ int enroll_boot(char * dst_name) info.proto.pref_version = 1; info.proto.pref_syntax = PROTO_GPB; - flow = cdap_flow_alloc(dst_name, ENROLL_AE, NULL, ANONYMOUS_AUTH, - &info); + flow = cdap_flow_alloc(dst_name, NULL, ANONYMOUS_AUTH, &info); if (flow == NULL) { log_err("Failed to allocate flow for enrollment request."); conn_info_fini(&info); diff --git a/src/ipcpd/normal/flow_alloc.proto b/src/ipcpd/normal/flow_alloc.proto index 16e8be2c..3b08f047 100644 --- a/src/ipcpd/normal/flow_alloc.proto +++ b/src/ipcpd/normal/flow_alloc.proto @@ -31,7 +31,6 @@ enum flow_alloc_code { message flow_alloc_msg { required flow_alloc_code code = 1; optional string dst_name = 2; - optional string src_ae_name = 3; - optional uint32 qoscube = 4; - optional sint32 response = 5; + optional uint32 qoscube = 3; + optional sint32 response = 4; }; diff --git a/src/ipcpd/normal/fmgr.c b/src/ipcpd/normal/fmgr.c index 74bdda88..071a895f 100644 --- a/src/ipcpd/normal/fmgr.c +++ b/src/ipcpd/normal/fmgr.c @@ -301,7 +301,7 @@ int fmgr_init(void) /* FIXME: Implement cacep policies */ (void) pc; - fmgr.gam = gam_create(pg, DT_AE); + fmgr.gam = gam_create(pg); if (fmgr.gam == NULL) { log_err("Failed to create graph adjacency manager."); fmgr_destroy_flows(); @@ -360,7 +360,6 @@ void fmgr_fini() int fmgr_np1_alloc(int fd, char * dst_ap_name, - char * src_ae_name, qoscube_t cube) { cep_id_t cep_id; @@ -406,7 +405,6 @@ int fmgr_np1_alloc(int fd, msg.code = FLOW_ALLOC_CODE__FLOW_REQ; msg.dst_name = dst_ap_name; - msg.src_ae_name = src_ae_name; msg.has_qoscube = true; msg.qoscube = cube; @@ -546,7 +544,6 @@ int fmgr_np1_post_buf(cep_id_t cep_id, case FLOW_ALLOC_CODE__FLOW_REQ: fd = ipcp_flow_req_arr(getpid(), msg->dst_name, - msg->src_ae_name, msg->qoscube); if (fd < 0) { flow_alloc_msg__free_unpacked(msg, NULL); diff --git a/src/ipcpd/normal/fmgr.h b/src/ipcpd/normal/fmgr.h index 3c61f55a..e75417f3 100644 --- a/src/ipcpd/normal/fmgr.h +++ b/src/ipcpd/normal/fmgr.h @@ -34,7 +34,6 @@ void fmgr_fini(void); int fmgr_np1_alloc(int fd, char * dst_ap_name, - char * src_ae_name, qoscube_t qos); int fmgr_np1_alloc_resp(int fd, diff --git a/src/ipcpd/normal/gam.c b/src/ipcpd/normal/gam.c index 02df0be7..2479fa62 100644 --- a/src/ipcpd/normal/gam.c +++ b/src/ipcpd/normal/gam.c @@ -53,14 +53,11 @@ struct gam { pthread_mutex_t gas_lock; pthread_cond_t gas_cond; - char * ae_name; - struct pol_gam_ops * ops; void * ops_o; }; -struct gam * gam_create(enum pol_gam gam_type, - const char * ae_name) +struct gam * gam_create(enum pol_gam gam_type) { struct gam * tmp; @@ -80,21 +77,13 @@ struct gam * gam_create(enum pol_gam gam_type, list_head_init(&tmp->gas); - tmp->ae_name = strdup(ae_name); - if (tmp->ae_name == NULL) { - free(tmp); - return NULL; - } - if (pthread_mutex_init(&tmp->gas_lock, NULL)) { - free(tmp->ae_name); free(tmp); return NULL; } if (pthread_cond_init(&tmp->gas_cond, NULL)) { pthread_mutex_destroy(&tmp->gas_lock); - free(tmp->ae_name); free(tmp); return NULL; } @@ -103,7 +92,6 @@ struct gam * gam_create(enum pol_gam gam_type, if (tmp->ops_o == NULL) { pthread_cond_destroy(&tmp->gas_cond); pthread_mutex_destroy(&tmp->gas_lock); - free(tmp->ae_name); free(tmp); return NULL; } @@ -111,7 +99,6 @@ struct gam * gam_create(enum pol_gam gam_type, if (tmp->ops->start(tmp->ops_o)) { pthread_cond_destroy(&tmp->gas_cond); pthread_mutex_destroy(&tmp->gas_lock); - free(tmp->ae_name); free(tmp); return NULL; } @@ -143,7 +130,6 @@ void gam_destroy(struct gam * instance) pthread_mutex_destroy(&instance->gas_lock); pthread_cond_destroy(&instance->gas_cond); - free(instance->ae_name); instance->ops->destroy(instance->ops_o); free(instance); } @@ -170,7 +156,7 @@ static int add_ga(struct gam * instance, pthread_cond_signal(&instance->gas_cond); pthread_mutex_unlock(&instance->gas_lock); - log_info("Added %s flow to %s.", instance->ae_name, info->name); + log_info("Added flow to %s.", info->name); return 0; } @@ -241,7 +227,7 @@ int gam_flow_alloc(struct gam * instance, log_dbg("Allocating flow to %s.", dst_name); - fd = flow_alloc(dst_name, instance->ae_name, NULL); + fd = flow_alloc(dst_name, NULL); if (fd < 0) { log_err("Failed to allocate flow to %s.", dst_name); return -1; diff --git a/src/ipcpd/normal/gam.h b/src/ipcpd/normal/gam.h index e4832ca6..58b028b9 100644 --- a/src/ipcpd/normal/gam.h +++ b/src/ipcpd/normal/gam.h @@ -26,8 +26,7 @@ #include #include -struct gam * gam_create(enum pol_gam gam_type, - const char * ae_name); +struct gam * gam_create(enum pol_gam gam_type); void gam_destroy(struct gam * instance); diff --git a/src/ipcpd/normal/main.c b/src/ipcpd/normal/main.c index 522daa3b..939544c3 100644 --- a/src/ipcpd/normal/main.c +++ b/src/ipcpd/normal/main.c @@ -85,8 +85,9 @@ void ipcp_sig_handler(int sig, static void * flow_acceptor(void * o) { int fd; - char * ae_name; qosspec_t qs; + /* FIXME: Remove once correct AE is known. */ + char * ae_name = ENROLL_AE; (void) o; @@ -101,14 +102,14 @@ static void * flow_acceptor(void * o) pthread_rwlock_unlock(&ipcpi.state_lock); - fd = flow_accept(&ae_name, &qs); + fd = flow_accept(&qs); if (fd < 0) { if (fd != -EIRMD) log_warn("Flow accept failed: %d", fd); continue; } - log_dbg("New flow allocation request for AE %s.", ae_name); + /* FIXME: Perform CACEP at this point */ if (strcmp(ae_name, ENROLL_AE) == 0) { enroll_handle(fd); @@ -123,8 +124,6 @@ static void * flow_acceptor(void * o) log_warn("Failed to reply to flow allocation."); flow_dealloc(fd); } - - free(ae_name); } return (void *) 0; diff --git a/src/ipcpd/normal/pol-gam-ops.h b/src/ipcpd/normal/pol-gam-ops.h index 6983e3a0..264f252b 100644 --- a/src/ipcpd/normal/pol-gam-ops.h +++ b/src/ipcpd/normal/pol-gam-ops.h @@ -23,7 +23,7 @@ #ifndef OUROBOROS_IPCPD_NORMAL_POL_GAM_OPS_H #define OUROBOROS_IPCPD_NORMAL_POL_GAM_OPS_H -#include "conn.h" +#include struct pol_gam_ops { void * (* create)(struct gam * instance); diff --git a/src/ipcpd/normal/ribmgr.c b/src/ipcpd/normal/ribmgr.c index f254bd50..1436a7d4 100644 --- a/src/ipcpd/normal/ribmgr.c +++ b/src/ipcpd/normal/ribmgr.c @@ -71,7 +71,7 @@ int ribmgr_init(void) /* FIXME: Implement cacep policies */ (void) pc; - ribmgr.gam = gam_create(pg, MGMT_AE); + ribmgr.gam = gam_create(pg); if (ribmgr.gam == NULL) { log_err("Failed to create gam."); return -1; diff --git a/src/ipcpd/shim-eth-llc/main.c b/src/ipcpd/shim-eth-llc/main.c index cd913de4..01121fa3 100644 --- a/src/ipcpd/shim-eth-llc/main.c +++ b/src/ipcpd/shim-eth-llc/main.c @@ -334,7 +334,6 @@ static int eth_llc_ipcp_send_mgmt_frame(shim_eth_llc_msg_t * msg, static int eth_llc_ipcp_sap_alloc(uint8_t * dst_addr, uint8_t ssap, char * dst_name, - char * src_ae_name, qoscube_t cube) { shim_eth_llc_msg_t msg = SHIM_ETH_LLC_MSG__INIT; @@ -343,7 +342,6 @@ static int eth_llc_ipcp_sap_alloc(uint8_t * dst_addr, msg.has_ssap = true; msg.ssap = ssap; msg.dst_name = dst_name; - msg.src_ae_name = src_ae_name; msg.has_qoscube = true; msg.qoscube = cube; @@ -371,7 +369,6 @@ static int eth_llc_ipcp_sap_alloc_resp(uint8_t * dst_addr, static int eth_llc_ipcp_sap_req(uint8_t r_sap, uint8_t * r_addr, char * dst_name, - char * src_ae_name, qoscube_t cube) { int fd; @@ -380,7 +377,7 @@ static int eth_llc_ipcp_sap_req(uint8_t r_sap, pthread_rwlock_wrlock(ð_llc_data.flows_lock); /* reply to IRM */ - fd = ipcp_flow_req_arr(getpid(), dst_name, src_ae_name, cube); + fd = ipcp_flow_req_arr(getpid(), dst_name, cube); if (fd < 0) { pthread_rwlock_unlock(ð_llc_data.flows_lock); pthread_rwlock_unlock(&ipcpi.state_lock); @@ -491,7 +488,6 @@ static int eth_llc_ipcp_mgmt_frame(uint8_t * buf, eth_llc_ipcp_sap_req(msg->ssap, r_addr, msg->dst_name, - msg->src_ae_name, msg->qoscube); } break; @@ -989,7 +985,6 @@ static int eth_llc_ipcp_name_query(char * name) static int eth_llc_ipcp_flow_alloc(int fd, char * dst_name, - char * src_ae_name, qoscube_t cube) { uint8_t ssap = 0; @@ -998,7 +993,7 @@ static int eth_llc_ipcp_flow_alloc(int fd, log_dbg("Allocating flow to %s.", dst_name); - if (dst_name == NULL || src_ae_name == NULL) + if (dst_name == NULL) return -1; if (cube != QOS_CUBE_BE && cube != QOS_CUBE_FRC) { @@ -1038,11 +1033,7 @@ static int eth_llc_ipcp_flow_alloc(int fd, memcpy(r_addr, &addr, MAC_SIZE); - if (eth_llc_ipcp_sap_alloc(r_addr, - ssap, - dst_name, - src_ae_name, - cube) < 0) { + if (eth_llc_ipcp_sap_alloc(r_addr, ssap, dst_name, cube) < 0) { pthread_rwlock_rdlock(&ipcpi.state_lock); pthread_rwlock_wrlock(ð_llc_data.flows_lock); bmp_release(eth_llc_data.saps, eth_llc_data.fd_to_ef[fd].sap); diff --git a/src/ipcpd/shim-eth-llc/shim_eth_llc_messages.proto b/src/ipcpd/shim-eth-llc/shim_eth_llc_messages.proto index cedb0fd4..2d66428c 100644 --- a/src/ipcpd/shim-eth-llc/shim_eth_llc_messages.proto +++ b/src/ipcpd/shim-eth-llc/shim_eth_llc_messages.proto @@ -32,9 +32,8 @@ enum shim_eth_llc_msg_code { message shim_eth_llc_msg { required shim_eth_llc_msg_code code = 1; optional string dst_name = 2; - optional string src_ae_name = 3; - optional uint32 ssap = 4; - optional uint32 dsap = 5; - optional uint32 qoscube = 6; - optional sint32 response = 7; + optional uint32 ssap = 3; + optional uint32 dsap = 4; + optional uint32 qoscube = 5; + optional sint32 response = 6; }; diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c index 4d6fdc3b..a67a60ee 100644 --- a/src/ipcpd/shim-udp/main.c +++ b/src/ipcpd/shim-udp/main.c @@ -197,7 +197,6 @@ static int send_shim_udp_msg(shim_udp_msg_t * msg, static int ipcp_udp_port_alloc(uint32_t dst_ip_addr, uint16_t src_udp_port, char * dst_name, - char * src_ae_name, qoscube_t cube) { shim_udp_msg_t msg = SHIM_UDP_MSG__INIT; @@ -205,7 +204,6 @@ static int ipcp_udp_port_alloc(uint32_t dst_ip_addr, msg.code = SHIM_UDP_MSG_CODE__FLOW_REQ; msg.src_udp_port = src_udp_port; msg.dst_name = dst_name; - msg.src_ae_name = src_ae_name; msg.has_qoscube = true; msg.qoscube = cube; @@ -231,7 +229,6 @@ static int ipcp_udp_port_alloc_resp(uint32_t dst_ip_addr, static int ipcp_udp_port_req(struct sockaddr_in * c_saddr, char * dst_name, - char * src_ae_name, qoscube_t cube) { int skfd; @@ -275,7 +272,7 @@ static int ipcp_udp_port_req(struct sockaddr_in * c_saddr, pthread_rwlock_wrlock(&udp_data.flows_lock); /* reply to IRM */ - fd = ipcp_flow_req_arr(getpid(), dst_name, src_ae_name, cube); + fd = ipcp_flow_req_arr(getpid(), dst_name, cube); if (fd < 0) { pthread_rwlock_unlock(&udp_data.flows_lock); pthread_rwlock_unlock(&ipcpi.state_lock); @@ -397,7 +394,6 @@ static void * ipcp_udp_listener(void * o) c_saddr.sin_port = msg->src_udp_port; ipcp_udp_port_req(&c_saddr, msg->dst_name, - msg->src_ae_name, msg->qoscube); break; case SHIM_UDP_MSG_CODE__FLOW_REPLY: @@ -957,7 +953,6 @@ static int ipcp_udp_name_query(char * name) static int ipcp_udp_flow_alloc(int fd, char * dst_name, - char * src_ae_name, qoscube_t cube) { struct sockaddr_in r_saddr; /* server address */ @@ -969,10 +964,8 @@ static int ipcp_udp_flow_alloc(int fd, log_dbg("Allocating flow to %s.", dst_name); assert(dst_name); - assert(src_ae_name); - if (strlen(dst_name) > 255 - || strlen(src_ae_name) > 255) { + if (strlen(dst_name) > 255) { log_err("Name too long for this shim."); return -1; } @@ -1043,7 +1036,6 @@ static int ipcp_udp_flow_alloc(int fd, if (ipcp_udp_port_alloc(ip_addr, f_saddr.sin_port, dst_name, - src_ae_name, cube) < 0) { pthread_rwlock_rdlock(&ipcpi.state_lock); pthread_rwlock_wrlock(&udp_data.flows_lock); diff --git a/src/irmd/ipcp.c b/src/irmd/ipcp.c index dcf77eec..ae9ec957 100644 --- a/src/irmd/ipcp.c +++ b/src/irmd/ipcp.c @@ -328,14 +328,13 @@ int ipcp_flow_alloc(pid_t api, int port_id, pid_t n_api, char * dst_name, - char * src_ae_name, qoscube_t cube) { ipcp_msg_t msg = IPCP_MSG__INIT; ipcp_msg_t * recv_msg = NULL; int ret = -1; - if (dst_name == NULL || src_ae_name == NULL) + if (dst_name == NULL) return -EINVAL; msg.code = IPCP_MSG_CODE__IPCP_FLOW_ALLOC; @@ -343,7 +342,6 @@ int ipcp_flow_alloc(pid_t api, msg.port_id = port_id; msg.has_api = true; msg.api = n_api; - msg.src_ae_name = src_ae_name; msg.dst_name = dst_name; msg.has_qoscube = true; msg.qoscube = cube; diff --git a/src/irmd/ipcp.h b/src/irmd/ipcp.h index 658aa2ea..7ddfc3c4 100644 --- a/src/irmd/ipcp.h +++ b/src/irmd/ipcp.h @@ -52,7 +52,6 @@ int ipcp_flow_alloc(pid_t api, int port_id, pid_t n_api, char * dst_name, - char * src_ae_name, qoscube_t qos); int ipcp_flow_alloc_resp(pid_t api, diff --git a/src/irmd/main.c b/src/irmd/main.c index 9aceb27a..a0115f56 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -976,7 +976,6 @@ static int api_announce(pid_t api, } static struct irm_flow * flow_accept(pid_t api, - char ** dst_ae_name, qoscube_t * cube) { struct irm_flow * f = NULL; @@ -999,8 +998,10 @@ static struct irm_flow * flow_accept(pid_t api, log_err("Unknown instance %d calling accept.", api); return NULL; } + log_dbg("New instance (%d) of %s added.", api, e->apn); log_dbg("This instance accepts flows for:"); + list_for_each(p, &e->names) { struct str_el * s = list_entry(p, struct str_el, next); log_dbg(" %s", s->str); @@ -1064,9 +1065,6 @@ static struct irm_flow * flow_accept(pid_t api, *cube = re->qos; - if (dst_ae_name != NULL) - *dst_ae_name = re->req_ae_name; - log_info("Flow on port_id %d allocated.", f->port_id); pthread_rwlock_unlock(&irmd->flows_lock); @@ -1148,7 +1146,6 @@ static int flow_alloc_resp(pid_t n_api, static struct irm_flow * flow_alloc(pid_t api, char * dst_name, - char * src_ae_name, qoscube_t cube) { struct irm_flow * f; @@ -1197,7 +1194,7 @@ static struct irm_flow * flow_alloc(pid_t api, pthread_rwlock_unlock(&irmd->state_lock); if (ipcp_flow_alloc(ipcp, port_id, api, - dst_name, src_ae_name, cube) < 0) { + dst_name, cube) < 0) { pthread_rwlock_rdlock(&irmd->state_lock); pthread_rwlock_wrlock(&irmd->flows_lock); list_del(&f->next); @@ -1348,7 +1345,6 @@ static pid_t auto_execute(char ** argv) static struct irm_flow * flow_req_arr(pid_t api, char * dst_name, - char * ae_name, qoscube_t cube) { struct reg_entry * re = NULL; @@ -1363,8 +1359,7 @@ static struct irm_flow * flow_req_arr(pid_t api, struct timespec wt = {IRMD_REQ_ARR_TIMEOUT % 1000, (IRMD_REQ_ARR_TIMEOUT % 1000) * MILLION}; - log_dbg("Flow req arrived from IPCP %d for %s on AE %s.", - api, dst_name, ae_name); + log_dbg("Flow req arrived from IPCP %d for %s.", api, dst_name); pthread_rwlock_rdlock(&irmd->state_lock); pthread_rwlock_rdlock(&irmd->reg_lock); @@ -1469,7 +1464,6 @@ static struct irm_flow * flow_req_arr(pid_t api, pthread_rwlock_unlock(&irmd->flows_lock); pthread_rwlock_rdlock(&irmd->reg_lock); - re->req_ae_name = ae_name; re->qos = cube; reg_entry_set_state(re, REG_NAME_FLOW_ARRIVED); @@ -1926,7 +1920,6 @@ void * mainloop(void * o) case IRM_MSG_CODE__IRM_FLOW_ACCEPT: ret_msg.has_qoscube = true; e = flow_accept(msg->api, - &ret_msg.ae_name, (qoscube_t *) &ret_msg.qoscube); if (e == NULL) { ret_msg.has_result = true; @@ -1947,7 +1940,6 @@ void * mainloop(void * o) case IRM_MSG_CODE__IRM_FLOW_ALLOC: e = flow_alloc(msg->api, msg->dst_name, - msg->ae_name, msg->qoscube); if (e == NULL) { ret_msg.has_result = true; @@ -1970,7 +1962,6 @@ void * mainloop(void * o) case IRM_MSG_CODE__IPCP_FLOW_REQ_ARR: e = flow_req_arr(msg->api, msg->dst_name, - msg->ae_name, msg->qoscube); if (e == NULL) { ret_msg.has_result = true; diff --git a/src/irmd/registry.c b/src/irmd/registry.c index 985ecda0..f4579d08 100644 --- a/src/irmd/registry.c +++ b/src/irmd/registry.c @@ -52,7 +52,6 @@ static struct reg_entry * reg_entry_create(void) e->name = NULL; e->state = REG_NAME_NULL; - e->req_ae_name = NULL; e->response = -1; return e; diff --git a/src/irmd/registry.h b/src/irmd/registry.h index 67e4da40..76b32398 100644 --- a/src/irmd/registry.h +++ b/src/irmd/registry.h @@ -62,7 +62,6 @@ struct reg_entry { struct list_head reg_apis; enum reg_name_state state; - char * req_ae_name; qoscube_t qos; int response; pthread_cond_t state_cond; diff --git a/src/lib/dev.c b/src/lib/dev.c index 4d85a5d9..cb8044cf 100644 --- a/src/lib/dev.c +++ b/src/lib/dev.c @@ -382,8 +382,7 @@ void ap_fini() pthread_rwlock_destroy(&ai.data_lock); } -int flow_accept(char ** ae_name, - qosspec_t * spec) +int flow_accept(qosspec_t * spec) { irm_msg_t msg = IRM_MSG__INIT; irm_msg_t * recv_msg = NULL; @@ -451,18 +450,6 @@ int flow_accept(char ** ae_name, return -1; } - if (ae_name != NULL) { - *ae_name = strdup(recv_msg->ae_name); - if (*ae_name == NULL) { - reset_flow(fd); - bmp_release(ai.fds, fd); - pthread_rwlock_unlock(&ai.flows_lock); - pthread_rwlock_unlock(&ai.data_lock); - irm_msg__free_unpacked(recv_msg, NULL); - return -ENOMEM; - } - } - ai.flows[fd].port_id = recv_msg->port_id; ai.flows[fd].oflags = FLOW_O_DEFAULT; ai.flows[fd].api = recv_msg->api; @@ -531,7 +518,6 @@ int flow_alloc_resp(int fd, } int flow_alloc(const char * dst_name, - const char * src_ae_name, qosspec_t * spec) { irm_msg_t msg = IRM_MSG__INIT; @@ -541,12 +527,8 @@ int flow_alloc(const char * dst_name, if (dst_name == NULL) return -EINVAL; - if (src_ae_name == NULL) - src_ae_name = UNKNOWN_AE; - msg.code = IRM_MSG_CODE__IRM_FLOW_ALLOC; msg.dst_name = (char *) dst_name; - msg.ae_name = (char *) src_ae_name; msg.has_api = true; msg.has_qoscube = true; msg.qoscube = spec_to_cube(spec); @@ -1270,7 +1252,6 @@ int ipcp_create_r(pid_t api, int ipcp_flow_req_arr(pid_t api, char * dst_name, - char * src_ae_name, qoscube_t cube) { irm_msg_t msg = IRM_MSG__INIT; @@ -1278,14 +1259,13 @@ int ipcp_flow_req_arr(pid_t api, int port_id = -1; int fd = -1; - if (dst_name == NULL || src_ae_name == NULL) + if (dst_name == NULL) return -EINVAL; msg.code = IRM_MSG_CODE__IPCP_FLOW_REQ_ARR; msg.has_api = true; msg.api = api; msg.dst_name = dst_name; - msg.ae_name = src_ae_name; msg.has_qoscube = true; msg.qoscube = cube; diff --git a/src/lib/ipcpd_messages.proto b/src/lib/ipcpd_messages.proto index 827bd370..da817944 100644 --- a/src/lib/ipcpd_messages.proto +++ b/src/lib/ipcpd_messages.proto @@ -45,11 +45,10 @@ message ipcp_msg { optional string name = 5; optional sint32 port_id = 6; optional string dst_name = 7; - optional string src_ae_name = 8; - optional sint32 qoscube = 9; - optional dif_config_msg conf = 10; - optional sint32 fd = 11; - optional sint32 api = 12; - optional sint32 response = 13; - optional sint32 result = 14; + optional sint32 qoscube = 8; + optional dif_config_msg conf = 9; + optional sint32 fd = 10; + optional sint32 api = 11; + optional sint32 response = 12; + optional sint32 result = 13; }; diff --git a/src/lib/irmd_messages.proto b/src/lib/irmd_messages.proto index a0965f43..c25d2c18 100644 --- a/src/lib/irmd_messages.proto +++ b/src/lib/irmd_messages.proto @@ -52,17 +52,16 @@ enum irm_msg_code { message irm_msg { required irm_msg_code code = 1; optional string ap_name = 2; - optional string ae_name = 3; - optional sint32 api = 4; - optional uint32 ipcp_type = 5; - repeated string dif_name = 6; - repeated string args = 7; - optional sint32 response = 8; - optional string dst_name = 9; - optional sint32 port_id = 10; - optional sint32 qoscube = 11; - optional dif_config_msg conf = 12; - optional uint32 opts = 13; - repeated sint32 apis = 14; - optional sint32 result = 15; + optional sint32 api = 3; + optional uint32 ipcp_type = 4; + repeated string dif_name = 5; + repeated string args = 6; + optional sint32 response = 7; + optional string dst_name = 8; + optional sint32 port_id = 9; + optional sint32 qoscube = 10; + optional dif_config_msg conf = 11; + optional uint32 opts = 12; + repeated sint32 apis = 13; + optional sint32 result = 14; }; diff --git a/src/tools/cbr/cbr_client.c b/src/tools/cbr/cbr_client.c index 173dab24..48a18cd1 100644 --- a/src/tools/cbr/cbr_client.c +++ b/src/tools/cbr/cbr_client.c @@ -90,7 +90,7 @@ int client_main(char * server, printf("Client started, duration %d, rate %lu b/s, size %d B.\n", duration, rate, size); - fd = flow_alloc(server, NULL, NULL); + fd = flow_alloc(server, NULL); if (fd < 0) { printf("Failed to allocate flow.\n"); return -1; diff --git a/src/tools/cbr/cbr_server.c b/src/tools/cbr/cbr_server.c index 7105ff09..b0be9d7b 100644 --- a/src/tools/cbr/cbr_server.c +++ b/src/tools/cbr/cbr_server.c @@ -164,7 +164,7 @@ static void * listener(void * o) server_settings.interval, server_settings.timeout); while (true) { - client_fd = flow_accept(NULL, &qs); + client_fd = flow_accept(&qs); if (client_fd < 0) { printf("Failed to accept flow.\n"); break; diff --git a/src/tools/echo/echo_client.c b/src/tools/echo/echo_client.c index 783188d5..3036d338 100644 --- a/src/tools/echo/echo_client.c +++ b/src/tools/echo/echo_client.c @@ -30,7 +30,7 @@ int client_main(void) char * message = "Client says hi!"; ssize_t count = 0; - fd = flow_alloc("echo", NULL, NULL); + fd = flow_alloc("echo", NULL); if (fd < 0) { printf("Failed to allocate flow.\n"); return -1; diff --git a/src/tools/echo/echo_server.c b/src/tools/echo/echo_server.c index 8940a0b5..94c54eee 100644 --- a/src/tools/echo/echo_server.c +++ b/src/tools/echo/echo_server.c @@ -50,7 +50,7 @@ int server_main(void) } while (true) { - client_fd = flow_accept(NULL, &qs); + client_fd = flow_accept(&qs); if (client_fd < 0) { printf("Failed to accept flow.\n"); break; diff --git a/src/tools/operf/operf_client.c b/src/tools/operf/operf_client.c index 5b31e27b..0c943cf7 100644 --- a/src/tools/operf/operf_client.c +++ b/src/tools/operf/operf_client.c @@ -182,7 +182,7 @@ int client_main(void) client.sent = 0; client.rcvd = 0; - fd = flow_alloc(client.s_apn, NULL, NULL); + fd = flow_alloc(client.s_apn, NULL); if (fd < 0) { printf("Failed to allocate flow.\n"); return -1; diff --git a/src/tools/operf/operf_server.c b/src/tools/operf/operf_server.c index 3c3b9788..f23b52f3 100644 --- a/src/tools/operf/operf_server.c +++ b/src/tools/operf/operf_server.c @@ -108,7 +108,7 @@ void * accept_thread(void * o) printf("Ouroboros perf server started.\n"); while (true) { - fd = flow_accept(NULL, &qs); + fd = flow_accept(&qs); if (fd < 0) { printf("Failed to accept flow.\n"); break; diff --git a/src/tools/oping/oping_client.c b/src/tools/oping/oping_client.c index 99c11a68..253ea168 100644 --- a/src/tools/oping/oping_client.c +++ b/src/tools/oping/oping_client.c @@ -213,7 +213,7 @@ int client_main(void) return -1; } - fd = flow_alloc(client.s_apn, NULL, NULL); + fd = flow_alloc(client.s_apn, NULL); if (fd < 0) { printf("Failed to allocate flow.\n"); return -1; diff --git a/src/tools/oping/oping_server.c b/src/tools/oping/oping_server.c index 24cd9bf1..e0a6655b 100644 --- a/src/tools/oping/oping_server.c +++ b/src/tools/oping/oping_server.c @@ -119,7 +119,7 @@ void * accept_thread(void * o) printf("Ouroboros ping server started.\n"); while (true) { - fd = flow_accept(NULL, &qs); + fd = flow_accept(&qs); if (fd < 0) { printf("Failed to accept flow.\n"); break; -- cgit v1.2.3 From d06cb62e111be1ac3f09398ae559f99e4833b4bf Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Mon, 27 Feb 2017 17:04:40 +0100 Subject: lib: Split authentication from CACEP By removing authentication as part of CACEP, all policies disappear. CACEP becomes a policy-free connection establishment protocol between Application Entities. Authentication can later be added cleanly as a pure policy function when needed. --- include/ouroboros/cacep.h | 37 +++--- include/ouroboros/irm_config.h | 5 - src/ipcpd/normal/cdap_flow.c | 25 ++-- src/ipcpd/normal/cdap_flow.h | 8 +- src/ipcpd/normal/enroll.c | 42 +++---- src/ipcpd/normal/fmgr.c | 11 -- src/ipcpd/normal/gam.c | 87 ++++++-------- src/ipcpd/normal/main.c | 11 -- src/ipcpd/normal/pol/complete.c | 6 +- src/ipcpd/normal/ribmgr.c | 10 -- src/lib/CMakeLists.txt | 14 +-- src/lib/cacep.c | 152 ++++++++++++++---------- src/lib/cacep.proto | 33 ++++++ src/lib/pol/cacep_anonymous_auth.c | 209 --------------------------------- src/lib/pol/cacep_anonymous_auth.h | 35 ------ src/lib/pol/cacep_anonymous_auth.proto | 30 ----- src/lib/pol/cacep_proto.c | 52 -------- src/lib/pol/cacep_proto.h | 36 ------ src/lib/pol/cacep_proto.proto | 38 ------ src/lib/pol/cacep_simple_auth.c | 190 ------------------------------ src/lib/pol/cacep_simple_auth.h | 35 ------ src/lib/pol/cacep_simple_auth.proto | 32 ----- 22 files changed, 210 insertions(+), 888 deletions(-) create mode 100644 src/lib/cacep.proto delete mode 100644 src/lib/pol/cacep_anonymous_auth.c delete mode 100644 src/lib/pol/cacep_anonymous_auth.h delete mode 100644 src/lib/pol/cacep_anonymous_auth.proto delete mode 100644 src/lib/pol/cacep_proto.c delete mode 100644 src/lib/pol/cacep_proto.h delete mode 100644 src/lib/pol/cacep_proto.proto delete mode 100644 src/lib/pol/cacep_simple_auth.c delete mode 100644 src/lib/pol/cacep_simple_auth.h delete mode 100644 src/lib/pol/cacep_simple_auth.proto (limited to 'src/ipcpd/normal/cdap_flow.c') diff --git a/include/ouroboros/cacep.h b/include/ouroboros/cacep.h index f155023e..5ef66433 100644 --- a/include/ouroboros/cacep.h +++ b/include/ouroboros/cacep.h @@ -1,7 +1,7 @@ /* * Ouroboros - Copyright (C) 2016 - 2017 * - * The Common Application Connection Establishment Phase + * The Common Application Connection Establishment Protocol * * Sander Vrijders * Dimitri Staessens @@ -24,7 +24,7 @@ #ifndef OUROBOROS_CACEP_H #define OUROBOROS_CACEP_H -#include +#include enum proto_concrete_syntax { PROTO_GPB = 0, @@ -33,27 +33,22 @@ enum proto_concrete_syntax { }; struct conn_info{ - struct { - char * protocol; - uint32_t pref_version; - enum proto_concrete_syntax pref_syntax; - } proto; - char * name; - uint64_t addr; + char ae_name[64]; + char protocol[64]; + uint32_t pref_version; + enum proto_concrete_syntax pref_syntax; + union { + char name[64]; + uint64_t addr; + } ae; }; -int conn_info_init(struct conn_info * info); +int cacep_connect(int fd, + const struct conn_info * in, + struct conn_info * out); -void conn_info_fini(struct conn_info * info); - -struct conn_info * cacep_auth(int fd, - enum pol_cacep pc, - const struct conn_info * info, - const void * auth); - -struct conn_info * cacep_auth_wait(int fd, - enum pol_cacep pc, - const struct conn_info * info, - const void * auth); +int cacep_listen(int fd, + const struct conn_info * in, + struct conn_info * out); #endif /* OUROBOROS_CACEP_H */ diff --git a/include/ouroboros/irm_config.h b/include/ouroboros/irm_config.h index 9a05a434..5e3c84b4 100644 --- a/include/ouroboros/irm_config.h +++ b/include/ouroboros/irm_config.h @@ -47,11 +47,6 @@ enum pol_gam { COMPLETE = 0 }; -enum pol_cacep { - ANONYMOUS_AUTH = 0, - SIMPLE_AUTH -}; - struct dif_config { char * dif_name; enum ipcp_type type; diff --git a/src/ipcpd/normal/cdap_flow.c b/src/ipcpd/normal/cdap_flow.c index 3d1b2b22..d3d98884 100644 --- a/src/ipcpd/normal/cdap_flow.c +++ b/src/ipcpd/normal/cdap_flow.c @@ -29,6 +29,7 @@ #include "cdap_flow.h" #include +#include #include static void cdap_flow_destroy(struct cdap_flow * flow) @@ -37,20 +38,15 @@ static void cdap_flow_destroy(struct cdap_flow * flow) if (flow->ci != NULL) cdap_destroy(flow->ci); - if (flow->info != NULL) { - conn_info_fini(flow->info); - free(flow->info); - } free(flow); } -struct cdap_flow * cdap_flow_arr(int fd, +struct cdap_flow * cdap_flow_arr(int fd, int resp, - enum pol_cacep pc, const struct conn_info * info) { - struct cdap_flow * flow; + struct cdap_flow * flow; if (flow_alloc_resp(fd, resp) < 0) { log_err("Could not respond to new flow."); @@ -66,12 +62,13 @@ struct cdap_flow * cdap_flow_arr(int fd, return NULL; } + memset(&flow->info, 0, sizeof(flow->info)); + flow->fd = fd; flow->ci = NULL; - flow->info = cacep_auth_wait(fd, pc, info, NULL); - if (flow->info == NULL) { - log_err("Other side failed to authenticate."); + if (cacep_listen(fd, info, &flow->info)) { + log_err("Error establishing application connection."); cdap_flow_destroy(flow); return NULL; } @@ -88,7 +85,6 @@ struct cdap_flow * cdap_flow_arr(int fd, struct cdap_flow * cdap_flow_alloc(const char * dst_name, qosspec_t * qs, - enum pol_cacep pc, const struct conn_info * info) { struct cdap_flow * flow; @@ -119,12 +115,13 @@ struct cdap_flow * cdap_flow_alloc(const char * dst_name, return NULL; } + memset(&flow->info, 0, sizeof(flow->info)); + flow->fd = fd; flow->ci = NULL; - flow->info = cacep_auth(fd, pc, info, NULL); - if (flow->info == NULL) { - log_err("Failed to authenticate."); + if (cacep_connect(fd, info, &flow->info)) { + log_err("Failed to connect to application."); cdap_flow_dealloc(flow); return NULL; } diff --git a/src/ipcpd/normal/cdap_flow.h b/src/ipcpd/normal/cdap_flow.h index 8aa26dc0..761f3463 100644 --- a/src/ipcpd/normal/cdap_flow.h +++ b/src/ipcpd/normal/cdap_flow.h @@ -28,19 +28,17 @@ #include struct cdap_flow { - int fd; - struct cdap * ci; - struct conn_info * info; + int fd; + struct cdap * ci; + struct conn_info info; }; struct cdap_flow * cdap_flow_arr(int fd, int resp, - enum pol_cacep pc, const struct conn_info * info); struct cdap_flow * cdap_flow_alloc(const char * dst_name, qosspec_t * qs, - enum pol_cacep pc, const struct conn_info * info); void cdap_flow_dealloc(struct cdap_flow * flow); diff --git a/src/ipcpd/normal/enroll.c b/src/ipcpd/normal/enroll.c index b420533e..5c7ebd7e 100644 --- a/src/ipcpd/normal/enroll.c +++ b/src/ipcpd/normal/enroll.c @@ -44,7 +44,7 @@ int enroll_handle(int fd) { struct cdap_flow * flow; - struct conn_info info; + struct conn_info info; cdap_key_t key; enum cdap_opcode oc; char * name; @@ -61,27 +61,20 @@ int enroll_handle(int fd) char * members_ro = MEMBERS_PATH; char * dif_ro = DIF_PATH; - conn_info_init(&info); + memset(&info, 0, sizeof(info)); - info.proto.protocol = strdup(CDAP_PROTO); - if (info.proto.protocol == NULL) { - conn_info_fini(&info); - return -ENOMEM; - } - - info.proto.pref_version = 1; - info.proto.pref_syntax = PROTO_GPB; + strcpy(info.ae_name, ENROLL_AE); + strcpy(info.protocol, CDAP_PROTO); + info.pref_version = 1; + info.pref_syntax = PROTO_GPB; - flow = cdap_flow_arr(fd, 0, ANONYMOUS_AUTH, &info); + flow = cdap_flow_arr(fd, 0, &info); if (flow == NULL) { log_err("Failed to auth enrollment request."); - conn_info_fini(&info); flow_dealloc(fd); return -1; } - conn_info_fini(&info); - while (!(boot_r && members_r && dif_name_r)) { key = cdap_request_wait(flow->ci, &oc, &name, &data, (size_t *) &len , &flags); @@ -156,7 +149,7 @@ int enroll_handle(int fd) int enroll_boot(char * dst_name) { struct cdap_flow * flow; - struct conn_info info; + struct conn_info info; cdap_key_t key; uint8_t * data; size_t len; @@ -170,26 +163,19 @@ int enroll_boot(char * dst_name) char * members_ro = MEMBERS_PATH; char * dif_ro = DIF_PATH; - conn_info_init(&info); + memset(&info, 0, sizeof(info)); - info.proto.protocol = strdup(CDAP_PROTO); - if (info.proto.protocol == NULL) { - conn_info_fini(&info); - return -ENOMEM; - } - - info.proto.pref_version = 1; - info.proto.pref_syntax = PROTO_GPB; + strcpy(info.ae_name, ENROLL_AE); + strcpy(info.protocol, CDAP_PROTO); + info.pref_version = 1; + info.pref_syntax = PROTO_GPB; - flow = cdap_flow_alloc(dst_name, NULL, ANONYMOUS_AUTH, &info); + flow = cdap_flow_alloc(dst_name, NULL, &info); if (flow == NULL) { log_err("Failed to allocate flow for enrollment request."); - conn_info_fini(&info); return -1; } - conn_info_fini(&info); - log_dbg("Getting boot information from %s.", dst_name); clock_gettime(CLOCK_REALTIME, &t0); diff --git a/src/ipcpd/normal/fmgr.c b/src/ipcpd/normal/fmgr.c index 071a895f..0c927fc7 100644 --- a/src/ipcpd/normal/fmgr.c +++ b/src/ipcpd/normal/fmgr.c @@ -249,7 +249,6 @@ static void fmgr_destroy_flows(void) int fmgr_init(void) { - enum pol_cacep pc; enum pol_gam pg; int i; @@ -292,15 +291,6 @@ int fmgr_init(void) return -1; } - if (rib_read(BOOT_PATH "/dt/gam/cacep", &pc, sizeof(pc)) - != sizeof(pc)) { - log_err("Failed to read CACEP policy for ribmgr gam."); - return -1; - } - - /* FIXME: Implement cacep policies */ - (void) pc; - fmgr.gam = gam_create(pg); if (fmgr.gam == NULL) { log_err("Failed to create graph adjacency manager."); @@ -345,7 +335,6 @@ void fmgr_fini() flow_dealloc(flow->fd); ipcp_flow_get_qoscube(flow->fd, &cube); flow_set_del(fmgr.nm1_set[cube], flow->fd); - free(flow->info->name); free(flow->info); free(flow); } diff --git a/src/ipcpd/normal/gam.c b/src/ipcpd/normal/gam.c index 2479fa62..bdfc8cb9 100644 --- a/src/ipcpd/normal/gam.c +++ b/src/ipcpd/normal/gam.c @@ -120,7 +120,6 @@ void gam_destroy(struct gam * instance) list_for_each_safe(p, n, &instance->gas) { struct ga * e = list_entry(p, struct ga, next); list_del(&e->next); - free(e->info->name); free(e->info); free(e); } @@ -156,7 +155,7 @@ static int add_ga(struct gam * instance, pthread_cond_signal(&instance->gas_cond); pthread_mutex_unlock(&instance->gas_lock); - log_info("Added flow to %s.", info->name); + log_info("Added flow."); return 0; } @@ -166,7 +165,7 @@ int gam_flow_arr(struct gam * instance, qosspec_t qs) { struct conn_info * rcv_info; - struct conn_info snd_info; + struct conn_info snd_info; if (flow_alloc_resp(fd, instance->ops->accept_new_flow(instance->ops_o)) < 0) { @@ -174,34 +173,29 @@ int gam_flow_arr(struct gam * instance, return -1; } - conn_info_init(&snd_info); - snd_info.proto.protocol = strdup(CDAP_PROTO); - if (snd_info.proto.protocol == NULL) { - conn_info_fini(&snd_info); + rcv_info = malloc(sizeof(*rcv_info)); + if (rcv_info == NULL) return -ENOMEM; - } - snd_info.proto.pref_version = 1; - snd_info.proto.pref_syntax = PROTO_GPB; - snd_info.addr = ipcpi.address; - snd_info.name = strdup(ipcpi.name); - if (snd_info.name == NULL) { - conn_info_fini(&snd_info); - return -ENOMEM; - } + memset(&snd_info, 0, sizeof(snd_info)); + memset(rcv_info, 0, sizeof(*rcv_info)); + + /* FIXME: send correct AE */ + strcpy(snd_info.ae_name, "FIXME:CORRECT_AE"); + strcpy(snd_info.protocol, CDAP_PROTO); + snd_info.pref_version = 1; + snd_info.pref_syntax = PROTO_GPB; + snd_info.ae.addr = ipcpi.address; - rcv_info = cacep_auth_wait(fd, SIMPLE_AUTH, &snd_info, NULL); - if (rcv_info == NULL) { - log_err("Other side failed to authenticate."); - conn_info_fini(&snd_info); + if (cacep_listen(fd, &snd_info, rcv_info)) { + log_err("Failed to create application connection."); + flow_dealloc(fd); + free(rcv_info); return -1; } - conn_info_fini(&snd_info); - if (instance->ops->accept_flow(instance->ops_o, qs, rcv_info)) { flow_dealloc(fd); - conn_info_fini(rcv_info); free(rcv_info); return 0; } @@ -209,7 +203,6 @@ int gam_flow_arr(struct gam * instance, if (add_ga(instance, fd, qs, rcv_info)) { log_err("Failed to add ga to graph adjacency manager list."); flow_dealloc(fd); - conn_info_fini(rcv_info); free(rcv_info); return -1; } @@ -222,11 +215,15 @@ int gam_flow_alloc(struct gam * instance, qosspec_t qs) { struct conn_info * rcv_info; - struct conn_info snd_info; + struct conn_info snd_info; int fd; log_dbg("Allocating flow to %s.", dst_name); + rcv_info = malloc(sizeof(*rcv_info)); + if (rcv_info == NULL) + return -ENOMEM; + fd = flow_alloc(dst_name, NULL); if (fd < 0) { log_err("Failed to allocate flow to %s.", dst_name); @@ -239,34 +236,25 @@ int gam_flow_alloc(struct gam * instance, return -1; } - conn_info_init(&snd_info); - snd_info.proto.protocol = strdup(CDAP_PROTO); - if (snd_info.proto.protocol == NULL) { - conn_info_fini(&snd_info); - return -ENOMEM; - } + memset(&snd_info, 0, sizeof(snd_info)); + memset(rcv_info, 0, sizeof(*rcv_info)); - snd_info.proto.pref_version = 1; - snd_info.proto.pref_syntax = PROTO_GPB; - snd_info.addr = ipcpi.address; - snd_info.name = strdup(ipcpi.name); - if (snd_info.name == NULL) { - conn_info_fini(&snd_info); - return -ENOMEM; - } + /* FIXME: send correct AE */ + strcpy(snd_info.ae_name, "FIXME:CORRECT_AE"); + strcpy(snd_info.protocol, CDAP_PROTO); + snd_info.pref_version = 1; + snd_info.pref_syntax = PROTO_GPB; + snd_info.ae.addr = ipcpi.address; - rcv_info = cacep_auth(fd, SIMPLE_AUTH, &snd_info, NULL); - if (rcv_info == NULL) { - log_err("Other side failed to authenticate."); - conn_info_fini(&snd_info); + if (cacep_connect(fd, &snd_info, rcv_info)) { + log_err("Failed to create application connection."); + flow_dealloc(fd); + free(rcv_info); return -1; } - conn_info_fini(&snd_info); - if (instance->ops->accept_flow(instance->ops_o, qs, rcv_info)) { flow_dealloc(fd); - conn_info_fini(rcv_info); free(rcv_info); return 0; } @@ -274,7 +262,6 @@ int gam_flow_alloc(struct gam * instance, if (add_ga(instance, fd, qs, rcv_info)) { log_err("Failed to add GA to graph adjacency manager list."); flow_dealloc(fd); - conn_info_fini(rcv_info); free(rcv_info); return -1; } @@ -282,10 +269,10 @@ int gam_flow_alloc(struct gam * instance, return 0; } -int gam_flow_wait(struct gam * instance, - int * fd, +int gam_flow_wait(struct gam * instance, + int * fd, struct conn_info ** info, - qosspec_t * qs) + qosspec_t * qs) { struct ga * ga; diff --git a/src/ipcpd/normal/main.c b/src/ipcpd/normal/main.c index 939544c3..c75a74d6 100644 --- a/src/ipcpd/normal/main.c +++ b/src/ipcpd/normal/main.c @@ -336,11 +336,6 @@ int normal_rib_init(void) static int normal_ipcp_bootstrap(struct dif_config * conf) { - /* FIXME: get CACEP policies from conf */ - enum pol_cacep pol = SIMPLE_AUTH; - - (void) pol; - assert(conf); assert(conf->type == THIS_TYPE); @@ -388,12 +383,6 @@ static int normal_ipcp_bootstrap(struct dif_config * conf) rib_write(BOOT_PATH "/rm/gam/type", &conf->rm_gam_type, sizeof(conf->rm_gam_type)) || - rib_write(BOOT_PATH "/rm/gam/cacep", - &pol, - sizeof(pol)) || - rib_write(BOOT_PATH "/dt/gam/cacep", - &pol, - sizeof(pol)) || rib_write(BOOT_PATH "/addr_auth/type", &conf->addr_auth_type, sizeof(conf->addr_auth_type))) { diff --git a/src/ipcpd/normal/pol/complete.c b/src/ipcpd/normal/pol/complete.c index 1d4811d2..68f43e81 100644 --- a/src/ipcpd/normal/pol/complete.c +++ b/src/ipcpd/normal/pol/complete.c @@ -167,7 +167,8 @@ int complete_accept_flow(void * o, list_for_each(pos, &complete->neighbors) { struct neighbor * e = list_entry(pos, struct neighbor, next); - if (strcmp(e->neighbor, info->name) == 0) { + /* FIXME: figure out union type and check name or address */ + if (strcmp(e->neighbor, info->ae.name) == 0) { pthread_mutex_unlock(&complete->neighbors_lock); return -1; } @@ -185,7 +186,8 @@ int complete_accept_flow(void * o, list_head_init(&n->next); - n->neighbor = strdup(info->name); + /* FIXME: figure out union type and check name or address */ + n->neighbor = strdup(info->ae.name); if (n->neighbor == NULL) { pthread_mutex_unlock(&complete->neighbors_lock); free(n); diff --git a/src/ipcpd/normal/ribmgr.c b/src/ipcpd/normal/ribmgr.c index 1436a7d4..25f1687e 100644 --- a/src/ipcpd/normal/ribmgr.c +++ b/src/ipcpd/normal/ribmgr.c @@ -53,7 +53,6 @@ struct { int ribmgr_init(void) { - enum pol_cacep pc; enum pol_gam pg; if (rib_read(BOOT_PATH "/rm/gam/type", &pg, sizeof(pg)) @@ -62,15 +61,6 @@ int ribmgr_init(void) return -1; } - if (rib_read(BOOT_PATH "/rm/gam/cacep", &pc, sizeof(pc)) - != sizeof(pc)) { - log_err("Failed to read CACEP policy for ribmgr gam."); - return -1; - } - - /* FIXME: Implement cacep policies */ - (void) pc; - ribmgr.gam = gam_create(pg); if (ribmgr.gam == NULL) { log_err("Failed to create gam."); diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index fcea0fb2..03452705 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -10,12 +10,7 @@ protobuf_generate_c(DIF_CONFIG_PROTO_SRCS DIF_CONFIG_PROTO_HDRS dif_config.proto) protobuf_generate_c(CDAP_PROTO_SRCS CDAP_PROTO_HDRS cdap.proto) protobuf_generate_c(RO_PROTO_SRCS RO_PROTO_HDRS ro.proto) -protobuf_generate_c(CACEP_PROTO_PROTO_SRCS CACEP_CDAP_PROTO_HDRS - pol/cacep_proto.proto) -protobuf_generate_c(CACEP_ANONYMOUS_AUTH_PROTO_SRCS - CACEP_ANONYMOUS_AUTH_PROTO_HDRS pol/cacep_anonymous_auth.proto) -protobuf_generate_c(CACEP_SIMPLE_AUTH_PROTO_SRCS CACEP_SIMPLE_AUTH_PROTO_HDRS - pol/cacep_simple_auth.proto) +protobuf_generate_c(CACEP_PROTO_SRCS CACEP_PROTO_HDRS cacep.proto) if(NOT APPLE) find_library(LIBRT_LIBRARIES rt) @@ -54,16 +49,11 @@ set(SOURCE_FILES sockets.c time_utils.c utils.c - # Add policies last - pol/cacep_proto.c - pol/cacep_anonymous_auth.c - pol/cacep_simple_auth.c ) add_library(ouroboros SHARED ${SOURCE_FILES} ${IRM_PROTO_SRCS} ${IPCP_PROTO_SRCS} ${DIF_CONFIG_PROTO_SRCS} ${CDAP_PROTO_SRCS} - ${CACEP_PROTO_PROTO_SRCS} ${CACEP_ANONYMOUS_AUTH_PROTO_SRCS} - ${CACEP_SIMPLE_AUTH_PROTO_SRCS} ${RO_PROTO_SRCS}) + ${CACEP_PROTO_SRCS} ${RO_PROTO_SRCS}) target_link_libraries(ouroboros ${LIBRT_LIBRARIES} ${LIBPTHREAD_LIBRARIES} ${PROTOBUF_C_LIBRARY}) diff --git a/src/lib/cacep.c b/src/lib/cacep.c index 89bd05e7..badeccc0 100644 --- a/src/lib/cacep.c +++ b/src/lib/cacep.c @@ -1,9 +1,10 @@ /* * Ouroboros - Copyright (C) 2016 - 2017 * - * The Common Application Connection Establishment Phase + * The Common Application Connection Establishment Protocol * - * Sander Vrijders + * Dimitri Staessens + * Sander Vrijders * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -20,91 +21,118 @@ * 02110-1301 USA */ -#define OUROBOROS_PREFIX "cacep" - #include #include #include #include -#include - -#include "pol/cacep_anonymous_auth.h" -#include "pol/cacep_simple_auth.h" #include #include -#define BUF_SIZE 2048 +#include "cacep.pb-c.h" +typedef CacepMsg cacep_msg_t; -int conn_info_init(struct conn_info * info) +#define BUF_SIZE 64 + +int read_msg(int fd, + struct conn_info * info) { - if (info == NULL) - return -EINVAL; + uint8_t buf[BUF_SIZE]; + cacep_msg_t * msg; + ssize_t len; + + len = flow_read(fd, buf, BUF_SIZE); + if (len < 0) + return -1; + + msg = cacep_msg__unpack(NULL, len, buf); + if (msg == NULL) + return -1; + + strcpy(info->protocol, msg->protocol); + + info->pref_version = msg->pref_version; + info->pref_syntax = msg->pref_syntax; - info->proto.protocol = NULL; - info->name = NULL; + cacep_msg__free_unpacked(msg, NULL); return 0; } -void conn_info_fini(struct conn_info * info) +static int send_msg(int fd, + const struct conn_info * info) { - if (info == NULL) - return; + cacep_msg_t msg = CACEP_MSG__INIT; + uint8_t * data = NULL; + size_t len = 0; - if (info->proto.protocol != NULL) { - free(info->proto.protocol); - info->proto.protocol = NULL; - } + msg.ae_name = (char *) info->ae_name; + msg.protocol = (char *) info->protocol; + msg.pref_version = info->pref_version; + msg.pref_syntax = info->pref_syntax; + if (msg.pref_syntax < 0) + return -1; + + len = cacep_msg__get_packed_size(&msg); + if (len == 0) + return -1; + + data = malloc(len); + if (data == NULL) + return -ENOMEM; + + cacep_msg__pack(&msg, data); - if (info->name != NULL) { - free(info->name); - info->name = NULL; + if (flow_write(fd, data, len) < 0) { + free(data); + return -1; } + + free(data); + + return 0; } -struct conn_info * cacep_auth(int fd, - enum pol_cacep pc, - const struct conn_info * info, - const void * auth) +int cacep_connect(int fd, + const struct conn_info * in, + struct conn_info * out) { - if (info == NULL) { - log_err("No info provided."); - return NULL; - } + if (in == NULL || out == NULL) + return -EINVAL; - switch (pc) { - case ANONYMOUS_AUTH: - return cacep_anonymous_auth(fd, info, auth); - case SIMPLE_AUTH: - if (info == NULL) - return NULL; - return cacep_simple_auth_auth(fd, info, auth); - default: - log_err("Unsupported CACEP policy."); - return NULL; - } + if (send_msg(fd, in)) + return -1; + + if (read_msg(fd, out)) + return -1; + + if (strcmp(in->ae_name, out->ae_name) || + strcmp(in->protocol, out->protocol) || + in->pref_version != out->pref_version || + in->pref_syntax != out->pref_syntax) + return -EPROTO; + + return 0; } -struct conn_info * cacep_auth_wait(int fd, - enum pol_cacep pc, - const struct conn_info * info, - const void * auth) +int cacep_listen(int fd, + const struct conn_info * in, + struct conn_info * out) { - if (info == NULL) { - log_err("No info provided."); - return NULL; - } + if (in == NULL || out == NULL) + return -EINVAL; - switch (pc) { - case ANONYMOUS_AUTH: - return cacep_anonymous_auth_wait(fd, info, auth); - case SIMPLE_AUTH: - if (info == NULL) - return NULL; - return cacep_simple_auth_auth_wait(fd, info, auth); - default: - log_err("Unsupported CACEP policy."); - return NULL; - } + if (send_msg(fd, in)) + return -1; + + if (read_msg(fd, out)) + return -1; + + if (strcmp(in->ae_name, out->ae_name) || + strcmp(in->protocol, out->protocol) || + in->pref_version != out->pref_version || + in->pref_syntax != out->pref_syntax) + return -EPROTO; + + return 0; } diff --git a/src/lib/cacep.proto b/src/lib/cacep.proto new file mode 100644 index 00000000..3e1291f6 --- /dev/null +++ b/src/lib/cacep.proto @@ -0,0 +1,33 @@ +/* + * Ouroboros - Copyright (C) 2016 - 2017 + * + * Message for Connection Information in CACEP + * + * Dimitri Staessens + * Sander Vrijders + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +syntax = "proto2"; + +message cacep_msg { + required string ae_name = 1; + required string protocol = 2; + required int32 pref_version = 3; + repeated int32 supp_version = 4; + required int32 pref_syntax = 5; + repeated int32 supp_syntax = 6; +} \ No newline at end of file diff --git a/src/lib/pol/cacep_anonymous_auth.c b/src/lib/pol/cacep_anonymous_auth.c deleted file mode 100644 index 44c7bd17..00000000 --- a/src/lib/pol/cacep_anonymous_auth.c +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Ouroboros - Copyright (C) 2016 - 2017 - * - * Anonymous policy for CACEP - * - * Dimitri Staessens - * Sander Vrijders - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -#include -#include -#include -#include -#include - -#include "cacep_proto.h" -#include "cacep_anonymous_auth.h" - -#include -#include -#include -#include - -#include "cacep_anonymous_auth.pb-c.h" -typedef CacepAnonymousAuthMsg cacep_anonymous_auth_msg_t; -typedef CacepProtoMsg cacep_proto_msg_t; - -#define BUF_SIZE 2048 -#define NAME_LEN 8 - -/* this policy generates a hex string */ -static struct conn_info * anonymous_info(void) -{ - struct conn_info * info; - struct timespec t; - - info = malloc(sizeof(*info)); - if (info == NULL) - return NULL; - - conn_info_init(info); - - info->name = malloc(NAME_LEN + 1); - if (info->name == NULL) { - free(info); - return NULL; - } - - clock_gettime(CLOCK_REALTIME, &t); - srand(t.tv_nsec); - - sprintf(info->name, "%8x", - (uint32_t)((rand() % RAND_MAX) & 0xFFFFFFFF)); - - info->addr = 0; - - return info; -} - -static struct conn_info * read_msg(int fd) -{ - struct conn_info * tmp; - uint8_t buf[BUF_SIZE]; - cacep_anonymous_auth_msg_t * msg; - ssize_t len; - - len = flow_read(fd, buf, BUF_SIZE); - if (len < 0) - return NULL; - - msg = cacep_anonymous_auth_msg__unpack(NULL, len, buf); - if (msg == NULL) - return NULL; - - tmp = anonymous_info(); - if (tmp == NULL) { - cacep_anonymous_auth_msg__free_unpacked(msg, NULL); - return NULL; - } - - tmp->proto.protocol = strdup(msg->proto->protocol); - if (tmp->proto.protocol == NULL) { - free(tmp); - cacep_anonymous_auth_msg__free_unpacked(msg, NULL); - return NULL; - } - - tmp->proto.pref_version = msg->proto->pref_version; - tmp->proto.pref_syntax = code_to_syntax(msg->proto->pref_syntax); - if (tmp->proto.pref_syntax < 0) { - free(tmp->proto.protocol); - free(tmp); - cacep_anonymous_auth_msg__free_unpacked(msg, NULL); - return NULL; - } - - cacep_anonymous_auth_msg__free_unpacked(msg, NULL); - - return tmp; -} - -static int send_msg(int fd, - const struct conn_info * info) -{ - cacep_anonymous_auth_msg_t msg = CACEP_ANONYMOUS_AUTH_MSG__INIT; - cacep_proto_msg_t cmsg = CACEP_PROTO_MSG__INIT; - int ret = 0; - uint8_t * data = NULL; - size_t len = 0; - - cmsg.protocol = info->proto.protocol; - cmsg.pref_version = info->proto.pref_version; - cmsg.pref_syntax = syntax_to_code(info->proto.pref_syntax); - if (cmsg.pref_syntax < 0) - return -1; - - msg.proto = &cmsg; - - len = cacep_anonymous_auth_msg__get_packed_size(&msg); - if (len == 0) - return -1; - - data = malloc(len); - if (data == NULL) - return -ENOMEM; - - cacep_anonymous_auth_msg__pack(&msg, data); - - if (flow_write(fd, data, len) < 0) - ret = -1; - - free(data); - - return ret; -} - -struct conn_info * cacep_anonymous_auth(int fd, - const struct conn_info * info, - const void * auth) -{ - struct conn_info * tmp; - - assert(info); - - (void) auth; - - if (send_msg(fd, info)) - return NULL; - - tmp = read_msg(fd); - if (tmp == NULL) - return NULL; - - if (strcmp(info->proto.protocol, tmp->proto.protocol) || - info->proto.pref_version != tmp->proto.pref_version || - info->proto.pref_syntax != tmp->proto.pref_syntax) { - conn_info_fini(tmp); - free(tmp); - return NULL; - } - - return tmp; -} - - -struct conn_info * cacep_anonymous_auth_wait(int fd, - const struct conn_info * info, - const void * auth) -{ - struct conn_info * tmp; - - assert(info); - - (void) auth; - - tmp = read_msg(fd); - if (tmp == NULL) - return NULL; - - if (send_msg(fd, info)) { - conn_info_fini(tmp); - free(tmp); - return NULL; - } - - if (strcmp(info->proto.protocol, tmp->proto.protocol) || - info->proto.pref_version != tmp->proto.pref_version || - info->proto.pref_syntax != tmp->proto.pref_syntax) { - conn_info_fini(tmp); - free(tmp); - return NULL; - } - - return tmp; -} diff --git a/src/lib/pol/cacep_anonymous_auth.h b/src/lib/pol/cacep_anonymous_auth.h deleted file mode 100644 index ca47b1b8..00000000 --- a/src/lib/pol/cacep_anonymous_auth.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Ouroboros - Copyright (C) 2016 - 2017 - * - * Anonymous policy for CACEP - * - * Dimitri Staessens - * Sander Vrijders - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -#ifndef OUROBOROS_LIB_CACEP_ANONYMOUS_AUTH_H -#define OUROBOROS_LIB_CACEP_ANONYMOUS_AUTH_H - -struct conn_info * cacep_anonymous_auth(int fd, - const struct conn_info * info, - const void * auth); - -struct conn_info * cacep_anonymous_auth_wait(int fd, - const struct conn_info * info, - const void * auth); - -#endif /* OUROBOROS_LIB_CACEP_ANONYMOUS_AUTH_H */ diff --git a/src/lib/pol/cacep_anonymous_auth.proto b/src/lib/pol/cacep_anonymous_auth.proto deleted file mode 100644 index 79734e28..00000000 --- a/src/lib/pol/cacep_anonymous_auth.proto +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Ouroboros - Copyright (C) 2016 - 2017 - * - * Message for no authentication CACEP policy - * - * Dimitri Staessens - * Sander Vrijders - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -syntax = "proto2"; - -import "cacep_proto.proto"; - -message cacep_anonymous_auth_msg { - required cacep_proto_msg proto = 1; -} \ No newline at end of file diff --git a/src/lib/pol/cacep_proto.c b/src/lib/pol/cacep_proto.c deleted file mode 100644 index 9990a05a..00000000 --- a/src/lib/pol/cacep_proto.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Ouroboros - Copyright (C) 2016 - 2017 - * - * CACEP - Read/Write Protocol info - * - * Sander Vrijders - * Dimitri Staessens - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -#include "cacep_proto.h" - -enum proto_concrete_syntax code_to_syntax(int code) -{ - switch(code) { - case PROTO_CONCRETE_SYNTAX_CODE__GPB: - return PROTO_GPB; - case PROTO_CONCRETE_SYNTAX_CODE__ASN_1: - return PROTO_ASN_1; - case PROTO_CONCRETE_SYNTAX_CODE__FIXED: - return PROTO_FIXED; - default: - return -1; - } -} - -int syntax_to_code(enum proto_concrete_syntax stx) -{ - switch(stx) { - case PROTO_GPB: - return PROTO_CONCRETE_SYNTAX_CODE__GPB; - case PROTO_ASN_1: - return PROTO_CONCRETE_SYNTAX_CODE__ASN_1; - case PROTO_FIXED: - return PROTO_CONCRETE_SYNTAX_CODE__FIXED; - default: - return -1; - } -} diff --git a/src/lib/pol/cacep_proto.h b/src/lib/pol/cacep_proto.h deleted file mode 100644 index bfb1b247..00000000 --- a/src/lib/pol/cacep_proto.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Ouroboros - Copyright (C) 2016 - 2017 - * - * CACEP - Convert syntax to msg code and back - * - * Sander Vrijders - * Dimitri Staessens - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -#ifndef OUROBOROS_LIB_CACEP_CDAP_H -#define OUROBOROS_LIB_CACEP_CDAP_H - -#include -#include - -#include "cacep_proto.pb-c.h" - -enum proto_concrete_syntax code_to_syntax(int code); - -int syntax_to_code(enum proto_concrete_syntax stx); - -#endif /* OUROBOROS_LIB_CACEP_CDAP_H */ diff --git a/src/lib/pol/cacep_proto.proto b/src/lib/pol/cacep_proto.proto deleted file mode 100644 index f313bfc1..00000000 --- a/src/lib/pol/cacep_proto.proto +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Ouroboros - Copyright (C) 2016 - 2017 - * - * Message for setting Protocol information in CACEP - * - * Dimitri Staessens - * Sander Vrijders - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -syntax = "proto2"; - -enum proto_concrete_syntax_code { - GPB = 1; - ASN_1 = 2; - FIXED = 3; -} - -message cacep_proto_msg { - required string protocol = 1; - required int32 pref_version = 2; - repeated int32 supp_version = 3; - required proto_concrete_syntax_code pref_syntax = 4; - repeated proto_concrete_syntax_code supp_syntax = 5; -} diff --git a/src/lib/pol/cacep_simple_auth.c b/src/lib/pol/cacep_simple_auth.c deleted file mode 100644 index 69189114..00000000 --- a/src/lib/pol/cacep_simple_auth.c +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Ouroboros - Copyright (C) 2016 - 2017 - * - * Simple authentication policy for CACEP - * - * Dimitri Staessens - * Sander Vrijders - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -#include -#include -#include -#include - -#include "cacep_proto.h" -#include "cacep_simple_auth.h" - -#include -#include - -#include "cacep_simple_auth.pb-c.h" -typedef CacepSimpleAuthMsg cacep_simple_auth_msg_t; -typedef CacepProtoMsg cacep_proto_msg_t; - -#define BUF_SIZE 2048 - -static struct conn_info * read_msg(int fd) -{ - struct conn_info * tmp; - uint8_t buf[BUF_SIZE]; - cacep_simple_auth_msg_t * msg; - ssize_t len; - - len = flow_read(fd, buf, BUF_SIZE); - if (len < 0) - return NULL; - - msg = cacep_simple_auth_msg__unpack(NULL, len, buf); - if (msg == NULL) - return NULL; - - tmp = malloc(sizeof(*tmp)); - if (tmp == NULL) { - cacep_simple_auth_msg__free_unpacked(msg, NULL); - return NULL; - } - - conn_info_init(tmp); - - tmp->addr = msg->addr; - tmp->name = strdup(msg->name); - if (tmp->name == NULL) { - free(tmp); - cacep_simple_auth_msg__free_unpacked(msg, NULL); - return NULL; - } - - tmp->proto.protocol = strdup(msg->proto->protocol); - if (tmp->proto.protocol == NULL) { - conn_info_fini(tmp); - free(tmp); - cacep_simple_auth_msg__free_unpacked(msg, NULL); - return NULL; - } - - tmp->proto.pref_version = msg->proto->pref_version; - tmp->proto.pref_syntax = code_to_syntax(msg->proto->pref_syntax); - if (tmp->proto.pref_syntax < 0) { - conn_info_fini(tmp); - free(tmp); - cacep_simple_auth_msg__free_unpacked(msg, NULL); - return NULL; - } - - cacep_simple_auth_msg__free_unpacked(msg, NULL); - - return tmp; -} - -static int send_msg(int fd, - const struct conn_info * info) -{ - cacep_simple_auth_msg_t msg = CACEP_SIMPLE_AUTH_MSG__INIT; - cacep_proto_msg_t cmsg = CACEP_PROTO_MSG__INIT; - int ret = 0; - uint8_t * data = NULL; - size_t len = 0; - - cmsg.protocol = info->proto.protocol; - cmsg.pref_version = info->proto.pref_version; - cmsg.pref_syntax = syntax_to_code(info->proto.pref_syntax); - if (cmsg.pref_syntax < 0) - return -1; - - msg.proto = &cmsg; - msg.name = info->name; - msg.addr = info->addr; - - len = cacep_simple_auth_msg__get_packed_size(&msg); - if (len == 0) - return -1; - - data = malloc(len); - if (data == NULL) - return -ENOMEM; - - cacep_simple_auth_msg__pack(&msg, data); - - if (flow_write(fd, data, len) < 0) - ret = -1; - - free(data); - - return ret; -} - -struct conn_info * cacep_simple_auth_auth(int fd, - const struct conn_info * info, - const void * auth) -{ - struct conn_info * tmp; - - assert(info); - - /* This policy does not need info to authenticate */ - (void) auth; - - if (send_msg(fd, info)) - return NULL; - - tmp = read_msg(fd); - if (tmp == NULL) - return NULL; - - if (strcmp(info->proto.protocol, tmp->proto.protocol) || - info->proto.pref_version != tmp->proto.pref_version || - info->proto.pref_syntax != tmp->proto.pref_syntax) { - conn_info_fini(tmp); - free(tmp); - return NULL; - } - - return tmp; -} - - -struct conn_info * cacep_simple_auth_auth_wait(int fd, - const struct conn_info * info, - const void * auth) -{ - struct conn_info * tmp; - - assert(info); - - (void) auth; - - tmp = read_msg(fd); - if (tmp == NULL) - return NULL; - - if (send_msg(fd, info)) { - conn_info_fini(tmp); - free(tmp); - return NULL; - } - - if (strcmp(info->proto.protocol, tmp->proto.protocol) || - info->proto.pref_version != tmp->proto.pref_version || - info->proto.pref_syntax != tmp->proto.pref_syntax) { - conn_info_fini(tmp); - free(tmp); - return NULL; - } - - return tmp; -} diff --git a/src/lib/pol/cacep_simple_auth.h b/src/lib/pol/cacep_simple_auth.h deleted file mode 100644 index 31398a68..00000000 --- a/src/lib/pol/cacep_simple_auth.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Ouroboros - Copyright (C) 2016 - 2017 - * - * Simple authentication policy for CACEP - * - * Dimitri Staessens - * Sander Vrijders - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -#ifndef OUROBOROS_LIB_CACEP_SIMPLE_AUTH_H -#define OUROBOROS_LIB_CACEP_SIMPLE_AUTH_H - -struct conn_info * cacep_simple_auth_auth(int fd, - const struct conn_info * info, - const void * auth); - -struct conn_info * cacep_simple_auth_auth_wait(int fd, - const struct conn_info * info, - const void * auth); - -#endif /* OUROBOROS_LIB_CACEP_SIMPLE_AUTH_H */ diff --git a/src/lib/pol/cacep_simple_auth.proto b/src/lib/pol/cacep_simple_auth.proto deleted file mode 100644 index 1a1e7ea8..00000000 --- a/src/lib/pol/cacep_simple_auth.proto +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Ouroboros - Copyright (C) 2016 - 2017 - * - * Message for no authentication CACEP policy - * - * Dimitri Staessens - * Sander Vrijders - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * version 2.1 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -syntax = "proto2"; - -import "cacep_proto.proto"; - -message cacep_simple_auth_msg { - required cacep_proto_msg proto = 1; - required string name = 2; - required uint64 addr = 3; -} -- cgit v1.2.3 From e6f5d45855b4a8091b52b3fc91451d2d132a5a6d Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Mon, 27 Feb 2017 22:59:52 +0100 Subject: lib: Split CACEP into request/response protocol --- include/ouroboros/cacep.h | 10 ++++----- src/ipcpd/normal/cdap_flow.c | 48 ++++++++++++++++++++++++++++++++++++++++---- src/ipcpd/normal/gam.c | 43 ++++++++++++++++++++++++++++++++++++--- src/lib/cacep.c | 32 ++++++----------------------- 4 files changed, 94 insertions(+), 39 deletions(-) (limited to 'src/ipcpd/normal/cdap_flow.c') diff --git a/include/ouroboros/cacep.h b/include/ouroboros/cacep.h index 5ef66433..c7b7f38c 100644 --- a/include/ouroboros/cacep.h +++ b/include/ouroboros/cacep.h @@ -43,12 +43,10 @@ struct conn_info{ } ae; }; -int cacep_connect(int fd, - const struct conn_info * in, - struct conn_info * out); +int cacep_snd(int fd, + const struct conn_info * in); -int cacep_listen(int fd, - const struct conn_info * in, - struct conn_info * out); +int cacep_rcv(int fd, + struct conn_info * out); #endif /* OUROBOROS_CACEP_H */ diff --git a/src/ipcpd/normal/cdap_flow.c b/src/ipcpd/normal/cdap_flow.c index d3d98884..c694e637 100644 --- a/src/ipcpd/normal/cdap_flow.c +++ b/src/ipcpd/normal/cdap_flow.c @@ -67,12 +67,32 @@ struct cdap_flow * cdap_flow_arr(int fd, flow->fd = fd; flow->ci = NULL; - if (cacep_listen(fd, info, &flow->info)) { + if (cacep_rcv(fd, &flow->info)) { log_err("Error establishing application connection."); cdap_flow_destroy(flow); return NULL; } + if (cacep_snd(fd, info)) { + log_err("Failed to respond to application connection request."); + cdap_flow_destroy(flow); + return NULL; + } + + if (strcmp(flow->info.ae_name, info->ae_name)) { + log_err("Received connection for wrong AE."); + cdap_flow_destroy(flow); + return NULL; + } + + if (strcmp(flow->info.protocol, info->protocol) || + flow->info.pref_version != info->pref_version || + flow->info.pref_syntax != info->pref_syntax) { + log_err("Unknown protocol."); + cdap_flow_destroy(flow); + return NULL; + } + flow->ci = cdap_create(fd); if (flow->ci == NULL) { log_err("Failed to create CDAP instance."); @@ -87,8 +107,8 @@ struct cdap_flow * cdap_flow_alloc(const char * dst_name, qosspec_t * qs, const struct conn_info * info) { - struct cdap_flow * flow; - int fd; + struct cdap_flow * flow; + int fd; log_dbg("Allocating flow to %s.", dst_name); @@ -120,12 +140,32 @@ struct cdap_flow * cdap_flow_alloc(const char * dst_name, flow->fd = fd; flow->ci = NULL; - if (cacep_connect(fd, info, &flow->info)) { + if (cacep_snd(fd, info)) { + log_err("Failed to send connection request."); + cdap_flow_dealloc(flow); + return NULL; + } + + if (cacep_rcv(fd, &flow->info)) { log_err("Failed to connect to application."); cdap_flow_dealloc(flow); return NULL; } + if (strcmp(flow->info.ae_name, info->ae_name)) { + log_err("Received connection for wrong AE."); + cdap_flow_destroy(flow); + return NULL; + } + + if (strcmp(flow->info.protocol, info->protocol) || + flow->info.pref_version != info->pref_version || + flow->info.pref_syntax != info->pref_syntax) { + log_err("Unknown protocol."); + cdap_flow_destroy(flow); + return NULL; + } + flow->ci = cdap_create(fd); if (flow->ci == NULL) { log_err("Failed to create CDAP instance."); diff --git a/src/ipcpd/normal/gam.c b/src/ipcpd/normal/gam.c index bdfc8cb9..f98c0d4f 100644 --- a/src/ipcpd/normal/gam.c +++ b/src/ipcpd/normal/gam.c @@ -187,8 +187,30 @@ int gam_flow_arr(struct gam * instance, snd_info.pref_syntax = PROTO_GPB; snd_info.ae.addr = ipcpi.address; - if (cacep_listen(fd, &snd_info, rcv_info)) { - log_err("Failed to create application connection."); + if (cacep_rcv(fd, rcv_info)) { + log_err("Error establishing application connection."); + flow_dealloc(fd); + free(rcv_info); + return -1; + } + + if (cacep_snd(fd, &snd_info)) { + log_err("Failed to respond to application connection request."); + flow_dealloc(fd); + free(rcv_info); + return -1; + } + + if (strcmp(snd_info.ae_name, rcv_info->ae_name)) { + log_err("Received connection for wrong AE."); + flow_dealloc(fd); + free(rcv_info); + return -1; + } + + if (strcmp(snd_info.protocol, rcv_info->protocol) || + snd_info.pref_version != rcv_info->pref_version || + snd_info.pref_syntax != rcv_info->pref_syntax) { flow_dealloc(fd); free(rcv_info); return -1; @@ -246,13 +268,28 @@ int gam_flow_alloc(struct gam * instance, snd_info.pref_syntax = PROTO_GPB; snd_info.ae.addr = ipcpi.address; - if (cacep_connect(fd, &snd_info, rcv_info)) { + if (cacep_snd(fd, &snd_info)) { log_err("Failed to create application connection."); flow_dealloc(fd); free(rcv_info); return -1; } + if (cacep_rcv(fd, rcv_info)) { + log_err("Failed to connect to application."); + flow_dealloc(fd); + free(rcv_info); + return -1; + } + + if (strcmp(snd_info.protocol, rcv_info->protocol) || + snd_info.pref_version != rcv_info->pref_version || + snd_info.pref_syntax != rcv_info->pref_syntax) { + flow_dealloc(fd); + free(rcv_info); + return -1; + } + if (instance->ops->accept_flow(instance->ops_o, qs, rcv_info)) { flow_dealloc(fd); free(rcv_info); diff --git a/src/lib/cacep.c b/src/lib/cacep.c index badeccc0..abff0aaa 100644 --- a/src/lib/cacep.c +++ b/src/lib/cacep.c @@ -93,46 +93,26 @@ static int send_msg(int fd, return 0; } -int cacep_connect(int fd, - const struct conn_info * in, - struct conn_info * out) +int cacep_snd(int fd, + const struct conn_info * in) { - if (in == NULL || out == NULL) + if (in == NULL) return -EINVAL; if (send_msg(fd, in)) return -1; - if (read_msg(fd, out)) - return -1; - - if (strcmp(in->ae_name, out->ae_name) || - strcmp(in->protocol, out->protocol) || - in->pref_version != out->pref_version || - in->pref_syntax != out->pref_syntax) - return -EPROTO; - return 0; } -int cacep_listen(int fd, - const struct conn_info * in, - struct conn_info * out) +int cacep_rcv(int fd, + struct conn_info * out) { - if (in == NULL || out == NULL) + if (out == NULL) return -EINVAL; - if (send_msg(fd, in)) - return -1; - if (read_msg(fd, out)) return -1; - if (strcmp(in->ae_name, out->ae_name) || - strcmp(in->protocol, out->protocol) || - in->pref_version != out->pref_version || - in->pref_syntax != out->pref_syntax) - return -EPROTO; - return 0; } -- cgit v1.2.3 From e2616e184f023da7ce535efb5a676715283c092c Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Fri, 3 Mar 2017 14:40:29 +0100 Subject: ipcpd: normal: Deprecate CDAP flow This removes the CDAP flow class, which is no longer needed. --- src/ipcpd/normal/CMakeLists.txt | 1 - src/ipcpd/normal/cdap_flow.c | 186 ---------------------------------------- src/ipcpd/normal/cdap_flow.h | 46 ---------- 3 files changed, 233 deletions(-) delete mode 100644 src/ipcpd/normal/cdap_flow.c delete mode 100644 src/ipcpd/normal/cdap_flow.h (limited to 'src/ipcpd/normal/cdap_flow.c') diff --git a/src/ipcpd/normal/CMakeLists.txt b/src/ipcpd/normal/CMakeLists.txt index 772d5212..6319c3ef 100644 --- a/src/ipcpd/normal/CMakeLists.txt +++ b/src/ipcpd/normal/CMakeLists.txt @@ -19,7 +19,6 @@ protobuf_generate_c(FLOW_ALLOC_SRCS FLOW_ALLOC_HDRS flow_alloc.proto) set(SOURCE_FILES # Add source files here addr_auth.c - cdap_flow.c connmgr.c dir.c enroll.c diff --git a/src/ipcpd/normal/cdap_flow.c b/src/ipcpd/normal/cdap_flow.c deleted file mode 100644 index c694e637..00000000 --- a/src/ipcpd/normal/cdap_flow.c +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Ouroboros - Copyright (C) 2016 - 2017 - * - * Normal IPC Process - Authenticated CDAP Flow Allocator - * - * Sander Vrijders - * Dimitri Staessens - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#define OUROBOROS_PREFIX "cdap-flow" - -#include -#include -#include - -#include "cdap_flow.h" - -#include -#include -#include - -static void cdap_flow_destroy(struct cdap_flow * flow) -{ - assert(flow); - - if (flow->ci != NULL) - cdap_destroy(flow->ci); - - free(flow); -} - -struct cdap_flow * cdap_flow_arr(int fd, - int resp, - const struct conn_info * info) -{ - struct cdap_flow * flow; - - if (flow_alloc_resp(fd, resp) < 0) { - log_err("Could not respond to new flow."); - return NULL; - } - - if (resp) - return NULL; - - flow = malloc(sizeof(*flow)); - if (flow == NULL) { - log_err("Failed to malloc."); - return NULL; - } - - memset(&flow->info, 0, sizeof(flow->info)); - - flow->fd = fd; - flow->ci = NULL; - - if (cacep_rcv(fd, &flow->info)) { - log_err("Error establishing application connection."); - cdap_flow_destroy(flow); - return NULL; - } - - if (cacep_snd(fd, info)) { - log_err("Failed to respond to application connection request."); - cdap_flow_destroy(flow); - return NULL; - } - - if (strcmp(flow->info.ae_name, info->ae_name)) { - log_err("Received connection for wrong AE."); - cdap_flow_destroy(flow); - return NULL; - } - - if (strcmp(flow->info.protocol, info->protocol) || - flow->info.pref_version != info->pref_version || - flow->info.pref_syntax != info->pref_syntax) { - log_err("Unknown protocol."); - cdap_flow_destroy(flow); - return NULL; - } - - flow->ci = cdap_create(fd); - if (flow->ci == NULL) { - log_err("Failed to create CDAP instance."); - cdap_flow_destroy(flow); - return NULL; - } - - return flow; -} - -struct cdap_flow * cdap_flow_alloc(const char * dst_name, - qosspec_t * qs, - const struct conn_info * info) -{ - struct cdap_flow * flow; - int fd; - - log_dbg("Allocating flow to %s.", dst_name); - - if (dst_name == NULL) { - log_err("Not enough info to establish flow."); - return NULL; - } - - fd = flow_alloc(dst_name, qs); - if (fd < 0) { - log_err("Failed to allocate flow to %s.", dst_name); - return NULL; - } - - if (flow_alloc_res(fd)) { - log_err("Flow allocation to %s failed.", dst_name); - return NULL; - } - - flow = malloc(sizeof(*flow)); - if (flow == NULL) { - log_err("Failed to malloc."); - flow_dealloc(fd); - return NULL; - } - - memset(&flow->info, 0, sizeof(flow->info)); - - flow->fd = fd; - flow->ci = NULL; - - if (cacep_snd(fd, info)) { - log_err("Failed to send connection request."); - cdap_flow_dealloc(flow); - return NULL; - } - - if (cacep_rcv(fd, &flow->info)) { - log_err("Failed to connect to application."); - cdap_flow_dealloc(flow); - return NULL; - } - - if (strcmp(flow->info.ae_name, info->ae_name)) { - log_err("Received connection for wrong AE."); - cdap_flow_destroy(flow); - return NULL; - } - - if (strcmp(flow->info.protocol, info->protocol) || - flow->info.pref_version != info->pref_version || - flow->info.pref_syntax != info->pref_syntax) { - log_err("Unknown protocol."); - cdap_flow_destroy(flow); - return NULL; - } - - flow->ci = cdap_create(fd); - if (flow->ci == NULL) { - log_err("Failed to create CDAP instance."); - cdap_flow_dealloc(flow); - return NULL; - } - - return flow; -} - -void cdap_flow_dealloc(struct cdap_flow * flow) -{ - int fd = flow->fd; - - cdap_flow_destroy(flow); - - flow_dealloc(fd); -} diff --git a/src/ipcpd/normal/cdap_flow.h b/src/ipcpd/normal/cdap_flow.h deleted file mode 100644 index 761f3463..00000000 --- a/src/ipcpd/normal/cdap_flow.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Ouroboros - Copyright (C) 2016 - 2017 - * - * Normal IPC Process - Authenticated CDAP Flow Allocator - * - * Sander Vrijders - * Dimitri Staessens - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef OUROBOROS_IPCPD_NORMAL_CDAP_FLOW_H -#define OUROBOROS_IPCPD_NORMAL_CDAP_FLOW_H - -#include -#include -#include - -struct cdap_flow { - int fd; - struct cdap * ci; - struct conn_info info; -}; - -struct cdap_flow * cdap_flow_arr(int fd, - int resp, - const struct conn_info * info); - -struct cdap_flow * cdap_flow_alloc(const char * dst_name, - qosspec_t * qs, - const struct conn_info * info); - -void cdap_flow_dealloc(struct cdap_flow * flow); - -#endif /* OUROBOROS_IPCPD_NORMAL_CDAP_FLOW_H */ -- cgit v1.2.3