[sheepdog] [PATCH RFC 1/5] sheep: add nid_to_str() for formatting node id from sockfd subsystem
Hitoshi Mitake
mitake.hitoshi at lab.ntt.co.jp
Fri Jul 12 03:54:22 CEST 2013
From: Hitoshi Mitake <mitake.hitoshi at gmail.com>
sockfd subsystem only has node_id for representing node of each sockfd
entry, so it cannot use node_to_str() for formatting node id. This
patch implements a new function nid_to_str() for sockfd
subsystem, and make node_to_str() a wrapper for it.
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 9c7f96d..6423a1a 100644
--- a/include/sheep.h
+++ b/include/sheep.h
@@ -306,12 +306,12 @@ static inline int nodes_to_vnodes(struct sd_node *nodes, int nr,
#define MAX_NODE_STR_LEN 256
-static inline char *node_to_str(const struct sd_node *id)
+static inline char *nid_to_str(const struct node_id *nid)
{
static char str[MAX_NODE_STR_LEN];
char name[MAX_NODE_STR_LEN];
int af = AF_INET6;
- const uint8_t *addr = id->nid.addr;
+ const uint8_t *addr = nid->addr;
/* Find address family type */
if (addr[12]) {
@@ -324,11 +324,16 @@ static inline 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(name, sizeof(name), id->nid.addr, 0), id->nid.port);
+ addr_to_str(name, sizeof(name), nid->addr, 0), nid->port);
return str;
}
+static inline char *node_to_str(const struct sd_node *id)
+{
+ return nid_to_str(&id->nid);
+}
+
static inline struct sd_node *str_to_node(const char *str, struct sd_node *id)
{
int port;
--
1.7.10.4
More information about the sheepdog
mailing list