Index: src/OFDDPSocket.m ================================================================== --- src/OFDDPSocket.m +++ src/OFDDPSocket.m @@ -31,10 +31,20 @@ #import "OFReadFailedException.h" #import "OFWriteFailedException.h" #ifdef OF_HAVE_NETAT_APPLETALK_H # include +# include + +/* Unfortulately, there is no struct for the following in userland headers */ +struct ATInterfaceConfig { + char interfaceName[16]; + unsigned int flags; + struct at_addr address, router; + unsigned short netStart, netEnd; + at_nvestr_t zoneName; +}; #endif @implementation OFDDPSocket @dynamic delegate; @@ -42,10 +52,11 @@ node: (uint8_t)node port: (uint8_t)port { #ifdef OF_MACOS const int one = 1; + struct ATInterfaceConfig config = { { 0 } }; #endif OFSocketAddress address; #if SOCK_CLOEXEC == 0 && defined(HAVE_FCNTL_H) && defined(FD_CLOEXEC) int flags; #endif @@ -121,18 +132,23 @@ socket: self errNo: EAFNOSUPPORT]; } #ifdef OF_MACOS - if (setsockopt(_socket, ATPROTO_NONE, DDP_HDRINCL, &one, - sizeof(one)) != 0) + if (setsockopt(_socket, ATPROTO_NONE, DDP_HDRINCL, &one, sizeof(one)) != + 0 || + ioctl(_socket, _IOWR('a', 2, struct ATInterfaceConfig), &config) != + 0) @throw [OFBindDDPSocketFailedException exceptionWithNetwork: network node: node port: port socket: self errNo: OFSocketErrNo()]; + + OFSocketAddressSetAppleTalkNetwork(&address, config.address.s_net); + OFSocketAddressSetAppleTalkNode(&address, config.address.s_node); #endif return address; }