xref: /aosp_15_r20/external/ltp/utils/sctp/lib/opt_info.c (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1*49cdfc7eSAndroid Build Coastguard Worker /* SCTP kernel Implementation: User API extensions.
2*49cdfc7eSAndroid Build Coastguard Worker  *
3*49cdfc7eSAndroid Build Coastguard Worker  * opt_info.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 if 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. 2003
17*49cdfc7eSAndroid Build Coastguard Worker  * Copyright (c) 2002 Intel Corporation.
18*49cdfc7eSAndroid Build Coastguard Worker  *
19*49cdfc7eSAndroid Build Coastguard Worker  * Written or modified by:
20*49cdfc7eSAndroid Build Coastguard Worker  *   Ardelle Fan <[email protected]>
21*49cdfc7eSAndroid Build Coastguard Worker  */
22*49cdfc7eSAndroid Build Coastguard Worker 
23*49cdfc7eSAndroid Build Coastguard Worker #include <sys/socket.h>   /* struct sockaddr_storage, setsockopt() */
24*49cdfc7eSAndroid Build Coastguard Worker #include <netinet/sctp.h> /* SCTP_SOCKOPT_BINDX_* */
25*49cdfc7eSAndroid Build Coastguard Worker #include <errno.h>
26*49cdfc7eSAndroid Build Coastguard Worker 
27*49cdfc7eSAndroid Build Coastguard Worker /* Support the sctp_opt_info() interface.
28*49cdfc7eSAndroid Build Coastguard Worker  *
29*49cdfc7eSAndroid Build Coastguard Worker  * See Sockets API Extensions for SCTP. Section 7.
30*49cdfc7eSAndroid Build Coastguard Worker  *
31*49cdfc7eSAndroid Build Coastguard Worker  * Pass sctp option information pass both in to and out of the SCTP stack.
32*49cdfc7eSAndroid Build Coastguard Worker  * This is a new SCTP API described in the section 7 of the Sockets API
33*49cdfc7eSAndroid Build Coastguard Worker  * Extensions for SCTP. This is implemented using the getsockopt() interface.
34*49cdfc7eSAndroid Build Coastguard Worker  */
35*49cdfc7eSAndroid Build Coastguard Worker int
sctp_opt_info(int sd,sctp_assoc_t id,int opt,void * arg,socklen_t * size)36*49cdfc7eSAndroid Build Coastguard Worker sctp_opt_info(int sd, sctp_assoc_t id, int opt, void *arg, socklen_t *size)
37*49cdfc7eSAndroid Build Coastguard Worker {
38*49cdfc7eSAndroid Build Coastguard Worker 	switch (opt) {
39*49cdfc7eSAndroid Build Coastguard Worker 	case SCTP_RTOINFO:
40*49cdfc7eSAndroid Build Coastguard Worker 	case SCTP_ASSOCINFO:
41*49cdfc7eSAndroid Build Coastguard Worker 	case SCTP_INITMSG:
42*49cdfc7eSAndroid Build Coastguard Worker 	case SCTP_NODELAY:
43*49cdfc7eSAndroid Build Coastguard Worker 	case SCTP_AUTOCLOSE:
44*49cdfc7eSAndroid Build Coastguard Worker 	case SCTP_PRIMARY_ADDR:
45*49cdfc7eSAndroid Build Coastguard Worker 	case SCTP_DISABLE_FRAGMENTS:
46*49cdfc7eSAndroid Build Coastguard Worker 	case SCTP_PEER_ADDR_PARAMS:
47*49cdfc7eSAndroid Build Coastguard Worker 	case SCTP_DEFAULT_SEND_PARAM:
48*49cdfc7eSAndroid Build Coastguard Worker 	case SCTP_EVENTS:
49*49cdfc7eSAndroid Build Coastguard Worker 	case SCTP_I_WANT_MAPPED_V4_ADDR:
50*49cdfc7eSAndroid Build Coastguard Worker 	case SCTP_MAXSEG:
51*49cdfc7eSAndroid Build Coastguard Worker 	case SCTP_STATUS:
52*49cdfc7eSAndroid Build Coastguard Worker 	case SCTP_GET_PEER_ADDR_INFO:
53*49cdfc7eSAndroid Build Coastguard Worker 	case SCTP_AUTH_ACTIVE_KEY:
54*49cdfc7eSAndroid Build Coastguard Worker 	case SCTP_PEER_AUTH_CHUNKS:
55*49cdfc7eSAndroid Build Coastguard Worker 	case SCTP_LOCAL_AUTH_CHUNKS:
56*49cdfc7eSAndroid Build Coastguard Worker 		*(sctp_assoc_t *)arg = id;
57*49cdfc7eSAndroid Build Coastguard Worker 		return getsockopt(sd, IPPROTO_SCTP, opt, arg, size);
58*49cdfc7eSAndroid Build Coastguard Worker 	default:
59*49cdfc7eSAndroid Build Coastguard Worker 		return ENOTSUP;
60*49cdfc7eSAndroid Build Coastguard Worker 	}
61*49cdfc7eSAndroid Build Coastguard Worker 
62*49cdfc7eSAndroid Build Coastguard Worker } /* sctp_opt_info() */
63