summaryrefslogtreecommitdiff
path: root/src/lib/dev.c
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2016-08-21 21:12:03 +0200
committerSander Vrijders <sander.vrijders@intec.ugent.be>2016-08-21 21:12:03 +0200
commitf0d4305c067044e74c44032c32ce6c4db3c6fffa (patch)
treed895b25fb5a8f7af106c6c2d3228b62ade81b3b4 /src/lib/dev.c
parentba27593e3e8406e109393ae383f17c7416675c1e (diff)
parentcee5ae97ee14438b2dabc06bfad9b02e42e4d816 (diff)
downloadouroboros-f0d4305c067044e74c44032c32ce6c4db3c6fffa.tar.gz
ouroboros-f0d4305c067044e74c44032c32ce6c4db3c6fffa.zip
Merged in dstaesse/ouroboros/be-irmd-refactor (pull request #213)
irmd, lib: Rebuild the IRMd data model
Diffstat (limited to 'src/lib/dev.c')
-rw-r--r--src/lib/dev.c72
1 files changed, 36 insertions, 36 deletions
diff --git a/src/lib/dev.c b/src/lib/dev.c
index f27ef0fe..3a5fc8e0 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -54,6 +54,37 @@ struct ap_data {
pthread_rwlock_t flows_lock;
} * _ap_instance;
+static int api_announce(char * ap_name)
+{
+ irm_msg_t msg = IRM_MSG__INIT;
+ irm_msg_t * recv_msg = NULL;
+ int ret = -1;
+
+ msg.code = IRM_MSG_CODE__IRM_API_ANNOUNCE;
+ msg.has_api = true;
+
+ pthread_rwlock_rdlock(&_ap_instance->data_lock);
+
+ msg.api = _ap_instance->api;
+ msg.ap_name = ap_name;
+
+ pthread_rwlock_unlock(&_ap_instance->data_lock);
+
+ recv_msg = send_recv_irm_msg(&msg);
+ if (recv_msg == NULL) {
+ return -1;
+ }
+
+ if (!recv_msg->has_result || (ret = recv_msg->result)) {
+ irm_msg__free_unpacked(recv_msg, NULL);
+ return ret;
+ }
+
+ irm_msg__free_unpacked(recv_msg, NULL);
+
+ return ret;
+}
+
int ap_init(char * ap_name)
{
int i = 0;
@@ -100,6 +131,9 @@ int ap_init(char * ap_name)
pthread_rwlock_init(&_ap_instance->flows_lock, NULL);
pthread_rwlock_init(&_ap_instance->data_lock, NULL);
+ if (ap_name != NULL)
+ return api_announce(ap_name);
+
return 0;
}
@@ -134,42 +168,6 @@ void ap_fini(void)
free(_ap_instance);
}
-int api_bind(char * ap_subset)
-{
- irm_msg_t msg = IRM_MSG__INIT;
- irm_msg_t * recv_msg = NULL;
- int ret = -1;
-
- msg.code = IRM_MSG_CODE__IRM_API_BIND;
- msg.has_api = true;
-
- if (_ap_instance->ap_name == NULL)
- return -EPERM; /* call init first */
-
- pthread_rwlock_rdlock(&_ap_instance->data_lock);
-
- msg.api = _ap_instance->api;
- msg.ap_name = _ap_instance->ap_name;
-
- pthread_rwlock_unlock(&_ap_instance->data_lock);
-
- msg.ap_subset = ap_subset;
-
- recv_msg = send_recv_irm_msg(&msg);
- if (recv_msg == NULL) {
- return -1;
- }
-
- if (!recv_msg->has_result || (ret = recv_msg->result)) {
- irm_msg__free_unpacked(recv_msg, NULL);
- return ret;
- }
-
- irm_msg__free_unpacked(recv_msg, NULL);
-
- return ret;
-}
-
static int port_id_to_fd(int port_id)
{
int i;
@@ -417,6 +415,8 @@ int flow_dealloc(int fd)
msg.code = IRM_MSG_CODE__IRM_FLOW_DEALLOC;
msg.has_port_id = true;
+ msg.has_api = true;
+ msg.api = getpid();
pthread_rwlock_rdlock(&_ap_instance->data_lock);
pthread_rwlock_wrlock(&_ap_instance->flows_lock);