summaryrefslogtreecommitdiffstats
path: root/avahi-common
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2005-10-25 22:20:37 +0000
committerLennart Poettering <lennart@poettering.net>2005-10-25 22:20:37 +0000
commitc3575017e2137ef664e4735bd6f9ff1209653ef3 (patch)
tree975af5275fbba0ef9344671adf941f2a60f1968e /avahi-common
parentd2d2f82263bd1007b847324ec27236097bde1609 (diff)
* replace AF_UNSPEC by AVAHI_PROTO_UNSPEC in client-test.c
* remove some functions from the public API in avahi-common/{domain,address}.[ch] and move them into avahi-core/{domain-util,add-util}.[ch] * properly generate CNAME responses * add some more comments to server.c git-svn-id: file:///home/lennart/svn/public/avahi/trunk@871 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-common')
-rw-r--r--avahi-common/address.c47
-rw-r--r--avahi-common/address.h18
-rw-r--r--avahi-common/domain-test.c5
-rw-r--r--avahi-common/domain.c67
-rw-r--r--avahi-common/domain.h20
5 files changed, 8 insertions, 149 deletions
diff --git a/avahi-common/address.c b/avahi-common/address.c
index d02d997..56b4058 100644
--- a/avahi-common/address.c
+++ b/avahi-common/address.c
@@ -34,7 +34,7 @@
#include "address.h"
#include "malloc.h"
-size_t avahi_address_get_size(const AvahiAddress *a) {
+static size_t address_get_size(const AvahiAddress *a) {
assert(a);
if (a->proto == AVAHI_PROTO_INET)
@@ -52,7 +52,7 @@ int avahi_address_cmp(const AvahiAddress *a, const AvahiAddress *b) {
if (a->proto != b->proto)
return -1;
- return memcmp(a->data.data, b->data.data, avahi_address_get_size(a));
+ return memcmp(a->data.data, b->data.data, address_get_size(a));
}
char *avahi_address_snprint(char *s, size_t length, const AvahiAddress *a) {
@@ -126,49 +126,6 @@ AvahiAddress *avahi_address_parse(const char *s, AvahiProtocol proto, AvahiAddre
return ret_addr;
}
-AvahiAddress *avahi_address_from_sockaddr(const struct sockaddr* sa, AvahiAddress *ret_addr) {
- assert(sa);
- assert(ret_addr);
-
- assert(sa->sa_family == AF_INET || sa->sa_family == AF_INET6);
-
- ret_addr->proto = avahi_af_to_proto(sa->sa_family);
-
- if (sa->sa_family == AF_INET)
- memcpy(&ret_addr->data.ipv4, &((const struct sockaddr_in*) sa)->sin_addr, sizeof(ret_addr->data.ipv4));
- else
- memcpy(&ret_addr->data.ipv6, &((const struct sockaddr_in6*) sa)->sin6_addr, sizeof(ret_addr->data.ipv6));
-
- return ret_addr;
-}
-
-uint16_t avahi_port_from_sockaddr(const struct sockaddr* sa) {
- assert(sa);
-
- assert(sa->sa_family == AF_INET || sa->sa_family == AF_INET6);
-
- if (sa->sa_family == AF_INET)
- return ntohs(((const struct sockaddr_in*) sa)->sin_port);
- else
- return ntohs(((const struct sockaddr_in6*) sa)->sin6_port);
-}
-
-int avahi_address_is_ipv4_in_ipv6(const AvahiAddress *a) {
-
- static const uint8_t ipv4_in_ipv6[] = {
- 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- 0xFF, 0xFF, 0xFF, 0xFF
- };
-
- assert(a);
-
- if (a->proto != AVAHI_PROTO_INET6)
- return 0;
-
- return memcmp(a->data.ipv6.address, ipv4_in_ipv6, sizeof(ipv4_in_ipv6)) == 0;
-}
-
int avahi_proto_to_af(AvahiProtocol proto) {
if (proto == AVAHI_PROTO_INET)
return AF_INET;
diff --git a/avahi-common/address.h b/avahi-common/address.h
index c383250..95eb392 100644
--- a/avahi-common/address.h
+++ b/avahi-common/address.h
@@ -24,8 +24,8 @@
/** \file address.h Definitions and functions to manipulate IP addresses. */
-#include <sys/socket.h>
#include <inttypes.h>
+#include <sys/types.h>
#include <avahi-common/cdecl.h>
@@ -65,7 +65,6 @@ typedef struct {
uint32_t address; /**< Address data in network byte order. */
} AvahiIPv4Address;
-
/** An IPv6 address */
typedef struct {
uint8_t address[16]; /**< Address data */
@@ -78,13 +77,10 @@ typedef struct {
union {
AvahiIPv6Address ipv6; /** Address when IPv6 */
AvahiIPv4Address ipv4; /** Address when IPv4 */
- uint8_t data[1]; /** Type independant data field */
+ uint8_t data[1]; /** Type independant data field */
} data;
} AvahiAddress;
-/** Return the address data size of the specified address. (4 for IPv4, 16 for IPv6) */
-size_t avahi_address_get_size(const AvahiAddress *a);
-
/** Compare two addresses. Returns 0 when equal, a negative value when a < b, a positive value when a > b. */
int avahi_address_cmp(const AvahiAddress *a, const AvahiAddress *b);
@@ -96,19 +92,9 @@ char *avahi_address_snprint(char *ret_s, size_t length, const AvahiAddress *a);
* family detection. */
AvahiAddress *avahi_address_parse(const char *s, AvahiProtocol af, AvahiAddress *ret_addr);
-/** Make an address structture of a sockaddr structure */
-AvahiAddress *avahi_address_from_sockaddr(const struct sockaddr* sa, AvahiAddress *ret_addr);
-
-/** Return the port number of a sockaddr structure (either IPv4 or IPv6) */
-uint16_t avahi_port_from_sockaddr(const struct sockaddr* sa);
-
/** Generate the DNS reverse lookup name for an IPv4 or IPv6 address. */
char* avahi_reverse_lookup_name(char *ret_s, size_t length, const AvahiAddress *a);
-/** Check whether the specified IPv6 address is in fact an
- * encapsulated IPv4 address, returns 1 if yes, 0 otherwise */
-int avahi_address_is_ipv4_in_ipv6(const AvahiAddress *a);
-
/** Map AVAHI_PROTO_xxx constants to Unix AF_xxx constants */
int avahi_proto_to_af(AvahiProtocol proto);
diff --git a/avahi-common/domain-test.c b/avahi-common/domain-test.c
index 9926a1f..b765532 100644
--- a/avahi-common/domain-test.c
+++ b/avahi-common/domain-test.c
@@ -37,9 +37,6 @@ int main(int argc, char *argv[]) {
size_t size;
char name[64], type[AVAHI_DOMAIN_NAME_MAX], domain[AVAHI_DOMAIN_NAME_MAX];
- printf("host name: %s\n", s = avahi_get_host_name_strdup());
- avahi_free(s);
-
printf("%s\n", s = avahi_normalize_name_strdup("foo.foo\\046."));
avahi_free(s);
@@ -82,8 +79,6 @@ int main(int argc, char *argv[]) {
p = r;
printf("unescaped: <%s>\n", avahi_unescape_label(&p, t, sizeof(t)));
- assert(avahi_domain_ends_with("foo.bar.\\065\\\\\\.aaaa", "\\065\\\\\\.aaaa"));
-
assert(avahi_is_valid_service_type_generic("_foo._bar._waldo"));
assert(!avahi_is_valid_service_type_strict("_foo._bar._waldo"));
assert(!avahi_is_valid_service_subtype("_foo._bar._waldo"));
diff --git a/avahi-common/domain.c b/avahi-common/domain.c
index 7d954de..4927086 100644
--- a/avahi-common/domain.c
+++ b/avahi-common/domain.c
@@ -37,31 +37,6 @@
#include "malloc.h"
#include "error.h"
-char *avahi_get_host_name(char *ret_s, size_t size) {
-#ifdef HOST_NAME_MAX
- char t[HOST_NAME_MAX];
-#else
- char t[256];
-#endif
-
- assert(ret_s);
- assert(size > 0);
-
- gethostname(t, sizeof(t));
- t[sizeof(t)-1] = 0;
-
- return avahi_normalize_name(t, ret_s, size);
-}
-
-char *avahi_get_host_name_strdup(void) {
- char t[AVAHI_DOMAIN_NAME_MAX];
-
- if (!(avahi_get_host_name(t, sizeof(t))))
- return NULL;
-
- return avahi_strdup(t);
-}
-
/* Read the first label from string *name, unescape "\" and write it to dest */
char *avahi_unescape_label(const char **name, char *dest, size_t size) {
unsigned i = 0;
@@ -273,30 +248,6 @@ int avahi_domain_equal(const char *a, const char *b) {
return 1;
}
-int avahi_binary_domain_cmp(const char *a, const char *b) {
- assert(a);
- assert(b);
-
- if (a == b)
- return 0;
-
- for (;;) {
- char ca[AVAHI_LABEL_MAX], cb[AVAHI_LABEL_MAX], *p;
- int r;
-
- p = avahi_unescape_label(&a, ca, sizeof(ca));
- assert(p);
- p = avahi_unescape_label(&b, cb, sizeof(cb));
- assert(p);
-
- if ((r = strcmp(ca, cb)))
- return r;
-
- if (!*a && !*b)
- return 0;
- }
-}
-
int avahi_is_valid_service_type_generic(const char *t) {
assert(t);
@@ -483,24 +434,6 @@ unsigned avahi_domain_hash(const char *s) {
return hash;
}
-int avahi_domain_ends_with(const char *domain, const char *suffix) {
- assert(domain);
- assert(suffix);
-
- for (;;) {
- char dummy[AVAHI_LABEL_MAX], *r;
-
- if (*domain == 0)
- return 0;
-
- if (avahi_domain_equal(domain, suffix))
- return 1;
-
- r = avahi_unescape_label(&domain, dummy, sizeof(dummy));
- assert(r);
- }
-}
-
int avahi_service_name_join(char *p, size_t size, const char *name, const char *type, const char *domain) {
char escaped_name[AVAHI_LABEL_MAX*4];
char normalized_type[AVAHI_DOMAIN_NAME_MAX];
diff --git a/avahi-common/domain.h b/avahi-common/domain.h
index 4e3aa55..e5869ce 100644
--- a/avahi-common/domain.h
+++ b/avahi-common/domain.h
@@ -44,7 +44,7 @@ AVAHI_C_DECL_BEGIN
* the string brings us to 1014. */
#define AVAHI_DOMAIN_NAME_MAX 1014
-/** Maxium size of an unescaped label */
+/** Maximum size of an unescaped label */
#define AVAHI_LABEL_MAX 64
/** Normalize a domain name into canonical form. This drops trailing
@@ -56,18 +56,9 @@ char *avahi_normalize_name(const char *s, char *ret_s, size_t size);
* result! */
char *avahi_normalize_name_strdup(const char *s);
-/** Return the local host name. */
-char *avahi_get_host_name(char *ret_s, size_t size);
-
-/** Return the local host name. avahi_free() the result! */
-char *avahi_get_host_name_strdup(void);
-
/** Return 1 when the specified domain names are equal, 0 otherwise */
int avahi_domain_equal(const char *a, const char *b);
-/** Do a binary comparison of to specified domain names, return -1, 0, or 1, depending on the order. */
-int avahi_binary_domain_cmp(const char *a, const char *b);
-
/** Read the first label from the textual domain name *name, unescape
* it and write it to dest, *name is changed to point to the next label*/
char *avahi_unescape_label(const char **name, char *dest, size_t size);
@@ -75,6 +66,9 @@ char *avahi_unescape_label(const char **name, char *dest, size_t size);
/** Escape the domain name in *src and write it to *ret_name */
char *avahi_escape_label(const char* src, size_t src_length, char **ret_name, size_t *ret_size);
+/** Return a pointer to the type section of a subtype i.e. _foo._sub._bar._tcp => _bar._tcp */
+const char *avahi_get_type_from_subtype(const char *t);
+
/** Return 1 when the specified string contains a valid generic
* service type (i.e. a series of words starting with "_"), 0
* otherwise */
@@ -88,9 +82,6 @@ int avahi_is_valid_service_type_strict(const char *t);
/** Return 1 when the specified string contains a valid service subtype, 0 otherwise */
int avahi_is_valid_service_subtype(const char *t);
-/** Return a pointer to the type section of a subtype i.e. _foo._sub._bar._tcp => _bar._tcp */
-const char *avahi_get_type_from_subtype(const char *t);
-
/** Return 1 when the specified string contains a valid domain name, 0 otherwise */
int avahi_is_valid_domain_name(const char *t);
@@ -103,9 +94,6 @@ int avahi_is_valid_host_name(const char *t);
/** Return some kind of hash value for the domain, useful for using domains as hash table keys. */
unsigned avahi_domain_hash(const char *name);
-/** Returns 1 if the the end labels of domain are eqal to suffix */
-int avahi_domain_ends_with(const char *domain, const char *suffix);
-
/** Construct a valid complete service name from a name, a type and a domain */
int avahi_service_name_join(char *p, size_t size, const char *name, const char *type, const char *domain);