![]() |
|
|||
0001 // SPDX-License-Identifier: GPL-2.0-or-later 0002 /* SCTP kernel implementation 0003 * Copyright (c) 1999-2000 Cisco, Inc. 0004 * Copyright (c) 1999-2001 Motorola, Inc. 0005 * 0006 * This file is part of the SCTP kernel implementation 0007 * 0008 * These functions implement the SCTP primitive functions from Section 10. 0009 * 0010 * Note that the descriptions from the specification are USER level 0011 * functions--this file is the functions which populate the struct proto 0012 * for SCTP which is the BOTTOM of the sockets interface. 0013 * 0014 * Please send any bug reports or fixes you make to the 0015 * email address(es): 0016 * lksctp developers <linux-sctp@vger.kernel.org> 0017 * 0018 * Written or modified by: 0019 * La Monte H.P. Yarroll <piggy@acm.org> 0020 * Narasimha Budihal <narasimha@refcode.org> 0021 * Karl Knutson <karl@athena.chicago.il.us> 0022 * Ardelle Fan <ardelle.fan@intel.com> 0023 * Kevin Gao <kevin.gao@intel.com> 0024 */ 0025 0026 #include <linux/types.h> 0027 #include <linux/list.h> /* For struct list_head */ 0028 #include <linux/socket.h> 0029 #include <linux/ip.h> 0030 #include <linux/time.h> /* For struct timeval */ 0031 #include <linux/gfp.h> 0032 #include <net/sock.h> 0033 #include <net/sctp/sctp.h> 0034 #include <net/sctp/sm.h> 0035 0036 #define DECLARE_PRIMITIVE(name) \ 0037 /* This is called in the code as sctp_primitive_ ## name. */ \ 0038 int sctp_primitive_ ## name(struct net *net, struct sctp_association *asoc, \ 0039 void *arg) { \ 0040 int error = 0; \ 0041 enum sctp_event_type event_type; union sctp_subtype subtype; \ 0042 enum sctp_state state; \ 0043 struct sctp_endpoint *ep; \ 0044 \ 0045 event_type = SCTP_EVENT_T_PRIMITIVE; \ 0046 subtype = SCTP_ST_PRIMITIVE(SCTP_PRIMITIVE_ ## name); \ 0047 state = asoc ? asoc->state : SCTP_STATE_CLOSED; \ 0048 ep = asoc ? asoc->ep : NULL; \ 0049 \ 0050 error = sctp_do_sm(net, event_type, subtype, state, ep, asoc, \ 0051 arg, GFP_KERNEL); \ 0052 return error; \ 0053 } 0054 0055 /* 10.1 ULP-to-SCTP 0056 * B) Associate 0057 * 0058 * Format: ASSOCIATE(local SCTP instance name, destination transport addr, 0059 * outbound stream count) 0060 * -> association id [,destination transport addr list] [,outbound stream 0061 * count] 0062 * 0063 * This primitive allows the upper layer to initiate an association to a 0064 * specific peer endpoint. 0065 * 0066 * This version assumes that asoc is fully populated with the initial 0067 * parameters. We then return a traditional kernel indicator of 0068 * success or failure. 0069 */ 0070 0071 /* This is called in the code as sctp_primitive_ASSOCIATE. */ 0072 0073 DECLARE_PRIMITIVE(ASSOCIATE) 0074 0075 /* 10.1 ULP-to-SCTP 0076 * C) Shutdown 0077 * 0078 * Format: SHUTDOWN(association id) 0079 * -> result 0080 * 0081 * Gracefully closes an association. Any locally queued user data 0082 * will be delivered to the peer. The association will be terminated only 0083 * after the peer acknowledges all the SCTP packets sent. A success code 0084 * will be returned on successful termination of the association. If 0085 * attempting to terminate the association results in a failure, an error 0086 * code shall be returned. 0087 */ 0088 0089 DECLARE_PRIMITIVE(SHUTDOWN); 0090 0091 /* 10.1 ULP-to-SCTP 0092 * C) Abort 0093 * 0094 * Format: Abort(association id [, cause code]) 0095 * -> result 0096 * 0097 * Ungracefully closes an association. Any locally queued user data 0098 * will be discarded and an ABORT chunk is sent to the peer. A success 0099 * code will be returned on successful abortion of the association. If 0100 * attempting to abort the association results in a failure, an error 0101 * code shall be returned. 0102 */ 0103 0104 DECLARE_PRIMITIVE(ABORT); 0105 0106 /* 10.1 ULP-to-SCTP 0107 * E) Send 0108 * 0109 * Format: SEND(association id, buffer address, byte count [,context] 0110 * [,stream id] [,life time] [,destination transport address] 0111 * [,unorder flag] [,no-bundle flag] [,payload protocol-id] ) 0112 * -> result 0113 * 0114 * This is the main method to send user data via SCTP. 0115 * 0116 * Mandatory attributes: 0117 * 0118 * o association id - local handle to the SCTP association 0119 * 0120 * o buffer address - the location where the user message to be 0121 * transmitted is stored; 0122 * 0123 * o byte count - The size of the user data in number of bytes; 0124 * 0125 * Optional attributes: 0126 * 0127 * o context - an optional 32 bit integer that will be carried in the 0128 * sending failure notification to the ULP if the transportation of 0129 * this User Message fails. 0130 * 0131 * o stream id - to indicate which stream to send the data on. If not 0132 * specified, stream 0 will be used. 0133 * 0134 * o life time - specifies the life time of the user data. The user data 0135 * will not be sent by SCTP after the life time expires. This 0136 * parameter can be used to avoid efforts to transmit stale 0137 * user messages. SCTP notifies the ULP if the data cannot be 0138 * initiated to transport (i.e. sent to the destination via SCTP's 0139 * send primitive) within the life time variable. However, the 0140 * user data will be transmitted if SCTP has attempted to transmit a 0141 * chunk before the life time expired. 0142 * 0143 * o destination transport address - specified as one of the destination 0144 * transport addresses of the peer endpoint to which this packet 0145 * should be sent. Whenever possible, SCTP should use this destination 0146 * transport address for sending the packets, instead of the current 0147 * primary path. 0148 * 0149 * o unorder flag - this flag, if present, indicates that the user 0150 * would like the data delivered in an unordered fashion to the peer 0151 * (i.e., the U flag is set to 1 on all DATA chunks carrying this 0152 * message). 0153 * 0154 * o no-bundle flag - instructs SCTP not to bundle this user data with 0155 * other outbound DATA chunks. SCTP MAY still bundle even when 0156 * this flag is present, when faced with network congestion. 0157 * 0158 * o payload protocol-id - A 32 bit unsigned integer that is to be 0159 * passed to the peer indicating the type of payload protocol data 0160 * being transmitted. This value is passed as opaque data by SCTP. 0161 */ 0162 0163 DECLARE_PRIMITIVE(SEND); 0164 0165 /* 10.1 ULP-to-SCTP 0166 * J) Request Heartbeat 0167 * 0168 * Format: REQUESTHEARTBEAT(association id, destination transport address) 0169 * 0170 * -> result 0171 * 0172 * Instructs the local endpoint to perform a HeartBeat on the specified 0173 * destination transport address of the given association. The returned 0174 * result should indicate whether the transmission of the HEARTBEAT 0175 * chunk to the destination address is successful. 0176 * 0177 * Mandatory attributes: 0178 * 0179 * o association id - local handle to the SCTP association 0180 * 0181 * o destination transport address - the transport address of the 0182 * association on which a heartbeat should be issued. 0183 */ 0184 0185 DECLARE_PRIMITIVE(REQUESTHEARTBEAT); 0186 0187 /* ADDIP 0188 * 3.1.1 Address Configuration Change Chunk (ASCONF) 0189 * 0190 * This chunk is used to communicate to the remote endpoint one of the 0191 * configuration change requests that MUST be acknowledged. The 0192 * information carried in the ASCONF Chunk uses the form of a 0193 * Type-Length-Value (TLV), as described in "3.2.1 Optional/ 0194 * Variable-length Parameter Format" in RFC2960 [5], forall variable 0195 * parameters. 0196 */ 0197 0198 DECLARE_PRIMITIVE(ASCONF); 0199 0200 /* RE-CONFIG 5.1 */ 0201 DECLARE_PRIMITIVE(RECONF);
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |