sctp.c revision 2
2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. 2N/A/* This will hold either a v4 or a v6 sockaddr */ 2N/A * This file implements all the libsctp calls. 2N/A * To bind a list of addresses to a socket. If the socket is 2N/A * v4, the type of the list of addresses is (struct in_addr). 2N/A * If the socket is v6, the type is (struct in6_addr). 2N/A /* Assume the caller uses the correct family type. */ 2N/A * XXX currently not atomic -- need a better way to do this. 2N/A /* First, find out how many peer addresses there are. */ 2N/A * Now we can get all the peer addresses. This will over allocate 2N/A * space for v4 socket. But it should be OK and save us 2N/A * the job to find out if it is a v4 or v6 socket. 2N/A /* Calculate the number of addresses returned. */ 2N/A /* First, try to find out how many bound addresses there are. */ 2N/A * Now we can get all the bound addresses. This will over allocate 2N/A * space for v4 socket. But it should be OK and save us 2N/A * the job to find out if it is a v4 or v6 socket. 2N/A /* Calculate the number of addresses returned. */ 2N/A * Branch off an association to its own socket. ioctl() allocates and 2N/A /* Note that msg can be NULL for pure control message. */ 2N/A * This function uses the SIOCSCTPCTX ioctl to try setting up an association 2N/A * using the list of addresses given. For 1-N style socket, the assoc ID 2N/A * of the new association is returned in aid. 2N/A /* Need to return the aid created for 1-N style socket. */ 2N/A * Receive a message along with its SCTP attributes. The message is stored 2N/A * in the iov vector. The sender of the message is stored in from. The 2N/A * receive attriute is stoed in info. The type of attribute is stored in 2N/A * Just in case, allocate a space to hold both sctp_rcvinfo and 2N/A * SCTP does not send up sctp_recvv_rn. So we need to first 2N/A * find the sctp_rcvinfo and sctp_nxtinfo. If both are 2N/A * present, we create a sctp_recvv_rn. 2N/A * This function uses SIOCSCTPSNDV ioctl to send a message with attributes 2N/A * if given. It can also be used to set up an association and then send 2N/A * a message. The message is stored in vector iov. The addrs parameter 2N/A * is used to set up an association or to specify an address the message 2N/A * should be sent to. In the latter case, SCTP_ADDR_OVER should be set. 2N/A * The send attributes are stored in info and its type is passed in infotype. 2N/A /* Check if this is a connect request. */ 2N/A * If it is not a connect request, only take the first address 2N/A * and ignore the rest if any. 2N/A /* Terminate the new association if an error occurs. */ 2N/A /* Nothing we can do if an error happens again. */