OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [net/] [sctp/] [command.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/* SCTP kernel reference Implementation Copyright (C) 1999-2001
2
 * Cisco, Motorola, and IBM
3
 * Copyright 2001 La Monte H.P. Yarroll
4
 *
5
 * This file is part of the SCTP kernel reference Implementation
6
 *
7
 * These functions manipulate sctp command sequences.
8
 *
9
 * The SCTP reference implementation is free software;
10
 * 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
 *
15
 * The SCTP reference implementation is distributed in the hope that it
16
 * 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
22
 * along with GNU CC; see the file COPYING.  If not, write to
23
 * the Free Software Foundation, 59 Temple Place - Suite 330,
24
 * Boston, MA 02111-1307, USA.
25
 *
26
 * Please send any bug reports or fixes you make to the
27
 * email address(es):
28
 *    lksctp developers <lksctp-developers@lists.sourceforge.net>
29
 *
30
 * Or submit a bug report through the following website:
31
 *    http://www.sf.net/projects/lksctp
32
 *
33
 * Written or modified by:
34
 *    La Monte H.P. Yarroll <piggy@acm.org>
35
 *    Karl Knutson <karl@athena.chicago.il.us>
36
 *
37
 * Any bugs reported given to us we will try to fix... any fixes shared will
38
 * be incorporated into the next SCTP release.
39
 */
40
 
41
#include <linux/types.h>
42
#include <net/sctp/sctp.h>
43
#include <net/sctp/sm.h>
44
 
45
/* Create a new sctp_command_sequence.  */
46
sctp_cmd_seq_t *sctp_new_cmd_seq(int gfp)
47
{
48
        sctp_cmd_seq_t *retval = t_new(sctp_cmd_seq_t, gfp);
49
 
50
        if (retval)
51
                sctp_init_cmd_seq(retval);
52
 
53
        return retval;
54
}
55
 
56
/* Initialize a block of memory as a command sequence. */
57
int sctp_init_cmd_seq(sctp_cmd_seq_t *seq)
58
{
59
        memset(seq, 0, sizeof(sctp_cmd_seq_t));
60
        return 1;               /* We always succeed.  */
61
}
62
 
63
/* Add a command to a sctp_cmd_seq_t.
64
 * Return 0 if the command sequence is full.
65
 */
66
int sctp_add_cmd(sctp_cmd_seq_t *seq, sctp_verb_t verb, sctp_arg_t obj)
67
{
68
        if (seq->next_free_slot >= SCTP_MAX_NUM_COMMANDS)
69
                goto fail;
70
 
71
        seq->cmds[seq->next_free_slot].verb = verb;
72
        seq->cmds[seq->next_free_slot++].obj = obj;
73
 
74
        return 1;
75
 
76
fail:
77
        return 0;
78
}
79
 
80
/* Rewind an sctp_cmd_seq_t to iterate from the start.  */
81
int sctp_rewind_sequence(sctp_cmd_seq_t *seq)
82
{
83
        seq->next_cmd = 0;
84
        return 1;               /* We always succeed. */
85
}
86
 
87
/* Return the next command structure in a sctp_cmd_seq.
88
 * Returns NULL at the end of the sequence.
89
 */
90
sctp_cmd_t *sctp_next_cmd(sctp_cmd_seq_t *seq)
91
{
92
        sctp_cmd_t *retval = NULL;
93
 
94
        if (seq->next_cmd < seq->next_free_slot)
95
                retval = &seq->cmds[seq->next_cmd++];
96
 
97
        return retval;
98
}
99
 
100
/* Dispose of a command sequence.  */
101
void sctp_free_cmd_seq(sctp_cmd_seq_t *seq)
102
{
103
        kfree(seq);
104
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.