@@ -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,39 +181,39 @@ @"\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 } - (instancetype)initWithName: (OFString *)name - address: (const of_socket_address_t *)address + 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; } -- (const of_socket_address_t *)address +- (const OFSocketAddress *)address { return &_address; } - (bool)isEqual: (id)object @@ -233,30 +235,30 @@ return false; if (record->_recordType != _recordType) return false; - if (!of_socket_address_equal(&record->_address, &_address)) + if (!OFSocketAddressEqual(&record->_address, &_address)) return false; return true; } - (unsigned long)hash { - uint32_t hash; - - OF_HASH_INIT(hash); - - OF_HASH_ADD_HASH(hash, _name.hash); - OF_HASH_ADD(hash, _DNSClass >> 8); - OF_HASH_ADD(hash, _DNSClass); - OF_HASH_ADD(hash, _recordType >> 8); - OF_HASH_ADD(hash, _recordType); - OF_HASH_ADD_HASH(hash, of_socket_address_hash(&_address)); - - OF_HASH_FINALIZE(hash); + unsigned long hash; + + OFHashInit(&hash); + + OFHashAddHash(&hash, _name.hash); + OFHashAdd(&hash, _DNSClass >> 8); + OFHashAdd(&hash, _DNSClass); + OFHashAdd(&hash, _recordType >> 8); + OFHashAdd(&hash, _recordType); + OFHashAddHash(&hash, OFSocketAddressHash(&_address)); + + OFHashFinalize(&hash); return hash; } - (OFString *)description @@ -265,39 +267,38 @@ @"<%@:\n" @"\tName = %@\n" @"\tAddress = %@\n" @"\tTTL = %" PRIu32 "\n" @">", - self.className, _name, - of_socket_address_ip_string(&_address, NULL), _TTL]; + self.className, _name, OFSocketAddressString(&_address), _TTL]; } @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 } - (instancetype)initWithName: (OFString *)name - address: (const of_socket_address_t *)address + 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; } -- (const of_socket_address_t *)address +- (const OFSocketAddress *)address { return &_address; } - (bool)isEqual: (id)object @@ -319,30 +320,30 @@ return false; if (record->_recordType != _recordType) return false; - if (!of_socket_address_equal(&record->_address, &_address)) + if (!OFSocketAddressEqual(&record->_address, &_address)) return false; return true; } - (unsigned long)hash { - uint32_t hash; - - OF_HASH_INIT(hash); - - OF_HASH_ADD_HASH(hash, _name.hash); - OF_HASH_ADD(hash, _DNSClass >> 8); - OF_HASH_ADD(hash, _DNSClass); - OF_HASH_ADD(hash, _recordType >> 8); - OF_HASH_ADD(hash, _recordType); - OF_HASH_ADD_HASH(hash, of_socket_address_hash(&_address)); - - OF_HASH_FINALIZE(hash); + unsigned long hash; + + OFHashInit(&hash); + + OFHashAddHash(&hash, _name.hash); + OFHashAdd(&hash, _DNSClass >> 8); + OFHashAdd(&hash, _DNSClass); + OFHashAdd(&hash, _recordType >> 8); + OFHashAdd(&hash, _recordType); + OFHashAddHash(&hash, OFSocketAddressHash(&_address)); + + OFHashFinalize(&hash); return hash; } - (OFString *)description @@ -351,34 +352,33 @@ @"<%@:\n" @"\tName = %@\n" @"\tAddress = %@\n" @"\tTTL = %" PRIu32 "\n" @">", - self.className, _name, - of_socket_address_ip_string(&_address, NULL), _TTL]; + self.className, _name, OFSocketAddressString(&_address), _TTL]; } @end @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) { @@ -423,22 +423,22 @@ return true; } - (unsigned long)hash { - uint32_t hash; - - OF_HASH_INIT(hash); - - OF_HASH_ADD_HASH(hash, _name.hash); - OF_HASH_ADD(hash, _DNSClass >> 8); - OF_HASH_ADD(hash, _DNSClass); - OF_HASH_ADD(hash, _recordType >> 8); - OF_HASH_ADD(hash, _recordType); - OF_HASH_ADD_HASH(hash, _alias.hash); - - OF_HASH_FINALIZE(hash); + unsigned long hash; + + OFHashInit(&hash); + + OFHashAddHash(&hash, _name.hash); + OFHashAdd(&hash, _DNSClass >> 8); + OFHashAdd(&hash, _DNSClass); + OFHashAdd(&hash, _recordType >> 8); + OFHashAdd(&hash, _recordType); + OFHashAddHash(&hash, _alias.hash); + + OFHashFinalize(&hash); return hash; } - (OFString *)description @@ -448,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]; @@ -526,23 +525,23 @@ return true; } - (unsigned long)hash { - uint32_t hash; - - OF_HASH_INIT(hash); - - OF_HASH_ADD_HASH(hash, _name.hash); - OF_HASH_ADD(hash, _DNSClass >> 8); - OF_HASH_ADD(hash, _DNSClass); - OF_HASH_ADD(hash, _recordType >> 8); - OF_HASH_ADD(hash, _recordType); - OF_HASH_ADD_HASH(hash, _CPU.hash); - OF_HASH_ADD_HASH(hash, _OS.hash); - - OF_HASH_FINALIZE(hash); + unsigned long hash; + + OFHashInit(&hash); + + OFHashAddHash(&hash, _name.hash); + OFHashAdd(&hash, _DNSClass >> 8); + OFHashAdd(&hash, _DNSClass); + OFHashAdd(&hash, _recordType >> 8); + OFHashAdd(&hash, _recordType); + OFHashAddHash(&hash, _CPU.hash); + OFHashAddHash(&hash, _OS.hash); + + OFHashFinalize(&hash); return hash; } - (OFString *)description @@ -553,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]; @@ -631,24 +629,24 @@ return true; } - (unsigned long)hash { - uint32_t hash; - - OF_HASH_INIT(hash); - - OF_HASH_ADD_HASH(hash, _name.hash); - OF_HASH_ADD(hash, _DNSClass >> 8); - OF_HASH_ADD(hash, _DNSClass); - OF_HASH_ADD(hash, _recordType >> 8); - OF_HASH_ADD(hash, _recordType); - OF_HASH_ADD(hash, _preference >> 8); - OF_HASH_ADD(hash, _preference); - OF_HASH_ADD_HASH(hash, _mailExchange.hash); - - OF_HASH_FINALIZE(hash); + unsigned long hash; + + OFHashInit(&hash); + + OFHashAddHash(&hash, _name.hash); + OFHashAdd(&hash, _DNSClass >> 8); + OFHashAdd(&hash, _DNSClass); + OFHashAdd(&hash, _recordType >> 8); + OFHashAdd(&hash, _recordType); + OFHashAdd(&hash, _preference >> 8); + OFHashAdd(&hash, _preference); + OFHashAddHash(&hash, _mailExchange.hash); + + OFHashFinalize(&hash); return hash; } - (OFString *)description @@ -659,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) { @@ -732,22 +730,22 @@ return true; } - (unsigned long)hash { - uint32_t hash; - - OF_HASH_INIT(hash); - - OF_HASH_ADD_HASH(hash, _name.hash); - OF_HASH_ADD(hash, _DNSClass >> 8); - OF_HASH_ADD(hash, _DNSClass); - OF_HASH_ADD(hash, _recordType >> 8); - OF_HASH_ADD(hash, _recordType); - OF_HASH_ADD_HASH(hash, _authoritativeHost.hash); - - OF_HASH_FINALIZE(hash); + unsigned long hash; + + OFHashInit(&hash); + + OFHashAddHash(&hash, _name.hash); + OFHashAdd(&hash, _DNSClass >> 8); + OFHashAdd(&hash, _DNSClass); + OFHashAdd(&hash, _recordType >> 8); + OFHashAdd(&hash, _recordType); + OFHashAddHash(&hash, _authoritativeHost.hash); + + OFHashFinalize(&hash); return hash; } - (OFString *)description @@ -757,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) { @@ -830,22 +828,22 @@ return true; } - (unsigned long)hash { - uint32_t hash; - - OF_HASH_INIT(hash); - - OF_HASH_ADD_HASH(hash, _name.hash); - OF_HASH_ADD(hash, _DNSClass >> 8); - OF_HASH_ADD(hash, _DNSClass); - OF_HASH_ADD(hash, _recordType >> 8); - OF_HASH_ADD(hash, _recordType); - OF_HASH_ADD_HASH(hash, _domainName.hash); - - OF_HASH_FINALIZE(hash); + unsigned long hash; + + OFHashInit(&hash); + + OFHashAddHash(&hash, _name.hash); + OFHashAdd(&hash, _DNSClass >> 8); + OFHashAdd(&hash, _DNSClass); + OFHashAdd(&hash, _recordType >> 8); + OFHashAdd(&hash, _recordType); + OFHashAddHash(&hash, _domainName.hash); + + OFHashFinalize(&hash); return hash; } - (OFString *)description @@ -855,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]; @@ -935,23 +933,23 @@ return true; } - (unsigned long)hash { - uint32_t hash; - - OF_HASH_INIT(hash); - - OF_HASH_ADD_HASH(hash, _name.hash); - OF_HASH_ADD(hash, _DNSClass >> 8); - OF_HASH_ADD(hash, _DNSClass); - OF_HASH_ADD(hash, _recordType >> 8); - OF_HASH_ADD(hash, _recordType); - OF_HASH_ADD_HASH(hash, _mailbox.hash); - OF_HASH_ADD_HASH(hash, _TXTDomainName.hash); - - OF_HASH_FINALIZE(hash); + unsigned long hash; + + OFHashInit(&hash); + + OFHashAddHash(&hash, _name.hash); + OFHashAdd(&hash, _DNSClass >> 8); + OFHashAdd(&hash, _DNSClass); + OFHashAdd(&hash, _recordType >> 8); + OFHashAdd(&hash, _recordType); + OFHashAddHash(&hash, _mailbox.hash); + OFHashAddHash(&hash, _TXTDomainName.hash); + + OFHashFinalize(&hash); return hash; } - (OFString *)description @@ -962,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 @@ -975,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 @@ -995,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]; @@ -1071,43 +1069,43 @@ return true; } - (unsigned long)hash { - uint32_t hash; - - OF_HASH_INIT(hash); - - OF_HASH_ADD_HASH(hash, _name.hash); - OF_HASH_ADD(hash, _DNSClass >> 8); - OF_HASH_ADD(hash, _DNSClass); - OF_HASH_ADD(hash, _recordType >> 8); - OF_HASH_ADD(hash, _recordType); - OF_HASH_ADD_HASH(hash, _primaryNameServer.hash); - OF_HASH_ADD_HASH(hash, _responsiblePerson.hash); - OF_HASH_ADD(hash, _serialNumber >> 24); - OF_HASH_ADD(hash, _serialNumber >> 16); - OF_HASH_ADD(hash, _serialNumber >> 8); - OF_HASH_ADD(hash, _serialNumber); - OF_HASH_ADD(hash, _refreshInterval >> 24); - OF_HASH_ADD(hash, _refreshInterval >> 16); - OF_HASH_ADD(hash, _refreshInterval >> 8); - OF_HASH_ADD(hash, _refreshInterval); - OF_HASH_ADD(hash, _retryInterval >> 24); - OF_HASH_ADD(hash, _retryInterval >> 16); - OF_HASH_ADD(hash, _retryInterval >> 8); - OF_HASH_ADD(hash, _retryInterval); - OF_HASH_ADD(hash, _expirationInterval >> 24); - OF_HASH_ADD(hash, _expirationInterval >> 16); - OF_HASH_ADD(hash, _expirationInterval >> 8); - OF_HASH_ADD(hash, _expirationInterval); - OF_HASH_ADD(hash, _minTTL >> 24); - OF_HASH_ADD(hash, _minTTL >> 16); - OF_HASH_ADD(hash, _minTTL >> 8); - OF_HASH_ADD(hash, _minTTL); - - OF_HASH_FINALIZE(hash); + unsigned long hash; + + OFHashInit(&hash); + + OFHashAddHash(&hash, _name.hash); + OFHashAdd(&hash, _DNSClass >> 8); + OFHashAdd(&hash, _DNSClass); + OFHashAdd(&hash, _recordType >> 8); + OFHashAdd(&hash, _recordType); + OFHashAddHash(&hash, _primaryNameServer.hash); + OFHashAddHash(&hash, _responsiblePerson.hash); + OFHashAdd(&hash, _serialNumber >> 24); + OFHashAdd(&hash, _serialNumber >> 16); + OFHashAdd(&hash, _serialNumber >> 8); + OFHashAdd(&hash, _serialNumber); + OFHashAdd(&hash, _refreshInterval >> 24); + OFHashAdd(&hash, _refreshInterval >> 16); + OFHashAdd(&hash, _refreshInterval >> 8); + OFHashAdd(&hash, _refreshInterval); + OFHashAdd(&hash, _retryInterval >> 24); + OFHashAdd(&hash, _retryInterval >> 16); + OFHashAdd(&hash, _retryInterval >> 8); + OFHashAdd(&hash, _retryInterval); + OFHashAdd(&hash, _expirationInterval >> 24); + OFHashAdd(&hash, _expirationInterval >> 16); + OFHashAdd(&hash, _expirationInterval >> 8); + OFHashAdd(&hash, _expirationInterval); + OFHashAdd(&hash, _minTTL >> 24); + OFHashAdd(&hash, _minTTL >> 16); + OFHashAdd(&hash, _minTTL >> 8); + OFHashAdd(&hash, _minTTL); + + OFHashFinalize(&hash); return hash; } - (OFString *)description @@ -1123,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 @@ -1135,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 } @@ -1150,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; @@ -1212,28 +1210,28 @@ return true; } - (unsigned long)hash { - uint32_t hash; - - OF_HASH_INIT(hash); - - OF_HASH_ADD_HASH(hash, _name.hash); - OF_HASH_ADD(hash, _DNSClass >> 8); - OF_HASH_ADD(hash, _DNSClass); - OF_HASH_ADD(hash, _recordType >> 8); - OF_HASH_ADD(hash, _recordType); - OF_HASH_ADD(hash, _priority >> 8); - OF_HASH_ADD(hash, _priority); - OF_HASH_ADD(hash, _weight >> 8); - OF_HASH_ADD(hash, _weight); - OF_HASH_ADD_HASH(hash, _target.hash); - OF_HASH_ADD(hash, _port >> 8); - OF_HASH_ADD(hash, _port); - - OF_HASH_FINALIZE(hash); + unsigned long hash; + + OFHashInit(&hash); + + OFHashAddHash(&hash, _name.hash); + OFHashAdd(&hash, _DNSClass >> 8); + OFHashAdd(&hash, _DNSClass); + OFHashAdd(&hash, _recordType >> 8); + OFHashAdd(&hash, _recordType); + OFHashAdd(&hash, _priority >> 8); + OFHashAdd(&hash, _priority); + OFHashAdd(&hash, _weight >> 8); + OFHashAdd(&hash, _weight); + OFHashAddHash(&hash, _target.hash); + OFHashAdd(&hash, _port >> 8); + OFHashAdd(&hash, _port); + + OFHashFinalize(&hash); return hash; } - (OFString *)description @@ -1253,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) { @@ -1317,22 +1315,22 @@ return true; } - (unsigned long)hash { - uint32_t hash; - - OF_HASH_INIT(hash); - - OF_HASH_ADD_HASH(hash, _name.hash); - OF_HASH_ADD(hash, _DNSClass >> 8); - OF_HASH_ADD(hash, _DNSClass); - OF_HASH_ADD(hash, _recordType >> 8); - OF_HASH_ADD(hash, _recordType); - OF_HASH_ADD_HASH(hash, _textStrings.hash); - - OF_HASH_FINALIZE(hash); + unsigned long hash; + + OFHashInit(&hash); + + OFHashAddHash(&hash, _name.hash); + OFHashAdd(&hash, _DNSClass >> 8); + OFHashAdd(&hash, _DNSClass); + OFHashAdd(&hash, _recordType >> 8); + OFHashAdd(&hash, _recordType); + OFHashAddHash(&hash, _textStrings.hash); + + OFHashFinalize(&hash); return hash; } - (OFString *)description @@ -1373,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