Vlad Yasevich | 60c778b | 2008-01-11 09:57:09 -0500 | [diff] [blame] | 1 | /* SCTP kernel implementation |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | * |
Vlad Yasevich | 60c778b | 2008-01-11 09:57:09 -0500 | [diff] [blame] | 13 | * This file is part of the SCTP kernel implementation |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | * |
Vlad Yasevich | 60c778b | 2008-01-11 09:57:09 -0500 | [diff] [blame] | 15 | * This SCTP implementation is free software; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | * |
Vlad Yasevich | 60c778b | 2008-01-11 09:57:09 -0500 | [diff] [blame] | 21 | * This SCTP implementation is distributed in the hope that it |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 |
| 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): |
Daniel Borkmann | 91705c6 | 2013-07-23 14:51:47 +0200 | [diff] [blame] | 34 | * lksctp developers <linux-sctp@vger.kernel.org> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | * Written or modified by: |
| 37 | * Jon Grimm <jgrimm@us.ibm.com> |
| 38 | * La Monte H.P. Yarroll <piggy@acm.org> |
| 39 | * Karl Knutson <karl@athena.chicago.il.us> |
| 40 | * Sridhar Samudrala <sri@us.ibm.com> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | */ |
| 42 | |
| 43 | #ifndef __sctp_ulpevent_h__ |
| 44 | #define __sctp_ulpevent_h__ |
| 45 | |
| 46 | /* A structure to carry information to the ULP (e.g. Sockets API) */ |
| 47 | /* Warning: This sits inside an skb.cb[] area. Be very careful of |
| 48 | * growing this structure as it is at the maximum limit now. |
| 49 | */ |
| 50 | struct sctp_ulpevent { |
| 51 | struct sctp_association *asoc; |
| 52 | __u16 stream; |
| 53 | __u16 ssn; |
| 54 | __u16 flags; |
| 55 | __u32 ppid; |
| 56 | __u32 tsn; |
| 57 | __u32 cumtsn; |
| 58 | int msg_flags; |
| 59 | int iif; |
Vlad Yasevich | 331c4ee | 2006-10-09 21:34:04 -0700 | [diff] [blame] | 60 | unsigned int rmem_len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | /* Retrieve the skb this event sits inside of. */ |
Vlad Yasevich | ab38fb0 | 2008-04-12 18:40:06 -0700 | [diff] [blame] | 64 | static inline struct sk_buff *sctp_event2skb(const struct sctp_ulpevent *ev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | { |
| 66 | return container_of((void *)ev, struct sk_buff, cb); |
| 67 | } |
| 68 | |
| 69 | /* Retrieve & cast the event sitting inside the skb. */ |
| 70 | static inline struct sctp_ulpevent *sctp_skb2event(struct sk_buff *skb) |
| 71 | { |
| 72 | return (struct sctp_ulpevent *)skb->cb; |
| 73 | } |
| 74 | |
| 75 | void sctp_ulpevent_free(struct sctp_ulpevent *); |
| 76 | int sctp_ulpevent_is_notification(const struct sctp_ulpevent *); |
Thomas Graf | cd4fcc7 | 2011-07-08 04:37:46 +0000 | [diff] [blame] | 77 | unsigned int sctp_queue_purge_ulpevents(struct sk_buff_head *list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | |
| 79 | struct sctp_ulpevent *sctp_ulpevent_make_assoc_change( |
| 80 | const struct sctp_association *asoc, |
| 81 | __u16 flags, |
| 82 | __u16 state, |
| 83 | __u16 error, |
| 84 | __u16 outbound, |
| 85 | __u16 inbound, |
Vlad Yasevich | a5a35e7 | 2007-03-23 11:34:08 -0700 | [diff] [blame] | 86 | struct sctp_chunk *chunk, |
Al Viro | dd0fc66 | 2005-10-07 07:46:04 +0100 | [diff] [blame] | 87 | gfp_t gfp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | |
| 89 | struct sctp_ulpevent *sctp_ulpevent_make_peer_addr_change( |
| 90 | const struct sctp_association *asoc, |
| 91 | const struct sockaddr_storage *aaddr, |
| 92 | int flags, |
| 93 | int state, |
| 94 | int error, |
Al Viro | dd0fc66 | 2005-10-07 07:46:04 +0100 | [diff] [blame] | 95 | gfp_t gfp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | |
| 97 | struct sctp_ulpevent *sctp_ulpevent_make_remote_error( |
| 98 | const struct sctp_association *asoc, |
| 99 | struct sctp_chunk *chunk, |
| 100 | __u16 flags, |
Al Viro | dd0fc66 | 2005-10-07 07:46:04 +0100 | [diff] [blame] | 101 | gfp_t gfp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | struct sctp_ulpevent *sctp_ulpevent_make_send_failed( |
| 103 | const struct sctp_association *asoc, |
| 104 | struct sctp_chunk *chunk, |
| 105 | __u16 flags, |
| 106 | __u32 error, |
Al Viro | dd0fc66 | 2005-10-07 07:46:04 +0100 | [diff] [blame] | 107 | gfp_t gfp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | |
| 109 | struct sctp_ulpevent *sctp_ulpevent_make_shutdown_event( |
| 110 | const struct sctp_association *asoc, |
| 111 | __u16 flags, |
Al Viro | dd0fc66 | 2005-10-07 07:46:04 +0100 | [diff] [blame] | 112 | gfp_t gfp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | |
| 114 | struct sctp_ulpevent *sctp_ulpevent_make_pdapi( |
| 115 | const struct sctp_association *asoc, |
Al Viro | dd0fc66 | 2005-10-07 07:46:04 +0100 | [diff] [blame] | 116 | __u32 indication, gfp_t gfp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | |
Ivan Skytte Jorgensen | 0f3fffd | 2006-12-20 16:07:04 -0800 | [diff] [blame] | 118 | struct sctp_ulpevent *sctp_ulpevent_make_adaptation_indication( |
Al Viro | dd0fc66 | 2005-10-07 07:46:04 +0100 | [diff] [blame] | 119 | const struct sctp_association *asoc, gfp_t gfp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | |
| 121 | struct sctp_ulpevent *sctp_ulpevent_make_rcvmsg(struct sctp_association *asoc, |
| 122 | struct sctp_chunk *chunk, |
Al Viro | dd0fc66 | 2005-10-07 07:46:04 +0100 | [diff] [blame] | 123 | gfp_t gfp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | |
Vlad Yasevich | 65b07e5 | 2007-09-16 19:34:00 -0700 | [diff] [blame] | 125 | struct sctp_ulpevent *sctp_ulpevent_make_authkey( |
| 126 | const struct sctp_association *asoc, __u16 key_id, |
| 127 | __u32 indication, gfp_t gfp); |
| 128 | |
Wei Yongjun | e1cdd55 | 2011-04-17 17:29:03 +0000 | [diff] [blame] | 129 | struct sctp_ulpevent *sctp_ulpevent_make_sender_dry_event( |
| 130 | const struct sctp_association *asoc, gfp_t gfp); |
| 131 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event, |
| 133 | struct msghdr *); |
| 134 | __u16 sctp_ulpevent_get_notification_type(const struct sctp_ulpevent *event); |
| 135 | |
| 136 | /* Is this event type enabled? */ |
| 137 | static inline int sctp_ulpevent_type_enabled(__u16 sn_type, |
| 138 | struct sctp_event_subscribe *mask) |
| 139 | { |
| 140 | char *amask = (char *) mask; |
| 141 | return amask[sn_type - SCTP_SN_TYPE_BASE]; |
| 142 | } |
| 143 | |
| 144 | /* Given an event subscription, is this event enabled? */ |
| 145 | static inline int sctp_ulpevent_is_enabled(const struct sctp_ulpevent *event, |
| 146 | struct sctp_event_subscribe *mask) |
| 147 | { |
| 148 | __u16 sn_type; |
| 149 | int enabled = 1; |
| 150 | |
| 151 | if (sctp_ulpevent_is_notification(event)) { |
| 152 | sn_type = sctp_ulpevent_get_notification_type(event); |
| 153 | enabled = sctp_ulpevent_type_enabled(sn_type, mask); |
| 154 | } |
| 155 | return enabled; |
| 156 | } |
| 157 | |
| 158 | #endif /* __sctp_ulpevent_h__ */ |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 | |