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
49struct sctp_ulpevent {
50 struct sctp_association *asoc;
51 struct sctp_chunk *chunk;
52 unsigned int rmem_len;
53 __u32 ppid;
54 __u32 tsn;
55 __u32 cumtsn;
56 __u16 stream;
57 __u16 ssn;
58 __u16 flags;
59 __u16 msg_flags;
60};
61
62
63static inline struct sk_buff *sctp_event2skb(const struct sctp_ulpevent *ev)
64{
65 return container_of((void *)ev, struct sk_buff, cb);
66}
67
68
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 *);
76unsigned int sctp_queue_purge_ulpevents(struct sk_buff_head *list);
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,
85 struct sctp_chunk *chunk,
86 gfp_t gfp);
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,
94 gfp_t gfp);
95
96struct sctp_ulpevent *sctp_ulpevent_make_remote_error(
97 const struct sctp_association *asoc,
98 struct sctp_chunk *chunk,
99 __u16 flags,
100 gfp_t gfp);
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,
106 gfp_t gfp);
107
108struct sctp_ulpevent *sctp_ulpevent_make_shutdown_event(
109 const struct sctp_association *asoc,
110 __u16 flags,
111 gfp_t gfp);
112
113struct sctp_ulpevent *sctp_ulpevent_make_pdapi(
114 const struct sctp_association *asoc,
115 __u32 indication, gfp_t gfp);
116
117struct sctp_ulpevent *sctp_ulpevent_make_adaptation_indication(
118 const struct sctp_association *asoc, gfp_t gfp);
119
120struct sctp_ulpevent *sctp_ulpevent_make_rcvmsg(struct sctp_association *asoc,
121 struct sctp_chunk *chunk,
122 gfp_t gfp);
123
124struct sctp_ulpevent *sctp_ulpevent_make_authkey(
125 const struct sctp_association *asoc, __u16 key_id,
126 __u32 indication, gfp_t gfp);
127
128struct sctp_ulpevent *sctp_ulpevent_make_sender_dry_event(
129 const struct sctp_association *asoc, gfp_t gfp);
130
131struct sctp_ulpevent *sctp_ulpevent_make_stream_reset_event(
132 const struct sctp_association *asoc, __u16 flags,
133 __u16 stream_num, __be16 *stream_list, gfp_t gfp);
134
135struct sctp_ulpevent *sctp_ulpevent_make_assoc_reset_event(
136 const struct sctp_association *asoc, __u16 flags,
137 __u32 local_tsn, __u32 remote_tsn, gfp_t gfp);
138
139struct sctp_ulpevent *sctp_ulpevent_make_stream_change_event(
140 const struct sctp_association *asoc, __u16 flags,
141 __u32 strchange_instrms, __u32 strchange_outstrms, gfp_t gfp);
142
143void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event,
144 struct msghdr *);
145void sctp_ulpevent_read_rcvinfo(const struct sctp_ulpevent *event,
146 struct msghdr *);
147void sctp_ulpevent_read_nxtinfo(const struct sctp_ulpevent *event,
148 struct msghdr *, struct sock *sk);
149
150__u16 sctp_ulpevent_get_notification_type(const struct sctp_ulpevent *event);
151
152
153static inline int sctp_ulpevent_type_enabled(__u16 sn_type,
154 struct sctp_event_subscribe *mask)
155{
156 int offset = sn_type - SCTP_SN_TYPE_BASE;
157 char *amask = (char *) mask;
158
159 if (offset >= sizeof(struct sctp_event_subscribe))
160 return 0;
161 return amask[offset];
162}
163
164
165static inline int sctp_ulpevent_is_enabled(const struct sctp_ulpevent *event,
166 struct sctp_event_subscribe *mask)
167{
168 __u16 sn_type;
169 int enabled = 1;
170
171 if (sctp_ulpevent_is_notification(event)) {
172 sn_type = sctp_ulpevent_get_notification_type(event);
173 enabled = sctp_ulpevent_type_enabled(sn_type, mask);
174 }
175 return enabled;
176}
177
178#endif
179