Phonet: cleanup pipe enable socket option
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 <remi.denis-courmont@nokia.com> Cc: Kumar Sanghvi <kumar.sanghvi@stericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
6d8e74ed37
commit
03789f2672
3 changed files with 34 additions and 56 deletions
|
@ -38,9 +38,8 @@
|
|||
#define PNPIPE_IFINDEX 2
|
||||
#define PNPIPE_CREATE 3
|
||||
#define PNPIPE_ENABLE 4
|
||||
#define PNPIPE_DISABLE 5
|
||||
/* unused slot */
|
||||
#define PNPIPE_DESTROY 6
|
||||
#define PNPIPE_INQ 7
|
||||
|
||||
#define PNADDR_ANY 0
|
||||
#define PNADDR_BROADCAST 0xFC
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue