diff options
author | dimitri staessens <dimitri.staessens@ugent.be> | 2017-08-28 18:54:22 +0200 |
---|---|---|
committer | dimitri staessens <dimitri.staessens@ugent.be> | 2017-08-28 20:49:34 +0200 |
commit | 9de8dc4948cf7ce239232aae0889c39ffa39ede2 (patch) | |
tree | 396295b2d36f69ee55e5080e556891f11210aed8 /src/irmd/ipcp.c | |
parent | 176698e8c2fd7ab8007b8074515d6144e7177d8e (diff) | |
download | ouroboros-9de8dc4948cf7ce239232aae0889c39ffa39ede2.tar.gz ouroboros-9de8dc4948cf7ce239232aae0889c39ffa39ede2.zip |
tools: Add tool to connect IPCP components
This enables user-written tools to instruct IPCPs to establish and
tear down connections (a.k.a. adjacencies) between its internal
components (Management and Data Transfer).
For more info, do "irm ipcp connect" or "irm ipcp disconnect" on the
command line.
This commit exposes a deletion bug in the RIB where FSO's fail to
unpack/parse. This will be fixed when the RIB is deprecated.
Diffstat (limited to 'src/irmd/ipcp.c')
-rw-r--r-- | src/irmd/ipcp.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/irmd/ipcp.c b/src/irmd/ipcp.c index e1689b91..ed1ad924 100644 --- a/src/irmd/ipcp.c +++ b/src/irmd/ipcp.c @@ -281,6 +281,67 @@ int ipcp_enroll(pid_t api, return 0; } +int ipcp_connect(pid_t api, + const char * dst, + const char * component) +{ + ipcp_msg_t msg = IPCP_MSG__INIT; + ipcp_msg_t * recv_msg = NULL; + int ret = -1; + + msg.code = IPCP_MSG_CODE__IPCP_CONNECT; + msg.dst_name = (char *) dst; + msg.comp_name = (char *) component; + msg.has_api = true; + msg.api = api; + + recv_msg = send_recv_ipcp_msg(api, &msg); + if (recv_msg == NULL) { + log_dbg("bad msg"); + return -EIPCP; + } + + if (recv_msg->has_result == false) { + ipcp_msg__free_unpacked(recv_msg, NULL); + log_dbg("no result."); + return -EIPCP; + } + + ret = recv_msg->result; + ipcp_msg__free_unpacked(recv_msg, NULL); + + return ret; +} + +int ipcp_disconnect(pid_t api, + const char * dst, + const char * component) +{ + ipcp_msg_t msg = IPCP_MSG__INIT; + ipcp_msg_t * recv_msg = NULL; + int ret = -1; + + msg.code = IPCP_MSG_CODE__IPCP_DISCONNECT; + msg.dst_name = (char *) dst; + msg.comp_name = (char *) component; + msg.has_api = true; + msg.api = api; + + recv_msg = send_recv_ipcp_msg(api, &msg); + if (recv_msg == NULL) + return -EIPCP; + + if (recv_msg->has_result == false) { + ipcp_msg__free_unpacked(recv_msg, NULL); + return -EIPCP; + } + + ret = recv_msg->result; + ipcp_msg__free_unpacked(recv_msg, NULL); + + return ret; +} + int ipcp_reg(pid_t api, const uint8_t * hash, size_t len) |