aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp/socket.c
diff options
context:
space:
mode:
authorWei Yongjun <yjwei@cn.fujitsu.com>2008-12-25 19:57:24 -0500
committerDavid S. Miller <davem@davemloft.net>2008-12-25 19:57:24 -0500
commitaea3c5c05d2c409e93bfa80dcedc06af7da6c13b (patch)
tree2ee271efa68ef7677c94b1c9daaa33b9ad6a2531 /net/sctp/socket.c
parentea686a2653c5586b1c7192958b9d521abde66e92 (diff)
sctp: Implement socket option SCTP_GET_ASSOC_NUMBER
Implement socket option SCTP_GET_ASSOC_NUMBER of the latest ietf socket extensions API draft. 8.2.5. Get the Current Number of Associations (SCTP_GET_ASSOC_NUMBER) This option gets the current number of associations that are attached to a one-to-many style socket. The option value is an uint32_t. Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com> Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp/socket.c')
-rw-r--r--net/sctp/socket.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index e432927310c9..9f5fe23773a9 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -5460,6 +5460,38 @@ num:
5460 return 0; 5460 return 0;
5461} 5461}
5462 5462
5463/*
5464 * 8.2.5. Get the Current Number of Associations (SCTP_GET_ASSOC_NUMBER)
5465 * This option gets the current number of associations that are attached
5466 * to a one-to-many style socket. The option value is an uint32_t.
5467 */
5468static int sctp_getsockopt_assoc_number(struct sock *sk, int len,
5469 char __user *optval, int __user *optlen)
5470{
5471 struct sctp_sock *sp = sctp_sk(sk);
5472 struct sctp_association *asoc;
5473 u32 val = 0;
5474
5475 if (sctp_style(sk, TCP))
5476 return -EOPNOTSUPP;
5477
5478 if (len < sizeof(u32))
5479 return -EINVAL;
5480
5481 len = sizeof(u32);
5482
5483 list_for_each_entry(asoc, &(sp->ep->asocs), asocs) {
5484 val++;
5485 }
5486
5487 if (put_user(len, optlen))
5488 return -EFAULT;
5489 if (copy_to_user(optval, &val, len))
5490 return -EFAULT;
5491
5492 return 0;
5493}
5494
5463SCTP_STATIC int sctp_getsockopt(struct sock *sk, int level, int optname, 5495SCTP_STATIC int sctp_getsockopt(struct sock *sk, int level, int optname,
5464 char __user *optval, int __user *optlen) 5496 char __user *optval, int __user *optlen)
5465{ 5497{
@@ -5602,6 +5634,9 @@ SCTP_STATIC int sctp_getsockopt(struct sock *sk, int level, int optname,
5602 retval = sctp_getsockopt_local_auth_chunks(sk, len, optval, 5634 retval = sctp_getsockopt_local_auth_chunks(sk, len, optval,
5603 optlen); 5635 optlen);
5604 break; 5636 break;
5637 case SCTP_GET_ASSOC_NUMBER:
5638 retval = sctp_getsockopt_assoc_number(sk, len, optval, optlen);
5639 break;
5605 default: 5640 default:
5606 retval = -ENOPROTOOPT; 5641 retval = -ENOPROTOOPT;
5607 break; 5642 break;