ObjFW  Check-in [2ff4218405]

Overview
Comment:Replace of_socket_address_ipx_get()

Instead, provide getters and setters for the various address parts.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2ff4218405a0fc6afe35f750dbbe16f610b8aff978ba5377a5628497e4ee4b0f
User & Date: js on 2020-04-26 10:56:11
Other Links: manifest | tags
Context
2020-04-26
16:21
Add OFSequencedPacketSocket check-in: e5b2ee56ff user: js tags: trunk
10:56
Replace of_socket_address_ipx_get() check-in: 2ff4218405 user: js tags: trunk
10:42
Add -[OFProcess waitForTermination] check-in: bdf82f10b4 user: js tags: trunk
Changes

Modified src/socket.h from [797887223d] to [f684cec31b].

246
247
248
249
250
251
252
253
254
255
256



257








258





259
260










261
262
263
264
265
266
267
268
269
 * @param address The address on which to get the port
 * @return The port of the address
 */
extern uint16_t of_socket_address_get_port(
    const of_socket_address_t *_Nonnull address);

/*!
 * @brief Gets the IPX network, node and port from an IPX address.
 *
 * @param address The address on which to get the IPX network, node and port
 * @param network The IPX network



 * @param node A buffer to store the node








 * @param port The IPX port (sometimes called socket number) on the node





 */
extern void of_socket_address_ipx_get(










    const of_socket_address_t *_Nonnull address, uint32_t *_Nonnull network,
    unsigned char node[_Nonnull IPX_NODE_LEN], uint16_t *_Nonnull port);

extern bool of_socket_init(void);
#if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS)
extern void of_socket_deinit(void);
#endif
extern int of_socket_errno(void);
#if !defined(OF_WII) && !defined(OF_NINTENDO_3DS)







|

|
|
>
>
>
|
>
>
>
>
>
>
>
>
|
>
>
>
>
>

|
>
>
>
>
>
>
>
>
>
>
|
|







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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
 * @param address The address on which to get the port
 * @return The port of the address
 */
extern uint16_t of_socket_address_get_port(
    const of_socket_address_t *_Nonnull address);

/*!
 * @brief Sets the IPX network of the specified of_socket_address_t.
 *
 * @param address The address on which to set the IPX network
 * @param network The IPX network to set on the address
 */
extern void of_socket_address_set_ipx_network(
    of_socket_address_t *_Nonnull address, uint32_t network);

/*!
 * @brief Returns the IPX network of the specified of_socket_address_t.
 *
 * @param address The address on which to get the IPX network
 * @return The IPX network of the address
 */
extern uint32_t of_socket_address_get_ipx_network(
    const of_socket_address_t *_Nonnull address);

/*!
 * @brief Sets the IPX node of the specified of_socket_address_t.
 *
 * @param address The address on which to set the IPX node
 * @param node The IPX node to set on the address
 */
extern void of_socket_address_set_ipx_node(
    of_socket_address_t *_Nonnull address,
    const unsigned char node[_Nonnull IPX_NODE_LEN]);

/*!
 * @brief Gets the IPX node of the specified of_socket_address_t.
 *
 * @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 of_socket_address_get_ipx_node(
    const of_socket_address_t *_Nonnull address,
    unsigned char node[_Nonnull IPX_NODE_LEN]);

extern bool of_socket_init(void);
#if defined(OF_HAVE_THREADS) && defined(OF_AMIGAOS)
extern void of_socket_deinit(void);
#endif
extern int of_socket_errno(void);
#if !defined(OF_WII) && !defined(OF_NINTENDO_3DS)

Modified src/socket.m from [685346fedf] to [b25bff7c1b].

778
779
780
781
782
783
784



785
786
787
788
789
790
791
	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];
	}
}

uint16_t
of_socket_address_get_port(const of_socket_address_t *address)







>
>
>







778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
	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;
	case OF_SOCKET_ADDRESS_FAMILY_IPX:
		address->sockaddr.ipx.sipx_port = OF_BSWAP16_IF_LE(port);
		break;
	default:
		@throw [OFInvalidArgumentException exception];
	}
}

uint16_t
of_socket_address_get_port(const of_socket_address_t *address)
799
800
801
802
803
804
805












806













807
808
809
810
811
812

813







814
815
816
		return OF_BSWAP16_IF_LE(address->sockaddr.ipx.sipx_port);
	default:
		@throw [OFInvalidArgumentException exception];
	}
}

void












of_socket_address_ipx_get(const of_socket_address_t *address, uint32_t *network,













    unsigned char node[IPX_NODE_LEN], uint16_t *port)
{
	if (address->family != OF_SOCKET_ADDRESS_FAMILY_IPX)
		@throw [OFInvalidArgumentException exception];

	memcpy(network, &address->sockaddr.ipx.sipx_network, sizeof(*network));

	*network = OF_BSWAP32_IF_LE(*network);







	memcpy(node, address->sockaddr.ipx.sipx_node, IPX_NODE_LEN);
	*port = OF_BSWAP16_IF_LE(address->sockaddr.ipx.sipx_port);
}







>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
|




|
>
|
>
>
>
>
>
>
>

<

802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850

851
		return OF_BSWAP16_IF_LE(address->sockaddr.ipx.sipx_port);
	default:
		@throw [OFInvalidArgumentException exception];
	}
}

void
of_socket_address_set_ipx_network(of_socket_address_t *address,
    uint32_t network)
{
	if (address->family != OF_SOCKET_ADDRESS_FAMILY_IPX)
		@throw [OFInvalidArgumentException exception];

	network = OF_BSWAP32_IF_LE(network);
	memcpy(&address->sockaddr.ipx.sipx_network, &network,
	    sizeof(address->sockaddr.ipx.sipx_network));
}

uint32_t
of_socket_address_get_ipx_network(const of_socket_address_t *address)
{
	uint32_t network;

	if (address->family != OF_SOCKET_ADDRESS_FAMILY_IPX)
		@throw [OFInvalidArgumentException exception];

	memcpy(&network, &address->sockaddr.ipx.sipx_network, sizeof(network));

	return OF_BSWAP32_IF_LE(network);
}

void
of_socket_address_set_ipx_node(of_socket_address_t *address,
    const unsigned char node[IPX_NODE_LEN])
{
	if (address->family != OF_SOCKET_ADDRESS_FAMILY_IPX)
		@throw [OFInvalidArgumentException exception];

	memcpy(address->sockaddr.ipx.sipx_node, node, IPX_NODE_LEN);
}

void
of_socket_address_get_ipx_node(const of_socket_address_t *address,
    unsigned char node[IPX_NODE_LEN])
{
	if (address->family != OF_SOCKET_ADDRESS_FAMILY_IPX)
		@throw [OFInvalidArgumentException exception];

	memcpy(node, address->sockaddr.ipx.sipx_node, IPX_NODE_LEN);

}