]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/net/sctp/ulpevent.h
Merge branch 'fix/dapm' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie...
[mirror_ubuntu-bionic-kernel.git] / include / net / sctp / ulpevent.h
CommitLineData
60c778b2 1/* SCTP kernel implementation
1da177e4
LT
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.
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 *
60c778b2 13 * This file is part of the SCTP kernel implementation
1da177e4 14 *
60c778b2 15 * This SCTP implementation is free software;
1da177e4
LT
16 * 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 *
60c778b2 21 * This SCTP implementation is distributed in the hope that it
1da177e4
LT
22 * 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
4b2f13a2
JK
28 * along with GNU CC; see the file COPYING. If not, see
29 * <http://www.gnu.org/licenses/>.
1da177e4
LT
30 *
31 * Please send any bug reports or fixes you make to the
32 * email address(es):
91705c61 33 * lksctp developers <linux-sctp@vger.kernel.org>
1da177e4 34 *
1da177e4
LT
35 * Written or modified by:
36 * Jon Grimm <jgrimm@us.ibm.com>
37 * La Monte H.P. Yarroll <piggy@acm.org>
38 * Karl Knutson <karl@athena.chicago.il.us>
39 * Sridhar Samudrala <sri@us.ibm.com>
1da177e4
LT
40 */
41
42#ifndef __sctp_ulpevent_h__
43#define __sctp_ulpevent_h__
44
45/* A structure to carry information to the ULP (e.g. Sockets API) */
46/* Warning: This sits inside an skb.cb[] area. Be very careful of
47 * growing this structure as it is at the maximum limit now.
48 */
49struct sctp_ulpevent {
50 struct sctp_association *asoc;
51 __u16 stream;
52 __u16 ssn;
53 __u16 flags;
54 __u32 ppid;
55 __u32 tsn;
56 __u32 cumtsn;
57 int msg_flags;
58 int iif;
331c4ee7 59 unsigned int rmem_len;
1da177e4
LT
60};
61
62/* Retrieve the skb this event sits inside of. */
ab38fb04 63static inline struct sk_buff *sctp_event2skb(const struct sctp_ulpevent *ev)
1da177e4
LT
64{
65 return container_of((void *)ev, struct sk_buff, cb);
66}
67
68/* Retrieve & cast the event sitting inside the skb. */
69static inline struct sctp_ulpevent *sctp_skb2event(struct sk_buff *skb)
70{
71 return (struct sctp_ulpevent *)skb->cb;
72}
73
74void sctp_ulpevent_free(struct sctp_ulpevent *);
75int sctp_ulpevent_is_notification(const struct sctp_ulpevent *);
cd4fcc70 76unsigned int sctp_queue_purge_ulpevents(struct sk_buff_head *list);
1da177e4
LT
77
78struct sctp_ulpevent *sctp_ulpevent_make_assoc_change(
79 const struct sctp_association *asoc,
80 __u16 flags,
81 __u16 state,
82 __u16 error,
83 __u16 outbound,
84 __u16 inbound,
a5a35e76 85 struct sctp_chunk *chunk,
dd0fc66f 86 gfp_t gfp);
1da177e4
LT
87
88struct sctp_ulpevent *sctp_ulpevent_make_peer_addr_change(
89 const struct sctp_association *asoc,
90 const struct sockaddr_storage *aaddr,
91 int flags,
92 int state,
93 int error,
dd0fc66f 94 gfp_t gfp);
1da177e4
LT
95
96struct sctp_ulpevent *sctp_ulpevent_make_remote_error(
97 const struct sctp_association *asoc,
98 struct sctp_chunk *chunk,
99 __u16 flags,
dd0fc66f 100 gfp_t gfp);
1da177e4
LT
101struct sctp_ulpevent *sctp_ulpevent_make_send_failed(
102 const struct sctp_association *asoc,
103 struct sctp_chunk *chunk,
104 __u16 flags,
105 __u32 error,
dd0fc66f 106 gfp_t gfp);
1da177e4
LT
107
108struct sctp_ulpevent *sctp_ulpevent_make_shutdown_event(
109 const struct sctp_association *asoc,
110 __u16 flags,
dd0fc66f 111 gfp_t gfp);
1da177e4
LT
112
113struct sctp_ulpevent *sctp_ulpevent_make_pdapi(
114 const struct sctp_association *asoc,
dd0fc66f 115 __u32 indication, gfp_t gfp);
1da177e4 116
0f3fffd8 117struct sctp_ulpevent *sctp_ulpevent_make_adaptation_indication(
dd0fc66f 118 const struct sctp_association *asoc, gfp_t gfp);
1da177e4
LT
119
120struct sctp_ulpevent *sctp_ulpevent_make_rcvmsg(struct sctp_association *asoc,
121 struct sctp_chunk *chunk,
dd0fc66f 122 gfp_t gfp);
1da177e4 123
65b07e5d
VY
124struct sctp_ulpevent *sctp_ulpevent_make_authkey(
125 const struct sctp_association *asoc, __u16 key_id,
126 __u32 indication, gfp_t gfp);
127
e1cdd553
WY
128struct sctp_ulpevent *sctp_ulpevent_make_sender_dry_event(
129 const struct sctp_association *asoc, gfp_t gfp);
130
1da177e4 131void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event,
0d3a421d
GOV
132 struct msghdr *);
133void sctp_ulpevent_read_rcvinfo(const struct sctp_ulpevent *event,
134 struct msghdr *);
2347c80f
GOV
135void sctp_ulpevent_read_nxtinfo(const struct sctp_ulpevent *event,
136 struct msghdr *, struct sock *sk);
0d3a421d 137
1da177e4
LT
138__u16 sctp_ulpevent_get_notification_type(const struct sctp_ulpevent *event);
139
140/* Is this event type enabled? */
141static inline int sctp_ulpevent_type_enabled(__u16 sn_type,
142 struct sctp_event_subscribe *mask)
143{
144 char *amask = (char *) mask;
145 return amask[sn_type - SCTP_SN_TYPE_BASE];
146}
147
148/* Given an event subscription, is this event enabled? */
149static inline int sctp_ulpevent_is_enabled(const struct sctp_ulpevent *event,
150 struct sctp_event_subscribe *mask)
151{
152 __u16 sn_type;
153 int enabled = 1;
154
155 if (sctp_ulpevent_is_notification(event)) {
156 sn_type = sctp_ulpevent_get_notification_type(event);
157 enabled = sctp_ulpevent_type_enabled(sn_type, mask);
158 }
159 return enabled;
160}
161
162#endif /* __sctp_ulpevent_h__ */