• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SCTP kernel Implementation: User API extensions.
2  *
3  * peeloff.c
4  *
5  * Distributed under the terms of the LGPL v2.1 as described in
6  *    http://www.gnu.org/copyleft/lesser.txt
7  *
8  * This file is part of the user library that offers support for the
9  * SCTP kernel Implementation. The main purpose of this
10  * code is to provide the SCTP Socket API mappings for user
11  * application to interface with the SCTP in kernel.
12  *
13  * This implementation is based on the Socket API Extensions for SCTP
14  * defined in <draft-ietf-tsvwg-sctpsocket-10.txt.
15  *
16  * (C) Copyright IBM Corp. 2001, 2003
17  *
18  * Written or modified by:
19  *  Sridhar Samudrala     <sri@us.ibm.com>
20  */
21 
22 #include <sys/socket.h>   /* struct sockaddr_storage, setsockopt() */
23 #include <netinet/sctp.h> /* SCTP_SOCKOPT_BINDX_* */
24 #include <errno.h>
25 
26 /* Branch off an association into a seperate socket.  This is a new SCTP API
27  * described in the section 8.2 of the Sockets API Extensions for SCTP.
28  * This is implemented using the getsockopt() interface.
29  */
30 int
sctp_peeloff(int fd,sctp_assoc_t associd)31 sctp_peeloff(int fd, sctp_assoc_t associd)
32 {
33 	sctp_peeloff_arg_t peeloff;
34 	socklen_t peeloff_size = sizeof(peeloff);
35 	int err;
36 
37 	peeloff.associd = associd;
38 	peeloff.sd = 0;
39 	err = getsockopt(fd, SOL_SCTP, SCTP_SOCKOPT_PEELOFF, &peeloff,
40 			 &peeloff_size);
41 	if (err < 0) {
42 		return err;
43 	}
44 
45 	return peeloff.sd;
46 
47 } /* sctp_peeloff() */
48