Overview
Comment: | Add support for LOC DNS resource records |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
d37c636a61bd0d1a56026b304fcb811b |
User & Date: | js on 2024-01-20 21:40:17 |
Other Links: | manifest | tags |
References
2024-01-20
| ||
21:41 | • Fixed ticket [1fd01665f1]: OFDNSResolver Support for LOC records plus 4 other changes artifact: 93676ac0ef user: js | |
Context
2024-01-21
| ||
09:38 | OFSubprocess: Correctly handle nil environment check-in: 6ca56b4f15 user: js tags: trunk | |
2024-01-20
| ||
21:40 | Add support for LOC DNS resource records check-in: d37c636a61 user: js tags: trunk | |
15:18 | +[OFSystemInfo networkInterfaces]: Avoid IfIndex check-in: abe3ccd61e user: js tags: trunk | |
Changes
Modified src/Makefile from [ff67b028ce] to [738e08751f].
︙ | ︙ | |||
128 129 130 131 132 133 134 135 136 137 138 139 140 141 | OFHINFODNSResourceRecord.m \ OFHTTPClient.m \ OFHTTPCookie.m \ OFHTTPCookieManager.m \ OFHTTPRequest.m \ OFHTTPResponse.m \ OFHTTPServer.m \ OFMXDNSResourceRecord.m \ OFNSDNSResourceRecord.m \ OFPTRDNSResourceRecord.m \ OFRPDNSResourceRecord.m \ OFSOADNSResourceRecord.m \ OFSRVDNSResourceRecord.m \ OFSequencedPacketSocket.m \ | > | 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | OFHINFODNSResourceRecord.m \ OFHTTPClient.m \ OFHTTPCookie.m \ OFHTTPCookieManager.m \ OFHTTPRequest.m \ OFHTTPResponse.m \ OFHTTPServer.m \ OFLOCDNSResourceRecord.m \ OFMXDNSResourceRecord.m \ OFNSDNSResourceRecord.m \ OFPTRDNSResourceRecord.m \ OFRPDNSResourceRecord.m \ OFSOADNSResourceRecord.m \ OFSRVDNSResourceRecord.m \ OFSequencedPacketSocket.m \ |
︙ | ︙ |
Modified src/OFDNSResolver.m from [1cf3f921a3] to [294ed882f2].
︙ | ︙ | |||
375 376 377 378 379 380 381 382 383 384 385 386 387 388 | #endif memcpy(address.sockaddr.in6.sin6_addr.s6_addr, buffer + i, 16); return [[[OFAAAADNSResourceRecord alloc] initWithName: name address: &address TTL: TTL] autorelease]; } else if (recordType == OFDNSRecordTypeSRV && DNSClass == OFDNSClassIN) { uint16_t priority, weight, port; size_t j; OFString *target; if (dataLength < 6) | > > > > > > > > > > > > > > > > > > > > > > > > > > > | 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 | #endif memcpy(address.sockaddr.in6.sin6_addr.s6_addr, buffer + i, 16); return [[[OFAAAADNSResourceRecord alloc] initWithName: name address: &address TTL: TTL] autorelease]; } else if (recordType == OFDNSRecordTypeLOC) { uint8_t size, horizontalPrecision, verticalPrecision; uint32_t latitude, longitude, altitude; if (dataLength < 16 || buffer[i] != 0) @throw [OFInvalidServerResponseException exception]; size = buffer[i + 1]; horizontalPrecision = buffer[i + 2]; verticalPrecision = buffer[i + 3]; latitude = (buffer[i + 4] << 24) | (buffer[i + 5] << 16) | (buffer[i + 6] << 8) | buffer[i + 7]; longitude = (buffer[i + 8] << 24) | (buffer[i + 9] << 16) | (buffer[i + 10] << 8) | buffer[i + 11]; altitude = (buffer[i + 12] << 24) | (buffer[i + 13] << 16) | (buffer[i + 14] << 8) | buffer[i + 15]; return [[[OFLOCDNSResourceRecord alloc] initWithName: name DNSClass: DNSClass size: size horizontalPrecision: horizontalPrecision verticalPrecision: verticalPrecision latitude: latitude longitude: longitude altitude: altitude TTL: TTL] autorelease]; } else if (recordType == OFDNSRecordTypeSRV && DNSClass == OFDNSClassIN) { uint16_t priority, weight, port; size_t j; OFString *target; if (dataLength < 6) |
︙ | ︙ |
Modified src/OFDNSResourceRecord.h from [22c9db5136] to [97a2085498].
︙ | ︙ | |||
54 55 56 57 58 59 60 61 62 63 64 65 66 67 | OFDNSRecordTypeMX = 15, /** TXT */ OFDNSRecordTypeTXT = 16, /** RP */ OFDNSRecordTypeRP = 17, /** AAAA */ OFDNSRecordTypeAAAA = 28, /** SRV */ OFDNSRecordTypeSRV = 33, /** All types. Only for queries. */ OFDNSRecordTypeAll = 255, /** URI */ OFDNSRecordTypeURI = 256, } OFDNSRecordType; | > > | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | OFDNSRecordTypeMX = 15, /** TXT */ OFDNSRecordTypeTXT = 16, /** RP */ OFDNSRecordTypeRP = 17, /** AAAA */ OFDNSRecordTypeAAAA = 28, /** LOC */ OFDNSRecordTypeLOC = 29, /** SRV */ OFDNSRecordTypeSRV = 33, /** All types. Only for queries. */ OFDNSRecordTypeAll = 255, /** URI */ OFDNSRecordTypeURI = 256, } OFDNSRecordType; |
︙ | ︙ | |||
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | OF_ASSUME_NONNULL_END #import "OFAAAADNSResourceRecord.h" #import "OFADNSResourceRecord.h" #import "OFCNAMEDNSResourceRecord.h" #import "OFHINFODNSResourceRecord.h" #import "OFMXDNSResourceRecord.h" #import "OFNSDNSResourceRecord.h" #import "OFPTRDNSResourceRecord.h" #import "OFRPDNSResourceRecord.h" #import "OFSOADNSResourceRecord.h" #import "OFSRVDNSResourceRecord.h" #import "OFTXTDNSResourceRecord.h" #import "OFURIDNSResourceRecord.h" | > | 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | OF_ASSUME_NONNULL_END #import "OFAAAADNSResourceRecord.h" #import "OFADNSResourceRecord.h" #import "OFCNAMEDNSResourceRecord.h" #import "OFHINFODNSResourceRecord.h" #import "OFLOCDNSResourceRecord.h" #import "OFMXDNSResourceRecord.h" #import "OFNSDNSResourceRecord.h" #import "OFPTRDNSResourceRecord.h" #import "OFRPDNSResourceRecord.h" #import "OFSOADNSResourceRecord.h" #import "OFSRVDNSResourceRecord.h" #import "OFTXTDNSResourceRecord.h" #import "OFURIDNSResourceRecord.h" |
Modified src/OFDNSResourceRecord.m from [2231be948e] to [1387c4ff44].
︙ | ︙ | |||
54 55 56 57 58 59 60 61 62 63 64 65 66 67 | return @"MX"; case OFDNSRecordTypeTXT: return @"TXT"; case OFDNSRecordTypeRP: return @"RP"; case OFDNSRecordTypeAAAA: return @"AAAA"; case OFDNSRecordTypeSRV: return @"SRV"; case OFDNSRecordTypeAll: return @"all"; case OFDNSRecordTypeURI: return @"URI"; default: | > > | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | return @"MX"; case OFDNSRecordTypeTXT: return @"TXT"; case OFDNSRecordTypeRP: return @"RP"; case OFDNSRecordTypeAAAA: return @"AAAA"; case OFDNSRecordTypeLOC: return @"LOC"; case OFDNSRecordTypeSRV: return @"SRV"; case OFDNSRecordTypeAll: return @"all"; case OFDNSRecordTypeURI: return @"URI"; default: |
︙ | ︙ | |||
113 114 115 116 117 118 119 120 121 122 123 124 125 126 | recordType = OFDNSRecordTypeMX; else if ([string isEqual: @"TXT"]) recordType = OFDNSRecordTypeTXT; else if ([string isEqual: @"RP"]) recordType = OFDNSRecordTypeRP; else if ([string isEqual: @"AAAA"]) recordType = OFDNSRecordTypeAAAA; else if ([string isEqual: @"SRV"]) recordType = OFDNSRecordTypeSRV; else if ([string isEqual: @"ALL"]) recordType = OFDNSRecordTypeAll; else if ([string isEqual: @"URI"]) recordType = OFDNSRecordTypeURI; else { | > > | 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | recordType = OFDNSRecordTypeMX; else if ([string isEqual: @"TXT"]) recordType = OFDNSRecordTypeTXT; else if ([string isEqual: @"RP"]) recordType = OFDNSRecordTypeRP; else if ([string isEqual: @"AAAA"]) recordType = OFDNSRecordTypeAAAA; else if ([string isEqual: @"LOC"]) recordType = OFDNSRecordTypeLOC; else if ([string isEqual: @"SRV"]) recordType = OFDNSRecordTypeSRV; else if ([string isEqual: @"ALL"]) recordType = OFDNSRecordTypeAll; else if ([string isEqual: @"URI"]) recordType = OFDNSRecordTypeURI; else { |
︙ | ︙ |
Added src/OFLOCDNSResourceRecord.h version [de5628693e].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFDNSResourceRecord.h" OF_ASSUME_NONNULL_BEGIN /** * @class OFLOCDNSResourceRecord \ * OFDNSResourceRecord.h ObjFW/OFDNSResourceRecord.h * * @brief A class representing an LOC DNS resource record. */ OF_SUBCLASSING_RESTRICTED @interface OFLOCDNSResourceRecord: OFDNSResourceRecord { uint8_t _size, _horizontalPrecision, _verticalPrecision; uint32_t _latitude, _longitude, _altitude; } /** * @brief The diameter in centimeters of a sphere enclosing the position, * encoded as per RFCC 1876. */ @property (readonly, nonatomic) uint8_t size; /** * @brief The horizontal precision in centimeters, encoded as per RFC 1876. */ @property (readonly, nonatomic) uint8_t horizontalPrecision; /** * @brief The vertical precision in centimeters, encoded as per RFC 1876. */ @property (readonly, nonatomic) uint8_t verticalPrecision; /** * @brief The latitude in thousands of a second of an arc. */ @property (readonly, nonatomic) uint32_t latitude; /** * @brief The longitude in thousands of a second of an arc. */ @property (readonly, nonatomic) uint32_t longitude; /** * @brief The altitude in centimeters from a base of 100000 meters below the * GPS reference. */ @property (readonly, nonatomic) uint32_t altitude; - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL OF_UNAVAILABLE; /** * @brief Initializes an already allocated OFLOCDNSResourceRecord with the * specified name, class, domain name and time to live. * * @param name The name for the resource record * @param DNSClass The class code for the resource record * @param size The diameter in centimeters of a sphere enclosing the position, * encoded as per RFCC 1876 * @param horizontalPrecision The horizontal precision in centimeters, encoded * as per RFC 1876 * @param verticalPrecision The vertical precision in centimeters, encoded as * per RFC 1876 * @param latitude The latitude in thousands of a second of an arc * @param longitude The longitude in thousands of a second of an arc * @param altitude The altitude in centimeters from a base of 100000 meters * below the GPS reference * @param TTL The time to live for the resource record * @return An initialized OFLOCDNSResourceRecord */ - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass size: (uint8_t)size horizontalPrecision: (uint8_t)horizontalPrecision verticalPrecision: (uint8_t)verticalPrecision latitude: (uint32_t)latitude longitude: (uint32_t)longitude altitude: (uint32_t)altitude TTL: (uint32_t)TTL OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Added src/OFLOCDNSResourceRecord.m version [bd7a5c4c92].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | /* * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #import "OFLOCDNSResourceRecord.h" @implementation OFLOCDNSResourceRecord @synthesize size = _size, horizontalPrecision = _horizontalPrecision; @synthesize verticalPrecision = _verticalPrecision, latitude = _latitude; @synthesize longitude = _longitude, altitude = _altitude; - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass recordType: (OFDNSRecordType)recordType TTL: (uint32_t)TTL { OF_INVALID_INIT_METHOD } - (instancetype)initWithName: (OFString *)name DNSClass: (OFDNSClass)DNSClass size: (uint8_t)size horizontalPrecision: (uint8_t)horizontalPrecision verticalPrecision: (uint8_t)verticalPrecision latitude: (uint32_t)latitude longitude: (uint32_t)longitude altitude: (uint32_t)altitude TTL: (uint32_t)TTL { self = [super initWithName: name DNSClass: DNSClass recordType: OFDNSRecordTypeLOC TTL: TTL]; @try { _size = size; _horizontalPrecision = horizontalPrecision; _verticalPrecision = verticalPrecision; _latitude = latitude; _longitude = longitude; _altitude = altitude; } @catch (id e) { [self release]; @throw e; } return self; } - (bool)isEqual: (id)object { OFLOCDNSResourceRecord *record; if (object == self) return true; if (![object isKindOfClass: [OFLOCDNSResourceRecord class]]) return false; record = object; if (record->_name != _name && ![record->_name isEqual: _name]) return false; if (record->_DNSClass != _DNSClass) return false; if (record->_recordType != _recordType) return false; if (record->_size != _size) return false; if (record->_horizontalPrecision != _horizontalPrecision) return false; if (record->_verticalPrecision != _verticalPrecision) return false; if (record->_latitude != _latitude) return false; if (record->_longitude != _longitude) return false; if (record->_altitude != _altitude) return false; return true; } - (unsigned long)hash { unsigned long hash; OFHashInit(&hash); OFHashAddHash(&hash, _name.hash); OFHashAddByte(&hash, _DNSClass >> 8); OFHashAddByte(&hash, _DNSClass); OFHashAddByte(&hash, _recordType >> 8); OFHashAddByte(&hash, _recordType); OFHashAddByte(&hash, _size); OFHashAddByte(&hash, _horizontalPrecision); OFHashAddByte(&hash, _verticalPrecision); OFHashAddByte(&hash, _latitude >> 24); OFHashAddByte(&hash, _latitude >> 16); OFHashAddByte(&hash, _latitude >> 8); OFHashAddByte(&hash, _latitude); OFHashAddByte(&hash, _longitude >> 24); OFHashAddByte(&hash, _longitude >> 16); OFHashAddByte(&hash, _longitude >> 8); OFHashAddByte(&hash, _longitude); OFHashAddByte(&hash, _altitude >> 24); OFHashAddByte(&hash, _altitude >> 16); OFHashAddByte(&hash, _altitude >> 8); OFHashAddByte(&hash, _altitude); OFHashFinalize(&hash); return hash; } - (OFString *)description { return [OFString stringWithFormat: @"<%@:\n" @"\tName = %@\n" @"\tClass = %@\n" @"\tSize = %ue%u\n" @"\tHorizontal precision = %ue%u\n" @"\tVertical precision = %ue%u\n" @"\tLatitude = %f\n" @"\tLongitude = %f\n" @"\tAltitude = %f\n" @"\tTTL = %" PRIu32 "\n" @">", self.className, _name, OFDNSClassName(_DNSClass), _size >> 4, _size & 0xF, _horizontalPrecision >> 4, _horizontalPrecision & 0xF, _verticalPrecision >> 4, _verticalPrecision & 0xF, ((double)_latitude - 2147483648) / 3600000, ((double)_longitude - 2147483648) / 3600000, ((double)_altitude - 10000000) / 100, _TTL]; } @end |