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 | 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 \ |
︙ | |||
126 127 128 129 130 131 132 133 134 135 136 137 138 139 | 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 | 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 |
︙ |
Modified src/OFHTTPRequest.h from [7ce0d63ac4] to [7136743ab3].
︙ | |||
13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 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 | 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; |
︙ | |||
101 102 103 104 105 106 107 | 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. */ |
︙ |
Modified src/OFHTTPRequest.m from [9ef3db2e96] to [f2c9b5d838].
︙ | |||
76 77 78 79 80 81 82 | 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; |
︙ | |||
117 118 119 120 121 122 123 | 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]; |
︙ | |||
157 158 159 160 161 162 163 | 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] || |
︙ | |||
244 245 246 247 248 249 250 | 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" @">", |
Modified src/OFTCPSocket.h from [6656d5bf06] to [0973252c95].
︙ | |||
58 59 60 61 62 63 64 | 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; |
︙ |
Modified src/OFTCPSocket.m from [e5ab8ac35c] to [a77bbf08e1].
︙ | |||
362 363 364 365 366 367 368 | 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; |
︙ | |||
479 480 481 482 483 484 485 | 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) |
︙ | |||
537 538 539 540 541 542 543 | 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 |
︙ | |||
600 601 602 603 604 605 606 | 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 |
︙ | |||
683 684 685 686 687 688 689 | 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 | - - + - | } #endif - (void)close { _listening = false; |
Modified src/OFUDPSocket.m from [6cab00e4d5] to [1e4bb48119].
︙ | |||
202 203 204 205 206 207 208 | 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 <= |
︙ | |||
314 315 316 317 318 319 320 | 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; |
︙ | |||
421 422 423 424 425 426 427 | 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) |
︙ | |||
524 525 526 527 528 529 530 | 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, |
︙ |
Modified src/ObjFW.h from [de95586181] to [410a981ac1].
︙ | |||
74 75 76 77 78 79 80 | 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 |
︙ |
Modified src/socket.h from [232e64699e] to [d1393543d0].
︙ | |||
46 47 48 49 50 51 52 | 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 */ |
︙ | |||
173 174 175 176 177 178 179 180 181 182 183 184 | 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 | 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; |
︙ | |||
273 274 275 276 277 278 279 | 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; } |
︙ | |||
296 297 298 299 300 301 302 | 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; |
︙ | |||
366 367 368 369 370 371 372 | 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; } |
︙ | |||
583 584 585 586 587 588 589 | 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; } |
Modified tests/OFTCPSocketTests.m from [7ae6276193] to [7c3189d9e4].
︙ | |||
47 48 49 50 51 52 53 | 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) |
Modified tests/SocketTests.m from [25f3a27b64] to [43991614fd].
︙ | |||
22 23 24 25 26 27 28 | 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" |
︙ | |||
101 102 103 104 105 106 107 | 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) |
︙ | |||
226 227 228 229 230 231 232 | 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) |