ObjFW  Check-in [4571eada47]

Overview
Comment:Use native endian for AppleTalk network on Windows

For some strange reason, Windows does not use big endian here like
everyone else.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 4571eada47f04359a7b16ed95ead4505fe39815764c415cf2db36817a2718929
User & Date: js on 2022-11-02 20:26:49
Other Links: manifest | tags
Context
2022-11-03
00:14
OFDDPSocket: Don't include the type with the data check-in: 9c2f20e736 user: js tags: trunk
2022-11-02
20:26
Use native endian for AppleTalk network on Windows check-in: 4571eada47 user: js tags: trunk
2022-11-01
23:23
OFDDPSocket: Return correct bound address on macOS check-in: e5075e42ab user: js tags: trunk
Changes

Modified src/OFSocket.m from [4fc1cbbf22] to [da4b96c1d5].

583
584
585
586
587
588
589



590

591
592
593
594
595
596
597
	ret.length = sizeof(ret.sockaddr.at);

#ifdef AF_APPLETALK
	ret.sockaddr.at.sat_family = AF_APPLETALK;
#else
	ret.sockaddr.at.sat_family = AF_UNSPEC;
#endif



	ret.sockaddr.at.sat_net = OFToBigEndian16(network);

	ret.sockaddr.at.sat_node = node;
	ret.sockaddr.at.sat_port = port;

	return ret;
}

bool







>
>
>

>







583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
	ret.length = sizeof(ret.sockaddr.at);

#ifdef AF_APPLETALK
	ret.sockaddr.at.sat_family = AF_APPLETALK;
#else
	ret.sockaddr.at.sat_family = AF_UNSPEC;
#endif
#ifdef OF_WINDOWS
	ret.sockaddr.at.sat_net = network;
#else
	ret.sockaddr.at.sat_net = OFToBigEndian16(network);
#endif
	ret.sockaddr.at.sat_node = node;
	ret.sockaddr.at.sat_port = port;

	return ret;
}

bool
998
999
1000
1001
1002
1003
1004



1005

1006
1007
1008
1009
1010
1011
1012
1013



1014

1015
1016
1017
1018
1019
1020
1021

void
OFSocketAddressSetAppleTalkNetwork(OFSocketAddress *address, uint16_t network)
{
	if (address->family != OFSocketAddressFamilyAppleTalk)
		@throw [OFInvalidArgumentException exception];




	address->sockaddr.at.sat_net = OFToBigEndian16(network);

}

uint16_t
OFSocketAddressAppleTalkNetwork(const OFSocketAddress *address)
{
	if (address->family != OFSocketAddressFamilyAppleTalk)
		@throw [OFInvalidArgumentException exception];




	return OFFromBigEndian16(address->sockaddr.at.sat_net);

}

void
OFSocketAddressSetAppleTalkNode(OFSocketAddress *address, uint8_t node)
{
	if (address->family != OFSocketAddressFamilyAppleTalk)
		@throw [OFInvalidArgumentException exception];







>
>
>

>








>
>
>

>







1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033

void
OFSocketAddressSetAppleTalkNetwork(OFSocketAddress *address, uint16_t network)
{
	if (address->family != OFSocketAddressFamilyAppleTalk)
		@throw [OFInvalidArgumentException exception];

#ifdef OF_WINDOWS
	address->sockaddr.at.sat_net = network;
#else
	address->sockaddr.at.sat_net = OFToBigEndian16(network);
#endif
}

uint16_t
OFSocketAddressAppleTalkNetwork(const OFSocketAddress *address)
{
	if (address->family != OFSocketAddressFamilyAppleTalk)
		@throw [OFInvalidArgumentException exception];

#ifdef OF_WINDOWS
	return address->sockaddr.at.sat_net;
#else
	return OFFromBigEndian16(address->sockaddr.at.sat_net);
#endif
}

void
OFSocketAddressSetAppleTalkNode(OFSocketAddress *address, uint8_t node)
{
	if (address->family != OFSocketAddressFamilyAppleTalk)
		@throw [OFInvalidArgumentException exception];