]>
git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - net/sctp/stream.c
1 /* SCTP kernel implementation
2 * (C) Copyright IBM Corp. 2001, 2004
3 * Copyright (c) 1999-2000 Cisco, Inc.
4 * Copyright (c) 1999-2001 Motorola, Inc.
5 * Copyright (c) 2001 Intel Corp.
7 * This file is part of the SCTP kernel implementation
9 * These functions manipulate sctp tsn mapping array.
11 * This SCTP implementation is free software;
12 * you can redistribute it and/or modify it under the terms of
13 * the GNU General Public License as published by
14 * the Free Software Foundation; either version 2, or (at your option)
17 * This SCTP implementation is distributed in the hope that it
18 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
19 * ************************
20 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 * See the GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with GNU CC; see the file COPYING. If not, see
25 * <http://www.gnu.org/licenses/>.
27 * Please send any bug reports or fixes you make to the
29 * lksctp developers <linux-sctp@vger.kernel.org>
31 * Written or modified by:
32 * Xin Long <lucien.xin@gmail.com>
35 #include <net/sctp/sctp.h>
37 struct sctp_stream
*sctp_stream_new(__u16 incnt
, __u16 outcnt
, gfp_t gfp
)
39 struct sctp_stream
*stream
;
42 stream
= kzalloc(sizeof(*stream
), gfp
);
46 stream
->outcnt
= outcnt
;
47 stream
->out
= kcalloc(stream
->outcnt
, sizeof(*stream
->out
), gfp
);
52 for (i
= 0; i
< stream
->outcnt
; i
++)
53 stream
->out
[i
].state
= SCTP_STREAM_OPEN
;
55 stream
->incnt
= incnt
;
56 stream
->in
= kcalloc(stream
->incnt
, sizeof(*stream
->in
), gfp
);
66 void sctp_stream_free(struct sctp_stream
*stream
)
68 if (unlikely(!stream
))
76 void sctp_stream_clear(struct sctp_stream
*stream
)
80 for (i
= 0; i
< stream
->outcnt
; i
++)
81 stream
->out
[i
].ssn
= 0;
83 for (i
= 0; i
< stream
->incnt
; i
++)
84 stream
->in
[i
].ssn
= 0;