Overview
Comment: | OFSocket: Don't combine port for IP and IPX
While it works for those two protocols, it's a bad precedent as other |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
a54730b88fe9615500588eace5e92765 |
User & Date: | js on 2022-10-22 18:41:45 |
Other Links: | manifest | tags |
Context
2022-10-22
| ||
18:51 | Fix overlooked OFSocketAddress(Set)Port check-in: 64fc4f6344 user: js tags: trunk | |
18:46 | Merge trunk into branch "appletalk" check-in: d1c9ed8498 user: js tags: appletalk | |
18:41 | OFSocket: Don't combine port for IP and IPX check-in: a54730b88f user: js tags: trunk | |
17:40 | Rename OFListen{ -> OnSocket}FailedException check-in: df7f59b26c user: js tags: trunk | |
Changes
Modified src/OFIPSocketAsyncConnector.m from [11edaa9dd3] to [ca32b06485].
︙ | |||
134 135 136 137 138 139 140 | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | - + | - (void)tryNextAddressWithRunLoopMode: (OFRunLoopMode)runLoopMode { OFSocketAddress address = *(const OFSocketAddress *) [_socketAddresses itemAtIndex: _socketAddressesIndex++]; int errNo; |
︙ |
Modified src/OFSocket.h from [ed92d6e459] to [e6bf54de5e].
︙ | |||
242 243 244 245 246 247 248 | 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | - + - - + - + - - + | * @param address The address to convert to a string * @return The address as an IP string */ extern OFString *_Nonnull OFSocketAddressString( const OFSocketAddress *_Nonnull address); /** |
︙ | |||
305 306 307 308 309 310 311 312 313 314 315 316 317 318 | 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 | + + + + + + + + + + + + + + + + + | * * @param address The address on which to get the IPX node * @param node A byte array to store the IPX node of the address */ extern void OFSocketAddressGetIPXNode(const OFSocketAddress *_Nonnull address, unsigned char node[_Nonnull IPX_NODE_LEN]); /** * @brief Sets the IPX port of the specified @ref OFSocketAddress. * * @param address The address on which to set the port * @param port The port to set on the address */ extern void OFSocketAddressSetIPXPort(OFSocketAddress *_Nonnull address, uint16_t port); /** * @brief Returns the IPX port of the specified @ref OFSocketAddress. * * @param address The address on which to get the port * @return The port of the address */ extern uint16_t OFSocketAddressIPXPort(const OFSocketAddress *_Nonnull address); extern bool OFSocketInit(void); #if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS) && !defined(OF_MORPHOS) extern void OFSocketDeinit(void); #endif extern int OFSocketErrNo(void); #if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) extern int OFGetSockName(OFSocketHandle sock, struct sockaddr *restrict addr, |
︙ |
Modified src/OFSocket.m from [85e7c00ebd] to [d0ea6d0ea9].
︙ | |||
834 835 836 837 838 839 840 | 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 | - + - - - - + - - | return IPv6String(address); default: @throw [OFInvalidArgumentException exception]; } } void |
︙ | |||
931 932 933 934 935 936 937 | 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 | + + + + + + + + + + + + + + + + + + | unsigned char node[IPX_NODE_LEN]) { if (address->family != OFSocketAddressFamilyIPX) @throw [OFInvalidArgumentException exception]; memcpy(node, address->sockaddr.ipx.sipx_node, IPX_NODE_LEN); } void OFSocketAddressSetIPXPort(OFSocketAddress *address, uint16_t port) { if (address->family != OFSocketAddressFamilyIPX) @throw [OFInvalidArgumentException exception]; address->sockaddr.ipx.sipx_port = OFToBigEndian16(port); } uint16_t OFSocketAddressIPXPort(const OFSocketAddress *address) { if (address->family != OFSocketAddressFamilyIPX) @throw [OFInvalidArgumentException exception]; return OFFromBigEndian16(address->sockaddr.ipx.sipx_port); } |
Modified src/OFTCPSocket.m from [e6378dfef4] to [74ced9f7d1].
︙ | |||
307 308 309 310 311 312 313 | 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 | - + | object: self]; socketAddresses = [[OFThread DNSResolver] resolveAddressesForHost: host addressFamily: OFSocketAddressFamilyAny]; address = *(OFSocketAddress *)[socketAddresses itemAtIndex: 0]; |
︙ |
Modified src/OFUDPSocket.m from [fd8f9dff29] to [f8c53776df].
︙ | |||
50 51 52 53 54 55 56 | 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 | - + - + - + | #endif if ((_socket = socket( ((struct sockaddr *)&address->sockaddr)->sa_family, SOCK_DGRAM | SOCK_CLOEXEC | extraType, 0)) == OFInvalidSocketHandle) @throw [OFBindIPSocketFailedException exceptionWithHost: OFSocketAddressString(address) |
︙ | |||
98 99 100 101 102 103 104 | 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 160 161 162 163 164 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 | - + - + - + - + - + - + | (struct sockaddr *)&address->sockaddr, address->length)) == 0) break; if (OFSocketErrNo() != EADDRINUSE) { int errNo = OFSocketErrNo(); OFString *host = OFSocketAddressString(address); |
Modified tests/OFSPXSocketTests.m from [2398c8daff] to [951eb7a23c].
︙ | |||
116 117 118 119 120 121 122 | 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | - + | objc_autoreleasePoolPop(pool); return; } network = OFSocketAddressIPXNetwork(&address1); OFSocketAddressGetIPXNode(&address1, node); |
︙ | |||
156 157 158 159 160 161 162 | 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | - + | [sockServer listen]; [sockServer asyncAccept]; delegate->_expectedNetwork = network = OFSocketAddressIPXNetwork(&address1); OFSocketAddressGetIPXNode(&address1, node); memcpy(delegate->_expectedNode, node, IPX_NODE_LEN); |
︙ |
Modified tests/OFSPXStreamSocketTests.m from [5afcf8a434] to [ca6bf9ee77].
︙ | |||
117 118 119 120 121 122 123 | 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | - + | objc_autoreleasePoolPop(pool); return; } network = OFSocketAddressIPXNetwork(&address1); OFSocketAddressGetIPXNode(&address1, node); |
︙ | |||
160 161 162 163 164 165 166 | 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | - + | [sockServer listen]; [sockServer asyncAccept]; delegate->_expectedNetwork = network = OFSocketAddressIPXNetwork(&address1); OFSocketAddressGetIPXNode(&address1, node); memcpy(delegate->_expectedNode, node, IPX_NODE_LEN); |
︙ |
Modified tests/OFSocketTests.m from [3d043537f3] to [0766971ff5].
︙ | |||
79 80 81 82 83 84 85 | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | - + | EXPECT_EXCEPTION(@"Refusing invalid IPv4 #5", OFInvalidFormatException, OFSocketAddressParseIP(@"127.0.a.1", 1234)) EXPECT_EXCEPTION(@"Refusing invalid IPv4 #6", OFInvalidFormatException, OFSocketAddressParseIP(@"127.0..1", 1234)) |
︙ | |||
141 142 143 144 145 146 147 | 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | - + | EXPECT_EXCEPTION(@"Refusing invalid IPv6 #9", OFInvalidFormatException, OFSocketAddressParseIP(@"1:2:3:4:5:6:7::", 1234)) EXPECT_EXCEPTION(@"Refusing invalid IPv6 #10", OFInvalidFormatException, OFSocketAddressParseIP(@"1:2", 1234)) |
︙ |
Modified tests/OFUDPSocketTests.m from [b882de1802] to [435a3297c3].
︙ | |||
40 41 42 43 44 45 46 | 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | - + | TEST(@"-[sendBuffer:length:receiver:]", R([sock sendBuffer: "Hello" length: 6 receiver: &addr1])) TEST(@"-[receiveIntoBuffer:length:sender:]", [sock receiveIntoBuffer: buf length: 6 sender: &addr2] == 6 && !memcmp(buf, "Hello", 6) && [OFSocketAddressString(&addr2) isEqual: @"127.0.0.1"] && |
︙ |