From 7834e92b218da69cd934679dec9c2d714d89d15e Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Mon, 13 Jun 2016 13:48:17 +0200 Subject: lib, irmd, tools, ipcpd: updates to dev API. The registration function has been moved to the irm tool, applications now need to be registered by an administrator. Currently only supports one instance per registered name, and an AP can be registered under only one name. The irmd can now start a registered server application on demand. For the full functionality of the tool, execute "irm register". AP name removed from flow allocation. Flow allocation does not send the source ap name as it is quite useless. The accept() call now only returns the AE name. --- src/ipcpd/ipcp-ops.h | 1 - src/ipcpd/ipcp.c | 1 - src/ipcpd/local/main.c | 6 ++---- src/ipcpd/shim-udp/main.c | 12 ++---------- src/ipcpd/shim-udp/shim_udp_messages.proto | 1 - 5 files changed, 4 insertions(+), 17 deletions(-) (limited to 'src/ipcpd') diff --git a/src/ipcpd/ipcp-ops.h b/src/ipcpd/ipcp-ops.h index 72c57595..ffbc9cd7 100644 --- a/src/ipcpd/ipcp-ops.h +++ b/src/ipcpd/ipcp-ops.h @@ -41,7 +41,6 @@ struct ipcp_ops { int (* ipcp_flow_alloc)(pid_t n_pid, int port_id, char * dst_ap_name, - char * src_ap_name, char * src_ae_name, enum qos_cube qos); int (* ipcp_flow_alloc_resp)(pid_t n_pid, diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c index e0dd1b60..09dfa449 100644 --- a/src/ipcpd/ipcp.c +++ b/src/ipcpd/ipcp.c @@ -206,7 +206,6 @@ void * ipcp_main_loop(void * o) _ipcp->ops->ipcp_flow_alloc(msg->pid, msg->port_id, msg->dst_name, - msg->src_ap_name, msg->src_ae_name, msg->qos_cube); break; diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c index 4a0ad683..cb20a336 100644 --- a/src/ipcpd/local/main.c +++ b/src/ipcpd/local/main.c @@ -341,7 +341,6 @@ static int ipcp_local_name_unreg(char * name) static int ipcp_local_flow_alloc(pid_t n_pid, int port_id, char * dst_name, - char * src_ap_name, char * src_ae_name, enum qos_cube qos) { @@ -350,9 +349,9 @@ static int ipcp_local_flow_alloc(pid_t n_pid, struct shm_ap_rbuff * rb; - LOG_INFO("Allocating flow from %s to %s.", src_ap_name, dst_name); + LOG_INFO("Allocating flow to %s.", dst_name); - if (dst_name == NULL || src_ap_name == NULL || src_ae_name == NULL) + if (dst_name == NULL || src_ae_name == NULL) return -1; /* This ipcpd has all QoS */ @@ -387,7 +386,6 @@ static int ipcp_local_flow_alloc(pid_t n_pid, /* reply to IRM */ port_id = ipcp_flow_req_arr(getpid(), dst_name, - src_ap_name, src_ae_name); if (port_id < 0) { diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c index 48fa141e..99fb134d 100644 --- a/src/ipcpd/shim-udp/main.c +++ b/src/ipcpd/shim-udp/main.c @@ -384,7 +384,6 @@ static int send_shim_udp_msg(shim_udp_msg_t * msg, static int ipcp_udp_port_alloc(uint32_t dst_ip_addr, uint32_t src_udp_port, char * dst_name, - char * src_ap_name, char * src_ae_name) { shim_udp_msg_t msg = SHIM_UDP_MSG__INIT; @@ -392,7 +391,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_ap_name = src_ap_name; msg.src_ae_name = src_ae_name; return send_shim_udp_msg(&msg, dst_ip_addr); @@ -428,7 +426,6 @@ static int ipcp_udp_port_dealloc(uint32_t dst_ip_addr, static int ipcp_udp_port_req(struct sockaddr_in * c_saddr, char * dst_name, - char * src_ap_name, char * src_ae_name) { int fd; @@ -486,7 +483,6 @@ static int ipcp_udp_port_req(struct sockaddr_in * c_saddr, /* reply to IRM */ port_id = ipcp_flow_req_arr(getpid(), dst_name, - src_ap_name, src_ae_name); if (port_id < 0) { @@ -682,7 +678,6 @@ static void * ipcp_udp_listener() c_saddr.sin_port = msg->src_udp_port; ipcp_udp_port_req(&c_saddr, msg->dst_name, - msg->src_ap_name, msg->src_ae_name); break; case SHIM_UDP_MSG_CODE__FLOW_REPLY: @@ -1214,7 +1209,6 @@ static int ipcp_udp_name_unreg(char * name) static int ipcp_udp_flow_alloc(pid_t n_pid, int port_id, char * dst_name, - char * src_ap_name, char * src_ae_name, enum qos_cube qos) { @@ -1229,12 +1223,11 @@ static int ipcp_udp_flow_alloc(pid_t n_pid, #endif struct shm_ap_rbuff * rb; - LOG_INFO("Allocating flow from %s to %s.", src_ap_name, dst_name); + LOG_INFO("Allocating flow to %s.", dst_name); - if (dst_name == NULL || src_ap_name == NULL || src_ae_name == NULL) + if (dst_name == NULL || src_ae_name == NULL) return -1; if (strlen(dst_name) > 255 - || strlen(src_ap_name) > 255 || strlen(src_ae_name) > 255) { LOG_ERR("Name too long for this shim."); return -1; @@ -1332,7 +1325,6 @@ static int ipcp_udp_flow_alloc(pid_t n_pid, if (ipcp_udp_port_alloc(ip_addr, f_saddr.sin_port, dst_name, - src_ap_name, src_ae_name) < 0) { LOG_DBGF("Port alloc returned -1."); rw_lock_rdlock(&_ipcp->state_lock); diff --git a/src/ipcpd/shim-udp/shim_udp_messages.proto b/src/ipcpd/shim-udp/shim_udp_messages.proto index a15fc18c..e6bac908 100644 --- a/src/ipcpd/shim-udp/shim_udp_messages.proto +++ b/src/ipcpd/shim-udp/shim_udp_messages.proto @@ -7,7 +7,6 @@ enum shim_udp_msg_code { message shim_udp_msg { required shim_udp_msg_code code = 1; optional string dst_name = 2; - optional string src_ap_name = 3; optional string src_ae_name = 4; required sint32 src_udp_port = 5; optional sint32 dst_udp_port = 6; -- cgit v1.2.3 From be68864173cf12d9998e4dbe73d876d8974a2ec1 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Tue, 14 Jun 2016 11:39:37 +0200 Subject: ipdpd: fixed flow deallocation in local ipcpd Now correctly deallocates the local fd if the remote already deallocated the flow. --- src/ipcpd/local/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/ipcpd') diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c index cb20a336..e7db58b6 100644 --- a/src/ipcpd/local/main.c +++ b/src/ipcpd/local/main.c @@ -519,7 +519,9 @@ static int ipcp_local_flow_dealloc(int port_id) bmp_release(_ap_instance->fds, fd); - _ap_instance->in_out[_ap_instance->in_out[fd]] = -1; + if (_ap_instance->in_out[fd] != -1) + _ap_instance->in_out[_ap_instance->in_out[fd]] =-1; + _ap_instance->in_out[fd] = -1; _ap_instance->flows[fd].state = FLOW_NULL; -- cgit v1.2.3 From 95124310f647913a678060fc10155a0ad9311dba Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Tue, 14 Jun 2016 14:52:26 +0200 Subject: Fixed comments on #122 --- src/ipcpd/local/main.c | 2 +- src/irmd/main.c | 7 +++---- src/tools/cbr/cbr.c | 2 -- 3 files changed, 4 insertions(+), 7 deletions(-) (limited to 'src/ipcpd') diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c index e7db58b6..6357487f 100644 --- a/src/ipcpd/local/main.c +++ b/src/ipcpd/local/main.c @@ -520,7 +520,7 @@ static int ipcp_local_flow_dealloc(int port_id) bmp_release(_ap_instance->fds, fd); if (_ap_instance->in_out[fd] != -1) - _ap_instance->in_out[_ap_instance->in_out[fd]] =-1; + _ap_instance->in_out[_ap_instance->in_out[fd]] = -1; _ap_instance->in_out[fd] = -1; diff --git a/src/irmd/main.c b/src/irmd/main.c index fc856687..db96b6ed 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -705,7 +705,7 @@ static int ap_reg(char * name, /* we need to duplicate argv */ if (argc != 0) { - argv_dup = malloc ((argc + 2) * sizeof(*argv_dup)); + argv_dup = malloc((argc + 2) * sizeof(*argv_dup)); argv_dup[0] = strdup(api->name); for (i = 1; i <= argc; ++i) argv_dup[i] = strdup(argv[i - 1]); @@ -1108,7 +1108,7 @@ static int auto_execute(char * ap, char ** argv) execv(ap, argv); - LOG_DBG("Failed to execute."); + LOG_ERR("Failed to execute."); exit(EXIT_FAILURE); return 0; @@ -1161,8 +1161,7 @@ static struct port_map_entry * flow_req_arr(pid_t pid, while (rne->accept == false) pthread_cond_wait(&rne->acc_signal, &rne->acc_lock); - } - else { + } else { pthread_mutex_unlock(&rne->acc_lock); LOG_WARN("%s is not accepting flow allocations.", rne->name); diff --git a/src/tools/cbr/cbr.c b/src/tools/cbr/cbr.c index 750b5a15..ab178ca3 100644 --- a/src/tools/cbr/cbr.c +++ b/src/tools/cbr/cbr.c @@ -132,9 +132,7 @@ int main(int argc, char ** argv) if (server) { ret = server_main(); - } else { - if (s_apn == NULL) { printf("No server specified.\n"); usage(); -- cgit v1.2.3