summaryrefslogtreecommitdiff
path: root/sql/wsrep_utils.cc
diff options
context:
space:
mode:
authorJan Lindström <jan.lindstrom@mariadb.com>2017-08-21 13:35:00 +0300
committerJan Lindström <jan.lindstrom@mariadb.com>2017-08-21 13:35:00 +0300
commitc23efc7d50530570e6c13207f3c76adcb9237346 (patch)
tree7c57ca7a1dc61590019abb5608c2b19327f8ed7c /sql/wsrep_utils.cc
parent06106c01481401b6d7ef4309391ca2f66242cc85 (diff)
parentf1af2114993f884b1a6dc34fb1d972ead08f1966 (diff)
downloadmariadb-git-c23efc7d50530570e6c13207f3c76adcb9237346.tar.gz
Merge remote-tracking branch 'origin/10.0-galera' into 10.1
Diffstat (limited to 'sql/wsrep_utils.cc')
-rw-r--r--sql/wsrep_utils.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/sql/wsrep_utils.cc b/sql/wsrep_utils.cc
index a0111354d02..580c8bbd55c 100644
--- a/sql/wsrep_utils.cc
+++ b/sql/wsrep_utils.cc
@@ -574,3 +574,17 @@ done:
return ret;
}
+/* returns the length of the host part of the address string */
+size_t wsrep_host_len(const char* const addr, size_t const addr_len)
+{
+ // check for IPv6 notation first
+ const char* const bracket= ('[' == addr[0] ? strchr(addr, ']') : NULL);
+
+ if (bracket) { // IPv6
+ return (bracket - addr + 1);
+ }
+ else { // host part ends at ':' or end of string
+ const char* const colon= strchr(addr, ':');
+ return (colon ? colon - addr : addr_len);
+ }
+}