diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ipcpd/shim-udp/main.c | 12 | ||||
-rw-r--r-- | src/irmd/main.c | 54 | ||||
-rw-r--r-- | src/tools/echo/echo_server.c | 3 |
3 files changed, 59 insertions, 10 deletions
diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c index c41d35a1..130ac17e 100644 --- a/src/ipcpd/shim-udp/main.c +++ b/src/ipcpd/shim-udp/main.c @@ -366,8 +366,6 @@ int ipcp_udp_bootstrap(struct dif_config * conf) int ipcp_udp_ap_reg(char * ap_name, uint32_t reg_ap_id) { - LOG_DBG("Registering local ap %s, %u.", ap_name, reg_ap_id); - if (_ipcp->state != IPCP_ENROLLED) { LOG_DBGF("Won't register with non-enrolled IPCP."); return -1; @@ -378,6 +376,9 @@ int ipcp_udp_ap_reg(char * ap_name, uint32_t reg_ap_id) return -1; } + LOG_DBG("Registered local ap %s, %u.", ap_name, reg_ap_id); + + /* FIXME: register application with DNS server */ LOG_MISSING; return 0; @@ -385,16 +386,11 @@ int ipcp_udp_ap_reg(char * ap_name, uint32_t reg_ap_id) int ipcp_udp_ap_unreg(uint32_t reg_ap_id) { - char * name = strdup(ipcp_data_get_reg_ap_name(_ipcp->data, - reg_ap_id)); - ipcp_data_del_reg_entry(_ipcp->data, reg_ap_id); - /* we are using dns */ + /* FIXME: unregister application from DNS server */ LOG_MISSING; - free (name); - return 0; } diff --git a/src/irmd/main.c b/src/irmd/main.c index b5a5e145..9a65cd4a 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -87,6 +87,24 @@ static struct ipcp_entry * find_ipcp_by_name(instance_name_t * api) return tmp; } +static pid_t find_pid_by_dif_name(char * dif_name) +{ + struct list_head * pos = NULL; + + list_for_each(pos, &instance->ipcps) { + struct ipcp_entry * tmp = + list_entry(pos, struct ipcp_entry, next); + + if (tmp->dif_name == NULL) + return tmp->pid; + + if (strcmp(dif_name, tmp->dif_name) == 0) + return tmp->pid; + } + + return 0; +} + static int create_ipcp(instance_name_t * api, enum ipcp_type ipcp_type) { @@ -266,7 +284,41 @@ static int ap_reg(char * ap_name, char ** difs, size_t difs_size) { - return -1; + pid_t pid = 0; + int i; + int ret = 0; + + if (instance->ipcps.next == NULL) + LOG_ERR("No IPCPs in this system."); + + /* + * FIXME: this should be resolved by NSM + * Now it just takes the first DIF + */ + + if (strcmp(difs[0], "*") == 0) { + difs[0] = list_entry(instance->ipcps.next, + struct ipcp_entry, + next)->dif_name; + difs_size = 1; + } + + for (i = 0; i < difs_size; ++i) { + pid = find_pid_by_dif_name(difs[i]); + if (pid == 0) { + LOG_ERR("%s: No such DIF.", difs[i]); + continue; + } + + /* FIXME: get proper reg_ap_id */ + if (ipcp_ap_reg(pid, rand(),ap_name)) { + LOG_ERR("Could not register %s in DIF %s.", + ap_name, difs[i]); + ret = -1; + } + } + + return ret; } static int ap_unreg(char * ap_name, diff --git a/src/tools/echo/echo_server.c b/src/tools/echo/echo_server.c index b1547d8c..d7099a2d 100644 --- a/src/tools/echo/echo_server.c +++ b/src/tools/echo/echo_server.c @@ -64,11 +64,12 @@ int server_main() return -1; } + printf("Echo server started..."); + while (true) { client_fd = flow_accept(server_fd, client_name, NULL); if (client_fd < 0) { - printf("Failed to accept flow\n"); continue; } |