[Ocfs2-tools-devel] [PATCH 07/32] libo2cb: Extend libo2cb api to learn ip address/port/local of a registered node
Sunil Mushran
sunil.mushran at oracle.com
Tue Sep 14 15:54:37 PDT 2010
Adds three function calls, o2cb_get_node_ip_string(), o2cb_get_node_port()
and o2cb_get_node_local, to learn the ip address, port. local of the registered
node.
Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
---
include/o2cb/o2cb.h | 10 +++++++++
libo2cb/o2cb_abi.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 64 insertions(+), 0 deletions(-)
diff --git a/include/o2cb/o2cb.h b/include/o2cb/o2cb.h
index e1c0351..8526ad7 100644
--- a/include/o2cb/o2cb.h
+++ b/include/o2cb/o2cb.h
@@ -129,6 +129,16 @@ errcode_t o2cb_num_region_refs(const char *region_name,
errcode_t o2cb_get_node_num(const char *cluster_name,
const char *node_name,
uint16_t *node_num);
+errcode_t o2cb_get_node_port(const char *cluster_name,
+ const char *node_name,
+ uint32_t *ip_port);
+errcode_t o2cb_get_node_ip_string(const char *cluster_name,
+ const char *node_name,
+ char *ip_address, int count);
+errcode_t o2cb_get_node_local(const char *cluster_name,
+ const char *node_name,
+ uint32_t *local);
+
void o2cb_free_cluster_desc(struct o2cb_cluster_desc *cluster);
errcode_t o2cb_running_cluster_desc(struct o2cb_cluster_desc *cluster);
diff --git a/libo2cb/o2cb_abi.c b/libo2cb/o2cb_abi.c
index 05a13bc..2f6a443 100644
--- a/libo2cb/o2cb_abi.c
+++ b/libo2cb/o2cb_abi.c
@@ -2190,6 +2190,60 @@ errcode_t o2cb_get_node_num(const char *cluster_name, const char *node_name,
return 0;
}
+errcode_t o2cb_get_node_port(const char *cluster_name, const char *node_name,
+ uint32_t *ip_port)
+{
+ char val[30];
+ char *p;
+ errcode_t ret;
+
+ ret = o2cb_get_node_attribute(cluster_name, node_name, "ipv4_port",
+ val, sizeof(val));
+ if (ret)
+ return ret;
+
+ *ip_port = strtoul(val, &p, 0);
+ if (!p || (*p && *p != '\n'))
+ return O2CB_ET_INTERNAL_FAILURE;
+
+ return 0;
+}
+
+errcode_t o2cb_get_node_ip_string(const char *cluster_name,
+ const char *node_name,
+ char *ip_address, int count)
+{
+ errcode_t ret;
+
+ ret = o2cb_get_node_attribute(cluster_name, node_name, "ipv4_address",
+ ip_address, count - 1);
+ if (ret)
+ return ret;
+
+ /* wipeout the last newline character */
+ do_strchomp(ip_address);
+
+ return 0;
+}
+
+errcode_t o2cb_get_node_local(const char *cluster_name, const char *node_name,
+ uint32_t *local)
+{
+ char val[30];
+ char *p;
+ errcode_t ret;
+
+ ret = o2cb_get_node_attribute(cluster_name, node_name, "local",
+ val, sizeof(val));
+ if (ret)
+ return ret;
+
+ *local = strtoul(val, &p, 0);
+ if (!p || (*p && *p != '\n'))
+ return O2CB_ET_INTERNAL_FAILURE;
+
+ return 0;
+}
/*
* The handshake is pretty simple. We need to read all supported control
* device protocols from the kernel. Once we've read them, we can write
--
1.7.0.4
More information about the Ocfs2-tools-devel
mailing list