diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /net/sctp/primitive.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'net/sctp/primitive.c')
-rw-r--r-- | net/sctp/primitive.c | 219 |
1 files changed, 219 insertions, 0 deletions
diff --git a/net/sctp/primitive.c b/net/sctp/primitive.c new file mode 100644 index 000000000000..3a7ebfcc1fdb --- /dev/null +++ b/net/sctp/primitive.c | |||
@@ -0,0 +1,219 @@ | |||
1 | /* SCTP kernel reference Implementation | ||
2 | * Copyright (c) 1999-2000 Cisco, Inc. | ||
3 | * Copyright (c) 1999-2001 Motorola, Inc. | ||
4 | * | ||
5 | * This file is part of the SCTP kernel reference Implementation | ||
6 | * | ||
7 | * These functions implement the SCTP primitive functions from Section 10. | ||
8 | * | ||
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. | ||
12 | * | ||
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. | ||
18 | * | ||
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. | ||
24 | * | ||
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. | ||
29 | * | ||
30 | * Please send any bug reports or fixes you make to the | ||
31 | * email address(es): | ||
32 | * lksctp developers <lksctp-developers@lists.sourceforge.net> | ||
33 | * | ||
34 | * Or submit a bug report through the following website: | ||
35 | * http://www.sf.net/projects/lksctp | ||
36 | * | ||
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> | ||
42 | * Kevin Gao <kevin.gao@intel.com> | ||
43 | * | ||
44 | * Any bugs reported given to us we will try to fix... any fixes shared will | ||
45 | * be incorporated into the next SCTP release. | ||
46 | */ | ||
47 | |||
48 | #include <linux/types.h> | ||
49 | #include <linux/list.h> /* For struct list_head */ | ||
50 | #include <linux/socket.h> | ||
51 | #include <linux/ip.h> | ||
52 | #include <linux/time.h> /* For struct timeval */ | ||
53 | #include <net/sock.h> | ||
54 | #include <net/sctp/sctp.h> | ||
55 | #include <net/sctp/sm.h> | ||
56 | |||
57 | #define DECLARE_PRIMITIVE(name) \ | ||
58 | /* This is called in the code as sctp_primitive_ ## name. */ \ | ||
59 | int sctp_primitive_ ## name(struct sctp_association *asoc, \ | ||
60 | void *arg) { \ | ||
61 | int error = 0; \ | ||
62 | sctp_event_t event_type; sctp_subtype_t subtype; \ | ||
63 | sctp_state_t state; \ | ||
64 | struct sctp_endpoint *ep; \ | ||
65 | \ | ||
66 | event_type = SCTP_EVENT_T_PRIMITIVE; \ | ||
67 | subtype = SCTP_ST_PRIMITIVE(SCTP_PRIMITIVE_ ## name); \ | ||
68 | state = asoc ? asoc->state : SCTP_STATE_CLOSED; \ | ||
69 | ep = asoc ? asoc->ep : NULL; \ | ||
70 | \ | ||
71 | error = sctp_do_sm(event_type, subtype, state, ep, asoc, \ | ||
72 | arg, GFP_KERNEL); \ | ||
73 | return error; \ | ||
74 | } | ||
75 | |||
76 | /* 10.1 ULP-to-SCTP | ||
77 | * B) Associate | ||
78 | * | ||
79 | * Format: ASSOCIATE(local SCTP instance name, destination transport addr, | ||
80 | * outbound stream count) | ||
81 | * -> association id [,destination transport addr list] [,outbound stream | ||
82 | * count] | ||
83 | * | ||
84 | * This primitive allows the upper layer to initiate an association to a | ||
85 | * specific peer endpoint. | ||
86 | * | ||
87 | * This version assumes that asoc is fully populated with the initial | ||
88 | * parameters. We then return a traditional kernel indicator of | ||
89 | * success or failure. | ||
90 | */ | ||
91 | |||
92 | /* This is called in the code as sctp_primitive_ASSOCIATE. */ | ||
93 | |||
94 | DECLARE_PRIMITIVE(ASSOCIATE) | ||
95 | |||
96 | /* 10.1 ULP-to-SCTP | ||
97 | * C) Shutdown | ||
98 | * | ||
99 | * Format: SHUTDOWN(association id) | ||
100 | * -> result | ||
101 | * | ||
102 | * Gracefully closes an association. Any locally queued user data | ||
103 | * will be delivered to the peer. The association will be terminated only | ||
104 | * after the peer acknowledges all the SCTP packets sent. A success code | ||
105 | * will be returned on successful termination of the association. If | ||
106 | * attempting to terminate the association results in a failure, an error | ||
107 | * code shall be returned. | ||
108 | */ | ||
109 | |||
110 | DECLARE_PRIMITIVE(SHUTDOWN); | ||
111 | |||
112 | /* 10.1 ULP-to-SCTP | ||
113 | * C) Abort | ||
114 | * | ||
115 | * Format: Abort(association id [, cause code]) | ||
116 | * -> result | ||
117 | * | ||
118 | * Ungracefully closes an association. Any locally queued user data | ||
119 | * will be discarded and an ABORT chunk is sent to the peer. A success | ||
120 | * code will be returned on successful abortion of the association. If | ||
121 | * attempting to abort the association results in a failure, an error | ||
122 | * code shall be returned. | ||
123 | */ | ||
124 | |||
125 | DECLARE_PRIMITIVE(ABORT); | ||
126 | |||
127 | /* 10.1 ULP-to-SCTP | ||
128 | * E) Send | ||
129 | * | ||
130 | * Format: SEND(association id, buffer address, byte count [,context] | ||
131 | * [,stream id] [,life time] [,destination transport address] | ||
132 | * [,unorder flag] [,no-bundle flag] [,payload protocol-id] ) | ||
133 | * -> result | ||
134 | * | ||
135 | * This is the main method to send user data via SCTP. | ||
136 | * | ||
137 | * Mandatory attributes: | ||
138 | * | ||
139 | * o association id - local handle to the SCTP association | ||
140 | * | ||
141 | * o buffer address - the location where the user message to be | ||
142 | * transmitted is stored; | ||
143 | * | ||
144 | * o byte count - The size of the user data in number of bytes; | ||
145 | * | ||
146 | * Optional attributes: | ||
147 | * | ||
148 | * o context - an optional 32 bit integer that will be carried in the | ||
149 | * sending failure notification to the ULP if the transportation of | ||
150 | * this User Message fails. | ||
151 | * | ||
152 | * o stream id - to indicate which stream to send the data on. If not | ||
153 | * specified, stream 0 will be used. | ||
154 | * | ||
155 | * o life time - specifies the life time of the user data. The user data | ||
156 | * will not be sent by SCTP after the life time expires. This | ||
157 | * parameter can be used to avoid efforts to transmit stale | ||
158 | * user messages. SCTP notifies the ULP if the data cannot be | ||
159 | * initiated to transport (i.e. sent to the destination via SCTP's | ||
160 | * send primitive) within the life time variable. However, the | ||
161 | * user data will be transmitted if SCTP has attempted to transmit a | ||
162 | * chunk before the life time expired. | ||
163 | * | ||
164 | * o destination transport address - specified as one of the destination | ||
165 | * transport addresses of the peer endpoint to which this packet | ||
166 | * should be sent. Whenever possible, SCTP should use this destination | ||
167 | * transport address for sending the packets, instead of the current | ||
168 | * primary path. | ||
169 | * | ||
170 | * o unorder flag - this flag, if present, indicates that the user | ||
171 | * would like the data delivered in an unordered fashion to the peer | ||
172 | * (i.e., the U flag is set to 1 on all DATA chunks carrying this | ||
173 | * message). | ||
174 | * | ||
175 | * o no-bundle flag - instructs SCTP not to bundle this user data with | ||
176 | * other outbound DATA chunks. SCTP MAY still bundle even when | ||
177 | * this flag is present, when faced with network congestion. | ||
178 | * | ||
179 | * o payload protocol-id - A 32 bit unsigned integer that is to be | ||
180 | * passed to the peer indicating the type of payload protocol data | ||
181 | * being transmitted. This value is passed as opaque data by SCTP. | ||
182 | */ | ||
183 | |||
184 | DECLARE_PRIMITIVE(SEND); | ||
185 | |||
186 | /* 10.1 ULP-to-SCTP | ||
187 | * J) Request Heartbeat | ||
188 | * | ||
189 | * Format: REQUESTHEARTBEAT(association id, destination transport address) | ||
190 | * | ||
191 | * -> result | ||
192 | * | ||
193 | * Instructs the local endpoint to perform a HeartBeat on the specified | ||
194 | * destination transport address of the given association. The returned | ||
195 | * result should indicate whether the transmission of the HEARTBEAT | ||
196 | * chunk to the destination address is successful. | ||
197 | * | ||
198 | * Mandatory attributes: | ||
199 | * | ||
200 | * o association id - local handle to the SCTP association | ||
201 | * | ||
202 | * o destination transport address - the transport address of the | ||
203 | * association on which a heartbeat should be issued. | ||
204 | */ | ||
205 | |||
206 | DECLARE_PRIMITIVE(REQUESTHEARTBEAT); | ||
207 | |||
208 | /* ADDIP | ||
209 | * 3.1.1 Address Configuration Change Chunk (ASCONF) | ||
210 | * | ||
211 | * This chunk is used to communicate to the remote endpoint one of the | ||
212 | * configuration change requests that MUST be acknowledged. The | ||
213 | * information carried in the ASCONF Chunk uses the form of a | ||
214 | * Type-Length-Value (TLV), as described in "3.2.1 Optional/ | ||
215 | * Variable-length Parameter Format" in RFC2960 [5], forall variable | ||
216 | * parameters. | ||
217 | */ | ||
218 | |||
219 | DECLARE_PRIMITIVE(ASCONF); | ||