dns-domain.h revision df6cfeeff7b66856dd20956efe97d87faf8ce1c3
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering/***
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering This file is part of systemd.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Copyright 2014 Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is free software; you can redistribute it and/or modify it
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering under the terms of the GNU Lesser General Public License as published by
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering (at your option) any later version.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is distributed in the hope that it will be useful, but
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Lesser General Public License for more details.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering You should have received a copy of the GNU Lesser General Public License
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering ***/
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#pragma once
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
3c0cf502796be355431d4a64d738e75f543aa51dLennart Poettering
3c0cf502796be355431d4a64d738e75f543aa51dLennart Poettering#include "hashmap.h"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#include "in-addr-util.h"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#define DNS_LABEL_MAX 63
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#define DNS_NAME_MAX 255
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringint dns_label_unescape(const char **name, char *dest, size_t sz);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringint dns_label_escape(const char *p, size_t l, char **ret);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringint dns_label_apply_idna(const char *encoded, size_t encoded_size, char *decoded, size_t decoded_max);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringint dns_label_undo_idna(const char *encoded, size_t encoded_size, char *decoded, size_t decoded_max);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringint dns_name_normalize(const char *s, char **_ret);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstatic inline int dns_name_is_valid(const char *s) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering int r;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering r = dns_name_normalize(s, NULL);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering if (r == -EINVAL)
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering return 0;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering if (r < 0)
3c0cf502796be355431d4a64d738e75f543aa51dLennart Poettering return r;
3c0cf502796be355431d4a64d738e75f543aa51dLennart Poettering return 1;
0dd25fb9f005d8ab7ac4bc10a609d00569f8c56aLennart Poettering}
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringunsigned long dns_name_hash_func(const void *s, const uint8_t hash_key[HASH_KEY_SIZE]);
3c0cf502796be355431d4a64d738e75f543aa51dLennart Poetteringint dns_name_compare_func(const void *a, const void *b);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringextern const struct hash_ops dns_name_hash_ops;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringint dns_name_equal(const char *x, const char *y);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringint dns_name_endswith(const char *name, const char *suffix);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringint dns_name_reverse(int family, const union in_addr_union *a, char **ret);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringint dns_name_address(const char *p, int *family, union in_addr_union *a);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringint dns_name_root(const char *name);
0dd25fb9f005d8ab7ac4bc10a609d00569f8c56aLennart Poetteringint dns_name_single_label(const char *name);
3c0cf502796be355431d4a64d738e75f543aa51dLennart Poettering