net/sctp: Make wrappers for accessing in/out streams
This patch introduces wrappers for accessing in/out streams indirectly. This will enable to replace physically contiguous memory arrays of streams with flexible arrays (or maybe any other appropriate mechanism) which do memory allocation on a per-page basis. Signed-off-by: Oleg Babin <obabin@virtuozzo.com> Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
b70f1f3af4
commit
05364ca03c
@@ -398,37 +398,35 @@ void sctp_stream_update(struct sctp_stream *stream, struct sctp_stream *new);
|
||||
|
||||
/* What is the current SSN number for this stream? */
|
||||
#define sctp_ssn_peek(stream, type, sid) \
|
||||
((stream)->type[sid].ssn)
|
||||
(sctp_stream_##type((stream), (sid))->ssn)
|
||||
|
||||
/* Return the next SSN number for this stream. */
|
||||
#define sctp_ssn_next(stream, type, sid) \
|
||||
((stream)->type[sid].ssn++)
|
||||
(sctp_stream_##type((stream), (sid))->ssn++)
|
||||
|
||||
/* Skip over this ssn and all below. */
|
||||
#define sctp_ssn_skip(stream, type, sid, ssn) \
|
||||
((stream)->type[sid].ssn = ssn + 1)
|
||||
(sctp_stream_##type((stream), (sid))->ssn = ssn + 1)
|
||||
|
||||
/* What is the current MID number for this stream? */
|
||||
#define sctp_mid_peek(stream, type, sid) \
|
||||
((stream)->type[sid].mid)
|
||||
(sctp_stream_##type((stream), (sid))->mid)
|
||||
|
||||
/* Return the next MID number for this stream. */
|
||||
#define sctp_mid_next(stream, type, sid) \
|
||||
((stream)->type[sid].mid++)
|
||||
(sctp_stream_##type((stream), (sid))->mid++)
|
||||
|
||||
/* Skip over this mid and all below. */
|
||||
#define sctp_mid_skip(stream, type, sid, mid) \
|
||||
((stream)->type[sid].mid = mid + 1)
|
||||
|
||||
#define sctp_stream_in(asoc, sid) (&(asoc)->stream.in[sid])
|
||||
(sctp_stream_##type((stream), (sid))->mid = mid + 1)
|
||||
|
||||
/* What is the current MID_uo number for this stream? */
|
||||
#define sctp_mid_uo_peek(stream, type, sid) \
|
||||
((stream)->type[sid].mid_uo)
|
||||
(sctp_stream_##type((stream), (sid))->mid_uo)
|
||||
|
||||
/* Return the next MID_uo number for this stream. */
|
||||
#define sctp_mid_uo_next(stream, type, sid) \
|
||||
((stream)->type[sid].mid_uo++)
|
||||
(sctp_stream_##type((stream), (sid))->mid_uo++)
|
||||
|
||||
/*
|
||||
* Pointers to address related SCTP functions.
|
||||
@@ -1463,6 +1461,23 @@ struct sctp_stream {
|
||||
struct sctp_stream_interleave *si;
|
||||
};
|
||||
|
||||
static inline struct sctp_stream_out *sctp_stream_out(
|
||||
const struct sctp_stream *stream,
|
||||
__u16 sid)
|
||||
{
|
||||
return ((struct sctp_stream_out *)(stream->out)) + sid;
|
||||
}
|
||||
|
||||
static inline struct sctp_stream_in *sctp_stream_in(
|
||||
const struct sctp_stream *stream,
|
||||
__u16 sid)
|
||||
{
|
||||
return ((struct sctp_stream_in *)(stream->in)) + sid;
|
||||
}
|
||||
|
||||
#define SCTP_SO(s, i) sctp_stream_out((s), (i))
|
||||
#define SCTP_SI(s, i) sctp_stream_in((s), (i))
|
||||
|
||||
#define SCTP_STREAM_CLOSED 0x00
|
||||
#define SCTP_STREAM_OPEN 0x01
|
||||
|
||||
|
Reference in New Issue
Block a user