From: Stephens, A. <all...@wi...> - 2005-04-25 17:56:14
|
Hi all: As part of the TIPC facelift, it has been recommended that we eliminate all use of ioctl() within TIPC. Jon's recent TIPC facelift announcement highlighted the plans for the two biggest ioctl() users: - replace configuration-related ioctl()s with the netlink interface - replace subscription-related ioctl()s with a connection-oriented messaging service however there are still a handful of other ioctl()s that need to be addressed. This email identifies them & suggests possible replacements. Take a look & let me know what you think. Regards, Al -------------------- TIPC_OWN_NODE - Returns the node address (i.e. <Z.C.N.>) for a socket. Suggested replacement:=20 - NONE - Use getsockaddr() to retrieve the socket's port ID, which contains the node address. - Not quite as efficient as ioctl() -- i.e. involves copying more bytes -- but this isn't usually a time-critical operation. TIPC_UNBIND - Unbinds a TIPC port name sequence (including a simple TIPC port name) from a socket. - Unbinds all names bound to a socket if a NULL pointer is passed in instead of a port name sequence structure. Suggested replacement #1: - Use bind() but specify a port name sequence (or name) with a scope of 0 (i.e. the null scope). - To unbind all names currently bound to a socket, use bind() and pass in the port name using a NULL pointer and 0-length structure. - Comment: it may seem a little bizarre to use bind() to unbind things, but we could do worse ... Suggested replacement #2: - Use setsockopt() to trigger the unbind operation in a manner similar to the previous proposal. - Comment: this is stretching the concept of a "socket option" pretty far. TIPC_GET_ADDR - Gets the destination address of the message most recently received by the socket (useful if a socket has multiple port names bound to it and the application needs to know which one the message sender wanted to communicate with). Suggested replacement: - Use recvmsg() and provide this via ancillary data. - Comment: this would be totally aligned with the way IP works (i.e. can get a UDP datagram destination address using a cmsg_type of IP_RECVDSTADDR). TIPC_CONNECT / TIPC_DISCONNECT - Allows an application to "locally" connect or disconnect a socket without going through the normal handshake with the far end of the connection. Suggested replacement: - NONE - Comment: Jon has previously expressed doubts about supporting this functionality with the socket API, so maybe we should take this opportunity to get rid of it. (We can always add it back in later if necessary.) F_SETFL / F_GETFL - Allows an application to make a socket non-blocking, or to read it's current state (i.e. blocking or non-blocking). Suggested replacement: - Use these flags with fcntl(), which is where they were supposed to be all along. (Their use with ioctl() was a mistake in TIPC.) [END OF LIST] |