blob: ca4693b4e09e4bb879c0ef8e483247c913bffb6b [file] [log] [blame]
Vlad Yasevich60c778b2008-01-11 09:57:09 -05001/* SCTP kernel implementation
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 * (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.
6 * Copyright (c) 2001 Nokia, Inc.
7 * Copyright (c) 2001 La Monte H.P. Yarroll
8 *
9 * These are the definitions needed for the sctp_ulpevent type. The
10 * sctp_ulpevent type is used to carry information from the state machine
11 * upwards to the ULP.
12 *
Vlad Yasevich60c778b2008-01-11 09:57:09 -050013 * This file is part of the SCTP kernel implementation
Linus Torvalds1da177e2005-04-16 15:20:36 -070014 *
Vlad Yasevich60c778b2008-01-11 09:57:09 -050015 * This SCTP implementation is free software;
Linus Torvalds1da177e2005-04-16 15:20:36 -070016 * you can redistribute it and/or modify it under the terms of
17 * the GNU General Public License as published by
18 * the Free Software Foundation; either version 2, or (at your option)
19 * any later version.
20 *
Vlad Yasevich60c778b2008-01-11 09:57:09 -050021 * This SCTP implementation is distributed in the hope that it
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
23 * ************************
24 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
25 * See the GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with GNU CC; see the file COPYING. If not, write to
29 * the Free Software Foundation, 59 Temple Place - Suite 330,
30 * Boston, MA 02111-1307, USA.
31 *
32 * Please send any bug reports or fixes you make to the
33 * email address(es):
34 * lksctp developers <lksctp-developers@lists.sourceforge.net>
35 *
36 * Or submit a bug report through the following website:
37 * http://www.sf.net/projects/lksctp
38 *
39 * Written or modified by:
40 * Jon Grimm <jgrimm@us.ibm.com>
41 * La Monte H.P. Yarroll <piggy@acm.org>
42 * Karl Knutson <karl@athena.chicago.il.us>
43 * Sridhar Samudrala <sri@us.ibm.com>
44 *
45 * Any bugs reported given to us we will try to fix... any fixes shared will
46 * be incorporated into the next SCTP release.
47 */
48
49#ifndef __sctp_ulpevent_h__
50#define __sctp_ulpevent_h__
51
52/* A structure to carry information to the ULP (e.g. Sockets API) */
53/* Warning: This sits inside an skb.cb[] area. Be very careful of
54 * growing this structure as it is at the maximum limit now.
55 */
56struct sctp_ulpevent {
57 struct sctp_association *asoc;
58 __u16 stream;
59 __u16 ssn;
60 __u16 flags;
61 __u32 ppid;
62 __u32 tsn;
63 __u32 cumtsn;
64 int msg_flags;
65 int iif;
Vlad Yasevich331c4ee2006-10-09 21:34:04 -070066 unsigned int rmem_len;
Linus Torvalds1da177e2005-04-16 15:20:36 -070067};
68
69/* Retrieve the skb this event sits inside of. */
Vlad Yasevichab38fb02008-04-12 18:40:06 -070070static inline struct sk_buff *sctp_event2skb(const struct sctp_ulpevent *ev)
Linus Torvalds1da177e2005-04-16 15:20:36 -070071{
72 return container_of((void *)ev, struct sk_buff, cb);
73}
74
75/* Retrieve & cast the event sitting inside the skb. */
76static inline struct sctp_ulpevent *sctp_skb2event(struct sk_buff *skb)
77{
78 return (struct sctp_ulpevent *)skb->cb;
79}
80
81void sctp_ulpevent_free(struct sctp_ulpevent *);
82int sctp_ulpevent_is_notification(const struct sctp_ulpevent *);
Thomas Grafcd4fcc72011-07-08 04:37:46 +000083unsigned int sctp_queue_purge_ulpevents(struct sk_buff_head *list);
Linus Torvalds1da177e2005-04-16 15:20:36 -070084
85struct sctp_ulpevent *sctp_ulpevent_make_assoc_change(
86 const struct sctp_association *asoc,
87 __u16 flags,
88 __u16 state,
89 __u16 error,
90 __u16 outbound,
91 __u16 inbound,
Vlad Yasevicha5a35e72007-03-23 11:34:08 -070092 struct sctp_chunk *chunk,
Al Virodd0fc662005-10-07 07:46:04 +010093 gfp_t gfp);
Linus Torvalds1da177e2005-04-16 15:20:36 -070094
95struct sctp_ulpevent *sctp_ulpevent_make_peer_addr_change(
96 const struct sctp_association *asoc,
97 const struct sockaddr_storage *aaddr,
98 int flags,
99 int state,
100 int error,
Al Virodd0fc662005-10-07 07:46:04 +0100101 gfp_t gfp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102
103struct sctp_ulpevent *sctp_ulpevent_make_remote_error(
104 const struct sctp_association *asoc,
105 struct sctp_chunk *chunk,
106 __u16 flags,
Al Virodd0fc662005-10-07 07:46:04 +0100107 gfp_t gfp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108struct sctp_ulpevent *sctp_ulpevent_make_send_failed(
109 const struct sctp_association *asoc,
110 struct sctp_chunk *chunk,
111 __u16 flags,
112 __u32 error,
Al Virodd0fc662005-10-07 07:46:04 +0100113 gfp_t gfp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114
115struct sctp_ulpevent *sctp_ulpevent_make_shutdown_event(
116 const struct sctp_association *asoc,
117 __u16 flags,
Al Virodd0fc662005-10-07 07:46:04 +0100118 gfp_t gfp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119
120struct sctp_ulpevent *sctp_ulpevent_make_pdapi(
121 const struct sctp_association *asoc,
Al Virodd0fc662005-10-07 07:46:04 +0100122 __u32 indication, gfp_t gfp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123
Ivan Skytte Jorgensen0f3fffd2006-12-20 16:07:04 -0800124struct sctp_ulpevent *sctp_ulpevent_make_adaptation_indication(
Al Virodd0fc662005-10-07 07:46:04 +0100125 const struct sctp_association *asoc, gfp_t gfp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126
127struct sctp_ulpevent *sctp_ulpevent_make_rcvmsg(struct sctp_association *asoc,
128 struct sctp_chunk *chunk,
Al Virodd0fc662005-10-07 07:46:04 +0100129 gfp_t gfp);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130
Vlad Yasevich65b07e52007-09-16 19:34:00 -0700131struct sctp_ulpevent *sctp_ulpevent_make_authkey(
132 const struct sctp_association *asoc, __u16 key_id,
133 __u32 indication, gfp_t gfp);
134
Wei Yongjune1cdd552011-04-17 17:29:03 +0000135struct sctp_ulpevent *sctp_ulpevent_make_sender_dry_event(
136 const struct sctp_association *asoc, gfp_t gfp);
137
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event,
139 struct msghdr *);
140__u16 sctp_ulpevent_get_notification_type(const struct sctp_ulpevent *event);
141
142/* Is this event type enabled? */
143static inline int sctp_ulpevent_type_enabled(__u16 sn_type,
144 struct sctp_event_subscribe *mask)
145{
146 char *amask = (char *) mask;
147 return amask[sn_type - SCTP_SN_TYPE_BASE];
148}
149
150/* Given an event subscription, is this event enabled? */
151static inline int sctp_ulpevent_is_enabled(const struct sctp_ulpevent *event,
152 struct sctp_event_subscribe *mask)
153{
154 __u16 sn_type;
155 int enabled = 1;
156
157 if (sctp_ulpevent_is_notification(event)) {
158 sn_type = sctp_ulpevent_get_notification_type(event);
159 enabled = sctp_ulpevent_type_enabled(sn_type, mask);
160 }
161 return enabled;
162}
163
164#endif /* __sctp_ulpevent_h__ */
165
166
167
168
169
170
171