1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42#ifndef __sctp_ulpevent_h__
43#define __sctp_ulpevent_h__
44
45
46
47
48
49
50
51
52
53struct sctp_ulpevent {
54 struct sctp_association *asoc;
55 struct sctp_chunk *chunk;
56 unsigned int rmem_len;
57 union {
58 __u32 mid;
59 __u16 ssn;
60 };
61 union {
62 __u32 ppid;
63 __u32 fsn;
64 };
65 __u32 tsn;
66 __u32 cumtsn;
67 __u16 stream;
68 __u16 flags;
69 __u16 msg_flags;
70} __packed;
71
72
73static inline struct sk_buff *sctp_event2skb(const struct sctp_ulpevent *ev)
74{
75 return container_of((void *)ev, struct sk_buff, cb);
76}
77
78
79static inline struct sctp_ulpevent *sctp_skb2event(struct sk_buff *skb)
80{
81 return (struct sctp_ulpevent *)skb->cb;
82}
83
84void sctp_ulpevent_free(struct sctp_ulpevent *);
85int sctp_ulpevent_is_notification(const struct sctp_ulpevent *);
86unsigned int sctp_queue_purge_ulpevents(struct sk_buff_head *list);
87
88struct sctp_ulpevent *sctp_ulpevent_make_assoc_change(
89 const struct sctp_association *asoc,
90 __u16 flags,
91 __u16 state,
92 __u16 error,
93 __u16 outbound,
94 __u16 inbound,
95 struct sctp_chunk *chunk,
96 gfp_t gfp);
97
98struct 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);
105
106struct sctp_ulpevent *sctp_ulpevent_make_remote_error(
107 const struct sctp_association *asoc,
108 struct sctp_chunk *chunk,
109 __u16 flags,
110 gfp_t gfp);
111struct sctp_ulpevent *sctp_ulpevent_make_send_failed(
112 const struct sctp_association *asoc,
113 struct sctp_chunk *chunk,
114 __u16 flags,
115 __u32 error,
116 gfp_t gfp);
117
118struct sctp_ulpevent *sctp_ulpevent_make_shutdown_event(
119 const struct sctp_association *asoc,
120 __u16 flags,
121 gfp_t gfp);
122
123struct sctp_ulpevent *sctp_ulpevent_make_pdapi(
124 const struct sctp_association *asoc,
125 __u32 indication, __u32 sid, __u32 seq,
126 __u32 flags, gfp_t gfp);
127
128struct sctp_ulpevent *sctp_ulpevent_make_adaptation_indication(
129 const struct sctp_association *asoc, gfp_t gfp);
130
131struct sctp_ulpevent *sctp_ulpevent_make_rcvmsg(struct sctp_association *asoc,
132 struct sctp_chunk *chunk,
133 gfp_t gfp);
134
135struct sctp_ulpevent *sctp_ulpevent_make_authkey(
136 const struct sctp_association *asoc, __u16 key_id,
137 __u32 indication, gfp_t gfp);
138
139struct sctp_ulpevent *sctp_ulpevent_make_sender_dry_event(
140 const struct sctp_association *asoc, gfp_t gfp);
141
142struct sctp_ulpevent *sctp_ulpevent_make_stream_reset_event(
143 const struct sctp_association *asoc, __u16 flags,
144 __u16 stream_num, __be16 *stream_list, gfp_t gfp);
145
146struct sctp_ulpevent *sctp_ulpevent_make_assoc_reset_event(
147 const struct sctp_association *asoc, __u16 flags,
148 __u32 local_tsn, __u32 remote_tsn, gfp_t gfp);
149
150struct sctp_ulpevent *sctp_ulpevent_make_stream_change_event(
151 const struct sctp_association *asoc, __u16 flags,
152 __u32 strchange_instrms, __u32 strchange_outstrms, gfp_t gfp);
153
154struct sctp_ulpevent *sctp_make_reassembled_event(
155 struct net *net, struct sk_buff_head *queue,
156 struct sk_buff *f_frag, struct sk_buff *l_frag);
157
158void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event,
159 struct msghdr *);
160void sctp_ulpevent_read_rcvinfo(const struct sctp_ulpevent *event,
161 struct msghdr *);
162void sctp_ulpevent_read_nxtinfo(const struct sctp_ulpevent *event,
163 struct msghdr *, struct sock *sk);
164
165__u16 sctp_ulpevent_get_notification_type(const struct sctp_ulpevent *event);
166
167
168static inline int sctp_ulpevent_type_enabled(__u16 sn_type,
169 struct sctp_event_subscribe *mask)
170{
171 int offset = sn_type - SCTP_SN_TYPE_BASE;
172 char *amask = (char *) mask;
173
174 if (offset >= sizeof(struct sctp_event_subscribe))
175 return 0;
176 return amask[offset];
177}
178
179
180static inline int sctp_ulpevent_is_enabled(const struct sctp_ulpevent *event,
181 struct sctp_event_subscribe *mask)
182{
183 __u16 sn_type;
184 int enabled = 1;
185
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;
191}
192
193#endif
194