diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ipcpd/ipcp-data.c | 11 | ||||
-rw-r--r-- | src/ipcpd/ipcp.c | 40 | ||||
-rw-r--r-- | src/ipcpd/shim-udp/main.c | 53 |
3 files changed, 40 insertions, 64 deletions
diff --git a/src/ipcpd/ipcp-data.c b/src/ipcpd/ipcp-data.c index 106226de..72407a53 100644 --- a/src/ipcpd/ipcp-data.c +++ b/src/ipcpd/ipcp-data.c @@ -189,11 +189,12 @@ void ipcp_data_destroy(struct ipcp_data * data) clear_directory(data); clear_flows(data); - /* no need to unlock, just free the entire thing - pthread_mutex_unlock(&data->flow_lock); - pthread_mutex_unlock(&data->dir_lock); - pthread_mutex_unlock(&data->reg_lock); - */ + /* + * no need to unlock, just free the entire thing + * pthread_mutex_unlock(&data->flow_lock); + * pthread_mutex_unlock(&data->dir_lock); + * pthread_mutex_unlock(&data->reg_lock); + */ free(data); } diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c index 23c432f1..d6f373cd 100644 --- a/src/ipcpd/ipcp.c +++ b/src/ipcpd/ipcp.c @@ -126,8 +126,9 @@ int ipcp_main_loop(struct ipcp * _ipcp) break; } ret_msg.has_result = true; - ret_msg.result = _ipcp->ops->ipcp_enroll( - msg->member_name, msg->n_1_dif); + ret_msg.result = + _ipcp->ops->ipcp_enroll(msg->member_name, + msg->n_1_dif); break; @@ -138,8 +139,8 @@ int ipcp_main_loop(struct ipcp * _ipcp) } ret_msg.has_result = true; - ret_msg.result = _ipcp->ops->ipcp_reg( - msg->dif_names, msg->len); + ret_msg.result = + _ipcp->ops->ipcp_reg(msg->dif_names, msg->len); break; case IPCP_MSG_CODE__IPCP_UNREG: if (_ipcp->ops->ipcp_unreg == NULL) { @@ -147,8 +148,8 @@ int ipcp_main_loop(struct ipcp * _ipcp) break; } ret_msg.has_result = true; - ret_msg.result = _ipcp->ops->ipcp_unreg( - msg->dif_names, msg->len); + ret_msg.result = + _ipcp->ops->ipcp_unreg(msg->dif_names, msg->len); break; case IPCP_MSG_CODE__IPCP_NAME_REG: if (_ipcp->ops->ipcp_name_reg == NULL) { @@ -156,8 +157,7 @@ int ipcp_main_loop(struct ipcp * _ipcp) break; } ret_msg.has_result = true; - ret_msg.result = _ipcp->ops->ipcp_name_reg( - msg->name); + ret_msg.result = _ipcp->ops->ipcp_name_reg(msg->name); break; case IPCP_MSG_CODE__IPCP_NAME_UNREG: if (_ipcp->ops->ipcp_name_unreg == NULL) { @@ -165,8 +165,7 @@ int ipcp_main_loop(struct ipcp * _ipcp) break; } ret_msg.has_result = true; - ret_msg.result = _ipcp->ops->ipcp_name_unreg( - msg->name); + ret_msg.result = _ipcp->ops->ipcp_name_unreg(msg->name); break; case IPCP_MSG_CODE__IPCP_FLOW_ALLOC: if (_ipcp->ops->ipcp_flow_alloc == NULL) { @@ -174,12 +173,12 @@ int ipcp_main_loop(struct ipcp * _ipcp) break; } ret_msg.has_fd = true; - ret_msg.fd = _ipcp->ops->ipcp_flow_alloc( - msg->port_id, - msg->dst_name, - msg->src_ap_name, - msg->src_ae_name, - NULL); + ret_msg.fd = + _ipcp->ops->ipcp_flow_alloc(msg->port_id, + msg->dst_name, + msg->src_ap_name, + msg->src_ae_name, + NULL); break; case IPCP_MSG_CODE__IPCP_FLOW_ALLOC_RESP: if (_ipcp->ops->ipcp_flow_alloc_resp == NULL) { @@ -187,8 +186,9 @@ int ipcp_main_loop(struct ipcp * _ipcp) break; } ret_msg.has_result = true; - ret_msg.result = _ipcp->ops->ipcp_flow_alloc_resp( - msg->port_id, msg->result); + ret_msg.result = + _ipcp->ops->ipcp_flow_alloc_resp(msg->port_id, + msg->result); break; case IPCP_MSG_CODE__IPCP_FLOW_DEALLOC: if (_ipcp->ops->ipcp_flow_dealloc == NULL) { @@ -196,8 +196,8 @@ int ipcp_main_loop(struct ipcp * _ipcp) break; } ret_msg.has_result = true; - ret_msg.result = _ipcp->ops->ipcp_flow_dealloc( - msg->port_id); + ret_msg.result = + _ipcp->ops->ipcp_flow_dealloc(msg->port_id); break; default: LOG_ERR("Don't know that message code"); diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c index 029df111..c07d77c2 100644 --- a/src/ipcpd/shim-udp/main.c +++ b/src/ipcpd/shim-udp/main.c @@ -51,8 +51,8 @@ #define shim_data(type) ((struct ipcp_udp_data *) type->data) -#define local_ip (((struct ipcp_udp_data *) \ - _ipcp->data)->s_saddr.sin_addr.s_addr) +#define local_ip (((struct ipcp_udp_data *) \ + _ipcp->data)->s_saddr.sin_addr.s_addr) /* global for trapping signal */ int irmd_pid; @@ -133,7 +133,7 @@ struct ipcp_udp_data * ipcp_udp_data_create(char * ap_name) static void * ipcp_udp_listener() { char buf[SHIM_UDP_BUF_SIZE]; - int n = 0; + int n = 0; struct sockaddr_in f_saddr; struct sockaddr_in c_saddr; @@ -141,9 +141,6 @@ static void * ipcp_udp_listener() struct udp_flow * flow; int sfd = shim_data(_ipcp)->s_fd; - irm_msg_t msg = IRM_MSG__INIT; - irm_msg_t * ret_msg ; - while (true) { n = sizeof c_saddr; n = recvfrom(sfd, buf, SHIM_UDP_BUF_SIZE, 0, @@ -194,34 +191,20 @@ static void * ipcp_udp_listener() /* reply to IRM */ - msg.code = IRM_MSG_CODE__IPCP_FLOW_REQ_ARR; - msg.ap_name = ANONYMOUS_AP; - msg.ae_name = ""; /* no AE */ - msg.dst_name = buf; - - ret_msg = send_recv_irm_msg(&msg); - if (ret_msg == NULL) { - LOG_ERR("Could not send message to IRM."); - close(flow->fd); - free(flow); - continue; - } - - if (!ret_msg->has_port_id) { - LOG_ERR("Didn't get port_id."); - free(ret_msg); + flow->flow.port_id = ipcp_flow_req_arr(getpid(), buf, + ANONYMOUS_AP, ""); + if (flow->flow.port_id < 0) { + LOG_ERR("Could not get port id from IRMd"); close(flow->fd); free(flow); continue; } - flow->flow.port_id = ret_msg->port_id; - flow->flow.oflags = FLOW_O_DEFAULT; - flow->flow.state = FLOW_PENDING; + flow->flow.oflags = FLOW_O_DEFAULT; + flow->flow.state = FLOW_PENDING; if(ipcp_data_add_flow(_ipcp->data, (flow_t *) flow)) { LOG_DBGF("Could not add flow."); - free(ret_msg); close(flow->fd); free(flow); continue; @@ -269,7 +252,7 @@ static void * ipcp_udp_sdu_reader() (struct sockaddr *) &r_saddr, sizeof r_saddr) < 0) - continue; + continue; flow->state = FLOW_ALLOCATED; } @@ -391,9 +374,6 @@ int ipcp_udp_flow_alloc(uint32_t port_id, struct hostent * h; - irm_msg_t msg = IRM_MSG__INIT; - irm_msg_t * ret_msg = NULL; - if (dst_name == NULL || src_ap_name == NULL || src_ae_name == NULL) return -1; @@ -452,7 +432,8 @@ int ipcp_udp_flow_alloc(uint32_t port_id, /* at least try to get the packet on the wire */ while (sendto(flow->fd, dst_name, strlen(dst_name), 0, - (struct sockaddr *) &r_saddr, sizeof r_saddr) < 0) + (struct sockaddr *) &r_saddr, sizeof r_saddr) < 0) { + } flow->flow.port_id = port_id; flow->flow.oflags = FLOW_O_DEFAULT; @@ -474,14 +455,8 @@ int ipcp_udp_flow_alloc(uint32_t port_id, /* tell IRMd that flow allocation "worked" */ - msg.code = IRM_MSG_CODE__IPCP_FLOW_ALLOC_REPLY; - msg.has_port_id = true; - msg.port_id = flow->flow.port_id; - msg.has_response = true; - msg.response = 0; - - ret_msg = send_recv_irm_msg(&msg); - if (ret_msg == NULL) { + if (ipcp_flow_alloc_reply(getpid(), flow->flow.port_id, 0)) { + LOG_ERR("Failed to notify IRMd about flow allocation reply"); close(flow->fd); ipcp_data_del_flow(_ipcp->data, flow->flow.port_id); return -1; |