| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
|---|
| 1 | 2 | /* SCTP kernel implementation |
|---|
| 2 | 3 | * (C) Copyright IBM Corp. 2001, 2004 |
|---|
| 3 | 4 | * Copyright (c) 1999-2000 Cisco, Inc. |
|---|
| .. | .. |
|---|
| 11 | 12 | * upwards to the ULP. |
|---|
| 12 | 13 | * |
|---|
| 13 | 14 | * This file is part of the SCTP kernel implementation |
|---|
| 14 | | - * |
|---|
| 15 | | - * This SCTP implementation is free software; |
|---|
| 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 | | - * |
|---|
| 21 | | - * This SCTP implementation is distributed in the hope that it |
|---|
| 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, see |
|---|
| 29 | | - * <http://www.gnu.org/licenses/>. |
|---|
| 30 | 15 | * |
|---|
| 31 | 16 | * Please send any bug reports or fixes you make to the |
|---|
| 32 | 17 | * email address(es): |
|---|
| .. | .. |
|---|
| 95 | 80 | struct sctp_chunk *chunk, |
|---|
| 96 | 81 | gfp_t gfp); |
|---|
| 97 | 82 | |
|---|
| 98 | | -struct sctp_ulpevent *sctp_ulpevent_make_peer_addr_change( |
|---|
| 99 | | - const struct sctp_association *asoc, |
|---|
| 100 | | - const struct sockaddr_storage *aaddr, |
|---|
| 101 | | - int flags, |
|---|
| 102 | | - int state, |
|---|
| 103 | | - int error, |
|---|
| 104 | | - gfp_t gfp); |
|---|
| 83 | +void sctp_ulpevent_notify_peer_addr_change(struct sctp_transport *transport, |
|---|
| 84 | + int state, int error); |
|---|
| 105 | 85 | |
|---|
| 106 | 86 | struct sctp_ulpevent *sctp_ulpevent_make_remote_error( |
|---|
| 107 | 87 | const struct sctp_association *asoc, |
|---|
| .. | .. |
|---|
| 109 | 89 | __u16 flags, |
|---|
| 110 | 90 | gfp_t gfp); |
|---|
| 111 | 91 | struct sctp_ulpevent *sctp_ulpevent_make_send_failed( |
|---|
| 92 | + const struct sctp_association *asoc, |
|---|
| 93 | + struct sctp_chunk *chunk, |
|---|
| 94 | + __u16 flags, |
|---|
| 95 | + __u32 error, |
|---|
| 96 | + gfp_t gfp); |
|---|
| 97 | + |
|---|
| 98 | +struct sctp_ulpevent *sctp_ulpevent_make_send_failed_event( |
|---|
| 112 | 99 | const struct sctp_association *asoc, |
|---|
| 113 | 100 | struct sctp_chunk *chunk, |
|---|
| 114 | 101 | __u16 flags, |
|---|
| .. | .. |
|---|
| 164 | 151 | |
|---|
| 165 | 152 | __u16 sctp_ulpevent_get_notification_type(const struct sctp_ulpevent *event); |
|---|
| 166 | 153 | |
|---|
| 167 | | -/* Is this event type enabled? */ |
|---|
| 168 | | -static inline int sctp_ulpevent_type_enabled(__u16 sn_type, |
|---|
| 169 | | - struct sctp_event_subscribe *mask) |
|---|
| 154 | +static inline void sctp_ulpevent_type_set(__u16 *subscribe, |
|---|
| 155 | + __u16 sn_type, __u8 on) |
|---|
| 170 | 156 | { |
|---|
| 171 | | - int offset = sn_type - SCTP_SN_TYPE_BASE; |
|---|
| 172 | | - char *amask = (char *) mask; |
|---|
| 157 | + if (sn_type > SCTP_SN_TYPE_MAX) |
|---|
| 158 | + return; |
|---|
| 173 | 159 | |
|---|
| 174 | | - if (offset >= sizeof(struct sctp_event_subscribe)) |
|---|
| 175 | | - return 0; |
|---|
| 176 | | - return amask[offset]; |
|---|
| 160 | + if (on) |
|---|
| 161 | + *subscribe |= (1 << (sn_type - SCTP_SN_TYPE_BASE)); |
|---|
| 162 | + else |
|---|
| 163 | + *subscribe &= ~(1 << (sn_type - SCTP_SN_TYPE_BASE)); |
|---|
| 164 | +} |
|---|
| 165 | + |
|---|
| 166 | +/* Is this event type enabled? */ |
|---|
| 167 | +static inline bool sctp_ulpevent_type_enabled(__u16 subscribe, __u16 sn_type) |
|---|
| 168 | +{ |
|---|
| 169 | + if (sn_type > SCTP_SN_TYPE_MAX) |
|---|
| 170 | + return false; |
|---|
| 171 | + |
|---|
| 172 | + return subscribe & (1 << (sn_type - SCTP_SN_TYPE_BASE)); |
|---|
| 177 | 173 | } |
|---|
| 178 | 174 | |
|---|
| 179 | 175 | /* Given an event subscription, is this event enabled? */ |
|---|
| 180 | | -static inline int sctp_ulpevent_is_enabled(const struct sctp_ulpevent *event, |
|---|
| 181 | | - struct sctp_event_subscribe *mask) |
|---|
| 176 | +static inline bool sctp_ulpevent_is_enabled(const struct sctp_ulpevent *event, |
|---|
| 177 | + __u16 subscribe) |
|---|
| 182 | 178 | { |
|---|
| 183 | 179 | __u16 sn_type; |
|---|
| 184 | | - int enabled = 1; |
|---|
| 185 | 180 | |
|---|
| 186 | | - if (sctp_ulpevent_is_notification(event)) { |
|---|
| 187 | | - sn_type = sctp_ulpevent_get_notification_type(event); |
|---|
| 188 | | - enabled = sctp_ulpevent_type_enabled(sn_type, mask); |
|---|
| 189 | | - } |
|---|
| 190 | | - return enabled; |
|---|
| 181 | + if (!sctp_ulpevent_is_notification(event)) |
|---|
| 182 | + return true; |
|---|
| 183 | + |
|---|
| 184 | + sn_type = sctp_ulpevent_get_notification_type(event); |
|---|
| 185 | + |
|---|
| 186 | + return sctp_ulpevent_type_enabled(subscribe, sn_type); |
|---|
| 191 | 187 | } |
|---|
| 192 | 188 | |
|---|
| 193 | 189 | #endif /* __sctp_ulpevent_h__ */ |
|---|