| 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 <[email protected]> |
| 20 | */ |
| 21 | |
| 22 | #include <sys/socket.h> /* struct sockaddr_storage, setsockopt() */ |
| 23 | #include <netinet/sctp.h>cxx . . $ `<file>/src/include/netinet/sctp.h`/ /* SCTP_SOCKOPT_BINDX_* */ |
| 24 | #include <errno.h> |
| 25 | |
| 26 | #ifdef HAVE_SCTP_PEELOFF_FLAGScxx . . $ `src/include/netinet/sctp.h:66:9`! |
| 27 | int |
| 28 | sctp_peeloff_flagscxx . . $ sctp_peeloff_flags(d99491a1582a64ac).(int fd, sctp_assoc_tcxx . . $ sctp_assoc_t# associd, unsigned flags) |
| 29 | { |
| 30 | socklen_tcxx . . $ socklen_t# peeloff_size = sizeof(sctp_peeloff_flags_arg_tcxx . . $ sctp_peeloff_flags_arg_t#); |
| 31 | sctp_peeloff_flags_arg_tcxx . . $ sctp_peeloff_flags_arg_t# peeloff; |
| 32 | int err; |
| 33 | |
| 34 | if (!flags) |
| 35 | return sctp_peeloffcxx . . $ sctp_peeloff(9b79fb6aee4c0440).(fd, associd); |
| 36 | |
| 37 | peeloff.p_argcxx . . $ $anonymous_type_69a1fd1e4114ead1_6#p_arg..associdcxx . . $ $anonymous_type_69a1fd1e4114ead1_5#associd. = associd; |
| 38 | peeloff.p_argcxx . . $ $anonymous_type_69a1fd1e4114ead1_6#p_arg..sdcxx . . $ $anonymous_type_69a1fd1e4114ead1_5#sd. = 0; |
| 39 | peeloff.flagscxx . . $ $anonymous_type_69a1fd1e4114ead1_6#flags. = flags; |
| 40 | |
| 41 | err = getsockoptcxx . . $ getsockopt(b79d9f11efef15f9).(fd, SOL_SCTPcxx . . $ `src/include/netinet/sctp.h:48:9`!, SCTP_SOCKOPT_PEELOFF_FLAGScxx . . $ `<external>/17169092326581286071/sctp.h:132:9`!, &peeloff, |
| 42 | &peeloff_size); |
| 43 | |
| 44 | if (err < 0) |
| 45 | return err; |
| 46 | |
| 47 | return peeloff.p_argcxx . . $ $anonymous_type_69a1fd1e4114ead1_6#p_arg..sdcxx . . $ $anonymous_type_69a1fd1e4114ead1_5#sd.; |
| 48 | } |
| 49 | #endif |
| 50 | |
| 51 | /* Branch off an association into a seperate socket. This is a new SCTP API |
| 52 | * described in the section 8.2 of the Sockets API Extensions for SCTP. |
| 53 | * This is implemented using the getsockopt() interface. |
| 54 | */ |
| 55 | int |
| 56 | sctp_peeloffcxx . . $ sctp_peeloff(9b79fb6aee4c0440).(int fd, sctp_assoc_tcxx . . $ sctp_assoc_t# associd) |
| 57 | { |
| 58 | socklen_tcxx . . $ socklen_t# peeloff_size = sizeof(sctp_peeloff_arg_tcxx . . $ sctp_peeloff_arg_t#); |
| 59 | sctp_peeloff_arg_tcxx . . $ sctp_peeloff_arg_t# peeloff; |
| 60 | int err; |
| 61 | |
| 62 | peeloff.associdcxx . . $ $anonymous_type_69a1fd1e4114ead1_5#associd. = associd; |
| 63 | peeloff.sdcxx . . $ $anonymous_type_69a1fd1e4114ead1_5#sd. = 0; |
| 64 | |
| 65 | err = getsockoptcxx . . $ getsockopt(b79d9f11efef15f9).(fd, SOL_SCTPcxx . . $ `src/include/netinet/sctp.h:48:9`!, SCTP_SOCKOPT_PEELOFFcxx . . $ `<external>/17169092326581286071/sctp.h:115:9`!, &peeloff, |
| 66 | &peeloff_size); |
| 67 | |
| 68 | if (err < 0) |
| 69 | return err; |
| 70 | |
| 71 | return peeloff.sdcxx . . $ $anonymous_type_69a1fd1e4114ead1_5#sd.; |
| 72 | } |