ObjFW  Check-in [4d97d89c32]

Overview
Comment:Fix OFDDPSocket on NetBSD

While Linux just ignores the protocol, NetBSD insists on it being 0.
Since this code path was also used by Windows, which requires it to be
ATPROTO_BASE + protocol, this means an extra code path for Windows is
needed now.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 4d97d89c32e8109f7ecf11f0f4f8f03f48132c7eca610a873f0b5c5ff4d9e93b
User & Date: js on 2022-11-06 21:37:11
Other Links: manifest | tags
Context
2022-11-07
00:35
Update buildsys check-in: 7fa46d6a89 user: js tags: trunk
00:28
Merge trunk into branch "invoke-invocation" Leaf check-in: a43377bd13 user: js tags: invoke-invocation
00:24
Merge trunk into branch "3d-affine-transforms" Leaf check-in: fd7d3894ff user: js tags: 3d-affine-transforms
00:20
Merge trunk into branch "asn1" Leaf check-in: d8ef56254d user: js tags: asn1
00:06
Merge trunk into branch "ofsock" Leaf check-in: e2284a0f02 user: js tags: ofsock
2022-11-06
23:56
Merge trunk into branch "sctp" check-in: 9cb5c92f04 user: js tags: sctp
21:37
Fix OFDDPSocket on NetBSD check-in: 4d97d89c32 user: js tags: trunk
21:32
OFBindDDPSocketFailedException: Fix typo check-in: 15e5bfc523 user: js tags: trunk
Changes

Modified src/OFDDPSocket.m from [f84809166c] to [d532fdd70f].

42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
	unsigned int flags;
	struct at_addr address, router;
	unsigned short netStart, netEnd;
	at_nvestr_t zoneName;
};
#endif

#ifndef ATPROTO_BASE
# define ATPROTO_BASE 0
#endif

@implementation OFDDPSocket
@dynamic delegate;

- (OFSocketAddress)bindToNetwork: (uint16_t)network
			    node: (uint8_t)node
			    port: (uint8_t)port
		    protocolType: (uint8_t)protocolType







<
<
<
<







42
43
44
45
46
47
48




49
50
51
52
53
54
55
	unsigned int flags;
	struct at_addr address, router;
	unsigned short netStart, netEnd;
	at_nvestr_t zoneName;
};
#endif





@implementation OFDDPSocket
@dynamic delegate;

- (OFSocketAddress)bindToNetwork: (uint16_t)network
			    node: (uint8_t)node
			    port: (uint8_t)port
		    protocolType: (uint8_t)protocolType
71
72
73
74
75
76
77
78
79
80
81
82
83
84



85
86
87
88
89
90
91
		@throw [OFInvalidArgumentException exception];

	if (_socket != OFInvalidSocketHandle)
		@throw [OFAlreadyConnectedException exceptionWithSocket: self];

	address = OFSocketAddressMakeAppleTalk(network, node, port);

#ifdef OF_MACOS
	if ((_socket = socket(address.sockaddr.at.sat_family,
	    SOCK_RAW | SOCK_CLOEXEC, protocolType)) == OFInvalidSocketHandle)
#else
	if ((_socket = socket(address.sockaddr.at.sat_family,
	    SOCK_DGRAM | SOCK_CLOEXEC, ATPROTO_BASE + protocolType)) ==
	    OFInvalidSocketHandle)



#endif
		@throw [OFBindDDPSocketFailedException
		    exceptionWithNetwork: network
				    node: node
				    port: port
			    protocolType: protocolType
				  socket: self







|


|



>
>
>







67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
		@throw [OFInvalidArgumentException exception];

	if (_socket != OFInvalidSocketHandle)
		@throw [OFAlreadyConnectedException exceptionWithSocket: self];

	address = OFSocketAddressMakeAppleTalk(network, node, port);

#if defined(OF_MACOS)
	if ((_socket = socket(address.sockaddr.at.sat_family,
	    SOCK_RAW | SOCK_CLOEXEC, protocolType)) == OFInvalidSocketHandle)
#elif defined(OF_WINDOWS)
	if ((_socket = socket(address.sockaddr.at.sat_family,
	    SOCK_DGRAM | SOCK_CLOEXEC, ATPROTO_BASE + protocolType)) ==
	    OFInvalidSocketHandle)
#else
	if ((_socket = socket(address.sockaddr.at.sat_family,
	    SOCK_DGRAM | SOCK_CLOEXEC, 0)) == OFInvalidSocketHandle)
#endif
		@throw [OFBindDDPSocketFailedException
		    exceptionWithNetwork: network
				    node: node
				    port: port
			    protocolType: protocolType
				  socket: self