blob: dd73758516181cd3268a54ff8aa3177e4f680843 [file] [log] [blame]
Vlad Yasevich60c778b2008-01-11 09:57:09 -05001/* SCTP kernel implementation Copyright (C) 1999-2001
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * Cisco, Motorola, and IBM
3 * Copyright 2001 La Monte H.P. Yarroll
4 *
Vlad Yasevich60c778b2008-01-11 09:57:09 -05005 * This file is part of the SCTP kernel implementation
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 *
7 * These functions manipulate sctp command sequences.
8 *
Vlad Yasevich60c778b2008-01-11 09:57:09 -05009 * This SCTP implementation is free software;
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 * you can redistribute it and/or modify it under the terms of
11 * the GNU General Public License as published by
12 * the Free Software Foundation; either version 2, or (at your option)
13 * any later version.
14 *
Vlad Yasevich60c778b2008-01-11 09:57:09 -050015 * This SCTP implementation is distributed in the hope that it
Linus Torvalds1da177e2005-04-16 15:20:36 -070016 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
17 * ************************
18 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 * See the GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
Jeff Kirsher4b2f13a2013-12-06 06:28:48 -080022 * along with GNU CC; see the file COPYING. If not, see
23 * <http://www.gnu.org/licenses/>.
Linus Torvalds1da177e2005-04-16 15:20:36 -070024 *
25 * Please send any bug reports or fixes you make to the
26 * email address(es):
Daniel Borkmann91705c62013-07-23 14:51:47 +020027 * lksctp developers <linux-sctp@vger.kernel.org>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070029 * Written or modified by:
30 * La Monte H.P. Yarroll <piggy@acm.org>
31 * Karl Knutson <karl@athena.chicago.il.us>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032 */
33
34#include <linux/types.h>
35#include <net/sctp/sctp.h>
36#include <net/sctp/sm.h>
37
38/* Initialize a block of memory as a command sequence. */
39int sctp_init_cmd_seq(sctp_cmd_seq_t *seq)
40{
41 memset(seq, 0, sizeof(sctp_cmd_seq_t));
42 return 1; /* We always succeed. */
43}
44
45/* Add a command to a sctp_cmd_seq_t.
46 * Return 0 if the command sequence is full.
47 */
Ilpo Järvinenbc09dff2008-03-27 17:54:29 -070048void sctp_add_cmd_sf(sctp_cmd_seq_t *seq, sctp_verb_t verb, sctp_arg_t obj)
Linus Torvalds1da177e2005-04-16 15:20:36 -070049{
Ilpo Järvinenbc09dff2008-03-27 17:54:29 -070050 BUG_ON(seq->next_free_slot >= SCTP_MAX_NUM_COMMANDS);
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
52 seq->cmds[seq->next_free_slot].verb = verb;
53 seq->cmds[seq->next_free_slot++].obj = obj;
Linus Torvalds1da177e2005-04-16 15:20:36 -070054}
55
56/* Return the next command structure in a sctp_cmd_seq.
57 * Returns NULL at the end of the sequence.
58 */
59sctp_cmd_t *sctp_next_cmd(sctp_cmd_seq_t *seq)
60{
61 sctp_cmd_t *retval = NULL;
62
63 if (seq->next_cmd < seq->next_free_slot)
64 retval = &seq->cmds[seq->next_cmd++];
65
66 return retval;
67}
68