Differences From Artifact [bcc41be191]:
- File
src/OFDNSResolver.m
— part of check-in
[8f810ecb7e]
at
2018-08-11 14:00:46
on branch trunk
— Change the layout of of_socket_address_t
Instead of containing a struct sockaddr_storage - which does not exist
on all supported platforms - it now contains a union of all struct
sockaddr_* types.Additionally, if struct sockaddr_in6 does not exist, it is defined so
that an IPv6 can be stored even if the system does not support IPv6. (user: js, size: 33389) [annotate] [blame] [check-ins using]
To Artifact [9632f6597d]:
- File
src/OFDNSResolver.m
— part of check-in
[75d2d3ba01]
at
2018-08-11 14:29:25
on branch trunk
— OFDNSResourceRecord: Use of_socket_address_t
This avoids unnecessary string construction and parsing and removes
duplicate code to convert an address into a string. (user: js, size: 32496) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
217 218 219 220 221 222 223 | } while (componentLength > 0); *idx = i; return [components componentsJoinedByString: @"."]; } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | | > > | > > | | 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | } while (componentLength > 0); *idx = i; return [components componentsJoinedByString: @"."]; } static OF_KINDOF(OFDNSResourceRecord *) createResourceRecord(OFString *name, of_dns_resource_record_class_t recordClass, of_dns_resource_record_type_t recordType, uint32_t TTL, const unsigned char *buffer, size_t length, size_t i, uint16_t dataLength) { if (recordType == OF_DNS_RESOURCE_RECORD_TYPE_A && recordClass == OF_DNS_RESOURCE_RECORD_CLASS_IN) { of_socket_address_t address; if (dataLength != 4) @throw [OFInvalidServerReplyException exception]; memset(&address, 0, sizeof(address)); address.family = OF_SOCKET_ADDRESS_FAMILY_IPV4; address.length = sizeof(address.sockaddr.in); address.sockaddr.in.sin_family = AF_INET; memcpy(&address.sockaddr.in.sin_addr.s_addr, buffer + i, 4); return [[[OFADNSResourceRecord alloc] initWithName: name address: &address TTL: TTL] autorelease]; } else if (recordType == OF_DNS_RESOURCE_RECORD_TYPE_NS) { size_t j = i; OFString *authoritativeHost = parseName(buffer, length, &j, MAX_ALLOWED_POINTERS); if (j != i + dataLength) |
︙ | ︙ | |||
449 450 451 452 453 454 455 | initWithName: name recordClass: recordClass mailbox: mailbox TXTDomainName: TXTDomainName TTL: TTL] autorelease]; } else if (recordType == OF_DNS_RESOURCE_RECORD_TYPE_AAAA && recordClass == OF_DNS_RESOURCE_RECORD_CLASS_IN) { | | | | > > > > | > > > > | | 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | initWithName: name recordClass: recordClass mailbox: mailbox TXTDomainName: TXTDomainName TTL: TTL] autorelease]; } else if (recordType == OF_DNS_RESOURCE_RECORD_TYPE_AAAA && recordClass == OF_DNS_RESOURCE_RECORD_CLASS_IN) { of_socket_address_t address; if (dataLength != 16) @throw [OFInvalidServerReplyException exception]; memset(&address, 0, sizeof(address)); address.family = OF_SOCKET_ADDRESS_FAMILY_IPV6; address.length = sizeof(address.sockaddr.in6); #ifdef AF_INET6 address.sockaddr.in6.sin6_family = AF_INET6; #else address.sockaddr.in6.sin6_family = AF_UNSPEC; #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 == OF_DNS_RESOURCE_RECORD_TYPE_SRV && recordClass == OF_DNS_RESOURCE_RECORD_CLASS_IN) { uint16_t priority, weight, port; size_t j; OFString *target; |
︙ | ︙ |