1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#ifndef __net_sctp_command_h__
22#define __net_sctp_command_h__
23
24#include <net/sctp/constants.h>
25#include <net/sctp/structs.h>
26
27
28enum sctp_verb {
29 SCTP_CMD_NOP = 0,
30 SCTP_CMD_NEW_ASOC,
31 SCTP_CMD_DELETE_TCB,
32 SCTP_CMD_NEW_STATE,
33 SCTP_CMD_REPORT_TSN,
34 SCTP_CMD_GEN_SACK,
35 SCTP_CMD_PROCESS_SACK,
36 SCTP_CMD_GEN_INIT_ACK,
37 SCTP_CMD_PEER_INIT,
38 SCTP_CMD_GEN_COOKIE_ECHO,
39 SCTP_CMD_CHUNK_ULP,
40 SCTP_CMD_EVENT_ULP,
41 SCTP_CMD_REPLY,
42 SCTP_CMD_SEND_PKT,
43 SCTP_CMD_RETRAN,
44 SCTP_CMD_ECN_CE,
45 SCTP_CMD_ECN_ECNE,
46 SCTP_CMD_ECN_CWR,
47 SCTP_CMD_TIMER_START,
48 SCTP_CMD_TIMER_START_ONCE,
49 SCTP_CMD_TIMER_RESTART,
50 SCTP_CMD_TIMER_STOP,
51 SCTP_CMD_INIT_CHOOSE_TRANSPORT,
52 SCTP_CMD_INIT_COUNTER_RESET,
53 SCTP_CMD_INIT_COUNTER_INC,
54 SCTP_CMD_INIT_RESTART,
55 SCTP_CMD_COOKIEECHO_RESTART,
56 SCTP_CMD_INIT_FAILED,
57 SCTP_CMD_REPORT_DUP,
58 SCTP_CMD_STRIKE,
59 SCTP_CMD_HB_TIMERS_START,
60 SCTP_CMD_HB_TIMER_UPDATE,
61 SCTP_CMD_HB_TIMERS_STOP,
62 SCTP_CMD_PROBE_TIMER_UPDATE,
63 SCTP_CMD_TRANSPORT_HB_SENT,
64 SCTP_CMD_TRANSPORT_IDLE,
65 SCTP_CMD_TRANSPORT_ON,
66 SCTP_CMD_REPORT_ERROR,
67 SCTP_CMD_REPORT_BAD_TAG,
68 SCTP_CMD_PROCESS_CTSN,
69 SCTP_CMD_ASSOC_FAILED,
70 SCTP_CMD_DISCARD_PACKET,
71 SCTP_CMD_GEN_SHUTDOWN,
72 SCTP_CMD_PURGE_OUTQUEUE,
73 SCTP_CMD_SETUP_T2,
74 SCTP_CMD_RTO_PENDING,
75 SCTP_CMD_PART_DELIVER,
76 SCTP_CMD_RENEGE,
77 SCTP_CMD_SETUP_T4,
78 SCTP_CMD_PROCESS_OPERR,
79 SCTP_CMD_REPORT_FWDTSN,
80 SCTP_CMD_PROCESS_FWDTSN,
81 SCTP_CMD_CLEAR_INIT_TAG,
82 SCTP_CMD_DEL_NON_PRIMARY,
83 SCTP_CMD_T3_RTX_TIMERS_STOP,
84 SCTP_CMD_FORCE_PRIM_RETRAN,
85 SCTP_CMD_SET_SK_ERR,
86 SCTP_CMD_ASSOC_CHANGE,
87 SCTP_CMD_ADAPTATION_IND,
88 SCTP_CMD_PEER_NO_AUTH,
89 SCTP_CMD_ASSOC_SHKEY,
90 SCTP_CMD_T1_RETRAN,
91 SCTP_CMD_UPDATE_INITTAG,
92 SCTP_CMD_SEND_MSG,
93 SCTP_CMD_PURGE_ASCONF_QUEUE,
94 SCTP_CMD_SET_ASOC,
95 SCTP_CMD_LAST
96};
97
98
99
100
101
102
103#define SCTP_MAX_NUM_COMMANDS 20
104
105union sctp_arg {
106 void *zero_all;
107 __s32 i32;
108 __u32 u32;
109 __be32 be32;
110 __u16 u16;
111 __u8 u8;
112 int error;
113 __be16 err;
114 enum sctp_state state;
115 enum sctp_event_timeout to;
116 struct sctp_chunk *chunk;
117 struct sctp_association *asoc;
118 struct sctp_transport *transport;
119 struct sctp_bind_addr *bp;
120 struct sctp_init_chunk *init;
121 struct sctp_ulpevent *ulpevent;
122 struct sctp_packet *packet;
123 struct sctp_sackhdr *sackh;
124 struct sctp_datamsg *msg;
125};
126
127
128
129
130
131
132
133
134
135
136
137
138
139#define SCTP_ARG_CONSTRUCTOR(name, type, elt) \
140static inline union sctp_arg \
141SCTP_## name (type arg) \
142{ union sctp_arg retval;\
143 retval.zero_all = NULL;\
144 retval.elt = arg;\
145 return retval;\
146}
147
148SCTP_ARG_CONSTRUCTOR(I32, __s32, i32)
149SCTP_ARG_CONSTRUCTOR(U32, __u32, u32)
150SCTP_ARG_CONSTRUCTOR(BE32, __be32, be32)
151SCTP_ARG_CONSTRUCTOR(U16, __u16, u16)
152SCTP_ARG_CONSTRUCTOR(U8, __u8, u8)
153SCTP_ARG_CONSTRUCTOR(ERROR, int, error)
154SCTP_ARG_CONSTRUCTOR(PERR, __be16, err)
155SCTP_ARG_CONSTRUCTOR(STATE, enum sctp_state, state)
156SCTP_ARG_CONSTRUCTOR(TO, enum sctp_event_timeout, to)
157SCTP_ARG_CONSTRUCTOR(CHUNK, struct sctp_chunk *, chunk)
158SCTP_ARG_CONSTRUCTOR(ASOC, struct sctp_association *, asoc)
159SCTP_ARG_CONSTRUCTOR(TRANSPORT, struct sctp_transport *, transport)
160SCTP_ARG_CONSTRUCTOR(BA, struct sctp_bind_addr *, bp)
161SCTP_ARG_CONSTRUCTOR(PEER_INIT, struct sctp_init_chunk *, init)
162SCTP_ARG_CONSTRUCTOR(ULPEVENT, struct sctp_ulpevent *, ulpevent)
163SCTP_ARG_CONSTRUCTOR(PACKET, struct sctp_packet *, packet)
164SCTP_ARG_CONSTRUCTOR(SACKH, struct sctp_sackhdr *, sackh)
165SCTP_ARG_CONSTRUCTOR(DATAMSG, struct sctp_datamsg *, msg)
166
167static inline union sctp_arg SCTP_FORCE(void)
168{
169 return SCTP_I32(1);
170}
171
172static inline union sctp_arg SCTP_NOFORCE(void)
173{
174 return SCTP_I32(0);
175}
176
177static inline union sctp_arg SCTP_NULL(void)
178{
179 union sctp_arg retval;
180 retval.zero_all = NULL;
181 return retval;
182}
183
184struct sctp_cmd {
185 union sctp_arg obj;
186 enum sctp_verb verb;
187};
188
189struct sctp_cmd_seq {
190 struct sctp_cmd cmds[SCTP_MAX_NUM_COMMANDS];
191 struct sctp_cmd *last_used_slot;
192 struct sctp_cmd *next_cmd;
193};
194
195
196
197
198
199static inline int sctp_init_cmd_seq(struct sctp_cmd_seq *seq)
200{
201
202 seq->last_used_slot = seq->cmds + SCTP_MAX_NUM_COMMANDS;
203 seq->next_cmd = seq->last_used_slot;
204 return 1;
205}
206
207
208
209
210
211
212
213static inline void sctp_add_cmd_sf(struct sctp_cmd_seq *seq,
214 enum sctp_verb verb, union sctp_arg obj)
215{
216 struct sctp_cmd *cmd = seq->last_used_slot - 1;
217
218 BUG_ON(cmd < seq->cmds);
219
220 cmd->verb = verb;
221 cmd->obj = obj;
222 seq->last_used_slot = cmd;
223}
224
225
226
227
228static inline struct sctp_cmd *sctp_next_cmd(struct sctp_cmd_seq *seq)
229{
230 if (seq->next_cmd <= seq->last_used_slot)
231 return NULL;
232
233 return --seq->next_cmd;
234}
235
236#endif
237