Index: src/OFDNSQuery.h ================================================================== --- src/OFDNSQuery.h +++ src/OFDNSQuery.h @@ -26,12 +26,12 @@ * @brief A class representing a DNS query. */ @interface OFDNSQuery: OFObject { OFString *_domainName; - of_dns_class_t _DNSClass; - of_dns_record_type_t _recordType; + OFDNSClass _DNSClass; + OFDNSRecordType _recordType; OF_RESERVE_IVARS(OFDNSQuery, 4) } /** * @brief The domain name of the query. @@ -39,16 +39,16 @@ @property (readonly, nonatomic) OFString *domainName; /** * @brief The DNS class of the query. */ -@property (readonly, nonatomic) of_dns_class_t DNSClass; +@property (readonly, nonatomic) OFDNSClass DNSClass; /** * @brief The record type of the query. */ -@property (readonly, nonatomic) of_dns_record_type_t recordType; +@property (readonly, nonatomic) OFDNSRecordType recordType; /** * @brief Creates a new, autoreleased OFDNSQuery. * * @param domainName The domain name to query @@ -55,12 +55,12 @@ * @param DNSClass The DNS class of the query * @param recordType The record type of the query * @return A new, autoreleased OFDNSQuery */ + (instancetype)queryWithDomainName: (OFString *)domainName - DNSClass: (of_dns_class_t)DNSClass - recordType: (of_dns_record_type_t)recordType; + DNSClass: (OFDNSClass)DNSClass + recordType: (OFDNSRecordType)recordType; /** * @brief Initializes an already allocated OFDNSQuery. * * @param domainName The domain name to query @@ -67,13 +67,13 @@ * @param DNSClass The DNS class of the query * @param recordType The record type of the query * @return An initialized OFDNSQuery */ - (instancetype)initWithDomainName: (OFString *)domainName - DNSClass: (of_dns_class_t)DNSClass - recordType: (of_dns_record_type_t)recordType + DNSClass: (OFDNSClass)DNSClass + recordType: (OFDNSRecordType)recordType OF_DESIGNATED_INITIALIZER; - (instancetype)init OF_UNAVAILABLE; @end OF_ASSUME_NONNULL_END Index: src/OFDNSQuery.m ================================================================== --- src/OFDNSQuery.m +++ src/OFDNSQuery.m @@ -21,21 +21,21 @@ @implementation OFDNSQuery @synthesize domainName = _domainName, DNSClass = _DNSClass; @synthesize recordType = _recordType; + (instancetype)queryWithDomainName: (OFString *)domainName - DNSClass: (of_dns_class_t)DNSClass - recordType: (of_dns_record_type_t)recordType + DNSClass: (OFDNSClass)DNSClass + recordType: (OFDNSRecordType)recordType { return [[[self alloc] initWithDomainName: domainName DNSClass: DNSClass recordType: recordType] autorelease]; } - (instancetype)initWithDomainName: (OFString *)domainName - DNSClass: (of_dns_class_t)DNSClass - recordType: (of_dns_record_type_t)recordType + DNSClass: (OFDNSClass)DNSClass + recordType: (OFDNSRecordType)recordType { self = [super init]; @try { void *pool = objc_autoreleasePoolPush(); @@ -110,9 +110,9 @@ } - (OFString *)description { return [OFString stringWithFormat: @"<%@ %@ %@ %@>", - self.className, _domainName, of_dns_class_to_string(_DNSClass), - of_dns_record_type_to_string(_recordType)]; + self.className, _domainName, OFDNSClassName(_DNSClass), + OFDNSRecordTypeName(_recordType)]; } @end Index: src/OFDNSResolver.h ================================================================== --- src/OFDNSResolver.h +++ src/OFDNSResolver.h @@ -34,41 +34,41 @@ @class OFNumber; @class OFTCPSocket; @class OFUDPSocket; /** - * @enum of_dns_resolver_error_t OFDNSResolver.h ObjFW/OFDNSResolver.h + * @enum OFDNSResolverErrorCode OFDNSResolver.h ObjFW/OFDNSResolver.h * * @brief An enum describing why resolving a host failed. */ -typedef enum of_dns_resolver_error_t { +typedef enum OFDNSResolverErrorCode { /** An unknown error */ - OF_DNS_RESOLVER_ERROR_UNKNOWN, + OFDNSResolverErrorCodeUnknown, /** The query timed out */ - OF_DNS_RESOLVER_ERROR_TIMEOUT, + OFDNSResolverErrorCodeTimeout, /** The query was canceled */ - OF_DNS_RESOLVER_ERROR_CANCELED, + OFDNSResolverErrorCodeCanceled, /** * No result for the specified host with the specified type and class. * * This is only used in situations where this is an error, e.g. when * trying to connect to a host. */ - OF_DNS_RESOLVER_ERROR_NO_RESULT, + OFDNSResolverErrorCodeNoResult, /** The server considered the query to be malformed */ - OF_DNS_RESOLVER_ERROR_SERVER_INVALID_FORMAT, + OFDNSResolverErrorCodeServerInvalidFormat, /** The server was unable to process due to an internal error */ - OF_DNS_RESOLVER_ERROR_SERVER_FAILURE, + OFDNSResolverErrorCodeServerFailure, /** The server returned an error that the domain does not exist */ - OF_DNS_RESOLVER_ERROR_SERVER_NAME_ERROR, + OFDNSResolverErrorCodeServerNameError, /** The server does not have support for the requested query */ - OF_DNS_RESOLVER_ERROR_SERVER_NOT_IMPLEMENTED, + OFDNSResolverErrorCodeServerNotImplemented, /** The server refused the query */ - OF_DNS_RESOLVER_ERROR_SERVER_REFUSED, + OFDNSResolverErrorCodeServerRefused, /** There was no name server to query */ - OF_DNS_RESOLVER_ERROR_NO_NAME_SERVER -} of_dns_resolver_error_t; + OFDNSResolverErrorCodeNoNameServer +} OFDNSResolverErrorCode; /** * @protocol OFDNSResolverQueryDelegate OFDNSResolver.h ObjFW/OFDNSResolver.h * * @brief A delegate for performed DNS queries. Index: src/OFDNSResolver.m ================================================================== --- src/OFDNSResolver.m +++ src/OFDNSResolver.m @@ -166,15 +166,15 @@ return [components componentsJoinedByString: @"."]; } static OF_KINDOF(OFDNSResourceRecord *) -parseResourceRecord(OFString *name, of_dns_class_t DNSClass, - of_dns_record_type_t recordType, uint32_t TTL, const unsigned char *buffer, +parseResourceRecord(OFString *name, OFDNSClass DNSClass, + OFDNSRecordType recordType, uint32_t TTL, const unsigned char *buffer, size_t length, size_t i, uint16_t dataLength) { - if (recordType == OF_DNS_RECORD_TYPE_A && DNSClass == OF_DNS_CLASS_IN) { + if (recordType == OFDNSRecordTypeA && DNSClass == OFDNSClassIN) { OFSocketAddress address; if (dataLength != 4) @throw [OFInvalidServerReplyException exception]; @@ -187,11 +187,11 @@ return [[[OFADNSResourceRecord alloc] initWithName: name address: &address TTL: TTL] autorelease]; - } else if (recordType == OF_DNS_RECORD_TYPE_NS) { + } else if (recordType == OFDNSRecordTypeNS) { size_t j = i; OFString *authoritativeHost = parseName(buffer, length, &j, MAX_ALLOWED_POINTERS); if (j != i + dataLength) @@ -200,11 +200,11 @@ return [[[OFNSDNSResourceRecord alloc] initWithName: name DNSClass: DNSClass authoritativeHost: authoritativeHost TTL: TTL] autorelease]; - } else if (recordType == OF_DNS_RECORD_TYPE_CNAME) { + } else if (recordType == OFDNSRecordTypeCNAME) { size_t j = i; OFString *alias = parseName(buffer, length, &j, MAX_ALLOWED_POINTERS); if (j != i + dataLength) @@ -213,11 +213,11 @@ return [[[OFCNAMEDNSResourceRecord alloc] initWithName: name DNSClass: DNSClass alias: alias TTL: TTL] autorelease]; - } else if (recordType == OF_DNS_RECORD_TYPE_SOA) { + } else if (recordType == OFDNSRecordTypeSOA) { size_t j = i; OFString *primaryNameServer = parseName(buffer, length, &j, MAX_ALLOWED_POINTERS); OFString *responsiblePerson; uint32_t serialNumber, refreshInterval, retryInterval; @@ -254,11 +254,11 @@ refreshInterval: refreshInterval retryInterval: retryInterval expirationInterval: expirationInterval minTTL: minTTL TTL: TTL] autorelease]; - } else if (recordType == OF_DNS_RECORD_TYPE_PTR) { + } else if (recordType == OFDNSRecordTypePTR) { size_t j = i; OFString *domainName = parseName(buffer, length, &j, MAX_ALLOWED_POINTERS); if (j != i + dataLength) @@ -267,11 +267,11 @@ return [[[OFPTRDNSResourceRecord alloc] initWithName: name DNSClass: DNSClass domainName: domainName TTL: TTL] autorelease]; - } else if (recordType == OF_DNS_RECORD_TYPE_HINFO) { + } else if (recordType == OFDNSRecordTypeHINFO) { size_t j = i; OFString *CPU = parseString(buffer, length, &j); OFString *OS; if (j > i + dataLength) @@ -286,11 +286,11 @@ initWithName: name DNSClass: DNSClass CPU: CPU OS: OS TTL: TTL] autorelease]; - } else if (recordType == OF_DNS_RECORD_TYPE_MX) { + } else if (recordType == OFDNSRecordTypeMX) { uint16_t preference; size_t j; OFString *mailExchange; if (dataLength < 2) @@ -309,11 +309,11 @@ initWithName: name DNSClass: DNSClass preference: preference mailExchange: mailExchange TTL: TTL] autorelease]; - } else if (recordType == OF_DNS_RECORD_TYPE_TXT) { + } else if (recordType == OFDNSRecordTypeTXT) { OFMutableArray *textStrings = [OFMutableArray array]; while (dataLength > 0) { uint_fast8_t stringLength = buffer[i++]; dataLength--; @@ -335,11 +335,11 @@ return [[[OFTXTDNSResourceRecord alloc] initWithName: name DNSClass: DNSClass textStrings: textStrings TTL: TTL] autorelease]; - } else if (recordType == OF_DNS_RECORD_TYPE_RP) { + } else if (recordType == OFDNSRecordTypeRP) { size_t j = i; OFString *mailbox = parseName(buffer, length, &j, MAX_ALLOWED_POINTERS); OFString *TXTDomainName; @@ -356,12 +356,12 @@ initWithName: name DNSClass: DNSClass mailbox: mailbox TXTDomainName: TXTDomainName TTL: TTL] autorelease]; - } else if (recordType == OF_DNS_RECORD_TYPE_AAAA && - DNSClass == OF_DNS_CLASS_IN) { + } else if (recordType == OFDNSRecordTypeAAAA && + DNSClass == OFDNSClassIN) { OFSocketAddress address; if (dataLength != 16) @throw [OFInvalidServerReplyException exception]; @@ -378,12 +378,12 @@ return [[[OFAAAADNSResourceRecord alloc] initWithName: name address: &address TTL: TTL] autorelease]; - } else if (recordType == OF_DNS_RECORD_TYPE_SRV && - DNSClass == OF_DNS_CLASS_IN) { + } else if (recordType == OFDNSRecordTypeSRV && + DNSClass == OFDNSClassIN) { uint16_t priority, weight, port; size_t j; OFString *target; if (dataLength < 6) @@ -423,12 +423,12 @@ OFMutableArray *array; for (uint_fast16_t j = 0; j < count; j++) { OFString *name = parseName(buffer, length, i, MAX_ALLOWED_POINTERS); - of_dns_class_t DNSClass; - of_dns_record_type_t recordType; + OFDNSClass DNSClass; + OFDNSRecordType recordType; uint32_t TTL; uint16_t dataLength; OFDNSResourceRecord *record; if (*i + 10 > length) @@ -807,11 +807,11 @@ @throw [OFOutOfRangeException exception]; if (_settings->_nameServers.count == 0) { id exception = [OFDNSQueryFailedException exceptionWithQuery: query - error: OF_DNS_RESOLVER_ERROR_NO_NAME_SERVER]; + errorCode: OFDNSResolverErrorCodeNoNameServer]; [delegate resolver: self didPerformQuery: query response: nil exception: exception]; return; @@ -869,11 +869,11 @@ [_IPv6Socket asyncReceiveIntoBuffer: _buffer length: BUFFER_LENGTH]; #endif exception = [OFDNSQueryFailedException exceptionWithQuery: context->_query - error: OF_DNS_RESOLVER_ERROR_TIMEOUT]; + errorCode: OFDNSResolverErrorCodeTimeout]; [context->_delegate resolver: self didPerformQuery: context->_query response: nil exception: exception]; @@ -910,11 +910,11 @@ [context->_cancelTimer release]; context->_cancelTimer = nil; [_queries removeObjectForKey: ID]; @try { - of_dns_resolver_error_t error = 0; + OFDNSResolverErrorCode errorCode = 0; bool tryNextNameServer = false; const unsigned char *queryDataBuffer; size_t i; uint16_t numQuestions, numAnswers, numAuthorityRecords; uint16_t numAdditionalRecords; @@ -953,29 +953,29 @@ /* RCODE */ switch (buffer[3] & 0x0F) { case 0: break; case 1: - error = OF_DNS_RESOLVER_ERROR_SERVER_INVALID_FORMAT; + errorCode = OFDNSResolverErrorCodeServerInvalidFormat; break; case 2: - error = OF_DNS_RESOLVER_ERROR_SERVER_FAILURE; + errorCode = OFDNSResolverErrorCodeServerFailure; tryNextNameServer = true; break; case 3: - error = OF_DNS_RESOLVER_ERROR_SERVER_NAME_ERROR; + errorCode = OFDNSResolverErrorCodeServerNameError; break; case 4: - error = OF_DNS_RESOLVER_ERROR_SERVER_NOT_IMPLEMENTED; + errorCode = OFDNSResolverErrorCodeServerNotImplemented; tryNextNameServer = true; break; case 5: - error = OF_DNS_RESOLVER_ERROR_SERVER_REFUSED; + errorCode = OFDNSResolverErrorCodeServerRefused; tryNextNameServer = true; break; default: - error = OF_DNS_RESOLVER_ERROR_UNKNOWN; + errorCode = OFDNSResolverErrorCodeUnknown; tryNextNameServer = true; break; } if (tryNextNameServer) { @@ -993,11 +993,11 @@ } if (buffer[3] & 0x0F) @throw [OFDNSQueryFailedException exceptionWithQuery: context->_query - error: error]; + errorCode: errorCode]; numQuestions = (buffer[4] << 8) | buffer[5]; numAnswers = (buffer[6] << 8) | buffer[7]; numAuthorityRecords = (buffer[8] << 8) | buffer[9]; numAdditionalRecords = (buffer[10] << 8) | buffer[11]; @@ -1255,11 +1255,11 @@ while ((context = [enumerator nextObject]) != nil) { OFDNSQueryFailedException *exception; exception = [OFDNSQueryFailedException exceptionWithQuery: context->_query - error: OF_DNS_RESOLVER_ERROR_CANCELED]; + errorCode: OFDNSResolverErrorCodeCanceled]; [context->_delegate resolver: self didPerformQuery: context->_query response: nil exception: exception]; Index: src/OFDNSResourceRecord.h ================================================================== --- src/OFDNSResourceRecord.h +++ src/OFDNSResourceRecord.h @@ -26,57 +26,57 @@ @class OFData; /** * @brief The DNS class. */ -typedef enum { +typedef enum OFDNSClass { /** IN */ - OF_DNS_CLASS_IN = 1, + OFDNSClassIN = 1, /** Any class. Only for queries. */ - OF_DNS_CLASS_ANY = 255, -} of_dns_class_t; + OFDNSClassAny = 255, +} OFDNSClass; /** * @brief The type of a DNS resource record. */ -typedef enum { +typedef enum OFDNSRecordType { /** A */ - OF_DNS_RECORD_TYPE_A = 1, + OFDNSRecordTypeA = 1, /** NS */ - OF_DNS_RECORD_TYPE_NS = 2, + OFDNSRecordTypeNS = 2, /** CNAME */ - OF_DNS_RECORD_TYPE_CNAME = 5, + OFDNSRecordTypeCNAME = 5, /** SOA */ - OF_DNS_RECORD_TYPE_SOA = 6, + OFDNSRecordTypeSOA = 6, /** PTR */ - OF_DNS_RECORD_TYPE_PTR = 12, + OFDNSRecordTypePTR = 12, /** HINFO */ - OF_DNS_RECORD_TYPE_HINFO = 13, + OFDNSRecordTypeHINFO = 13, /** MX */ - OF_DNS_RECORD_TYPE_MX = 15, + OFDNSRecordTypeMX = 15, /** TXT */ - OF_DNS_RECORD_TYPE_TXT = 16, + OFDNSRecordTypeTXT = 16, /** RP */ - OF_DNS_RECORD_TYPE_RP = 17, + OFDNSRecordTypeRP = 17, /** AAAA */ - OF_DNS_RECORD_TYPE_AAAA = 28, + OFDNSRecordTypeAAAA = 28, /** SRV */ - OF_DNS_RECORD_TYPE_SRV = 33, + OFDNSRecordTypeSRV = 33, /** All types. Only for queries. */ - OF_DNS_RECORD_TYPE_ALL = 255, -} of_dns_record_type_t; + OFDNSRecordTypeAll = 255, +} OFDNSRecordType; /** * @class OFDNSResourceRecord OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h * * @brief A class representing a DNS resource record. */ @interface OFDNSResourceRecord: OFObject { OFString *_name; - of_dns_class_t _DNSClass; - of_dns_record_type_t _recordType; + OFDNSClass _DNSClass; + OFDNSRecordType _recordType; uint32_t _TTL; OF_RESERVE_IVARS(OFDNSResourceRecord, 4) } /** @@ -85,16 +85,16 @@ @property (readonly, nonatomic) OFString *name; /** * @brief The DNS class. */ -@property (readonly, nonatomic) of_dns_class_t DNSClass; +@property (readonly, nonatomic) OFDNSClass DNSClass; /** * @brief The resource record type code. */ -@property (readonly, nonatomic) of_dns_record_type_t recordType; +@property (readonly, nonatomic) OFDNSRecordType recordType; /** * @brief The number of seconds after which the resource record should be * discarded from the cache. */ @@ -109,12 +109,12 @@ * @param recordType The type code for the resource record * @param TTL The time to live for the resource record * @return An initialized OFDNSResourceRecord */ - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass - recordType: (of_dns_record_type_t)recordType + DNSClass: (OFDNSClass)DNSClass + recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end /** * @class OFADNSResourceRecord OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h @@ -131,12 +131,12 @@ * @brief The IPv4 address of the resource record. */ @property (readonly, nonatomic) const OFSocketAddress *address; - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass - recordType: (of_dns_record_type_t)recordType + DNSClass: (OFDNSClass)DNSClass + recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFADNSResourceRecord with the * specified name, class, address and time to live. @@ -167,12 +167,12 @@ * @brief The IPv6 address of the resource record. */ @property (readonly, nonatomic) const OFSocketAddress *address; - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass - recordType: (of_dns_record_type_t)recordType + DNSClass: (OFDNSClass)DNSClass + recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFAAAADNSResourceRecord with the * specified name, class, address and time to live. @@ -203,12 +203,12 @@ * @brief The alias of the resource record. */ @property (readonly, nonatomic) OFString *alias; - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass - recordType: (of_dns_record_type_t)recordType + DNSClass: (OFDNSClass)DNSClass + recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFCNAMEDNSResourceRecord with the * specified name, class, alias and time to live. @@ -218,11 +218,11 @@ * @param alias The alias for the resource record * @param TTL The time to live for the resource record * @return An initialized OFCNAMEDNSResourceRecord */ - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass + DNSClass: (OFDNSClass)DNSClass alias: (OFString *)alias TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end /** @@ -246,12 +246,12 @@ * @brief The OS of the host info of the resource record. */ @property (readonly, nonatomic) OFString *OS; - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass - recordType: (of_dns_record_type_t)recordType + DNSClass: (OFDNSClass)DNSClass + recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFHINFODNSResourceRecord with the * specified name, class, domain name and time to live. @@ -262,11 +262,11 @@ * @param OS The OS of the host info for the resource record * @param TTL The time to live for the resource record * @return An initialized OFHINFODNSResourceRecord */ - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass + DNSClass: (OFDNSClass)DNSClass CPU: (OFString *)CPU OS: (OFString *)OS TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end @@ -292,12 +292,12 @@ * @brief The mail exchange of the resource record. */ @property (readonly, nonatomic) OFString *mailExchange; - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass - recordType: (of_dns_record_type_t)recordType + DNSClass: (OFDNSClass)DNSClass + recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFMXDNSResourceRecord with the * specified name, class, preference, mail exchange and time to live. @@ -308,11 +308,11 @@ * @param mailExchange The mail exchange for the resource record * @param TTL The time to live for the resource record * @return An initialized OFMXDNSResourceRecord */ - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass + DNSClass: (OFDNSClass)DNSClass preference: (uint16_t)preference mailExchange: (OFString *)mailExchange TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end @@ -332,12 +332,12 @@ * @brief The authoritative host of the resource record. */ @property (readonly, nonatomic) OFString *authoritativeHost; - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass - recordType: (of_dns_record_type_t)recordType + DNSClass: (OFDNSClass)DNSClass + recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFNSDNSResourceRecord with the * specified name, class, authoritative host and time to live. @@ -347,11 +347,11 @@ * @param authoritativeHost The authoritative host for the resource record * @param TTL The time to live for the resource record * @return An initialized OFNSDNSResourceRecord */ - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass + DNSClass: (OFDNSClass)DNSClass authoritativeHost: (OFString *)authoritativeHost TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end /** @@ -370,12 +370,12 @@ * @brief The domain name of the resource record. */ @property (readonly, nonatomic) OFString *domainName; - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass - recordType: (of_dns_record_type_t)recordType + DNSClass: (OFDNSClass)DNSClass + recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFPTRDNSResourceRecord with the * specified name, class, domain name and time to live. @@ -385,11 +385,11 @@ * @param domainName The domain name for the resource record * @param TTL The time to live for the resource record * @return An initialized OFPTRDNSResourceRecord */ - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass + DNSClass: (OFDNSClass)DNSClass domainName: (OFString *)domainName TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end /** @@ -414,12 +414,12 @@ * person of the resource record. */ @property (readonly, nonatomic) OFString *TXTDomainName; - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass - recordType: (of_dns_record_type_t)recordType + DNSClass: (OFDNSClass)DNSClass + recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFRPDNSResourceRecord with the * specified name, class, alias and time to live. @@ -431,11 +431,11 @@ * the responsible person of the resource record * @param TTL The time to live for the resource record * @return An initialized OFRPDNSResourceRecord */ - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass + DNSClass: (OFDNSClass)DNSClass mailbox: (OFString *)mailbox TXTDomainName: (OFString *)TXTDomainName TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end @@ -487,12 +487,12 @@ * @brief The minimum TTL of the zone. */ @property (readonly, nonatomic) uint32_t minTTL; - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass - recordType: (of_dns_record_type_t)recordType + DNSClass: (OFDNSClass)DNSClass + recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFSOADNSResourceRecord with the * specified name, class, text data and time to live. @@ -508,11 +508,11 @@ * @param minTTL The minimum TTL of the zone * @param TTL The time to live for the resource record * @return An initialized OFSOADNSResourceRecord */ - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass + DNSClass: (OFDNSClass)DNSClass primaryNameServer: (OFString *)primaryNameServer responsiblePerson: (OFString *)responsiblePerson serialNumber: (uint32_t)serialNumber refreshInterval: (uint32_t)refreshInterval retryInterval: (uint32_t)retryInterval @@ -554,12 +554,12 @@ * @brief The port on the target of the resource record. */ @property (readonly, nonatomic) uint16_t port; - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass - recordType: (of_dns_record_type_t)recordType + DNSClass: (OFDNSClass)DNSClass + recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFSRVDNSResourceRecord with the * specified name, class, preference, mail exchange and time to live. @@ -596,12 +596,12 @@ * @brief The text of the resource record. */ @property (readonly, nonatomic) OFArray OF_GENERIC(OFData *) *textStrings; - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass - recordType: (of_dns_record_type_t)recordType + DNSClass: (OFDNSClass)DNSClass + recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFTXTDNSResourceRecord with the * specified name, class, text data and time to live. @@ -611,23 +611,22 @@ * @param textStrings An array of text strings for the resource record * @param TTL The time to live for the resource record * @return An initialized OFTXTDNSResourceRecord */ - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass + DNSClass: (OFDNSClass)DNSClass textStrings: (OFArray OF_GENERIC(OFData *) *)textStrings TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end #ifdef __cplusplus extern "C" { #endif -extern OFString *_Nonnull of_dns_class_to_string(of_dns_class_t DNSClass); -extern OFString *_Nonnull of_dns_record_type_to_string( - of_dns_record_type_t recordType); -extern of_dns_class_t of_dns_class_parse(OFString *_Nonnull string); -extern of_dns_record_type_t of_dns_record_type_parse(OFString *_Nonnull string); +extern OFString *_Nonnull OFDNSClassName(OFDNSClass DNSClass); +extern OFString *_Nonnull OFDNSRecordTypeName(OFDNSRecordType recordType); +extern OFDNSClass OFDNSClassParseName(OFString *_Nonnull string); +extern OFDNSRecordType OFDNSRecordTypeParseName(OFString *_Nonnull string); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END Index: src/OFDNSResourceRecord.m ================================================================== --- src/OFDNSResourceRecord.m +++ src/OFDNSResourceRecord.m @@ -21,67 +21,68 @@ #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" OFString * -of_dns_class_to_string(of_dns_class_t DNSClass) +OFDNSClassName(OFDNSClass DNSClass) { switch (DNSClass) { - case OF_DNS_CLASS_IN: + case OFDNSClassIN: return @"IN"; - case OF_DNS_CLASS_ANY: + case OFDNSClassAny: return @"any"; default: return [OFString stringWithFormat: @"%u", DNSClass]; } } OFString * -of_dns_record_type_to_string(of_dns_record_type_t recordType) +OFDNSRecordTypeName(OFDNSRecordType recordType) { switch (recordType) { - case OF_DNS_RECORD_TYPE_A: + case OFDNSRecordTypeA: return @"A"; - case OF_DNS_RECORD_TYPE_NS: + case OFDNSRecordTypeNS: return @"NS"; - case OF_DNS_RECORD_TYPE_CNAME: + case OFDNSRecordTypeCNAME: return @"CNAME"; - case OF_DNS_RECORD_TYPE_SOA: + case OFDNSRecordTypeSOA: return @"SOA"; - case OF_DNS_RECORD_TYPE_PTR: + case OFDNSRecordTypePTR: return @"PTR"; - case OF_DNS_RECORD_TYPE_HINFO: + case OFDNSRecordTypeHINFO: return @"HINFO"; - case OF_DNS_RECORD_TYPE_MX: + case OFDNSRecordTypeMX: return @"MX"; - case OF_DNS_RECORD_TYPE_TXT: + case OFDNSRecordTypeTXT: return @"TXT"; - case OF_DNS_RECORD_TYPE_RP: + case OFDNSRecordTypeRP: return @"RP"; - case OF_DNS_RECORD_TYPE_AAAA: + case OFDNSRecordTypeAAAA: return @"AAAA"; - case OF_DNS_RECORD_TYPE_SRV: + case OFDNSRecordTypeSRV: return @"SRV"; - case OF_DNS_RECORD_TYPE_ALL: + case OFDNSRecordTypeAll: return @"all"; default: return [OFString stringWithFormat: @"%u", recordType]; } } -of_dns_class_t of_dns_class_parse(OFString *string) +OFDNSClass +OFDNSClassParseName(OFString *string) { void *pool = objc_autoreleasePoolPush(); - of_dns_class_t DNSClass; + OFDNSClass DNSClass; string = string.uppercaseString; if ([string isEqual: @"IN"]) - DNSClass = OF_DNS_CLASS_IN; + DNSClass = OFDNSClassIN; else { @try { - DNSClass = (of_dns_class_t) + DNSClass = (OFDNSClass) [string unsignedLongLongValueWithBase: 0]; } @catch (OFInvalidFormatException *e) { @throw [OFInvalidArgumentException exception]; } } @@ -89,44 +90,45 @@ objc_autoreleasePoolPop(pool); return DNSClass; } -of_dns_record_type_t of_dns_record_type_parse(OFString *string) +OFDNSRecordType +OFDNSRecordTypeParseName(OFString *string) { void *pool = objc_autoreleasePoolPush(); - of_dns_record_type_t recordType; + OFDNSRecordType recordType; string = string.uppercaseString; if ([string isEqual: @"A"]) - recordType = OF_DNS_RECORD_TYPE_A; + recordType = OFDNSRecordTypeA; else if ([string isEqual: @"NS"]) - recordType = OF_DNS_RECORD_TYPE_NS; + recordType = OFDNSRecordTypeNS; else if ([string isEqual: @"CNAME"]) - recordType = OF_DNS_RECORD_TYPE_CNAME; + recordType = OFDNSRecordTypeCNAME; else if ([string isEqual: @"SOA"]) - recordType = OF_DNS_RECORD_TYPE_SOA; + recordType = OFDNSRecordTypeSOA; else if ([string isEqual: @"PTR"]) - recordType = OF_DNS_RECORD_TYPE_PTR; + recordType = OFDNSRecordTypePTR; else if ([string isEqual: @"HINFO"]) - recordType = OF_DNS_RECORD_TYPE_HINFO; + recordType = OFDNSRecordTypeHINFO; else if ([string isEqual: @"MX"]) - recordType = OF_DNS_RECORD_TYPE_MX; + recordType = OFDNSRecordTypeMX; else if ([string isEqual: @"TXT"]) - recordType = OF_DNS_RECORD_TYPE_TXT; + recordType = OFDNSRecordTypeTXT; else if ([string isEqual: @"RP"]) - recordType = OF_DNS_RECORD_TYPE_RP; + recordType = OFDNSRecordTypeRP; else if ([string isEqual: @"AAAA"]) - recordType = OF_DNS_RECORD_TYPE_AAAA; + recordType = OFDNSRecordTypeAAAA; else if ([string isEqual: @"SRV"]) - recordType = OF_DNS_RECORD_TYPE_SRV; + recordType = OFDNSRecordTypeSRV; else if ([string isEqual: @"ALL"]) - recordType = OF_DNS_RECORD_TYPE_ALL; + recordType = OFDNSRecordTypeAll; else { @try { - recordType = (of_dns_record_type_t) + recordType = (OFDNSRecordType) [string unsignedLongLongValueWithBase: 0]; } @catch (OFInvalidFormatException *e) { @throw [OFInvalidArgumentException exception]; } } @@ -139,12 +141,12 @@ @implementation OFDNSResourceRecord @synthesize name = _name, DNSClass = _DNSClass, recordType = _recordType; @synthesize TTL = _TTL; - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass - recordType: (of_dns_record_type_t)recordType + DNSClass: (OFDNSClass)DNSClass + recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL { self = [super init]; @try { @@ -179,19 +181,19 @@ @"\tName = %@\n" @"\tClass = %@\n" @"\tType = %@\n" @"\tTTL = %" PRIu32 "\n" @">", - self.className, _name, of_dns_class_to_string(_DNSClass), - of_dns_record_type_to_string(_recordType), _TTL]; + self.className, _name, OFDNSClassName(_DNSClass), + OFDNSRecordTypeName(_recordType), _TTL]; } @end @implementation OFADNSResourceRecord - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass - recordType: (of_dns_record_type_t)recordType + DNSClass: (OFDNSClass)DNSClass + recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } @@ -198,12 +200,12 @@ - (instancetype)initWithName: (OFString *)name address: (const OFSocketAddress *)address TTL: (uint32_t)TTL { self = [super initWithName: name - DNSClass: OF_DNS_CLASS_IN - recordType: OF_DNS_RECORD_TYPE_A + DNSClass: OFDNSClassIN + recordType: OFDNSRecordTypeA TTL: TTL]; _address = *address; return self; @@ -271,12 +273,12 @@ } @end @implementation OFAAAADNSResourceRecord - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass - recordType: (of_dns_record_type_t)recordType + DNSClass: (OFDNSClass)DNSClass + recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } @@ -283,12 +285,12 @@ - (instancetype)initWithName: (OFString *)name address: (const OFSocketAddress *)address TTL: (uint32_t)TTL { self = [super initWithName: name - DNSClass: OF_DNS_CLASS_IN - recordType: OF_DNS_RECORD_TYPE_AAAA + DNSClass: OFDNSClassIN + recordType: OFDNSRecordTypeAAAA TTL: TTL]; _address = *address; return self; @@ -358,25 +360,25 @@ @implementation OFCNAMEDNSResourceRecord @synthesize alias = _alias; - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass - recordType: (of_dns_record_type_t)recordType + DNSClass: (OFDNSClass)DNSClass + recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass + DNSClass: (OFDNSClass)DNSClass alias: (OFString *)alias TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: DNSClass - recordType: OF_DNS_RECORD_TYPE_CNAME + recordType: OFDNSRecordTypeCNAME TTL: TTL]; @try { _alias = [alias copy]; } @catch (id e) { @@ -446,35 +448,34 @@ @"\tName = %@\n" @"\tClass = %@\n" @"\tAlias = %@\n" @"\tTTL = %" PRIu32 "\n" @">", - self.className, _name, of_dns_class_to_string(_DNSClass), _alias, - _TTL]; + self.className, _name, OFDNSClassName(_DNSClass), _alias, _TTL]; } @end @implementation OFHINFODNSResourceRecord @synthesize CPU = _CPU, OS = _OS; - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass - recordType: (of_dns_record_type_t)recordType + DNSClass: (OFDNSClass)DNSClass + recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass + DNSClass: (OFDNSClass)DNSClass CPU: (OFString *)CPU OS: (OFString *)OS TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: DNSClass - recordType: OF_DNS_RECORD_TYPE_HINFO + recordType: OFDNSRecordTypeHINFO TTL: TTL]; @try { _CPU = [CPU copy]; _OS = [OS copy]; @@ -551,35 +552,34 @@ @"\tClass = %@\n" @"\tCPU = %@\n" @"\tOS = %@\n" @"\tTTL = %" PRIu32 "\n" @">", - self.className, _name, of_dns_class_to_string(_DNSClass), _CPU, _OS, - _TTL]; + self.className, _name, OFDNSClassName(_DNSClass), _CPU, _OS, _TTL]; } @end @implementation OFMXDNSResourceRecord @synthesize preference = _preference, mailExchange = _mailExchange; - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass - recordType: (of_dns_record_type_t)recordType + DNSClass: (OFDNSClass)DNSClass + recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass + DNSClass: (OFDNSClass)DNSClass preference: (uint16_t)preference mailExchange: (OFString *)mailExchange TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: DNSClass - recordType: OF_DNS_RECORD_TYPE_MX + recordType: OFDNSRecordTypeMX TTL: TTL]; @try { _preference = preference; _mailExchange = [mailExchange copy]; @@ -657,34 +657,34 @@ @"\tClass = %@\n" @"\tPreference = %" PRIu16 "\n" @"\tMail Exchange = %@\n" @"\tTTL = %" PRIu32 "\n" @">", - self.className, _name, of_dns_class_to_string(_DNSClass), - _preference, _mailExchange, _TTL]; + self.className, _name, OFDNSClassName(_DNSClass), _preference, + _mailExchange, _TTL]; } @end @implementation OFNSDNSResourceRecord @synthesize authoritativeHost = _authoritativeHost; - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass - recordType: (of_dns_record_type_t)recordType + DNSClass: (OFDNSClass)DNSClass + recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass + DNSClass: (OFDNSClass)DNSClass authoritativeHost: (OFString *)authoritativeHost TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: DNSClass - recordType: OF_DNS_RECORD_TYPE_NS + recordType: OFDNSRecordTypeNS TTL: TTL]; @try { _authoritativeHost = [authoritativeHost copy]; } @catch (id e) { @@ -755,34 +755,34 @@ @"\tName = %@\n" @"\tClass = %@\n" @"\tAuthoritative Host = %@\n" @"\tTTL = %" PRIu32 "\n" @">", - self.className, _name, of_dns_class_to_string(_DNSClass), + self.className, _name, OFDNSClassName(_DNSClass), _authoritativeHost, _TTL]; } @end @implementation OFPTRDNSResourceRecord @synthesize domainName = _domainName; - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass - recordType: (of_dns_record_type_t)recordType + DNSClass: (OFDNSClass)DNSClass + recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass + DNSClass: (OFDNSClass)DNSClass domainName: (OFString *)domainName TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: DNSClass - recordType: OF_DNS_RECORD_TYPE_PTR + recordType: OFDNSRecordTypePTR TTL: TTL]; @try { _domainName = [domainName copy]; } @catch (id e) { @@ -853,35 +853,35 @@ @"\tName = %@\n" @"\tClass = %@\n" @"\tDomain Name = %@\n" @"\tTTL = %" PRIu32 "\n" @">", - self.className, _name, of_dns_class_to_string(_DNSClass), - _domainName, _TTL]; + self.className, _name, OFDNSClassName(_DNSClass), _domainName, + _TTL]; } @end @implementation OFRPDNSResourceRecord @synthesize mailbox = _mailbox, TXTDomainName = _TXTDomainName; - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass - recordType: (of_dns_record_type_t)recordType + DNSClass: (OFDNSClass)DNSClass + recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass + DNSClass: (OFDNSClass)DNSClass mailbox: (OFString *)mailbox TXTDomainName: (OFString *)TXTDomainName TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: DNSClass - recordType: OF_DNS_RECORD_TYPE_RP + recordType: OFDNSRecordTypeRP TTL: TTL]; @try { _mailbox = [mailbox copy]; _TXTDomainName = [TXTDomainName copy]; @@ -960,11 +960,11 @@ @"\tClass = %@\n" @"\tMailbox = %@\n" @"\tTXT Domain Name = %@\n" @"\tTTL = %" PRIu32 "\n" @">", - self.className, _name, of_dns_class_to_string(_DNSClass), _mailbox, + self.className, _name, OFDNSClassName(_DNSClass), _mailbox, _TXTDomainName, _TTL]; } @end @implementation OFSOADNSResourceRecord @@ -973,19 +973,19 @@ @synthesize serialNumber = _serialNumber, refreshInterval = _refreshInterval; @synthesize retryInterval = _retryInterval; @synthesize expirationInterval = _expirationInterval, minTTL = _minTTL; - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass - recordType: (of_dns_record_type_t)recordType + DNSClass: (OFDNSClass)DNSClass + recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass + DNSClass: (OFDNSClass)DNSClass primaryNameServer: (OFString *)primaryNameServer responsiblePerson: (OFString *)responsiblePerson serialNumber: (uint32_t)serialNumber refreshInterval: (uint32_t)refreshInterval retryInterval: (uint32_t)retryInterval @@ -993,11 +993,11 @@ minTTL: (uint32_t)minTTL TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: DNSClass - recordType: OF_DNS_RECORD_TYPE_SOA + recordType: OFDNSRecordTypeSOA TTL: TTL]; @try { _primaryNameServer = [primaryNameServer copy]; _responsiblePerson = [responsiblePerson copy]; @@ -1121,11 +1121,11 @@ @"\tRetry Interval = %" PRIu32 "\n" @"\tExpiration Interval = %" PRIu32 "\n" @"\tMinimum TTL = %" PRIu32 "\n" @"\tTTL = %" PRIu32 "\n" @">", - self.className, _name, of_dns_class_to_string(_DNSClass), + self.className, _name, OFDNSClassName(_DNSClass), _primaryNameServer, _responsiblePerson, _serialNumber, _refreshInterval, _retryInterval, _expirationInterval, _minTTL, _TTL]; } @end @@ -1133,12 +1133,12 @@ @implementation OFSRVDNSResourceRecord @synthesize priority = _priority, weight = _weight, target = _target; @synthesize port = _port; - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass - recordType: (of_dns_record_type_t)recordType + DNSClass: (OFDNSClass)DNSClass + recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } @@ -1148,12 +1148,12 @@ target: (OFString *)target port: (uint16_t)port TTL: (uint32_t)TTL { self = [super initWithName: name - DNSClass: OF_DNS_CLASS_IN - recordType: OF_DNS_RECORD_TYPE_SRV + DNSClass: OFDNSClassIN + recordType: OFDNSRecordTypeSRV TTL: TTL]; @try { _priority = priority; _weight = weight; @@ -1251,25 +1251,25 @@ @implementation OFTXTDNSResourceRecord @synthesize textStrings = _textStrings; - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass - recordType: (of_dns_record_type_t)recordType + DNSClass: (OFDNSClass)DNSClass + recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name - DNSClass: (of_dns_class_t)DNSClass + DNSClass: (OFDNSClass)DNSClass textStrings: (OFArray OF_GENERIC(OFData *) *)textStrings TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: DNSClass - recordType: OF_DNS_RECORD_TYPE_TXT + recordType: OFDNSRecordTypeTXT TTL: TTL]; @try { _textStrings = [textStrings copy]; } @catch (id e) { @@ -1371,15 +1371,14 @@ @"\tName = %@\n" @"\tClass = %@\n" @"\tText strings = %@\n" @"\tTTL = %" PRIu32 "\n" @">", - self.className, _name, of_dns_class_to_string(_DNSClass), text, - _TTL]; + self.className, _name, OFDNSClassName(_DNSClass), text, _TTL]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } @end Index: src/OFHostAddressResolver.m ================================================================== --- src/OFHostAddressResolver.m +++ src/OFHostAddressResolver.m @@ -68,17 +68,17 @@ addressForRecord(OF_KINDOF(OFDNSResourceRecord *) record, const OFSocketAddress **address, OFSocketAddressFamily addressFamily) { switch ([record recordType]) { #ifdef OF_HAVE_IPV6 - case OF_DNS_RECORD_TYPE_AAAA: + case OFDNSRecordTypeAAAA: if (addressFamily != OFSocketAddressFamilyIPv6 && addressFamily != OFSocketAddressFamilyAny) return false; break; #endif - case OF_DNS_RECORD_TYPE_A: + case OFDNSRecordTypeA: if (addressFamily != OFSocketAddressFamilyIPv4 && addressFamily != OFSocketAddressFamilyAny) return false; break; default: @@ -164,12 +164,12 @@ #ifdef OF_HAVE_IPV6 if (_addressFamily == OFSocketAddressFamilyIPv6 || _addressFamily == OFSocketAddressFamilyAny) { OFDNSQuery *query = [OFDNSQuery queryWithDomainName: domainName - DNSClass: OF_DNS_CLASS_IN - recordType: OF_DNS_RECORD_TYPE_AAAA]; + DNSClass: OFDNSClassIN + recordType: OFDNSRecordTypeAAAA]; _numExpectedResponses++; [_resolver asyncPerformQuery: query runLoopMode: _runLoopMode delegate: self]; } @@ -177,12 +177,12 @@ if (_addressFamily == OFSocketAddressFamilyIPv4 || _addressFamily == OFSocketAddressFamilyAny) { OFDNSQuery *query = [OFDNSQuery queryWithDomainName: domainName - DNSClass: OF_DNS_CLASS_IN - recordType: OF_DNS_RECORD_TYPE_A]; + DNSClass: OFDNSClassIN + recordType: OFDNSRecordTypeA]; _numExpectedResponses++; [_resolver asyncPerformQuery: query runLoopMode: _runLoopMode delegate: self]; } @@ -194,11 +194,11 @@ exception: (id)exception { _numExpectedResponses--; if ([exception isKindOfClass: [OFDNSQueryFailedException class]] && - [exception error] == OF_DNS_RESOLVER_ERROR_SERVER_NAME_ERROR && + [exception errorCode] == OFDNSResolverErrorCodeServerNameError && !_isFQDN && _numExpectedResponses == 0 && _addresses.count == 0 && _searchDomainIndex + 1 < _settings->_searchDomains.count) { _searchDomainIndex++; [self sendQueries]; return; @@ -207,24 +207,24 @@ for (OF_KINDOF(OFDNSResourceRecord *) record in [response.answerRecords objectForKey: query.domainName]) { const OFSocketAddress *address = NULL; OFDNSQuery *CNAMEQuery; - if ([record DNSClass] != OF_DNS_CLASS_IN) + if ([record DNSClass] != OFDNSClassIN) continue; if (addressForRecord(record, &address, _addressFamily)) { [_addresses addItem: address]; continue; } - if ([record recordType] != OF_DNS_RECORD_TYPE_CNAME) + if ([record recordType] != OFDNSRecordTypeCNAME) continue; /* FIXME: Check if it's already in answers */ CNAMEQuery = [OFDNSQuery queryWithDomainName: [record alias] - DNSClass: OF_DNS_CLASS_IN + DNSClass: OFDNSClassIN recordType: query.recordType]; _numExpectedResponses++; [_resolver asyncPerformQuery: CNAMEQuery runLoopMode: _runLoopMode delegate: self]; @@ -242,17 +242,17 @@ if ([exception isKindOfClass: [OFDNSQueryFailedException class]]) exception = [OFResolveHostFailedException exceptionWithHost: _host addressFamily: _addressFamily - error: [exception error]]; + errorCode: [exception errorCode]]; if (exception == nil) exception = [OFResolveHostFailedException exceptionWithHost: _host addressFamily: _addressFamily - error: OF_DNS_RESOLVER_ERROR_NO_RESULT]; + errorCode: OFDNSResolverErrorCodeNoResult]; } else exception = nil; if ([_delegate respondsToSelector: @selector(resolver:didResolveHost:addresses:exception:)]) @@ -314,11 +314,11 @@ if (addresses.count == 0) { addresses = nil; exception = [OFResolveHostFailedException exceptionWithHost: _host addressFamily: _addressFamily - error: OF_DNS_RESOLVER_ERROR_NO_RESULT]; + errorCode: OFDNSResolverErrorCodeNoResult]; } callDelegateInMode(_runLoopMode, _delegate, _resolver, _host, addresses, exception); Index: src/exceptions/OFDNSQueryFailedException.h ================================================================== --- src/exceptions/OFDNSQueryFailedException.h +++ src/exceptions/OFDNSQueryFailedException.h @@ -27,48 +27,49 @@ * @brief An exception indicating that a DNS query failed. */ @interface OFDNSQueryFailedException: OFException { OFDNSQuery *_query; - of_dns_resolver_error_t _error; + OFDNSResolverErrorCode _errorCode; } /** * @brief The query which could not be performed. */ @property (readonly, nonatomic) OFDNSQuery *query; /** - * @brief The error from the resolver. + * @brief The error code from the resolver. */ -@property (readonly, nonatomic) of_dns_resolver_error_t error; +@property (readonly, nonatomic) OFDNSResolverErrorCode errorCode; /** * @brief Creates a new, autoreleased DNS query failed exception. * * @param query The query which could not be performed - * @param error The error from the resolver + * @param errorCode The error from the resolver * @return A new, autoreleased address translation failed exception */ + (instancetype)exceptionWithQuery: (OFDNSQuery *)query - error: (of_dns_resolver_error_t)error; + errorCode: (OFDNSResolverErrorCode)errorCode; /** * @brief Initializes an already allocated DNS query failed exception. * * @param query The query which could not be performed - * @param error The error from the resolver + * @param errorCode The error from the resolver * @return An initialized address translation failed exception */ - (instancetype)initWithQuery: (OFDNSQuery *)query - error: (of_dns_resolver_error_t)error; + errorCode: (OFDNSResolverErrorCode)errorCode; @end #ifdef __cplusplus extern "C" { #endif -extern OFString *of_dns_resolver_error_to_string(of_dns_resolver_error_t error); +extern OFString *OFDNSResolverErrorCodeDescription( + OFDNSResolverErrorCode errorCode); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END Index: src/exceptions/OFDNSQueryFailedException.m ================================================================== --- src/exceptions/OFDNSQueryFailedException.m +++ src/exceptions/OFDNSQueryFailedException.m @@ -17,57 +17,58 @@ #import "OFDNSQueryFailedException.h" #import "OFString.h" OFString * -of_dns_resolver_error_to_string(of_dns_resolver_error_t error) +OFDNSResolverErrorCodeDescription(OFDNSResolverErrorCode errorCode) { - switch (error) { - case OF_DNS_RESOLVER_ERROR_TIMEOUT: + switch (errorCode) { + case OFDNSResolverErrorCodeTimeout: return @"The query timed out."; - case OF_DNS_RESOLVER_ERROR_CANCELED: + case OFDNSResolverErrorCodeCanceled: return @"The query was canceled."; - case OF_DNS_RESOLVER_ERROR_NO_RESULT: + case OFDNSResolverErrorCodeNoResult: return @"No result for the specified host with the specified " @"type and class."; - case OF_DNS_RESOLVER_ERROR_SERVER_INVALID_FORMAT: + case OFDNSResolverErrorCodeServerInvalidFormat: return @"The server considered the query to be malformed."; - case OF_DNS_RESOLVER_ERROR_SERVER_FAILURE: + case OFDNSResolverErrorCodeServerFailure: return @"The server was unable to process due to an internal " @"error."; - case OF_DNS_RESOLVER_ERROR_SERVER_NAME_ERROR: + case OFDNSResolverErrorCodeServerNameError: return @"The server returned an error that the domain does not " @"exist."; - case OF_DNS_RESOLVER_ERROR_SERVER_NOT_IMPLEMENTED: + case OFDNSResolverErrorCodeServerNotImplemented: return @"The server does not have support for the requested " @"query."; - case OF_DNS_RESOLVER_ERROR_SERVER_REFUSED: + case OFDNSResolverErrorCodeServerRefused: return @"The server refused the query."; - case OF_DNS_RESOLVER_ERROR_NO_NAME_SERVER: + case OFDNSResolverErrorCodeNoNameServer: return @"There was no name server to query."; default: return @"Unknown error."; } } @implementation OFDNSQueryFailedException -@synthesize query = _query, error = _error; +@synthesize query = _query, errorCode = _errorCode; + (instancetype)exceptionWithQuery: (OFDNSQuery *)query - error: (of_dns_resolver_error_t)error + errorCode: (OFDNSResolverErrorCode)errorCode { - return [[[self alloc] initWithQuery: query error: error] autorelease]; + return [[[self alloc] initWithQuery: query + errorCode: errorCode] autorelease]; } - (instancetype)initWithQuery: (OFDNSQuery *)query - error: (of_dns_resolver_error_t)error + errorCode: (OFDNSResolverErrorCode)errorCode { self = [super init]; @try { _query = [query copy]; - _error = error; + _errorCode = errorCode; } @catch (id e) { [self release]; @throw e; } @@ -83,8 +84,8 @@ - (OFString *)description { return [OFString stringWithFormat: @"DNS query %@ could not be performed: %@", - _query, of_dns_resolver_error_to_string(_error)]; + _query, OFDNSResolverErrorCodeDescription(_errorCode)]; } @end Index: src/exceptions/OFResolveHostFailedException.h ================================================================== --- src/exceptions/OFResolveHostFailedException.h +++ src/exceptions/OFResolveHostFailedException.h @@ -26,11 +26,11 @@ */ @interface OFResolveHostFailedException: OFException { OFString *_host; OFSocketAddressFamily _addressFamily; - of_dns_resolver_error_t _error; + OFDNSResolverErrorCode _errorCode; } /** * @brief The host which could not be resolved. */ @@ -40,37 +40,37 @@ * @brief The address family for which the host could not be resolved. */ @property (readonly, nonatomic) OFSocketAddressFamily addressFamily; /** - * @brief The error from the resolver. + * @brief The error code from the resolver. */ -@property (readonly, nonatomic) of_dns_resolver_error_t error; +@property (readonly, nonatomic) OFDNSResolverErrorCode errorCode; /** * @brief Creates a new, autoreleased resolve host failed exception. * * @param host The host which could not be resolved * @param addressFamily The address family for which the host could not be * resolved - * @param error The error from the resolver + * @param errorCode The error code from the resolver * @return A new, autoreleased address translation failed exception */ + (instancetype)exceptionWithHost: (OFString *)host addressFamily: (OFSocketAddressFamily)addressFamily - error: (of_dns_resolver_error_t)error; + errorCode: (OFDNSResolverErrorCode)errorCode; /** * @brief Initializes an already allocated resolve host failed exception. * * @param host The host which could not be resolved * @param addressFamily The address family for which the host could not be * resolved - * @param error The error from the resolver + * @param errorCode The error code from the resolver * @return An initialized address translation failed exception */ - (instancetype)initWithHost: (OFString *)host addressFamily: (OFSocketAddressFamily)addressFamily - error: (of_dns_resolver_error_t)error; + errorCode: (OFDNSResolverErrorCode)errorCode; @end OF_ASSUME_NONNULL_END Index: src/exceptions/OFResolveHostFailedException.m ================================================================== --- src/exceptions/OFResolveHostFailedException.m +++ src/exceptions/OFResolveHostFailedException.m @@ -18,31 +18,32 @@ #import "OFResolveHostFailedException.h" #import "OFDNSQueryFailedException.h" #import "OFString.h" @implementation OFResolveHostFailedException -@synthesize host = _host, addressFamily = _addressFamily, error = _error; +@synthesize host = _host, addressFamily = _addressFamily; +@synthesize errorCode = _errorCode; + (instancetype)exceptionWithHost: (OFString *)host addressFamily: (OFSocketAddressFamily)addressFamily - error: (of_dns_resolver_error_t)error + errorCode: (OFDNSResolverErrorCode)errorCode { return [[[self alloc] initWithHost: host addressFamily: addressFamily - error: error] autorelease]; + errorCode: errorCode] autorelease]; } - (instancetype)initWithHost: (OFString *)host addressFamily: (OFSocketAddressFamily)addressFamily - error: (of_dns_resolver_error_t)error + errorCode: (OFDNSResolverErrorCode)errorCode { self = [super init]; @try { _host = [host copy]; _addressFamily = addressFamily; - _error = error; + _errorCode = errorCode; } @catch (id e) { [self release]; @throw e; } @@ -58,8 +59,8 @@ - (OFString *)description { return [OFString stringWithFormat: @"The host %@ could not be resolved: %@", - _host, of_dns_resolver_error_to_string(_error)]; + _host, OFDNSResolverErrorCodeDescription(_errorCode)]; } @end Index: utils/ofdns/OFDNS.m ================================================================== --- utils/ofdns/OFDNS.m +++ utils/ofdns/OFDNS.m @@ -93,11 +93,11 @@ OFMutableArray OF_GENERIC(OFString *) *recordTypes; OFOptionsParser *optionsParser; OFUnichar option; OFArray OF_GENERIC(OFString *) *remainingArguments; OFDNSResolver *resolver; - of_dns_class_t DNSClass; + OFDNSClass DNSClass; #ifdef OF_HAVE_FILES # ifndef OF_AMIGAOS [OFLocale addLanguageDirectory: @LANGUAGE_DIR]; # else @@ -178,12 +178,11 @@ if (remainingArguments.count < 1) help(of_stderr, false, 1); resolver = [OFDNSResolver resolver]; DNSClass = (DNSClassString != nil - ? of_dns_class_parse(DNSClassString) - : OF_DNS_CLASS_IN); + ? OFDNSClassParseName(DNSClassString) : OFDNSClassIN); if (recordTypes.count == 0) [recordTypes addObject: @"ALL"]; if (server != nil) { @@ -191,12 +190,12 @@ resolver.nameServers = [OFArray arrayWithObject: server]; } for (OFString *domainName in remainingArguments) { for (OFString *recordTypeString in recordTypes) { - of_dns_record_type_t recordType = - of_dns_record_type_parse(recordTypeString); + OFDNSRecordType recordType = + OFDNSRecordTypeParseName(recordTypeString); OFDNSQuery *query = [OFDNSQuery queryWithDomainName: domainName DNSClass: DNSClass recordType: recordType];