summaryrefslogtreecommitdiffstats
path: root/avahi-common
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2005-10-27 19:11:34 +0000
committerLennart Poettering <lennart@poettering.net>2005-10-27 19:11:34 +0000
commitf6712902a92eb82b6c8d7e7fd0980a20a716fa0d (patch)
tree039df978bd7ea226c54fdce3aa6b17ee5728d492 /avahi-common
parenta950fddba0cc84e64bc72eb621429ba05540e98e (diff)
* format unknown DNS records according to RFC3597
* add some DNS class and type validity checks to avahi_server_add() * move DNS type and class definitions to avahi-common/defs.h git-svn-id: file:///home/lennart/svn/public/avahi/trunk@896 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-common')
-rw-r--r--avahi-common/dbus.c8
-rw-r--r--avahi-common/dbus.h8
-rw-r--r--avahi-common/defs.h25
-rw-r--r--avahi-common/error.c5
-rw-r--r--avahi-common/error.h21
5 files changed, 53 insertions, 14 deletions
diff --git a/avahi-common/dbus.c b/avahi-common/dbus.c
index d8a6f48..cebf56d 100644
--- a/avahi-common/dbus.c
+++ b/avahi-common/dbus.c
@@ -41,6 +41,7 @@ static const char * const table[- AVAHI_ERR_MAX] = {
AVAHI_DBUS_ERR_IS_PATTERN,
AVAHI_DBUS_ERR_COLLISION,
AVAHI_DBUS_ERR_INVALID_RECORD,
+
AVAHI_DBUS_ERR_INVALID_SERVICE_NAME,
AVAHI_DBUS_ERR_INVALID_SERVICE_TYPE,
AVAHI_DBUS_ERR_INVALID_PORT,
@@ -51,6 +52,7 @@ static const char * const table[- AVAHI_ERR_MAX] = {
AVAHI_DBUS_ERR_TOO_MANY_OBJECTS,
AVAHI_DBUS_ERR_TOO_MANY_ENTRIES,
AVAHI_DBUS_ERR_OS,
+
AVAHI_DBUS_ERR_ACCESS_DENIED,
AVAHI_DBUS_ERR_INVALID_OPERATION,
AVAHI_DBUS_ERR_DBUS_ERROR,
@@ -61,6 +63,7 @@ static const char * const table[- AVAHI_ERR_MAX] = {
AVAHI_DBUS_ERR_INVALID_INTERFACE,
AVAHI_DBUS_ERR_INVALID_PROTOCOL,
AVAHI_DBUS_ERR_INVALID_FLAGS,
+
AVAHI_DBUS_ERR_NOT_FOUND,
AVAHI_DBUS_ERR_INVALID_CONFIG,
AVAHI_DBUS_ERR_VERSION_MISMATCH,
@@ -71,13 +74,16 @@ static const char * const table[- AVAHI_ERR_MAX] = {
AVAHI_DBUS_ERR_DNS_SERVFAIL,
AVAHI_DBUS_ERR_DNS_NXDOMAIN,
AVAHI_DBUS_ERR_DNS_NOTIMP,
+
AVAHI_DBUS_ERR_DNS_REFUSED,
AVAHI_DBUS_ERR_DNS_YXDOMAIN,
AVAHI_DBUS_ERR_DNS_YXRRSET,
AVAHI_DBUS_ERR_DNS_NXRRSET,
AVAHI_DBUS_ERR_DNS_NOTAUTH,
AVAHI_DBUS_ERR_DNS_NOTZONE,
- AVAHI_DBUS_ERR_INVALID_RDATA
+ AVAHI_DBUS_ERR_INVALID_RDATA,
+ AVAHI_DBUS_ERR_INVALID_DNS_CLASS,
+ AVAHI_DBUS_ERR_INVALID_DNS_TYPE
};
int avahi_error_dbus_to_number(const char *s) {
diff --git a/avahi-common/dbus.h b/avahi-common/dbus.h
index 16582d0..86c62f2 100644
--- a/avahi-common/dbus.h
+++ b/avahi-common/dbus.h
@@ -50,6 +50,7 @@ AVAHI_C_DECL_BEGIN
#define AVAHI_DBUS_ERR_IS_PATTERN "org.freedesktop.Avahi.IsPatternError"
#define AVAHI_DBUS_ERR_COLLISION "org.freedesktop.Avahi.CollisionError"
#define AVAHI_DBUS_ERR_INVALID_RECORD "org.freedesktop.Avahi.InvalidRecordError"
+
#define AVAHI_DBUS_ERR_INVALID_SERVICE_NAME "org.freedesktop.Avahi.InvalidServiceNameError"
#define AVAHI_DBUS_ERR_INVALID_SERVICE_TYPE "org.freedesktop.Avahi.InvalidServiceTypeError"
#define AVAHI_DBUS_ERR_INVALID_PORT "org.freedesktop.Avahi.InvalidPortError"
@@ -60,6 +61,7 @@ AVAHI_C_DECL_BEGIN
#define AVAHI_DBUS_ERR_TOO_MANY_OBJECTS "org.freedesktop.Avahi.TooManyObjectsError"
#define AVAHI_DBUS_ERR_TOO_MANY_ENTRIES "org.freedesktop.Avahi.TooManyEntriesError"
#define AVAHI_DBUS_ERR_OS "org.freedesktop.Avahi.OSError"
+
#define AVAHI_DBUS_ERR_ACCESS_DENIED DBUS_ERROR_ACCESS_DENIED
#define AVAHI_DBUS_ERR_INVALID_OPERATION "org.freedesktop.Avahi.InvalidOperationError"
#define AVAHI_DBUS_ERR_DBUS_ERROR "org.freedesktop.Avahi.DBusError"
@@ -70,6 +72,7 @@ AVAHI_C_DECL_BEGIN
#define AVAHI_DBUS_ERR_INVALID_INTERFACE "org.freedesktop.Avahi.InvalidInterfaceError"
#define AVAHI_DBUS_ERR_INVALID_PROTOCOL "org.freedesktop.Avahi.InvalidInterfaceProtocolError"
#define AVAHI_DBUS_ERR_INVALID_FLAGS "org.freedesktop.Avahi.InvalidFlagsError"
+
#define AVAHI_DBUS_ERR_NOT_FOUND "org.freedesktop.Avahi.NotFoundError"
#define AVAHI_DBUS_ERR_INVALID_CONFIG "org.freedesktop.Avahi.InvalidConfigurationError"
#define AVAHI_DBUS_ERR_VERSION_MISMATCH "org.freedesktop.Avahi.VersionMismatchError"
@@ -80,13 +83,16 @@ AVAHI_C_DECL_BEGIN
#define AVAHI_DBUS_ERR_DNS_SERVFAIL "org.freedesktop.Avahi.DNSSERVFAIL"
#define AVAHI_DBUS_ERR_DNS_NXDOMAIN "org.freedesktop.Avahi.DNSNXDOMAIN"
#define AVAHI_DBUS_ERR_DNS_NOTIMP "org.freedesktop.Avahi.DNSNOTIMP"
+
#define AVAHI_DBUS_ERR_DNS_REFUSED "org.freedesktop.Avahi.DNSREFUSED"
#define AVAHI_DBUS_ERR_DNS_YXDOMAIN "org.freedesktop.Avahi.DNSYXDOMAIN"
#define AVAHI_DBUS_ERR_DNS_YXRRSET "org.freedesktop.Avahi.DNSYXRRSET"
#define AVAHI_DBUS_ERR_DNS_NXRRSET "org.freedesktop.Avahi.DNSNXRRSET"
#define AVAHI_DBUS_ERR_DNS_NOTAUTH "org.freedesktop.Avahi.DNSNOTAUTH"
#define AVAHI_DBUS_ERR_DNS_NOTZONE "org.freedesktop.Avahi.DNSNOTZONE"
-#define AVAHI_DBUS_ERR_INVALID_RDATA "org.freedesktop.Avahi.InvalidRDATA"
+#define AVAHI_DBUS_ERR_INVALID_RDATA "org.freedesktop.Avahi.InvalidRDataError"
+#define AVAHI_DBUS_ERR_INVALID_DNS_CLASS "org.freedesktop.Avahi.InvalidDNSClass"
+#define AVAHI_DBUS_ERR_INVALID_DNS_TYPE "org.freedesktop.Avahi.InvalidDNSType"
/** Convert a DBus error string into an Avahi error number */
int avahi_error_dbus_to_number(const char *s);
diff --git a/avahi-common/defs.h b/avahi-common/defs.h
index 14a0ba3..4393e98 100644
--- a/avahi-common/defs.h
+++ b/avahi-common/defs.h
@@ -225,6 +225,31 @@ typedef enum {
/** In invalid cookie as special value */
#define AVAHI_SERVICE_COOKIE_INVALID (0)
+/** DNS record types, see RFC 1035 */
+enum {
+ AVAHI_DNS_TYPE_A = 0x01,
+ AVAHI_DNS_TYPE_NS = 0x02,
+ AVAHI_DNS_TYPE_CNAME = 0x05,
+ AVAHI_DNS_TYPE_SOA = 0x06,
+ AVAHI_DNS_TYPE_PTR = 0x0C,
+ AVAHI_DNS_TYPE_HINFO = 0x0D,
+ AVAHI_DNS_TYPE_MX = 0x0F,
+ AVAHI_DNS_TYPE_TXT = 0x10,
+ AVAHI_DNS_TYPE_AAAA = 0x1C,
+ AVAHI_DNS_TYPE_SRV = 0x21,
+};
+
+/** DNS record classes, see RFC 1035 */
+enum {
+ AVAHI_DNS_CLASS_IN = 0x01, /**< Probably the only class we will ever use */
+};
+
+/** The default TTL for RRs which contain a host name of some kind. */
+#define AVAHI_DEFAULT_TTL_HOST_NAME (120)
+
+/** The default TTL for all other records. */
+#define AVAHI_DEFAULT_TTL (75*60)
+
AVAHI_C_DECL_END
#endif
diff --git a/avahi-common/error.c b/avahi-common/error.c
index f2216b4..c997dc0 100644
--- a/avahi-common/error.c
+++ b/avahi-common/error.c
@@ -78,8 +78,9 @@ const char *avahi_strerror(int error) {
"DNS failure: NXRRSET",
"DNS failure: NOTAUTH",
"DNS failure: NOTZONE",
-
- "Invalid RDATA"
+ "Invalid RDATA",
+ "Invalid DNS type",
+ "Invalid DNS class"
};
if (-error < 0 || -error >= -AVAHI_ERR_MAX)
diff --git a/avahi-common/error.h b/avahi-common/error.h
index f1a019d..0c3320d 100644
--- a/avahi-common/error.h
+++ b/avahi-common/error.h
@@ -69,19 +69,20 @@ enum {
AVAHI_ERR_INVALID_SERVICE_SUBTYPE = -33, /**< Invalid service subtype */
AVAHI_ERR_INVALID_PACKET = -34, /**< Invalid packet */
AVAHI_ERR_INVALID_DNS_ERROR = -35, /**< Invlaid DNS return code */
- AVAHI_ERR_DNS_FORMERR = -36,
- AVAHI_ERR_DNS_SERVFAIL = -37,
- AVAHI_ERR_DNS_NXDOMAIN = -38,
- AVAHI_ERR_DNS_NOTIMP = -39,
+ AVAHI_ERR_DNS_FORMERR = -36, /**< DNS Error: Form error */
+ AVAHI_ERR_DNS_SERVFAIL = -37, /**< DNS Error: Server Failure */
+ AVAHI_ERR_DNS_NXDOMAIN = -38, /**< DNS Error: No such domain */
+ AVAHI_ERR_DNS_NOTIMP = -39, /**< DNS Error: Not implemented */
- AVAHI_ERR_DNS_REFUSED = -40,
+ AVAHI_ERR_DNS_REFUSED = -40, /**< DNS Error: Operation refused */
AVAHI_ERR_DNS_YXDOMAIN = -41,
AVAHI_ERR_DNS_YXRRSET = -42,
AVAHI_ERR_DNS_NXRRSET = -43,
- AVAHI_ERR_DNS_NOTAUTH = -44,
- AVAHI_ERR_DNS_NOTZONE = -45,
-
- AVAHI_ERR_INVALID_RDATA = -46,
+ AVAHI_ERR_DNS_NOTAUTH = -44, /**< DNS Error: Not authorized */
+ AVAHI_ERR_DNS_NOTZONE = -45,
+ AVAHI_ERR_INVALID_RDATA = -46, /**< Invalid RDATA */
+ AVAHI_ERR_INVALID_DNS_CLASS = -47, /**< Invalid DNS class */
+ AVAHI_ERR_INVALID_DNS_TYPE = -48, /**< Invalid DNS type */
/****
**** IF YOU ADD A NEW ERROR CODE HERE, PLEASE DON'T FORGET TO ADD
@@ -91,7 +92,7 @@ enum {
**** Also remember to update the MAX value below.
****/
- AVAHI_ERR_MAX = -47
+ AVAHI_ERR_MAX = -49
};
/** Return a human readable error string for the specified error code */