[sheepdog] [PATCH v6 1/4] move node_to_str() and str_to_node() from sheep/cluster.h to include/sheep.h
Hitoshi Mitake
mitake.hitoshi at lab.ntt.co.jp
Thu Jan 17 03:25:10 CET 2013
shephered uses node_to_str() and str_to_node(), so they should be
moved to the header which can be included by other directories of
sheep/.
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
v6: move the functions to include/sheep.h, not include/internal_proto.h
8<---
include/sheep.h | 36 ++++++++++++++++++++++++++++++++++++
sheep/cluster.h | 36 ------------------------------------
2 files changed, 36 insertions(+), 36 deletions(-)
diff --git a/include/sheep.h b/include/sheep.h
index e0d63a4..4a7713d 100644
--- a/include/sheep.h
+++ b/include/sheep.h
@@ -300,4 +300,40 @@ static inline int nodes_to_vnodes(struct sd_node *nodes, int nr,
return nr_vnodes;
}
+static inline char *node_to_str(const struct sd_node *id)
+{
+ static char str[256];
+ char name[256];
+ int af = AF_INET6;
+ const uint8_t *addr = id->nid.addr;
+
+ /* Find address family type */
+ if (addr[12]) {
+ int oct_no = 0;
+ while (!addr[oct_no] && oct_no++ < 12)
+ ;
+ if (oct_no == 12)
+ af = AF_INET;
+ }
+
+ snprintf(str, sizeof(str), "%s ip:%s port:%d",
+ (af == AF_INET) ? "IPv4" : "IPv6",
+ addr_to_str(name, sizeof(name), id->nid.addr, 0), id->nid.port);
+
+ return str;
+}
+
+static inline struct sd_node *str_to_node(const char *str, struct sd_node *id)
+{
+ int port;
+ char v[8], ip[256];
+
+ sscanf(str, "%s ip:%s port:%d", v, ip, &port);
+ id->nid.port = port;
+ if (!str_to_addr(ip, id->nid.addr))
+ return NULL;
+
+ return id;
+}
+
#endif
diff --git a/sheep/cluster.h b/sheep/cluster.h
index d078f48..a928bb1 100644
--- a/sheep/cluster.h
+++ b/sheep/cluster.h
@@ -153,42 +153,6 @@ static inline const char *get_cdrv_option(const struct cluster_driver *cdrv,
return NULL;
}
-static inline char *node_to_str(const struct sd_node *id)
-{
- static char str[256];
- char name[256];
- int af = AF_INET6;
- const uint8_t *addr = id->nid.addr;
-
- /* Find address family type */
- if (addr[12]) {
- int oct_no = 0;
- while (!addr[oct_no] && oct_no++ < 12)
- ;
- if (oct_no == 12)
- af = AF_INET;
- }
-
- snprintf(str, sizeof(str), "%s ip:%s port:%d",
- (af == AF_INET) ? "IPv4" : "IPv6",
- addr_to_str(name, sizeof(name), id->nid.addr, 0), id->nid.port);
-
- return str;
-}
-
-static inline struct sd_node *str_to_node(const char *str, struct sd_node *id)
-{
- int port;
- char v[8], ip[256];
-
- sscanf(str, "%s ip:%s port:%d", v, ip, &port);
- id->nid.port = port;
- if (!str_to_addr(ip, id->nid.addr))
- return NULL;
-
- return id;
-}
-
/* callbacks back into sheepdog from the cluster drivers */
void sd_join_handler(const struct sd_node *joined,
const struct sd_node *members,
--
1.7.2.5
More information about the sheepdog
mailing list