From 03789f26722a15ccfe6f191e9fb3d356f2f18a1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Fri, 8 Oct 2010 04:02:02 +0000 Subject: Phonet: cleanup pipe enable socket option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current code works like this: int garbage, status; socklen_t len = sizeof(status); /* enable pipe */ setsockopt(fd, SOL_PNPIPE, PNPIPE_ENABLE, &garbage, sizeof(garbage)); /* disable pipe */ setsockopt(fd, SOL_PNPIPE, PNPIPE_DISABLE, &garbage, sizeof(garbage)); /* get status */ getsockopt(fd, SOL_PNPIPE, PNPIPE_INQ, &status, &len); ...which does not follow the usual socket option pattern. This patch merges all three "options" into a single gettable&settable option, before Linux 2.6.37 gets out: int status; socklen_t len = sizeof(status); /* enable pipe */ status = 1; setsockopt(fd, SOL_PNPIPE, PNPIPE_ENABLE, &status, sizeof(status)); /* disable pipe */ status = 0; setsockopt(fd, SOL_PNPIPE, PNPIPE_ENABLE, &status, sizeof(status)); /* get status */ getsockopt(fd, SOL_PNPIPE, PNPIPE_ENABLE, &status, &len); This also fixes the error code from EFAULT to ENOTCONN. Signed-off-by: RĂ©mi Denis-Courmont Cc: Kumar Sanghvi Signed-off-by: David S. Miller --- Documentation/networking/phonet.txt | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'Documentation/networking') diff --git a/Documentation/networking/phonet.txt b/Documentation/networking/phonet.txt index cccf5ff07ec2..2d9bc2b711fc 100644 --- a/Documentation/networking/phonet.txt +++ b/Documentation/networking/phonet.txt @@ -213,12 +213,9 @@ The implementation adds socket options at SOL_PNPIPE level: It then updates the pipe state associated with the sequenced socket to be PIPE_DISABLED. - PNPIPE_ENABLE - It follows the same sequence as above for enabling a pipe by sending - PNS_PEP_ENABLE_REQ initially and then sending PNS_PEP_ENABLED_IND after - getting responses from sequenced socket and remote-pep. - It will also update the pipe state associated with the sequenced socket - to PIPE_ENABLED. + PNPIPE_ENABLE accepts one integer value (int). If set to zero, the pipe + is disabled. If the value is non-zero, the pipe is enabled. If the pipe + is not (yet) connected, ENOTCONN is error is returned. PNPIPE_DESTROY This will send out PNS_PEP_DISCONNECT_REQ on the sequenced socket and @@ -226,12 +223,6 @@ The implementation adds socket options at SOL_PNPIPE level: It will also update the pipe state associated with the sequenced socket to PIPE_IDLE - PNPIPE_INQ - This getsocktopt allows the user-space running on the sequenced socket - to examine the pipe state associated with that socket ie. whether the - pipe is created (PIPE_DISABLED) or enabled (PIPE_ENABLED) or disabled - (PIPE_DISABLED) or no pipe exists (PIPE_IDLE). - After a pipe has been created and enabled successfully, the Pipe data can be exchanged between the host-pep and remote-pep (modem). -- cgit v1.2.3