Fix compile problem with suspend due to a missed
[linux-2.6/history.git] / net / sctp / primitive.c
blob243b1d5a8657010851b3a13e4c2b23b8fbf74595
1 /* SCTP kernel reference Implementation
2 * Copyright (c) 1999-2000 Cisco, Inc.
3 * Copyright (c) 1999-2001 Motorola, Inc.
5 * This file is part of the SCTP kernel reference Implementation
7 * These functions implement the SCTP primitive functions from Section 10.
9 * Note that the descriptions from the specification are USER level
10 * functions--this file is the functions which populate the struct proto
11 * for SCTP which is the BOTTOM of the sockets interface.
13 * The SCTP reference implementation is free software;
14 * you can redistribute it and/or modify it under the terms of
15 * the GNU General Public License as published by
16 * the Free Software Foundation; either version 2, or (at your option)
17 * any later version.
19 * The SCTP reference implementation is distributed in the hope that it
20 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
21 * ************************
22 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23 * See the GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with GNU CC; see the file COPYING. If not, write to
27 * the Free Software Foundation, 59 Temple Place - Suite 330,
28 * Boston, MA 02111-1307, USA.
30 * Please send any bug reports or fixes you make to the
31 * email address(es):
32 * lksctp developers <lksctp-developers@lists.sourceforge.net>
34 * Or submit a bug report through the following website:
35 * http://www.sf.net/projects/lksctp
37 * Written or modified by:
38 * La Monte H.P. Yarroll <piggy@acm.org>
39 * Narasimha Budihal <narasimha@refcode.org>
40 * Karl Knutson <karl@athena.chicago.il.us>
41 * Ardelle Fan <ardelle.fan@intel.com>
43 * Any bugs reported given to us we will try to fix... any fixes shared will
44 * be incorporated into the next SCTP release.
47 #include <linux/types.h>
48 #include <linux/list.h> /* For struct list_head */
49 #include <linux/socket.h>
50 #include <linux/ip.h>
51 #include <linux/time.h> /* For struct timeval */
52 #include <net/sock.h>
53 #include <net/sctp/sctp.h>
54 #include <net/sctp/sm.h>
56 #define DECLARE_PRIMITIVE(name) \
57 /* This is called in the code as sctp_primitive_ ## name. */ \
58 int sctp_primitive_ ## name(struct sctp_association *asoc, \
59 void *arg) { \
60 int error = 0; \
61 sctp_event_t event_type; sctp_subtype_t subtype; \
62 sctp_state_t state; \
63 struct sctp_endpoint *ep; \
65 event_type = SCTP_EVENT_T_PRIMITIVE; \
66 subtype = SCTP_ST_PRIMITIVE(SCTP_PRIMITIVE_ ## name); \
67 state = asoc ? asoc->state : SCTP_STATE_CLOSED; \
68 ep = asoc ? asoc->ep : NULL; \
70 error = sctp_do_sm(event_type, subtype, state, ep, asoc, \
71 arg, GFP_KERNEL); \
72 return error; \
75 /* 10.1 ULP-to-SCTP
76 * B) Associate
78 * Format: ASSOCIATE(local SCTP instance name, destination transport addr,
79 * outbound stream count)
80 * -> association id [,destination transport addr list] [,outbound stream
81 * count]
83 * This primitive allows the upper layer to initiate an association to a
84 * specific peer endpoint.
86 * This version assumes that asoc is fully populated with the initial
87 * parameters. We then return a traditional kernel indicator of
88 * success or failure.
91 /* This is called in the code as sctp_primitive_ASSOCIATE. */
93 DECLARE_PRIMITIVE(ASSOCIATE)
95 /* 10.1 ULP-to-SCTP
96 * C) Shutdown
98 * Format: SHUTDOWN(association id)
99 * -> result
101 * Gracefully closes an association. Any locally queued user data
102 * will be delivered to the peer. The association will be terminated only
103 * after the peer acknowledges all the SCTP packets sent. A success code
104 * will be returned on successful termination of the association. If
105 * attempting to terminate the association results in a failure, an error
106 * code shall be returned.
109 DECLARE_PRIMITIVE(SHUTDOWN);
111 /* 10.1 ULP-to-SCTP
112 * C) Abort
114 * Format: Abort(association id [, cause code])
115 * -> result
117 * Ungracefully closes an association. Any locally queued user data
118 * will be discarded and an ABORT chunk is sent to the peer. A success
119 * code will be returned on successful abortion of the association. If
120 * attempting to abort the association results in a failure, an error
121 * code shall be returned.
124 DECLARE_PRIMITIVE(ABORT);
126 /* 10.1 ULP-to-SCTP
127 * E) Send
129 * Format: SEND(association id, buffer address, byte count [,context]
130 * [,stream id] [,life time] [,destination transport address]
131 * [,unorder flag] [,no-bundle flag] [,payload protocol-id] )
132 * -> result
134 * This is the main method to send user data via SCTP.
136 * Mandatory attributes:
138 * o association id - local handle to the SCTP association
140 * o buffer address - the location where the user message to be
141 * transmitted is stored;
143 * o byte count - The size of the user data in number of bytes;
145 * Optional attributes:
147 * o context - an optional 32 bit integer that will be carried in the
148 * sending failure notification to the ULP if the transportation of
149 * this User Message fails.
151 * o stream id - to indicate which stream to send the data on. If not
152 * specified, stream 0 will be used.
154 * o life time - specifies the life time of the user data. The user data
155 * will not be sent by SCTP after the life time expires. This
156 * parameter can be used to avoid efforts to transmit stale
157 * user messages. SCTP notifies the ULP if the data cannot be
158 * initiated to transport (i.e. sent to the destination via SCTP's
159 * send primitive) within the life time variable. However, the
160 * user data will be transmitted if SCTP has attempted to transmit a
161 * chunk before the life time expired.
163 * o destination transport address - specified as one of the destination
164 * transport addresses of the peer endpoint to which this packet
165 * should be sent. Whenever possible, SCTP should use this destination
166 * transport address for sending the packets, instead of the current
167 * primary path.
169 * o unorder flag - this flag, if present, indicates that the user
170 * would like the data delivered in an unordered fashion to the peer
171 * (i.e., the U flag is set to 1 on all DATA chunks carrying this
172 * message).
174 * o no-bundle flag - instructs SCTP not to bundle this user data with
175 * other outbound DATA chunks. SCTP MAY still bundle even when
176 * this flag is present, when faced with network congestion.
178 * o payload protocol-id - A 32 bit unsigned integer that is to be
179 * passed to the peer indicating the type of payload protocol data
180 * being transmitted. This value is passed as opaque data by SCTP.
183 DECLARE_PRIMITIVE(SEND);
185 /* 10.1 ULP-to-SCTP
186 * J) Request Heartbeat
188 * Format: REQUESTHEARTBEAT(association id, destination transport address)
190 * -> result
192 * Instructs the local endpoint to perform a HeartBeat on the specified
193 * destination transport address of the given association. The returned
194 * result should indicate whether the transmission of the HEARTBEAT
195 * chunk to the destination address is successful.
197 * Mandatory attributes:
199 * o association id - local handle to the SCTP association
201 * o destination transport address - the transport address of the
202 * association on which a heartbeat should be issued.
205 DECLARE_PRIMITIVE(REQUESTHEARTBEAT);