diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2011-05-27 11:42:38 +0200 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2011-06-02 14:12:42 -0400 |
commit | c326cfa73357be922105dd8ce42b39273fe21f37 (patch) | |
tree | b3fb9bf0500e7e8808a88959dffaaa38e731e1e5 /src | |
parent | 38e989bc5d5ff556505dbd149a0757276774983d (diff) | |
download | sssd-c326cfa73357be922105dd8ce42b39273fe21f37.tar.gz sssd-c326cfa73357be922105dd8ce42b39273fe21f37.tar.xz sssd-c326cfa73357be922105dd8ce42b39273fe21f37.zip |
Add a utility function to escape IPv6 address for use in URIs
Diffstat (limited to 'src')
-rw-r--r-- | src/util/sss_ldap.c | 8 | ||||
-rw-r--r-- | src/util/sss_ldap.h | 3 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/util/sss_ldap.c b/src/util/sss_ldap.c index f098e7d6d..94a10386d 100644 --- a/src/util/sss_ldap.c +++ b/src/util/sss_ldap.c @@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <stdlib.h> +#include <netdb.h> #include "config.h" @@ -68,3 +69,10 @@ int sss_ldap_control_create(const char *oid, int iscritical, return LDAP_SUCCESS; #endif } + +inline const char * +sss_ldap_escape_ip_address(TALLOC_CTX *mem_ctx, int family, const char *addr) +{ + return family == AF_INET6 ? talloc_asprintf(mem_ctx, "[%s]", addr) : + talloc_strdup(mem_ctx, addr); +} diff --git a/src/util/sss_ldap.h b/src/util/sss_ldap.h index 14747dffc..c71349ba1 100644 --- a/src/util/sss_ldap.h +++ b/src/util/sss_ldap.h @@ -27,4 +27,7 @@ int sss_ldap_control_create(const char *oid, int iscritical, struct berval *value, int dupval, LDAPControl **ctrlp); +inline const char * +sss_ldap_escape_ip_address(TALLOC_CTX *mem_ctx, int family, const char *addr); + #endif /* __SSS_LDAP_H__ */ |