summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2011-05-27 11:42:38 +0200
committerStephen Gallagher <sgallagh@redhat.com>2011-06-02 14:07:45 -0400
commitf8202685c80ca49734d554999062c58f4f470c37 (patch)
tree59a3024059e369eed552a0b44bfbb2b911a249d3 /src/util
parentbfdcff2b28f399d236b592d13663c7283d6eac2c (diff)
downloadsssd-f8202685c80ca49734d554999062c58f4f470c37.tar.gz
sssd-f8202685c80ca49734d554999062c58f4f470c37.tar.bz2
sssd-f8202685c80ca49734d554999062c58f4f470c37.zip
Add a utility function to escape IPv6 address for use in URIs
Diffstat (limited to 'src/util')
-rw-r--r--src/util/sss_ldap.c8
-rw-r--r--src/util/sss_ldap.h3
2 files changed, 11 insertions, 0 deletions
diff --git a/src/util/sss_ldap.c b/src/util/sss_ldap.c
index a4d73a8a..49d989b6 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"
@@ -86,3 +87,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 b77a2031..16c22641 100644
--- a/src/util/sss_ldap.h
+++ b/src/util/sss_ldap.h
@@ -46,4 +46,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__ */