Index: src/socket.h ================================================================== --- src/socket.h +++ src/socket.h @@ -248,20 +248,46 @@ */ 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. + * @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 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 + * @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_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 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 Index: src/socket.m ================================================================== --- src/socket.m +++ src/socket.m @@ -780,10 +780,13 @@ 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]; } } @@ -801,16 +804,48 @@ @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) +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(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); }