summaryrefslogtreecommitdiff
path: root/src/irmd
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2016-04-21 08:03:21 +0200
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2016-04-21 08:04:51 +0200
commit18c5da3a77fd736c45730d562e35c4957269ebe3 (patch)
tree16498a36877f2b5d9ca96f1d189689ef9a8b9023 /src/irmd
parentad99455aa38171c28705a7e9b002b53168dc8ff0 (diff)
downloadouroboros-18c5da3a77fd736c45730d562e35c4957269ebe3.tar.gz
ouroboros-18c5da3a77fd736c45730d562e35c4957269ebe3.zip
irmd: application registration
Initial code for application registration. Specifying "*" will (for now) register with the first IPCP available in the system. Modified the echo server not to barf messages on failed accept()
Diffstat (limited to 'src/irmd')
-rw-r--r--src/irmd/main.c54
1 files changed, 53 insertions, 1 deletions
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,