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