[sheepdog] [PATCH v2 5/7] sheep: a new helper function for formatting struct node_id

Hitoshi Mitake mitake.hitoshi at lab.ntt.co.jp
Wed Jul 30 09:24:40 CEST 2014


This is just a preparation patch.

Cc: Fabian Zimmermann <dev.faz at gmail.com>
Cc: Valerio Pachera <sirio81 at gmail.com>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
 include/sheep.h | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/include/sheep.h b/include/sheep.h
index 5b136a8..a8d97a8 100644
--- a/include/sheep.h
+++ b/include/sheep.h
@@ -282,11 +282,11 @@ static inline void nodes_to_buffer(struct rb_root *nroot, void *buffer)
 
 #define MAX_NODE_STR_LEN 256
 
-static inline const char *node_to_str(const struct sd_node *id)
+static inline const char *node_id_to_str(const struct node_id *id)
 {
 	static __thread char str[MAX_NODE_STR_LEN];
 	int af = AF_INET6;
-	const uint8_t *addr = id->nid.addr;
+	const uint8_t *addr = id->addr;
 
 	/* Find address family type */
 	if (addr[12]) {
@@ -299,11 +299,16 @@ static inline const char *node_to_str(const struct sd_node *id)
 
 	snprintf(str, sizeof(str), "%s ip:%s port:%d",
 		(af == AF_INET) ? "IPv4" : "IPv6",
-		addr_to_str(id->nid.addr, 0), id->nid.port);
+		addr_to_str(id->addr, 0), id->port);
 
 	return str;
 }
 
+static inline const char *node_to_str(const struct sd_node *id)
+{
+	return node_id_to_str(&id->nid);
+}
+
 static inline struct sd_node *str_to_node(const char *str, struct sd_node *id)
 {
 	int port;
-- 
1.8.3.2




More information about the sheepdog mailing list