0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 #ifndef __sctp_ulpevent_h__
0028 #define __sctp_ulpevent_h__
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 struct sctp_ulpevent {
0039 struct sctp_association *asoc;
0040 struct sctp_chunk *chunk;
0041 unsigned int rmem_len;
0042 union {
0043 __u32 mid;
0044 __u16 ssn;
0045 };
0046 union {
0047 __u32 ppid;
0048 __u32 fsn;
0049 };
0050 __u32 tsn;
0051 __u32 cumtsn;
0052 __u16 stream;
0053 __u16 flags;
0054 __u16 msg_flags;
0055 } __packed;
0056
0057
0058 static inline struct sk_buff *sctp_event2skb(const struct sctp_ulpevent *ev)
0059 {
0060 return container_of((void *)ev, struct sk_buff, cb);
0061 }
0062
0063
0064 static inline struct sctp_ulpevent *sctp_skb2event(struct sk_buff *skb)
0065 {
0066 return (struct sctp_ulpevent *)skb->cb;
0067 }
0068
0069 void sctp_ulpevent_free(struct sctp_ulpevent *);
0070 int sctp_ulpevent_is_notification(const struct sctp_ulpevent *);
0071 unsigned int sctp_queue_purge_ulpevents(struct sk_buff_head *list);
0072
0073 struct sctp_ulpevent *sctp_ulpevent_make_assoc_change(
0074 const struct sctp_association *asoc,
0075 __u16 flags,
0076 __u16 state,
0077 __u16 error,
0078 __u16 outbound,
0079 __u16 inbound,
0080 struct sctp_chunk *chunk,
0081 gfp_t gfp);
0082
0083 void sctp_ulpevent_notify_peer_addr_change(struct sctp_transport *transport,
0084 int state, int error);
0085
0086 struct sctp_ulpevent *sctp_ulpevent_make_remote_error(
0087 const struct sctp_association *asoc,
0088 struct sctp_chunk *chunk,
0089 __u16 flags,
0090 gfp_t gfp);
0091 struct sctp_ulpevent *sctp_ulpevent_make_send_failed(
0092 const struct sctp_association *asoc,
0093 struct sctp_chunk *chunk,
0094 __u16 flags,
0095 __u32 error,
0096 gfp_t gfp);
0097
0098 struct sctp_ulpevent *sctp_ulpevent_make_send_failed_event(
0099 const struct sctp_association *asoc,
0100 struct sctp_chunk *chunk,
0101 __u16 flags,
0102 __u32 error,
0103 gfp_t gfp);
0104
0105 struct sctp_ulpevent *sctp_ulpevent_make_shutdown_event(
0106 const struct sctp_association *asoc,
0107 __u16 flags,
0108 gfp_t gfp);
0109
0110 struct sctp_ulpevent *sctp_ulpevent_make_pdapi(
0111 const struct sctp_association *asoc,
0112 __u32 indication, __u32 sid, __u32 seq,
0113 __u32 flags, gfp_t gfp);
0114
0115 struct sctp_ulpevent *sctp_ulpevent_make_adaptation_indication(
0116 const struct sctp_association *asoc, gfp_t gfp);
0117
0118 struct sctp_ulpevent *sctp_ulpevent_make_rcvmsg(struct sctp_association *asoc,
0119 struct sctp_chunk *chunk,
0120 gfp_t gfp);
0121
0122 struct sctp_ulpevent *sctp_ulpevent_make_authkey(
0123 const struct sctp_association *asoc, __u16 key_id,
0124 __u32 indication, gfp_t gfp);
0125
0126 struct sctp_ulpevent *sctp_ulpevent_make_sender_dry_event(
0127 const struct sctp_association *asoc, gfp_t gfp);
0128
0129 struct sctp_ulpevent *sctp_ulpevent_make_stream_reset_event(
0130 const struct sctp_association *asoc, __u16 flags,
0131 __u16 stream_num, __be16 *stream_list, gfp_t gfp);
0132
0133 struct sctp_ulpevent *sctp_ulpevent_make_assoc_reset_event(
0134 const struct sctp_association *asoc, __u16 flags,
0135 __u32 local_tsn, __u32 remote_tsn, gfp_t gfp);
0136
0137 struct sctp_ulpevent *sctp_ulpevent_make_stream_change_event(
0138 const struct sctp_association *asoc, __u16 flags,
0139 __u32 strchange_instrms, __u32 strchange_outstrms, gfp_t gfp);
0140
0141 struct sctp_ulpevent *sctp_make_reassembled_event(
0142 struct net *net, struct sk_buff_head *queue,
0143 struct sk_buff *f_frag, struct sk_buff *l_frag);
0144
0145 void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event,
0146 struct msghdr *);
0147 void sctp_ulpevent_read_rcvinfo(const struct sctp_ulpevent *event,
0148 struct msghdr *);
0149 void sctp_ulpevent_read_nxtinfo(const struct sctp_ulpevent *event,
0150 struct msghdr *, struct sock *sk);
0151
0152 __u16 sctp_ulpevent_get_notification_type(const struct sctp_ulpevent *event);
0153
0154 static inline void sctp_ulpevent_type_set(__u16 *subscribe,
0155 __u16 sn_type, __u8 on)
0156 {
0157 if (sn_type > SCTP_SN_TYPE_MAX)
0158 return;
0159
0160 if (on)
0161 *subscribe |= (1 << (sn_type - SCTP_SN_TYPE_BASE));
0162 else
0163 *subscribe &= ~(1 << (sn_type - SCTP_SN_TYPE_BASE));
0164 }
0165
0166
0167 static inline bool sctp_ulpevent_type_enabled(__u16 subscribe, __u16 sn_type)
0168 {
0169 if (sn_type > SCTP_SN_TYPE_MAX)
0170 return false;
0171
0172 return subscribe & (1 << (sn_type - SCTP_SN_TYPE_BASE));
0173 }
0174
0175
0176 static inline bool sctp_ulpevent_is_enabled(const struct sctp_ulpevent *event,
0177 __u16 subscribe)
0178 {
0179 __u16 sn_type;
0180
0181 if (!sctp_ulpevent_is_notification(event))
0182 return true;
0183
0184 sn_type = sctp_ulpevent_get_notification_type(event);
0185
0186 return sctp_ulpevent_type_enabled(subscribe, sn_type);
0187 }
0188
0189 #endif