Comment: | Change the layout of of_socket_address_t
Instead of containing a struct sockaddr_storage - which does not exist Additionally, if struct sockaddr_in6 does not exist, it is defined so |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
8f810ecb7ee55780036ac1d70981c6f1 |
User & Date: | js on 2018-08-11 14:00:46 |
Other Links: | manifest | tags |
2018-08-11
| ||
14:29 | OFDNSResourceRecord: Use of_socket_address_t check-in: 75d2d3ba01 user: js tags: trunk | |
14:00 | Change the layout of of_socket_address_t check-in: 8f810ecb7e user: js tags: trunk | |
11:58 | OFDNSResolver: Minor refactoring check-in: 4afaa63320 user: js tags: trunk | |
Modified src/Makefile from [5b00ca5c8b] to [82b76260e6].
︙ | ︙ | |||
22 23 24 25 26 27 28 | OFData+CryptoHashing.m \ OFData+MessagePackValue.m \ OFDate.m \ OFDictionary.m \ OFEnumerator.m \ OFGZIPStream.m \ OFHMAC.m \ | < < < < < | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | OFData+CryptoHashing.m \ OFData+MessagePackValue.m \ OFDate.m \ OFDictionary.m \ OFEnumerator.m \ OFGZIPStream.m \ OFHMAC.m \ OFInflate64Stream.m \ OFInflateStream.m \ OFIntrospection.m \ OFInvocation.m \ OFLHAArchive.m \ OFLHAArchiveEntry.m \ OFList.m \ |
︙ | ︙ | |||
126 127 128 129 130 131 132 133 134 135 136 137 138 139 | OFINICategory.m \ OFINIFile.m \ OFSettings.m \ OFString+PathAdditions.m SRCS_PLUGINS = OFPlugin.m SRCS_SOCKETS = OFDNSResolver.m \ OFDNSResourceRecord.m \ OFHTTPServer.m \ OFStreamSocket.m \ OFTCPSocket.m \ OFUDPSocket.m \ resolver.m \ socket.m SRCS_THREADS = OFCondition.m \ | > > > > > | 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | OFINICategory.m \ OFINIFile.m \ OFSettings.m \ OFString+PathAdditions.m SRCS_PLUGINS = OFPlugin.m SRCS_SOCKETS = OFDNSResolver.m \ OFDNSResourceRecord.m \ ${OFHTTPCLIENT_M} \ OFHTTPCookie.m \ OFHTTPCookieManager.m \ OFHTTPRequest.m \ OFHTTPResponse.m \ OFHTTPServer.m \ OFStreamSocket.m \ OFTCPSocket.m \ OFUDPSocket.m \ resolver.m \ socket.m SRCS_THREADS = OFCondition.m \ |
︙ | ︙ |
Modified src/OFDNSResolver.m from [037c3906cf] to [bcc41be191].
︙ | ︙ | |||
1205 1206 1207 1208 1209 1210 1211 1212 | selector: @selector(of_queryWithIDTimedOut:) object: ID repeats: false]]; address = of_socket_address_parse_ip( [[query nameServers] firstObject], 53); #ifdef OF_HAVE_IPV6 | > < > | > > | > < | 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 | selector: @selector(of_queryWithIDTimedOut:) object: ID repeats: false]]; address = of_socket_address_parse_ip( [[query nameServers] firstObject], 53); switch (address.family) { #ifdef OF_HAVE_IPV6 case OF_SOCKET_ADDRESS_FAMILY_IPV6: if (_IPv6Socket == nil) { _IPv6Socket = [[OFUDPSocket alloc] init]; [_IPv6Socket bindToHost: @"::" port: 0]; [_IPv6Socket setBlocking: false]; } sock = _IPv6Socket; break; #endif case OF_SOCKET_ADDRESS_FAMILY_IPV4: if (_IPv4Socket == nil) { _IPv4Socket = [[OFUDPSocket alloc] init]; [_IPv4Socket bindToHost: @"0.0.0.0" port: 0]; [_IPv4Socket setBlocking: false]; } sock = _IPv4Socket; break; default: @throw [OFInvalidArgumentException exception]; } [sock asyncSendBuffer: [[query queryData] items] length: [[query queryData] count] receiver: address target: self selector: @selector(of_socket:didSendBuffer:bytesSent: receiver:context:exception:) |
︙ | ︙ |
Modified src/OFHTTPRequest.h from [7ce0d63ac4] to [7136743ab3].
︙ | ︙ | |||
13 14 15 16 17 18 19 20 21 22 23 24 25 26 | * 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 "OFObject.h" #import "OFString.h" OF_ASSUME_NONNULL_BEGIN @class OFURL; @class OFDictionary OF_GENERIC(KeyType, ObjectType); @class OFData; @class OFString; | > > | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | * 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 "OFObject.h" #import "OFString.h" #import "socket.h" OF_ASSUME_NONNULL_BEGIN @class OFURL; @class OFDictionary OF_GENERIC(KeyType, ObjectType); @class OFData; @class OFString; |
︙ | ︙ | |||
69 70 71 72 73 74 75 | */ @interface OFHTTPRequest: OFObject <OFCopying> { OFURL *_URL; of_http_request_method_t _method; of_http_request_protocol_version_t _protocolVersion; OFDictionary OF_GENERIC(OFString *, OFString *) *_Nullable _headers; | | | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | */ @interface OFHTTPRequest: OFObject <OFCopying> { OFURL *_URL; of_http_request_method_t _method; of_http_request_protocol_version_t _protocolVersion; OFDictionary OF_GENERIC(OFString *, OFString *) *_Nullable _headers; of_socket_address_t _remoteAddress; } /*! * @brief The URL of the HTTP request. */ @property (copy, nonatomic) OFURL *URL; |
︙ | ︙ | |||
101 102 103 104 105 106 107 | */ @property OF_NULLABLE_PROPERTY (copy, nonatomic) OFDictionary OF_GENERIC(OFString *, OFString *) *headers; /*! * @brief The remote address from which the request originates. */ | | > | 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | */ @property OF_NULLABLE_PROPERTY (copy, nonatomic) OFDictionary OF_GENERIC(OFString *, OFString *) *headers; /*! * @brief The remote address from which the request originates. */ @property OF_NULLABLE_PROPERTY (nonatomic) const of_socket_address_t *remoteAddress; /*! * @brief Creates a new OFHTTPRequest. * * @return A new, autoreleased OFHTTPRequest */ + (instancetype)request; |
︙ | ︙ |
Modified src/OFHTTPRequest.m from [9ef3db2e96] to [f2c9b5d838].
︙ | ︙ | |||
76 77 78 79 80 81 82 | return OF_HTTP_REQUEST_METHOD_CONNECT; @throw [OFInvalidFormatException exception]; } @implementation OFHTTPRequest @synthesize URL = _URL, method = _method, headers = _headers; | < | 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | return OF_HTTP_REQUEST_METHOD_CONNECT; @throw [OFInvalidFormatException exception]; } @implementation OFHTTPRequest @synthesize URL = _URL, method = _method, headers = _headers; + (instancetype)request { return [[[self alloc] init] autorelease]; } + (instancetype)requestWithURL: (OFURL *)URL |
︙ | ︙ | |||
117 118 119 120 121 122 123 | return self; } - (void)dealloc { [_URL release]; [_headers release]; | < > > > > > > > > > > | | 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 | return self; } - (void)dealloc { [_URL release]; [_headers release]; [super dealloc]; } - (void)setRemoteAddress: (const of_socket_address_t *)remoteAddress { _remoteAddress = *remoteAddress; } - (const of_socket_address_t *)remoteAddress { return &_remoteAddress; } - (id)copy { OFHTTPRequest *copy = [[OFHTTPRequest alloc] init]; @try { copy->_method = _method; copy->_protocolVersion = _protocolVersion; [copy setURL: _URL]; [copy setHeaders: _headers]; [copy setRemoteAddress: &_remoteAddress]; } @catch (id e) { [copy release]; @throw e; } return copy; } |
︙ | ︙ | |||
157 158 159 160 161 162 163 | request = object; if (request->_method != _method || request->_protocolVersion.major != _protocolVersion.major || request->_protocolVersion.minor != _protocolVersion.minor || ![request->_URL isEqual: _URL] || ![request->_headers isEqual: _headers] || | | | | 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | request = object; if (request->_method != _method || request->_protocolVersion.major != _protocolVersion.major || request->_protocolVersion.minor != _protocolVersion.minor || ![request->_URL isEqual: _URL] || ![request->_headers isEqual: _headers] || !of_socket_address_equal(&request->_remoteAddress, &_remoteAddress)) return false; return true; } - (uint32_t)hash { uint32_t hash; OF_HASH_INIT(hash); OF_HASH_ADD(hash, _method); OF_HASH_ADD(hash, _protocolVersion.major); OF_HASH_ADD(hash, _protocolVersion.minor); OF_HASH_ADD_HASH(hash, [_URL hash]); OF_HASH_ADD_HASH(hash, [_headers hash]); OF_HASH_ADD_HASH(hash, of_socket_address_hash(&_remoteAddress)); OF_HASH_FINALIZE(hash); return hash; } - (void)setProtocolVersion: (of_http_request_protocol_version_t)protocolVersion |
︙ | ︙ | |||
244 245 246 247 248 249 250 | ret = [[OFString alloc] initWithFormat: @"<%@:\n\tURL = %@\n" @"\tMethod = %s\n" @"\tHeaders = %@\n" @"\tRemote address = %@\n" @">", | | > | 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | ret = [[OFString alloc] initWithFormat: @"<%@:\n\tURL = %@\n" @"\tMethod = %s\n" @"\tHeaders = %@\n" @"\tRemote address = %@\n" @">", [self class], _URL, method, indentedHeaders, of_socket_address_ip_string(&_remoteAddress, NULL)]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } @end |
Modified src/OFTCPSocket.h from [6656d5bf06] to [0973252c95].
︙ | ︙ | |||
58 59 60 61 62 63 64 | * * To connect to a server, create a socket and connect it. * To create a server, create a socket, bind it and listen on it. */ @interface OFTCPSocket: OFStreamSocket { bool _listening; | < | | | | 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 | * * To connect to a server, create a socket and connect it. * To create a server, create a socket, bind it and listen on it. */ @interface OFTCPSocket: OFStreamSocket { bool _listening; of_socket_address_t _remoteAddress; OFString *_Nullable _SOCKS5Host; uint16_t _SOCKS5Port; #ifdef OF_WII uint16_t _port; #endif } #ifdef OF_HAVE_CLASS_PROPERTIES @property (class, nullable, copy, nonatomic) OFString *SOCKS5Host; @property (class, nonatomic) uint16_t SOCKS5Port; #endif /*! * @brief Whether the socket is a listening socket. */ @property (readonly, nonatomic, getter=isListening) bool listening; /*! * @brief The remote address. * * @note This only works for accepted sockets! */ @property (readonly, nonatomic) const of_socket_address_t *remoteAddress; #if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) /*! * @brief Whether keep alives are enabled for the connection. * * @warning This is not available on the Wii or Nintendo 3DS! */ |
︙ | ︙ |
Modified src/OFTCPSocket.m from [e5ab8ac35c] to [a77bbf08e1].
︙ | ︙ | |||
362 363 364 365 366 367 368 | #endif - (uint16_t)bindToHost: (OFString *)host port: (uint16_t)port { of_resolver_result_t **results; const int one = 1; | < < < < < < < | < < | 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 | #endif - (uint16_t)bindToHost: (OFString *)host port: (uint16_t)port { of_resolver_result_t **results; const int one = 1; of_socket_address_t address; if (_socket != INVALID_SOCKET) @throw [OFAlreadyConnectedException exceptionWithSocket: self]; if (_SOCKS5Host != nil) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; |
︙ | ︙ | |||
479 480 481 482 483 484 485 | of_resolver_free(results); } if (port > 0) return port; #if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) | | | | | | | | | 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 | of_resolver_free(results); } if (port > 0) return port; #if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) address.length = (socklen_t)sizeof(address.sockaddr); if (of_getsockname(_socket, &address.sockaddr.sockaddr, &address.length) != 0) { int errNo = of_socket_errno(); closesocket(_socket); _socket = INVALID_SOCKET; @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: errNo]; } if (address.sockaddr.sockaddr.sa_family == AF_INET) return OF_BSWAP16_IF_LE(address.sockaddr.in.sin_port); # ifdef OF_HAVE_IPV6 if (address.sockaddr.sockaddr.sa_family == AF_INET6) return OF_BSWAP16_IF_LE(address.sockaddr.in6.sin6_port); # endif #endif closesocket(_socket); _socket = INVALID_SOCKET; @throw [OFBindFailedException exceptionWithHost: host port: port |
︙ | ︙ | |||
537 538 539 540 541 542 543 | OFTCPSocket *client = [[[[self class] alloc] init] autorelease]; #if (!defined(HAVE_PACCEPT) && !defined(HAVE_ACCEPT4)) || !defined(SOCK_CLOEXEC) # if defined(HAVE_FCNTL) && defined(FD_CLOEXEC) int flags; # endif #endif | | < | | > | > | > | | > | | | | | | > > > | > > > | < < < > > | 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 | OFTCPSocket *client = [[[[self class] alloc] init] autorelease]; #if (!defined(HAVE_PACCEPT) && !defined(HAVE_ACCEPT4)) || !defined(SOCK_CLOEXEC) # if defined(HAVE_FCNTL) && defined(FD_CLOEXEC) int flags; # endif #endif client->_remoteAddress.length = (socklen_t)sizeof(client->_remoteAddress.sockaddr); #if defined(HAVE_PACCEPT) && defined(SOCK_CLOEXEC) if ((client->_socket = paccept(_socket, &client->_remoteAddress.sockaddr.sockaddr, &client->_remoteAddress.length, NULL, SOCK_CLOEXEC)) == INVALID_SOCKET) @throw [OFAcceptFailedException exceptionWithSocket: self errNo: of_socket_errno()]; #elif defined(HAVE_ACCEPT4) && defined(SOCK_CLOEXEC) if ((client->_socket = accept4(_socket, &client->_remoteAddress.sockaddr.sockaddr, &client->_remoteAddress.length, SOCK_CLOEXEC)) == INVALID_SOCKET) @throw [OFAcceptFailedException exceptionWithSocket: self errNo: of_socket_errno()]; #else if ((client->_socket = accept(_socket, &client->_remoteAddress.sockaddr.sockaddr, &client->_remoteAddress.length)) == INVALID_SOCKET) @throw [OFAcceptFailedException exceptionWithSocket: self errNo: of_socket_errno()]; # if defined(HAVE_FCNTL) && defined(FD_CLOEXEC) if ((flags = fcntl(client->_socket, F_GETFD, 0)) != -1) fcntl(client->_socket, F_SETFD, flags | FD_CLOEXEC); # endif #endif assert(client->_remoteAddress.length <= (socklen_t)sizeof(client->_remoteAddress.sockaddr)); switch (client->_remoteAddress.sockaddr.sockaddr.sa_family) { case AF_INET: client->_remoteAddress.family = OF_SOCKET_ADDRESS_FAMILY_IPV4; break; #ifdef OF_HAVE_IPV6 case AF_INET6: client->_remoteAddress.family = OF_SOCKET_ADDRESS_FAMILY_IPV6; break; #endif default: client->_remoteAddress.family = OF_SOCKET_ADDRESS_FAMILY_UNKNOWN; break; } return client; } - (void)asyncAcceptWithTarget: (id)target selector: (SEL)selector |
︙ | ︙ | |||
600 601 602 603 604 605 606 | - (void)asyncAcceptWithBlock: (of_tcp_socket_async_accept_block_t)block { [OFRunLoop of_addAsyncAcceptForTCPSocket: self block: block]; } #endif | < < | | | | < < < | < | 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 | - (void)asyncAcceptWithBlock: (of_tcp_socket_async_accept_block_t)block { [OFRunLoop of_addAsyncAcceptForTCPSocket: self block: block]; } #endif - (const of_socket_address_t *)remoteAddress { if (_socket == INVALID_SOCKET) @throw [OFNotOpenException exceptionWithObject: self]; if (_remoteAddress.length == 0) @throw [OFInvalidArgumentException exception]; if (_remoteAddress.length > (socklen_t)sizeof(_remoteAddress.sockaddr)) @throw [OFOutOfRangeException exception]; return &_remoteAddress; } - (bool)isListening { return _listening; } |
︙ | ︙ | |||
683 684 685 686 687 688 689 | } #endif - (void)close { _listening = false; | < | < | 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 | } #endif - (void)close { _listening = false; memset(&_remoteAddress, 0, sizeof(_remoteAddress)); #ifdef OF_WII _port = 0; #endif [super close]; } @end |
Modified src/OFUDPSocket.m from [6cab00e4d5] to [1e4bb48119].
︙ | ︙ | |||
202 203 204 205 206 207 208 | port: (uint16_t)port address: (of_socket_address_t *)address { of_resolver_result_t **results = of_resolve_host(host, port, SOCK_DGRAM); assert(results[0]->addressLength <= | | | > > > > > > > > > > > > > > | 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | port: (uint16_t)port address: (of_socket_address_t *)address { of_resolver_result_t **results = of_resolve_host(host, port, SOCK_DGRAM); assert(results[0]->addressLength <= (socklen_t)sizeof(address->sockaddr)); memcpy(&address->sockaddr, results[0]->address, results[0]->addressLength); address->length = results[0]->addressLength; switch (results[0]->address->sa_family) { case AF_INET: address->family = OF_SOCKET_ADDRESS_FAMILY_IPV4; break; #ifdef OF_HAVE_IPV6 case AF_INET6: address->family = OF_SOCKET_ADDRESS_FAMILY_IPV6; break; #endif default: address->family = OF_SOCKET_ADDRESS_FAMILY_UNKNOWN; break; } of_resolver_free(results); } #ifdef OF_HAVE_THREADS + (void)asyncResolveAddressForHost: (OFString *)host port: (uint16_t)port |
︙ | ︙ | |||
314 315 316 317 318 319 320 | #endif } - (uint16_t)bindToHost: (OFString *)host port: (uint16_t)port { of_resolver_result_t **results; | < < < < < < < | < < | 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | #endif } - (uint16_t)bindToHost: (OFString *)host port: (uint16_t)port { of_resolver_result_t **results; of_socket_address_t address; results = of_resolve_host(host, port, SOCK_DGRAM); @try { #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL) && defined(FD_CLOEXEC) int flags; #endif |
︙ | ︙ | |||
421 422 423 424 425 426 427 | of_resolver_free(results); } if (port > 0) return port; #if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) | | | | | | | | | | | > > > > > > > > > > > > > > | 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 | of_resolver_free(results); } if (port > 0) return port; #if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) address.length = (socklen_t)sizeof(address.sockaddr); if (of_getsockname(_socket, &address.sockaddr.sockaddr, &address.length) != 0) { int errNo = of_socket_errno(); closesocket(_socket); _socket = INVALID_SOCKET; @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: errNo]; } if (address.sockaddr.sockaddr.sa_family == AF_INET) return OF_BSWAP16_IF_LE(address.sockaddr.in.sin_port); # ifdef OF_HAVE_IPV6 if (address.sockaddr.sockaddr.sa_family == AF_INET6) return OF_BSWAP16_IF_LE(address.sockaddr.in6.sin6_port); # endif #endif closesocket(_socket); _socket = INVALID_SOCKET; @throw [OFBindFailedException exceptionWithHost: host port: port socket: self errNo: EAFNOSUPPORT]; } - (size_t)receiveIntoBuffer: (void *)buffer length: (size_t)length sender: (of_socket_address_t *)sender { ssize_t ret; if (_socket == INVALID_SOCKET) @throw [OFNotOpenException exceptionWithObject: self]; sender->length = (socklen_t)sizeof(sender->sockaddr); #ifndef OF_WINDOWS if ((ret = recvfrom(_socket, buffer, length, 0, &sender->sockaddr.sockaddr, &sender->length)) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: of_socket_errno()]; #else if (length > INT_MAX) @throw [OFOutOfRangeException exception]; if ((ret = recvfrom(_socket, buffer, (int)length, 0, &sender->sockaddr.sockaddr, &sender->length)) < 0) @throw [OFReadFailedException exceptionWithObject: self requestedLength: length errNo: of_socket_errno()]; #endif switch (sender->sockaddr.sockaddr.sa_family) { case AF_INET: sender->family = OF_SOCKET_ADDRESS_FAMILY_IPV4; break; #ifdef OF_HAVE_IPV6 case AF_INET6: sender->family = OF_SOCKET_ADDRESS_FAMILY_IPV6; break; #endif default: sender->family = OF_SOCKET_ADDRESS_FAMILY_UNKNOWN; break; } return ret; } - (void)asyncReceiveIntoBuffer: (void *)buffer length: (size_t)length target: (id)target |
︙ | ︙ | |||
524 525 526 527 528 529 530 | #ifndef OF_WINDOWS ssize_t bytesWritten; if (length > SSIZE_MAX) @throw [OFOutOfRangeException exception]; if ((bytesWritten = sendto(_socket, buffer, length, 0, | | < | | 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 | #ifndef OF_WINDOWS ssize_t bytesWritten; if (length > SSIZE_MAX) @throw [OFOutOfRangeException exception]; if ((bytesWritten = sendto(_socket, buffer, length, 0, &receiver->sockaddr.sockaddr, receiver->length)) < 0) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length bytesWritten: 0 errNo: of_socket_errno()]; #else int bytesWritten; if (length > INT_MAX) @throw [OFOutOfRangeException exception]; if ((bytesWritten = sendto(_socket, buffer, (int)length, 0, &receiver->sockaddr.sockaddr, receiver->length)) < 0) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length bytesWritten: 0 errNo: of_socket_errno()]; #endif |
︙ | ︙ |
Modified src/ObjFW.h from [de95586181] to [410a981ac1].
︙ | ︙ | |||
74 75 76 77 78 79 80 81 82 83 84 | # import "OFStreamSocket.h" # import "OFTCPSocket.h" # import "OFUDPSocket.h" # import "OFTLSSocket.h" # import "OFKernelEventObserver.h" # import "OFDNSResolver.h" #endif #import "OFHTTPCookie.h" #import "OFHTTPCookieManager.h" #import "OFHTTPRequest.h" #import "OFHTTPResponse.h" | > > > > < < < < | 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | # import "OFStreamSocket.h" # import "OFTCPSocket.h" # import "OFUDPSocket.h" # import "OFTLSSocket.h" # import "OFKernelEventObserver.h" # import "OFDNSResolver.h" #endif #ifdef OF_HAVE_SOCKETS # ifdef OF_HAVE_THREADS # import "OFHTTPClient.h" # endif #import "OFHTTPCookie.h" #import "OFHTTPCookieManager.h" #import "OFHTTPRequest.h" #import "OFHTTPResponse.h" # import "OFHTTPServer.h" #endif #ifdef OF_HAVE_PROCESSES # import "OFProcess.h" #endif |
︙ | ︙ |
Modified src/socket.h from [232e64699e] to [d1393543d0].
︙ | ︙ | |||
46 47 48 49 50 51 52 | # endif # include <windows.h> # include <ws2tcpip.h> #endif /*! @file */ | < < < < < < < < < < < < < < < < < < < < < < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > | 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 | # endif # include <windows.h> # include <ws2tcpip.h> #endif /*! @file */ #ifdef OF_MORPHOS typedef long socklen_t; #endif #ifdef OF_MORPHOS_IXEMUL typedef int socklen_t; #endif #ifdef OF_WII # include <network.h> #endif #ifdef OF_PSP # include <stdint.h> #endif #import "macros.h" OF_ASSUME_NONNULL_BEGIN #ifndef OF_WINDOWS typedef int of_socket_t; #else typedef SOCKET of_socket_t; #endif /*! * @enum of_socket_address_type_t socket.h ObjFW/socket.h */ typedef enum { OF_SOCKET_ADDRESS_FAMILY_UNKNOWN, OF_SOCKET_ADDRESS_FAMILY_IPV4, OF_SOCKET_ADDRESS_FAMILY_IPV6, } of_socket_address_family_t; #ifndef OF_HAVE_IPV6 struct sockaddr_in6 { sa_family_t sin6_family; in_port_t sin6_port; uint32_t sin6_flowinfo; struct in6_addr { uint8_t s6_addr[16]; } sin6_addr; uint32_t sin6_scope_id; }; #endif /*! * @struct of_socket_address_t socket.h ObjFW/socket.h * * @brief A struct which represents a host / port pair for a socket. */ typedef struct OF_BOXABLE { /* * Even though struct sockaddr contains the family, we need to use our * own family, as we need to support storing an IPv6 address on systems * that don't support IPv6. These may not have AF_INET6 defined and we * can't just define it, as the value is system-dependent and might * clash with an existing value. */ of_socket_address_family_t family; union { struct sockaddr sockaddr; struct sockaddr_in in; struct sockaddr_in6 in6; } sockaddr; socklen_t length; } of_socket_address_t; #ifdef __cplusplus extern "C" { #endif extern bool of_socket_init(void); |
︙ | ︙ | |||
173 174 175 176 177 178 179 180 181 182 183 184 | * @param address The address to convert to a string * @param port A pointer to an uint16_t which should be set to the port of the * address or NULL if the port is not needed * @return The address as an IP string */ extern OFString *_Nonnull of_socket_address_ip_string( const of_socket_address_t *_Nonnull address, uint16_t *_Nullable port); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END | > > > > > > > > > > | 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | * @param address The address to convert to a string * @param port A pointer to an uint16_t which should be set to the port of the * address or NULL if the port is not needed * @return The address as an IP string */ extern OFString *_Nonnull of_socket_address_ip_string( const of_socket_address_t *_Nonnull address, uint16_t *_Nullable port); /*! * @brief Sets the port of the specified of_socket_address_t, independent of * the address family used. * * @param address The address on which to set the port * @param port The port to set on the address */ extern void of_socket_address_set_port(of_socket_address_t *_Nonnull address, uint16_t port); #ifdef __cplusplus } #endif OF_ASSUME_NONNULL_END |
Modified src/socket.m from [2650e52f57] to [23b837d278].
︙ | ︙ | |||
231 232 233 234 235 236 237 | { /* TODO: Support IPs that are not in the a.b.c.d format? */ void *pool = objc_autoreleasePoolPush(); OFCharacterSet *whitespaceCharacterSet = [OFCharacterSet whitespaceCharacterSet]; of_socket_address_t ret; | | > | 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | { /* TODO: Support IPs that are not in the a.b.c.d format? */ void *pool = objc_autoreleasePoolPush(); OFCharacterSet *whitespaceCharacterSet = [OFCharacterSet whitespaceCharacterSet]; of_socket_address_t ret; struct sockaddr_in *addrIn = &ret.sockaddr.in; OFArray OF_GENERIC(OFString *) *components; uint32_t addr; memset(&ret, '\0', sizeof(ret)); ret.family = OF_SOCKET_ADDRESS_FAMILY_IPV4; ret.length = sizeof(struct sockaddr_in); addrIn->sin_family = AF_INET; addrIn->sin_port = OF_BSWAP16_IF_LE(port); components = [IPv4 componentsSeparatedByString: @"."]; |
︙ | ︙ | |||
273 274 275 276 277 278 279 | addrIn->sin_addr.s_addr = OF_BSWAP32_IF_LE(addr); objc_autoreleasePoolPop(pool); return ret; } | < | 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | addrIn->sin_addr.s_addr = OF_BSWAP32_IF_LE(addr); objc_autoreleasePoolPop(pool); return ret; } static uint16_t parseIPv6Component(OFString *component) { uintmax_t number; if ([component indexOfCharacterFromSet: [OFCharacterSet whitespaceCharacterSet]] != OF_NOT_FOUND) |
︙ | ︙ | |||
296 297 298 299 300 301 302 | } of_socket_address_t of_socket_address_parse_ipv6(OFString *IPv6, uint16_t port) { void *pool = objc_autoreleasePoolPush(); of_socket_address_t ret; | | > > > > > | 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | } of_socket_address_t of_socket_address_parse_ipv6(OFString *IPv6, uint16_t port) { void *pool = objc_autoreleasePoolPush(); of_socket_address_t ret; struct sockaddr_in6 *addrIn6 = &ret.sockaddr.in6; size_t doubleColon; memset(&ret, '\0', sizeof(ret)); ret.family = OF_SOCKET_ADDRESS_FAMILY_IPV6; ret.length = sizeof(struct sockaddr_in6); #ifdef AF_INET6 addrIn6->sin6_family = AF_INET6; #else addrIn6->sin6_family = AF_UNSPEC; #endif addrIn6->sin6_port = OF_BSWAP16_IF_LE(port); doubleColon = [IPv6 rangeOfString: @"::"].location; if (doubleColon != OF_NOT_FOUND) { OFString *left = [IPv6 substringWithRange: of_range(0, doubleColon)]; |
︙ | ︙ | |||
366 367 368 369 370 371 372 | } } objc_autoreleasePoolPop(pool); return ret; } | < < < < < < < | | | | | < | | | < | < < < < < > | | | | | | | > > < | < | < | < | < | | | < < > > | < < | < | 371 372 373 374 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 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 | } } objc_autoreleasePoolPop(pool); return ret; } of_socket_address_t of_socket_address_parse_ip(OFString *IP, uint16_t port) { @try { return of_socket_address_parse_ipv6(IP, port); } @catch (OFInvalidFormatException *e) { return of_socket_address_parse_ipv4(IP, port); } } bool of_socket_address_equal(of_socket_address_t *address1, of_socket_address_t *address2) { struct sockaddr_in *addrIn1, *addrIn2; struct sockaddr_in6 *addrIn6_1, *addrIn6_2; if (address1->family != address2->family) return false; switch (address1->family) { case OF_SOCKET_ADDRESS_FAMILY_IPV4: #if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) if (address1->length < (socklen_t)sizeof(struct sockaddr_in) || address2->length < (socklen_t)sizeof(struct sockaddr_in)) @throw [OFInvalidArgumentException exception]; #else if (address1->length < 8 || address2->length < 8) @throw [OFInvalidArgumentException exception]; #endif addrIn1 = &address1->sockaddr.in; addrIn2 = &address2->sockaddr.in; if (addrIn1->sin_port != addrIn2->sin_port) return false; if (addrIn1->sin_addr.s_addr != addrIn2->sin_addr.s_addr) return false; break; case OF_SOCKET_ADDRESS_FAMILY_IPV6: if (address1->length < (socklen_t)sizeof(struct sockaddr_in6) || address2->length < (socklen_t)sizeof(struct sockaddr_in6)) @throw [OFInvalidArgumentException exception]; addrIn6_1 = &address1->sockaddr.in6; addrIn6_2 = &address2->sockaddr.in6; if (addrIn6_1->sin6_port != addrIn6_2->sin6_port) return false; if (memcmp(addrIn6_1->sin6_addr.s6_addr, addrIn6_2->sin6_addr.s6_addr, sizeof(addrIn6_1->sin6_addr.s6_addr)) != 0) return false; break; default: @throw [OFInvalidArgumentException exception]; } return true; } uint32_t of_socket_address_hash(of_socket_address_t *address) { uint32_t hash; OF_HASH_INIT(hash); OF_HASH_ADD(hash, address->family); switch (address->family) { case OF_SOCKET_ADDRESS_FAMILY_IPV4: #if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) if (address->length < (socklen_t)sizeof(struct sockaddr_in)) @throw [OFInvalidArgumentException exception]; #else if (address->length < 8) @throw [OFInvalidArgumentException exception]; #endif OF_HASH_ADD(hash, address->sockaddr.in.sin_port >> 8); OF_HASH_ADD(hash, address->sockaddr.in.sin_port); OF_HASH_ADD(hash, address->sockaddr.in.sin_addr.s_addr >> 24); OF_HASH_ADD(hash, address->sockaddr.in.sin_addr.s_addr >> 16); OF_HASH_ADD(hash, address->sockaddr.in.sin_addr.s_addr >> 8); OF_HASH_ADD(hash, address->sockaddr.in.sin_addr.s_addr); break; case OF_SOCKET_ADDRESS_FAMILY_IPV6: if (address->length < (socklen_t)sizeof(struct sockaddr_in6)) @throw [OFInvalidArgumentException exception]; OF_HASH_ADD(hash, address->sockaddr.in6.sin6_port >> 8); OF_HASH_ADD(hash, address->sockaddr.in6.sin6_port); for (size_t i = 0; i < sizeof(address->sockaddr.in6.sin6_addr.s6_addr); i++) OF_HASH_ADD(hash, address->sockaddr.in6.sin6_addr.s6_addr[i]); break; default: @throw [OFInvalidArgumentException exception]; } OF_HASH_FINALIZE(hash); return hash; } static OFString * IPv4String(const of_socket_address_t *address, uint16_t *port) { const struct sockaddr_in *addrIn = &address->sockaddr.in; uint32_t addr = OF_BSWAP32_IF_LE(addrIn->sin_addr.s_addr); OFString *string; string = [OFString stringWithFormat: @"%u.%u.%u.%u", (addr & 0xFF000000) >> 24, (addr & 0x00FF0000) >> 16, (addr & 0x0000FF00) >> 8, addr & 0x000000FF]; if (port != NULL) *port = OF_BSWAP16_IF_LE(addrIn->sin_port); return string; } static OFString * IPv6String(const of_socket_address_t *address, uint16_t *port) { OFMutableString *string = [OFMutableString string]; const struct sockaddr_in6 *addrIn6 = &address->sockaddr.in6; int_fast8_t zerosStart = -1, maxZerosStart = -1; uint_fast8_t zerosCount = 0, maxZerosCount = 0; bool first = true; for (uint_fast8_t i = 0; i < 16; i += 2) { if (addrIn6->sin6_addr.s6_addr[i] == 0 && addrIn6->sin6_addr.s6_addr[i + 1] == 0) { |
︙ | ︙ | |||
583 584 585 586 587 588 589 | [string makeImmutable]; if (port != NULL) *port = OF_BSWAP16_IF_LE(addrIn6->sin6_port); return string; } | < | | < | > > > > | > > > > > > > > > > | 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 | [string makeImmutable]; if (port != NULL) *port = OF_BSWAP16_IF_LE(addrIn6->sin6_port); return string; } OFString * of_socket_address_ip_string(const of_socket_address_t *address, uint16_t *port) { switch (address->family) { case OF_SOCKET_ADDRESS_FAMILY_IPV4: return IPv4String(address, port); case OF_SOCKET_ADDRESS_FAMILY_IPV6: return IPv6String(address, port); default: @throw [OFInvalidArgumentException exception]; } } void of_socket_address_set_port(of_socket_address_t *address, uint16_t port) { switch (address->family) { case OF_SOCKET_ADDRESS_FAMILY_IPV4: address->sockaddr.in.sin_port = OF_BSWAP16_IF_LE(port); break; case OF_SOCKET_ADDRESS_FAMILY_IPV6: address->sockaddr.in6.sin6_port = OF_BSWAP16_IF_LE(port); break; default: @throw [OFInvalidArgumentException exception]; } } |
Modified tests/OFTCPSocketTests.m from [7ae6276193] to [7c3189d9e4].
︙ | ︙ | |||
47 48 49 50 51 52 53 | TEST(@"-[connectToHost:port:]", R([client connectToHost: @"127.0.0.1" port: port])) TEST(@"-[accept]", (accepted = [server accept])) TEST(@"-[remoteAddress]", | > | | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | TEST(@"-[connectToHost:port:]", R([client connectToHost: @"127.0.0.1" port: port])) TEST(@"-[accept]", (accepted = [server accept])) TEST(@"-[remoteAddress]", [of_socket_address_ip_string([accepted remoteAddress], NULL) isEqual: @"127.0.0.1"]) TEST(@"-[writeString:]", [client writeString: @"Hello!"]) TEST(@"-[readIntoBuffer:length:]", [accepted readIntoBuffer: buf length: 6] && !memcmp(buf, "Hello!", 6)) [pool drain]; } @end |
Modified tests/SocketTests.m from [25f3a27b64] to [43991614fd].
︙ | ︙ | |||
22 23 24 25 26 27 28 | #import "OFInvalidFormatException.h" #import "TestsAppDelegate.h" #import "socket.h" | < < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 | #import "OFInvalidFormatException.h" #import "TestsAppDelegate.h" #import "socket.h" #define COMPARE_V6(a, a0, a1, a2, a3, a4, a5, a6, a7) \ (a.sockaddr.in6.sin6_addr.s6_addr[0] == (a0 >> 8) && \ a.sockaddr.in6.sin6_addr.s6_addr[1] == (a0 & 0xFF) && \ a.sockaddr.in6.sin6_addr.s6_addr[2] == (a1 >> 8) && \ a.sockaddr.in6.sin6_addr.s6_addr[3] == (a1 & 0xFF) && \ a.sockaddr.in6.sin6_addr.s6_addr[4] == (a2 >> 8) && \ a.sockaddr.in6.sin6_addr.s6_addr[5] == (a2 & 0xFF) && \ a.sockaddr.in6.sin6_addr.s6_addr[6] == (a3 >> 8) && \ a.sockaddr.in6.sin6_addr.s6_addr[7] == (a3 & 0xFF) && \ a.sockaddr.in6.sin6_addr.s6_addr[8] == (a4 >> 8) && \ a.sockaddr.in6.sin6_addr.s6_addr[9] == (a4 & 0xFF) && \ a.sockaddr.in6.sin6_addr.s6_addr[10] == (a5 >> 8) && \ a.sockaddr.in6.sin6_addr.s6_addr[11] == (a5 & 0xFF) && \ a.sockaddr.in6.sin6_addr.s6_addr[12] == (a6 >> 8) && \ a.sockaddr.in6.sin6_addr.s6_addr[13] == (a6 & 0xFF) && \ a.sockaddr.in6.sin6_addr.s6_addr[14] == (a7 >> 8) && \ a.sockaddr.in6.sin6_addr.s6_addr[15] == (a7 & 0xFF)) #define SET_V6(a, a0, a1, a2, a3, a4, a5, a6, a7) \ a.sockaddr.in6.sin6_addr.s6_addr[0] = a0 >> 8; \ a.sockaddr.in6.sin6_addr.s6_addr[1] = a0 & 0xFF; \ a.sockaddr.in6.sin6_addr.s6_addr[2] = a1 >> 8; \ a.sockaddr.in6.sin6_addr.s6_addr[3] = a1 & 0xFF; \ a.sockaddr.in6.sin6_addr.s6_addr[4] = a2 >> 8; \ a.sockaddr.in6.sin6_addr.s6_addr[5] = a2 & 0xFF; \ a.sockaddr.in6.sin6_addr.s6_addr[6] = a3 >> 8; \ a.sockaddr.in6.sin6_addr.s6_addr[7] = a3 & 0xFF; \ a.sockaddr.in6.sin6_addr.s6_addr[8] = a4 >> 8; \ a.sockaddr.in6.sin6_addr.s6_addr[9] = a4 & 0xFF; \ a.sockaddr.in6.sin6_addr.s6_addr[10] = a5 >> 8; \ a.sockaddr.in6.sin6_addr.s6_addr[11] = a5 & 0xFF; \ a.sockaddr.in6.sin6_addr.s6_addr[12] = a6 >> 8; \ a.sockaddr.in6.sin6_addr.s6_addr[13] = a6 & 0xFF; \ a.sockaddr.in6.sin6_addr.s6_addr[14] = a7 >> 8; \ a.sockaddr.in6.sin6_addr.s6_addr[15] = a7 & 0xFF; static OFString *module = @"Socket"; @implementation TestsAppDelegate (SocketTests) - (void)socketTests { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; of_socket_address_t addr; uint16_t port; TEST(@"Parsing an IPv4", R(addr = of_socket_address_parse_ip(@"127.0.0.1", 1234)) && OF_BSWAP32_IF_LE(addr.sockaddr.in.sin_addr.s_addr) == 0x7F000001 && OF_BSWAP16_IF_LE(addr.sockaddr.in.sin_port) == 1234) EXPECT_EXCEPTION(@"Refusing invalid IPv4 #1", OFInvalidFormatException, of_socket_address_parse_ip(@"127.0.0.0.1", 1234)) EXPECT_EXCEPTION(@"Refusing invalid IPv4 #2", OFInvalidFormatException, |
︙ | ︙ | |||
101 102 103 104 105 106 107 | OFInvalidFormatException, of_socket_address_parse_ip(@"127.0..1", 1234)) TEST(@"Converting an IPv4 to a string", [of_socket_address_ip_string(&addr, &port) isEqual: @"127.0.0.1"] && port == 1234) | < | | | | | | 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 | OFInvalidFormatException, of_socket_address_parse_ip(@"127.0..1", 1234)) TEST(@"Converting an IPv4 to a string", [of_socket_address_ip_string(&addr, &port) isEqual: @"127.0.0.1"] && port == 1234) TEST(@"Parsing an IPv6 #1", R(addr = of_socket_address_parse_ip( @"1122:3344:5566:7788:99aa:bbCc:ddee:ff00", 1234)) && COMPARE_V6(addr, 0x1122, 0x3344, 0x5566, 0x7788, 0x99AA, 0xBBCC, 0xDDEE, 0xFF00) && OF_BSWAP16_IF_LE(addr.sockaddr.in6.sin6_port) == 1234) TEST(@"Parsing an IPv6 #2", R(addr = of_socket_address_parse_ip(@"::", 1234)) && COMPARE_V6(addr, 0, 0, 0, 0, 0, 0, 0, 0) && OF_BSWAP16_IF_LE(addr.sockaddr.in6.sin6_port) == 1234) TEST(@"Parsing an IPv6 #3", R(addr = of_socket_address_parse_ip(@"aaAa::bBbb", 1234)) && COMPARE_V6(addr, 0xAAAA, 0, 0, 0, 0, 0, 0, 0xBBBB) && OF_BSWAP16_IF_LE(addr.sockaddr.in6.sin6_port) == 1234) TEST(@"Parsing an IPv6 #4", R(addr = of_socket_address_parse_ip(@"aaAa::", 1234)) && COMPARE_V6(addr, 0xAAAA, 0, 0, 0, 0, 0, 0, 0) && OF_BSWAP16_IF_LE(addr.sockaddr.in6.sin6_port) == 1234) TEST(@"Parsing an IPv6 #5", R(addr = of_socket_address_parse_ip(@"::aaAa", 1234)) && COMPARE_V6(addr, 0, 0, 0, 0, 0, 0, 0, 0xAAAA) && OF_BSWAP16_IF_LE(addr.sockaddr.in6.sin6_port) == 1234) EXPECT_EXCEPTION(@"Refusing invalid IPv6 #1", OFInvalidFormatException, of_socket_address_parse_ip(@"1:::2", 1234)) EXPECT_EXCEPTION(@"Refusing invalid IPv6 #2", OFInvalidFormatException, |
︙ | ︙ | |||
226 227 228 229 230 231 232 | port == 1234) SET_V6(addr, 0, 0, 0x5566, 0x7788, 0x99AA, 0xBBCC, 0, 0) TEST(@"Converting an IPv6 to a string #10", [of_socket_address_ip_string(&addr, &port) isEqual: @"::5566:7788:99aa:bbcc:0:0"] && port == 1234) | < | 223 224 225 226 227 228 229 230 231 232 233 | port == 1234) SET_V6(addr, 0, 0, 0x5566, 0x7788, 0x99AA, 0xBBCC, 0, 0) TEST(@"Converting an IPv6 to a string #10", [of_socket_address_ip_string(&addr, &port) isEqual: @"::5566:7788:99aa:bbcc:0:0"] && port == 1234) [pool drain]; } @end |