diff options
author | Sander Vrijders <[email protected]> | 2016-08-10 19:16:41 +0200 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2016-08-10 19:16:41 +0200 |
commit | 16cf56fc3c31a2f6201c4d9cc6e6ad314f9a1f37 (patch) | |
tree | 8a1654ef31bb091c285887a3b6c5d4ad1287382c /src/lib/dev.c | |
parent | 88e820cd80323cf7f08fb7be1e683200016e9d34 (diff) | |
parent | 11c6be30491ebe4e41380f48a271c57bcff4b043 (diff) | |
download | ouroboros-16cf56fc3c31a2f6201c4d9cc6e6ad314f9a1f37.tar.gz ouroboros-16cf56fc3c31a2f6201c4d9cc6e6ad314f9a1f37.zip |
Merged in dstaesse/ouroboros/be-api-bind (pull request #203)
lib, irmd: Bind AP instances to AP_subsets
Diffstat (limited to 'src/lib/dev.c')
-rw-r--r-- | src/lib/dev.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/src/lib/dev.c b/src/lib/dev.c index c8577feb..f27ef0fe 100644 --- a/src/lib/dev.c +++ b/src/lib/dev.c @@ -134,6 +134,42 @@ 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; @@ -154,7 +190,6 @@ int flow_accept(char ** ae_name) pthread_rwlock_rdlock(&_ap_instance->data_lock); - msg.ap_name = _ap_instance->ap_name; msg.api = _ap_instance->api; pthread_rwlock_unlock(&_ap_instance->data_lock); |