Commit 13f5f8af authored by David S. Miller's avatar David S. Miller

[SCTP]: Whitespace/codingstyle fixups, plus a bug fix or two.

parent f82c185f
This diff is collapsed.
......@@ -73,21 +73,21 @@ typedef enum {
SCTP_CMD_SET_BIND_ADDR, /* Set the association bind_addr. */
SCTP_CMD_STRIKE, /* Mark a strike against a transport. */
SCTP_CMD_TRANSMIT, /* Transmit the outqueue. */
SCTP_CMD_HB_TIMERS_START, /* Start the heartbeat timers. */
SCTP_CMD_HB_TIMERS_START, /* Start the heartbeat timers. */
SCTP_CMD_TRANSPORT_RESET, /* Reset the status of a transport. */
SCTP_CMD_TRANSPORT_ON, /* Mark the transport as active. */
SCTP_CMD_TRANSPORT_ON, /* Mark the transport as active. */
SCTP_CMD_REPORT_ERROR, /* Pass this error back out of the sm. */
SCTP_CMD_REPORT_BAD_TAG, /* Verification tags didn't match. */
SCTP_CMD_PROCESS_CTSN, /* Sideeffect from shutdown. */
SCTP_CMD_ASSOC_FAILED, /* Handle association failure. */
SCTP_CMD_ASSOC_FAILED, /* Handle association failure. */
SCTP_CMD_DISCARD_PACKET, /* Discard the whole packet. */
SCTP_CMD_GEN_SHUTDOWN, /* Generate a SHUTDOWN chunk. */
SCTP_CMD_GEN_SHUTDOWN, /* Generate a SHUTDOWN chunk. */
SCTP_CMD_UPDATE_ASSOC, /* Update association information. */
SCTP_CMD_PURGE_OUTQUEUE, /* Purge all data waiting to be sent. */
SCTP_CMD_SETUP_T2, /* Hi-level, setup T2-shutdown parms. */
SCTP_CMD_LAST
} sctp_verb_t; /* enum */
} sctp_verb_t;
#define SCTP_CMD_MAX (SCTP_CMD_LAST - 1)
#define SCTP_CMD_NUM_VERBS (SCTP_CMD_MAX + 1)
......@@ -100,10 +100,10 @@ typedef enum {
#define SCTP_MAX_NUM_COMMANDS 14
typedef union {
int32_t i32;
uint32_t u32;
uint16_t u16;
uint8_t u8;
__s32 i32;
__u32 u32;
__u16 u16;
__u8 u8;
int error;
sctp_state_t state;
sctp_event_timeout_t to;
......@@ -120,41 +120,38 @@ typedef union {
} sctp_arg_t;
/* We are simulating ML type constructors here.
*
*
* SCTP_ARG_CONSTRUCTOR(NAME, TYPE, ELT) builds a function called
* SCTP_NAME() which takes an argument of type TYPE and returns an
* sctp_arg_t. It does this by inserting the sole argument into the
* ELT union element of a local sctp_arg_t.
*
* E.g., SCTP_ARG_CONSTRUCTOR(I32, int32_t, i32) builds SCTP_I32(arg),
* which takes an int32_t and returns a sctp_arg_t containing the
* int32_t. So, after foo = SCTP_I32(arg), foo.i32 == arg.
* E.g., SCTP_ARG_CONSTRUCTOR(I32, __s32, i32) builds SCTP_I32(arg),
* which takes an __s32 and returns a sctp_arg_t containing the
* __s32. So, after foo = SCTP_I32(arg), foo.i32 == arg.
*/
static inline sctp_arg_t
SCTP_NULL(void)
static inline sctp_arg_t SCTP_NULL(void)
{
sctp_arg_t retval; retval.ptr = NULL; return(retval);
sctp_arg_t retval; retval.ptr = NULL; return retval;
}
static inline sctp_arg_t
SCTP_NOFORCE(void)
static inline sctp_arg_t SCTP_NOFORCE(void)
{
sctp_arg_t retval; retval.i32 = 0; return(retval);
sctp_arg_t retval; retval.i32 = 0; return retval;
}
static inline sctp_arg_t
SCTP_FORCE(void)
static inline sctp_arg_t SCTP_FORCE(void)
{
sctp_arg_t retval; retval.i32 = 1; return(retval);
sctp_arg_t retval; retval.i32 = 1; return retval;
}
#define SCTP_ARG_CONSTRUCTOR(name, type, elt) \
static inline sctp_arg_t \
SCTP_## name (type arg) \
{ sctp_arg_t retval; retval.elt = arg; return(retval); }
{ sctp_arg_t retval; retval.elt = arg; return retval; }
SCTP_ARG_CONSTRUCTOR(I32, int32_t, i32)
SCTP_ARG_CONSTRUCTOR(U32, int32_t, u32)
SCTP_ARG_CONSTRUCTOR(U16, int32_t, u16)
SCTP_ARG_CONSTRUCTOR(U8, int32_t, u8)
SCTP_ARG_CONSTRUCTOR(I32, __s32, i32)
SCTP_ARG_CONSTRUCTOR(U32, __u32, u32)
SCTP_ARG_CONSTRUCTOR(U16, __u16, u16)
SCTP_ARG_CONSTRUCTOR(U8, __u8, u8)
SCTP_ARG_CONSTRUCTOR(ERROR, int, error)
SCTP_ARG_CONSTRUCTOR(STATE, sctp_state_t, state)
SCTP_ARG_CONSTRUCTOR(COUNTER, sctp_counter_t, counter)
......@@ -176,12 +173,12 @@ typedef struct {
typedef struct {
sctp_cmd_t cmds[SCTP_MAX_NUM_COMMANDS];
uint8_t next_free_slot;
uint8_t next_cmd;
__u8 next_free_slot;
__u8 next_cmd;
} sctp_cmd_seq_t;
/* Create a new sctp_command_sequence.
/* Create a new sctp_command_sequence.
* Return NULL if creating a new sequence fails.
*/
sctp_cmd_seq_t *sctp_new_cmd_seq(int priority);
......
......@@ -62,8 +62,8 @@
/* What a hack! Jiminy Cricket! */
enum { SCTP_MAX_STREAM = 10 };
/* Define the amount of space to reserve for SCTP, IP, LL.
* There is a little bit of waste that we are always allocating
/* Define the amount of space to reserve for SCTP, IP, LL.
* There is a little bit of waste that we are always allocating
* for ipv6 headers, but this seems worth the simplicity.
*/
......@@ -71,8 +71,8 @@ enum { SCTP_MAX_STREAM = 10 };
+ sizeof(struct ipv6hdr)\
+ MAX_HEADER))
/* Define the amount of space to reserve for SCTP, IP, LL.
* There is a little bit of waste that we are always allocating
/* Define the amount of space to reserve for SCTP, IP, LL.
* There is a little bit of waste that we are always allocating
* for ipv6 headers, but this seems worth the simplicity.
*/
......@@ -93,10 +93,10 @@ enum { SCTP_MAX_STREAM = 10 };
/* These are the different flavours of event. */
typedef enum {
SCTP_EVENT_T_CHUNK = 1,
SCTP_EVENT_T_TIMEOUT,
SCTP_EVENT_T_OTHER,
SCTP_EVENT_T_PRIMITIVE
SCTP_EVENT_T_CHUNK = 1,
SCTP_EVENT_T_TIMEOUT,
SCTP_EVENT_T_OTHER,
SCTP_EVENT_T_PRIMITIVE
} sctp_event_t;
......@@ -127,8 +127,8 @@ typedef enum {
typedef enum {
SCTP_EVENT_NO_PENDING_TSN = 0,
SCTP_EVENT_ICMP_UNREACHFRAG,
SCTP_EVENT_NO_PENDING_TSN = 0,
SCTP_EVENT_ICMP_UNREACHFRAG,
} sctp_event_other_t;
......@@ -138,22 +138,22 @@ typedef enum {
/* These are primitive requests from the ULP. */
typedef enum {
SCTP_PRIMITIVE_INITIALIZE = 0,
SCTP_PRIMITIVE_ASSOCIATE,
SCTP_PRIMITIVE_SHUTDOWN,
SCTP_PRIMITIVE_ABORT,
SCTP_PRIMITIVE_SEND,
SCTP_PRIMITIVE_SETPRIMARY,
SCTP_PRIMITIVE_RECEIVE,
SCTP_PRIMITIVE_STATUS,
SCTP_PRIMITIVE_CHANGEHEARTBEAT,
SCTP_PRIMITIVE_REQUESTHEARTBEAT,
SCTP_PRIMITIVE_GETSRTTREPORT,
SCTP_PRIMITIVE_SETFAILURETHRESHOLD,
SCTP_PRIMITIVE_SETPROTOPARAMETERS,
SCTP_PRIMITIVE_RECEIVE_UNSENT,
SCTP_PRIMITIVE_RECEIVE_UNACKED,
SCTP_PRIMITIVE_DESTROY,
SCTP_PRIMITIVE_INITIALIZE = 0,
SCTP_PRIMITIVE_ASSOCIATE,
SCTP_PRIMITIVE_SHUTDOWN,
SCTP_PRIMITIVE_ABORT,
SCTP_PRIMITIVE_SEND,
SCTP_PRIMITIVE_SETPRIMARY,
SCTP_PRIMITIVE_RECEIVE,
SCTP_PRIMITIVE_STATUS,
SCTP_PRIMITIVE_CHANGEHEARTBEAT,
SCTP_PRIMITIVE_REQUESTHEARTBEAT,
SCTP_PRIMITIVE_GETSRTTREPORT,
SCTP_PRIMITIVE_SETFAILURETHRESHOLD,
SCTP_PRIMITIVE_SETPROTOPARAMETERS,
SCTP_PRIMITIVE_RECEIVE_UNSENT,
SCTP_PRIMITIVE_RECEIVE_UNACKED,
SCTP_PRIMITIVE_DESTROY,
} sctp_event_primitive_t;
......@@ -167,7 +167,7 @@ typedef enum {
*/
typedef union {
sctp_cid_t chunk;
sctp_event_timeout_t timeout;
sctp_event_other_t other;
......@@ -178,7 +178,7 @@ typedef union {
#define SCTP_SUBTYPE_CONSTRUCTOR(_name, _type, _elt) \
static inline sctp_subtype_t \
SCTP_ST_## _name (_type _arg) \
{ sctp_subtype_t _retval; _retval._elt = _arg; return(_retval); }
{ sctp_subtype_t _retval; _retval._elt = _arg; return _retval; }
SCTP_SUBTYPE_CONSTRUCTOR(CHUNK, sctp_cid_t, chunk)
SCTP_SUBTYPE_CONSTRUCTOR(TIMEOUT, sctp_event_timeout_t, timeout)
......@@ -204,18 +204,18 @@ extern const char *sctp_param_tbl[];
/* Internal error codes */
typedef enum {
SCTP_IERROR_NO_ERROR = 0,
SCTP_IERROR_BASE = 1000,
SCTP_IERROR_NO_COOKIE,
SCTP_IERROR_BAD_SIG,
SCTP_IERROR_STALE_COOKIE,
SCTP_IERROR_NOMEM,
SCTP_IERROR_MALFORMED,
SCTP_IERROR_BAD_TAG,
SCTP_IERROR_BIG_GAP,
SCTP_IERROR_DUP_TSN,
SCTP_IERROR_NO_ERROR = 0,
SCTP_IERROR_BASE = 1000,
SCTP_IERROR_NO_COOKIE,
SCTP_IERROR_BAD_SIG,
SCTP_IERROR_STALE_COOKIE,
SCTP_IERROR_NOMEM,
SCTP_IERROR_MALFORMED,
SCTP_IERROR_BAD_TAG,
SCTP_IERROR_BIG_GAP,
SCTP_IERROR_DUP_TSN,
} sctp_ierror_t; /* enum */
} sctp_ierror_t;
......@@ -232,7 +232,7 @@ typedef enum {
SCTP_STATE_SHUTDOWN_RECEIVED = 7,
SCTP_STATE_SHUTDOWN_ACK_SENT = 8,
} sctp_state_t; /* enum */
} sctp_state_t;
#define SCTP_STATE_MAX SCTP_STATE_SHUTDOWN_ACK_SENT
#define SCTP_STATE_NUM_STATES (SCTP_STATE_MAX + 1)
......@@ -262,7 +262,7 @@ const char *sctp_oname(const sctp_subtype_t); /* other events */
const char *sctp_tname(const sctp_subtype_t); /* timeouts */
const char *sctp_pname(const sctp_subtype_t); /* primitives */
/* This is a table of printable names of sctp_state_t's. */
/* This is a table of printable names of sctp_state_t's. */
extern const char *sctp_state_tbl[], *sctp_evttype_tbl[], *sctp_status_tbl[];
/* SCTP reachability state for each address */
......@@ -281,7 +281,7 @@ extern const char *sctp_state_tbl[], *sctp_evttype_tbl[], *sctp_status_tbl[];
* NEVER make this more than 32767 (2^15-1). The Gap Ack Blocks in a
* SACK (see section 3.3.4) are only 16 bits, so 2*SCTP_TSN_MAP_SIZE
* must be less than 65535 (2^16 - 1), or we will have overflow
* problems creating SACK's.
* problems creating SACK's.
*/
#define SCTP_TSN_MAP_SIZE 2048
#define SCTP_TSN_MAX_GAP 65535
......@@ -289,20 +289,19 @@ extern const char *sctp_state_tbl[], *sctp_evttype_tbl[], *sctp_status_tbl[];
/* We will not record more than this many duplicate TSNs between two
* SACKs. The minimum PMTU is 576. Remove all the headers and there
* is enough room for 131 duplicate reports. Round down to the
* nearest power of 2.
* nearest power of 2.
*/
#define SCTP_MAX_DUP_TSNS 128
typedef enum {
SCTP_COUNTER_INIT_ERROR,
} sctp_counter_t;
} sctp_counter_t;
/* How many counters does an association need? */
#define SCTP_NUMBER_COUNTERS 5
/* Here we define the default timers.
*/
/* Here we define the default timers. */
/* cookie timer def = ? seconds */
#define SCTP_DEFAULT_TIMEOUT_T1_COOKIE (3 * HZ)
......@@ -355,7 +354,7 @@ typedef enum {
*/
#define SCTP_DEFAULT_MINSEGMENT 512 /* MTU size ... if no mtu disc */
#define SCTP_HOW_MANY_SECRETS 2 /* How many secrets I keep */
#define SCTP_HOW_LONG_COOKIE_LIVE 3600 /* How many seconds the current
#define SCTP_HOW_LONG_COOKIE_LIVE 3600 /* How many seconds the current
* secret will live?
*/
#define SCTP_SECRET_SIZE 32 /* Number of octets in a 256 bits. */
......@@ -370,10 +369,10 @@ typedef enum {
* routines which form the lower interface to SCTP_outqueue.
*/
typedef enum {
SCTP_XMIT_OK,
SCTP_XMIT_PMTU_FULL,
SCTP_XMIT_RWND_FULL,
SCTP_XMIT_MUST_FRAG,
SCTP_XMIT_OK,
SCTP_XMIT_PMTU_FULL,
SCTP_XMIT_RWND_FULL,
SCTP_XMIT_MUST_FRAG,
} sctp_xmit_t;
/* These are the commands for manipulating transports. */
......@@ -383,9 +382,9 @@ typedef enum {
} sctp_transport_cmd_t;
/* These are the address scopes defined mainly for IPv4 addresses
* based on draft of SCTP IPv4 scoping <draft-stewart-tsvwg-sctp-ipv4-00.txt>.
* These scopes are hopefully generic enough to be used on scoping both
* IPv4 and IPv6 addresses in SCTP.
* based on draft of SCTP IPv4 scoping <draft-stewart-tsvwg-sctp-ipv4-00.txt>.
* These scopes are hopefully generic enough to be used on scoping both
* IPv4 and IPv6 addresses in SCTP.
* At this point, the IPv6 scopes will be mapped to these internal scopes
* as much as possible.
*/
......@@ -397,10 +396,10 @@ typedef enum {
SCTP_SCOPE_UNUSABLE, /* IPv4 unusable addresses */
} sctp_scope_t;
/* Based on IPv4 scoping <draft-stewart-tsvwg-sctp-ipv4-00.txt>,
* SCTP IPv4 unusable addresses: 0.0.0.0/8, 224.0.0.0/4, 198.18.0.0/24,
/* Based on IPv4 scoping <draft-stewart-tsvwg-sctp-ipv4-00.txt>,
* SCTP IPv4 unusable addresses: 0.0.0.0/8, 224.0.0.0/4, 198.18.0.0/24,
* 192.88.99.0/24.
* Also, RFC 8.4, non-unicast addresses are not considered valid SCTP
* Also, RFC 8.4, non-unicast addresses are not considered valid SCTP
* addresses.
*/
#define IS_IPV4_UNUSABLE_ADDRESS(a) \
......@@ -436,7 +435,7 @@ typedef enum {
/* Flags used for the bind address copy functions. */
#define SCTP_ADDR6_ALLOWED 0x00000001 /* IPv6 address is allowed by
local sock family */
local sock family */
#define SCTP_ADDR4_PEERSUPP 0x00000002 /* IPv4 address is supported by
peer */
#define SCTP_ADDR6_PEERSUPP 0x00000004 /* IPv6 address is supported by
......
......@@ -31,28 +31,26 @@
#ifndef __SLA1_h__
#define __SLA1_h__
#ifdef __cplusplus
extern "C" {
#endif
struct SLA_1_Context {
unsigned int A;
unsigned int B;
unsigned int C;
unsigned int D;
unsigned int E;
unsigned int H0;
unsigned int H1;
unsigned int H2;
unsigned int H3;
unsigned int H4;
unsigned int words[80];
unsigned int TEMP;
/* block I am collecting to process */
char SLAblock[64];
struct SLA_1_Context{
unsigned int A;
unsigned int B;
unsigned int C;
unsigned int D;
unsigned int E;
unsigned int H0;
unsigned int H1;
unsigned int H2;
unsigned int H3;
unsigned int H4;
unsigned int words[80];
unsigned int TEMP;
/* block I am collecting to process */
char SLAblock[64];
/* collected so far */
int howManyInBlock;
unsigned int runningTotal;
/* collected so far */
int howManyInBlock;
unsigned int runningTotal;
};
......@@ -61,7 +59,7 @@ struct SLA_1_Context{
#define F3(B,C,D) ((B & C) | (B & D) | (C & D)) /* 40 <= t <= 59 */
#define F4(B,C,D) (B ^ C ^ D) /*600 <= t <= 79 */
/* circular shift */
#define CSHIFT(A,B) ((B << A) | (B >> (32-A)))
#define K1 0x5a827999 /* 0 <= t <= 19 */
......@@ -79,9 +77,4 @@ extern void SLA1_Init(struct SLA_1_Context *);
extern void SLA1_Process(struct SLA_1_Context *, const unsigned char *, int);
extern void SLA1_Final(struct SLA_1_Context *, unsigned char *);
#ifdef __cplusplus
}
#endif
#endif
......@@ -52,7 +52,6 @@
*/
#include <linux/config.h>
#include <linux/types.h>
#include <linux/compiler.h>
#include <linux/sched.h>
......@@ -91,11 +90,11 @@ typedef sctp_disposition_t (sctp_state_fn_t) (const sctp_endpoint_t *,
sctp_cmd_seq_t *);
typedef void (sctp_timer_event_t) (unsigned long);
typedef struct {
sctp_state_fn_t *fn;
char *name;
sctp_state_fn_t *fn;
char *name;
} sctp_sm_table_entry_t;
/* A naming convention of "sctp_sf_xxx" applies to all the state functions
/* A naming convention of "sctp_sf_xxx" applies to all the state functions
* currently in use.
*/
......@@ -113,7 +112,7 @@ sctp_state_fn_t sctp_sf_cookie_echoed_abort;
sctp_state_fn_t sctp_sf_do_5_1B_init;
sctp_state_fn_t sctp_sf_do_5_1C_ack;
sctp_state_fn_t sctp_sf_do_5_1D_ce;
sctp_state_fn_t sctp_sf_do_5_1E_ca ;
sctp_state_fn_t sctp_sf_do_5_1E_ca;
sctp_state_fn_t sctp_sf_do_4_C;
sctp_state_fn_t sctp_sf_eat_data_6_2;
sctp_state_fn_t sctp_sf_eat_data_fast_4_4;
......@@ -162,10 +161,10 @@ sctp_state_fn_t sctp_sf_do_6_2_sack;
sctp_state_fn_t sctp_sf_autoclose_timer_expire;
/* These are state functions which are either obsolete or not in use yet.
/* These are state functions which are either obsolete or not in use yet.
* If any of these functions needs to be revived, it should be renamed with
* the "sctp_sf_xxx" prefix, and be moved to the above prototype groups.
*/
*/
/* Prototypes for chunk state functions. Not in use. */
sctp_state_fn_t sctp_sf_do_5_2_6_stale;
......@@ -189,7 +188,7 @@ sctp_state_fn_t sctp_addip_do_asconf;
sctp_state_fn_t sctp_addip_do_asconf_ack;
/* Prototypes for utility support functions. */
uint8_t sctp_get_chunk_type(sctp_chunk_t *chunk);
__u8 sctp_get_chunk_type(sctp_chunk_t *chunk);
sctp_sm_table_entry_t *sctp_sm_lookup_event(sctp_event_t event_type,
sctp_state_t state,
sctp_subtype_t event_subtype);
......@@ -198,13 +197,11 @@ time_t timeval_sub(struct timeval *, struct timeval *);
sctp_association_t *sctp_make_temp_asoc(const sctp_endpoint_t *,
sctp_chunk_t *,
const int priority);
uint32_t sctp_generate_verification_tag(void);
__u32 sctp_generate_verification_tag(void);
sctpParam_t sctp_get_my_addrs_raw(const sctp_association_t *,
const int priority, int *addrs_len);
void sctp_populate_tie_tags(uint8_t *cookie, uint32_t curTag, uint32_t hisTag);
void sctp_populate_tie_tags(__u8 *cookie, __u32 curTag, __u32 hisTag);
/* Prototypes for chunk-building functions. */
sctp_chunk_t *sctp_make_init(const sctp_association_t *,
......@@ -218,36 +215,36 @@ sctp_chunk_t *sctp_make_cookie_echo(const sctp_association_t *,
sctp_chunk_t *sctp_make_cookie_ack(const sctp_association_t *,
const sctp_chunk_t *);
sctp_chunk_t *sctp_make_cwr(const sctp_association_t *,
const uint32_t lowest_tsn,
const __u32 lowest_tsn,
const sctp_chunk_t *);
sctp_chunk_t *sctp_make_datafrag(sctp_association_t *,
const struct sctp_sndrcvinfo *sinfo,
int len, const uint8_t *data,
uint8_t flags, uint16_t ssn);
int len, const __u8 *data,
__u8 flags, __u16 ssn);
sctp_chunk_t * sctp_make_datafrag_empty(sctp_association_t *,
const struct sctp_sndrcvinfo *sinfo,
int len, const uint8_t flags,
uint16_t ssn);
int len, const __u8 flags,
__u16 ssn);
sctp_chunk_t *sctp_make_data(sctp_association_t *,
const struct sctp_sndrcvinfo *sinfo,
int len, const uint8_t *data);
int len, const __u8 *data);
sctp_chunk_t *sctp_make_data_empty(sctp_association_t *,
const struct sctp_sndrcvinfo *, int len);
sctp_chunk_t *sctp_make_ecne(const sctp_association_t *,
const uint32_t);
const __u32);
sctp_chunk_t *sctp_make_sack(const sctp_association_t *);
sctp_chunk_t *sctp_make_shutdown(const sctp_association_t *asoc);
sctp_chunk_t *sctp_make_shutdown_ack(const sctp_association_t *asoc,
const sctp_chunk_t *);
sctp_chunk_t *sctp_make_shutdown_complete(const sctp_association_t *,
const sctp_chunk_t *);
void sctp_init_cause(sctp_chunk_t *, uint16_t cause, const void *, size_t);
void sctp_init_cause(sctp_chunk_t *, __u16 cause, const void *, size_t);
sctp_chunk_t *sctp_make_abort(const sctp_association_t *,
const sctp_chunk_t *,
const size_t hint);
sctp_chunk_t *sctp_make_abort_no_data(const sctp_association_t *,
const sctp_chunk_t *,
uint32_t tsn);
__u32 tsn);
sctp_chunk_t *sctp_make_heartbeat(const sctp_association_t *,
const sctp_transport_t *,
const void *payload,
......@@ -258,7 +255,7 @@ sctp_chunk_t *sctp_make_heartbeat_ack(const sctp_association_t *,
const size_t paylen);
sctp_chunk_t *sctp_make_op_error(const sctp_association_t *,
const sctp_chunk_t *chunk,
uint16_t cause_code,
__u16 cause_code,
const void *payload,
size_t paylen);
void sctp_chunk_assign_tsn(sctp_chunk_t *);
......@@ -305,20 +302,20 @@ sctp_sackhdr_t *sctp_sm_pull_sack(sctp_chunk_t *);
sctp_cookie_param_t *
sctp_pack_cookie(const sctp_endpoint_t *, const sctp_association_t *,
const sctp_chunk_t *, int *cookie_len,
const uint8_t *, int addrs_len);
sctp_association_t *sctp_unpack_cookie(const sctp_endpoint_t *,
const __u8 *, int addrs_len);
sctp_association_t *sctp_unpack_cookie(const sctp_endpoint_t *,
const sctp_association_t *,
sctp_chunk_t *, int priority, int *err);
int sctp_addip_addr_config(sctp_association_t *, sctp_param_t,
struct sockaddr_storage*, int);
/* 3rd level prototypes */
uint32_t sctp_generate_tag(const sctp_endpoint_t *);
uint32_t sctp_generate_tsn(const sctp_endpoint_t *);
__u32 sctp_generate_tag(const sctp_endpoint_t *);
__u32 sctp_generate_tsn(const sctp_endpoint_t *);
/* 4th level prototypes */
void sctp_param2sockaddr(sockaddr_storage_t *addr, const sctpParam_t param,
uint16_t port);
__u16 port);
int sctp_addr2sockaddr(const sctpParam_t, sockaddr_storage_t *);
int sockaddr2sctp_addr(const sockaddr_storage_t *, sctpParam_t);
......@@ -336,17 +333,15 @@ extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
/* Get the size of a DATA chunk payload. */
static inline uint16_t
sctp_data_size(sctp_chunk_t *chunk)
static inline __u16 sctp_data_size(sctp_chunk_t *chunk)
{
uint16_t size;
__u16 size;
size = ntohs(chunk->chunk_hdr->length);
size -= sizeof(sctp_data_chunk_t);
return(size);
} /* sctp_data_size( ) */
return size;
}
/* Compare two TSNs */
......@@ -366,12 +361,12 @@ sctp_data_size(sctp_chunk_t *chunk)
* s2, and
*
* (i1 < i2 and i2 - i1 > 2^(SERIAL_BITS - 1)) or
* (i1 > i2 and i1 - i2 < 2^(SERIAL_BITS - 1))
* (i1 > i2 and i1 - i2 < 2^(SERIAL_BITS - 1))
*/
/*
* RFC 2960
* 1.6 Serial Number Arithmetic
* 1.6 Serial Number Arithmetic
*
* Comparisons and arithmetic on TSNs in this document SHOULD use Serial
* Number Arithmetic as defined in [RFC1982] where SERIAL_BITS = 32.
......@@ -381,14 +376,12 @@ enum {
TSN_SIGN_BIT = (1<<31)
};
static inline int
TSN_lt(__u32 s, __u32 t)
static inline int TSN_lt(__u32 s, __u32 t)
{
return (((s) - (t)) & TSN_SIGN_BIT);
}
static inline int
TSN_lte(__u32 s, __u32 t)
static inline int TSN_lte(__u32 s, __u32 t)
{
return (((s) == (t)) || (((s) - (t)) & TSN_SIGN_BIT));
}
......@@ -397,37 +390,31 @@ TSN_lte(__u32 s, __u32 t)
/*
* RFC 2960
* 1.6 Serial Number Arithmetic
* 1.6 Serial Number Arithmetic
*
* Comparisons and arithmetic on Stream Sequence Numbers in this document
* SHOULD use Serial Number Arithmetic as defined in [RFC1982] where
* Comparisons and arithmetic on Stream Sequence Numbers in this document
* SHOULD use Serial Number Arithmetic as defined in [RFC1982] where
* SERIAL_BITS = 16.
*/
enum {
SSN_SIGN_BIT = (1<<15)
};
static inline int
SSN_lt(__u16 s, __u16 t)
static inline int SSN_lt(__u16 s, __u16 t)
{
return (((s) - (t)) & SSN_SIGN_BIT);
}
static inline int
SSN_lte(__u16 s, __u16 t)
static inline int SSN_lte(__u16 s, __u16 t)
{
return (((s) == (t)) || (((s) - (t)) & SSN_SIGN_BIT));
}
/* Run sctp_add_cmd() generating a BUG() if there is a failure. */
static inline void
sctp_add_cmd_sf(sctp_cmd_seq_t *seq, sctp_verb_t verb, sctp_arg_t obj)
static inline void sctp_add_cmd_sf(sctp_cmd_seq_t *seq, sctp_verb_t verb, sctp_arg_t obj)
{
if (unlikely(!sctp_add_cmd(seq, verb, obj))) {
if (unlikely(!sctp_add_cmd(seq, verb, obj)))
BUG();
}
} /* sctp_add_cmd_sf() */
}
#endif /* __sctp_sm_h__ */
This diff is collapsed.
......@@ -52,77 +52,76 @@
*/
typedef struct sctp_tsnmap {
/* This array counts the number of chunks with each TSN.
* It points at one of the two buffers with which we will
* ping-pong between.
* ping-pong between.
*/
uint8_t *tsn_map;
__u8 *tsn_map;
/* This marks the tsn which overflows the tsn_map, when the
* cumulative ack point reaches this point we know we can switch
* maps (tsn_map and overflow_map swap).
*/
uint32_t overflow_tsn;
__u32 overflow_tsn;
/* This is the overflow array for tsn_map.
* It points at one of the other ping-pong buffers.
*/
uint8_t *overflow_map;
__u8 *overflow_map;
/* This is the TSN at tsn_map[0]. */
uint32_t base_tsn;
__u32 base_tsn;
/* Last Rcvd : This is the last TSN received in
/* Last Rcvd : This is the last TSN received in
* TSN : sequence. This value is set initially by
* : taking the peer's Initial TSN, received in
* : the INIT or INIT ACK chunk, and subtracting
* : one from it.
* : one from it.
*
* Throughout most of the specification this is called the
* "Cumulative TSN ACK Point". In this case, we
* ignore the advice in 12.2 in favour of the term
* used in the bulk of the text.
*/
uint32_t cumulative_tsn_ack_point;
*/
__u32 cumulative_tsn_ack_point;
/* This is the minimum number of TSNs we can track. This corresponds
* to the size of tsn_map. Note: the overflow_map allows us to
* potentially track more than this quantity.
* to the size of tsn_map. Note: the overflow_map allows us to
* potentially track more than this quantity.
*/
uint16_t len;
__u16 len;
/* This is the highest TSN we've marked. */
uint32_t max_tsn_seen;
__u32 max_tsn_seen;
/* No. of data chunks pending receipt. used by SCTP_STATUS sockopt */
uint16_t pending_data;
__u16 pending_data;
int malloced;
uint8_t raw_map[0];
__u8 raw_map[0];
} sctp_tsnmap_t;
typedef struct sctp_tsnmap_iter {
uint32_t start;
__u32 start;
} sctp_tsnmap_iter_t;
/* Create a new tsnmap. */
sctp_tsnmap_t *sctp_tsnmap_new(uint16_t len, uint32_t initial_tsn,
sctp_tsnmap_t *sctp_tsnmap_new(__u16 len, __u32 initial_tsn,
int priority);
/* Dispose of a tsnmap. */
void sctp_tsnmap_free(sctp_tsnmap_t *map);
/* This macro assists in creation of external storage for variable length
/* This macro assists in creation of external storage for variable length
* internal buffers. We double allocate so the overflow map works.
*/
#define sctp_tsnmap_storage_size(count) (sizeof(uint8_t) * (count) * 2)
#define sctp_tsnmap_storage_size(count) (sizeof(__u8) * (count) * 2)
/* Initialize a block of memory as a tsnmap. */
sctp_tsnmap_t *sctp_tsnmap_init(sctp_tsnmap_t *map, uint16_t len,
uint32_t initial_tsn);
sctp_tsnmap_t *sctp_tsnmap_init(sctp_tsnmap_t *map, __u16 len, __u32 initial_tsn);
......@@ -132,16 +131,16 @@ sctp_tsnmap_t *sctp_tsnmap_init(sctp_tsnmap_t *map, uint16_t len,
* >0 if the TSN has been seen (duplicate)
* <0 if the TSN is invalid (too large to track)
*/
int sctp_tsnmap_check(const sctp_tsnmap_t *map, uint32_t tsn);
int sctp_tsnmap_check(const sctp_tsnmap_t *map, __u32 tsn);
/* Mark this TSN as seen. */
void sctp_tsnmap_mark(sctp_tsnmap_t *map, uint32_t tsn);
void sctp_tsnmap_mark(sctp_tsnmap_t *map, __u32 tsn);
/* Retrieve the Cumulative TSN ACK Point. */
uint32_t sctp_tsnmap_get_ctsn(const sctp_tsnmap_t *map);
__u32 sctp_tsnmap_get_ctsn(const sctp_tsnmap_t *map);
/* Retrieve the highest TSN we've seen. */
uint32_t sctp_tsnmap_get_max_tsn_seen(const sctp_tsnmap_t *map);
__u32 sctp_tsnmap_get_max_tsn_seen(const sctp_tsnmap_t *map);
/* Is there a gap in the TSN map? */
int sctp_tsnmap_has_gap(const sctp_tsnmap_t *map);
......@@ -152,9 +151,8 @@ void sctp_tsnmap_iter_init(const sctp_tsnmap_t *map, sctp_tsnmap_iter_t *iter);
/* Get the next gap ack blocks. We return 0 if there are no more
* gap ack blocks.
*/
int
sctp_tsnmap_next_gap_ack(const sctp_tsnmap_t *map, sctp_tsnmap_iter_t *iter,
uint16_t *start, uint16_t *end);
int sctp_tsnmap_next_gap_ack(const sctp_tsnmap_t *map, sctp_tsnmap_iter_t *iter,
__u16 *start, __u16 *end);
#endif /* __sctp_tsnmap_h__ */
......
......@@ -45,8 +45,8 @@
#define __sctp_ulpevent_h__
/* A structure to carry information to the ULP (e.g. Sockets API) */
/* Warning: This sits inside an skb.cb[] area. Be very careful of
* growing this structure as it is at the maximum limit now.
/* Warning: This sits inside an skb.cb[] area. Be very careful of
* growing this structure as it is at the maximum limit now.
*/
typedef struct sctp_ulpevent {
int malloced;
......@@ -58,83 +58,73 @@ typedef struct sctp_ulpevent {
} sctp_ulpevent_t;
sctp_ulpevent_t *
sctp_ulpevent_new(int size, int msg_flags, int priority);
sctp_ulpevent_t *sctp_ulpevent_new(int size, int msg_flags, int priority);
sctp_ulpevent_t *
sctp_ulpevent_init(sctp_ulpevent_t *event, struct sk_buff *skb, int msg_flags);
sctp_ulpevent_t *sctp_ulpevent_init(sctp_ulpevent_t *event, struct sk_buff *skb, int msg_flags);
void
sctp_ulpevent_free(sctp_ulpevent_t *event);
void sctp_ulpevent_free(sctp_ulpevent_t *event);
int sctp_ulpevent_is_notification(const sctp_ulpevent_t *event);
int
sctp_ulpevent_is_notification(const sctp_ulpevent_t *event);
sctp_ulpevent_t *
sctp_ulpevent_make_assoc_change(const struct SCTP_association *asoc,
uint16_t flags,
uint16_t state,
uint16_t error,
uint16_t outbound,
uint16_t inbound,
sctp_ulpevent_t *sctp_ulpevent_make_assoc_change(
const struct SCTP_association *asoc,
__u16 flags,
__u16 state,
__u16 error,
__u16 outbound,
__u16 inbound,
int priority);
sctp_ulpevent_t *
sctp_ulpevent_make_peer_addr_change(const struct SCTP_association *asoc,
const struct sockaddr_storage *aaddr,
int flags,
int state,
int error,
int priority);
sctp_ulpevent_t *sctp_ulpevent_make_peer_addr_change(
const struct SCTP_association *asoc,
const struct sockaddr_storage *aaddr,
int flags,
int state,
int error,
int priority);
sctp_ulpevent_t *
sctp_ulpevent_make_remote_error(const struct SCTP_association *asoc,
sctp_ulpevent_t *sctp_ulpevent_make_remote_error(
const struct SCTP_association *asoc,
struct SCTP_chunk *chunk,
__u16 flags,
int priority);
sctp_ulpevent_t *sctp_ulpevent_make_send_failed(
const struct SCTP_association *asoc,
struct SCTP_chunk *chunk,
uint16_t flags,
__u16 flags,
__u32 error,
int priority);
sctp_ulpevent_t *
sctp_ulpevent_make_send_failed(const struct SCTP_association *asoc,
struct SCTP_chunk *chunk,
uint16_t flags,
uint32_t error,
int priority);
sctp_ulpevent_t *
sctp_ulpevent_make_shutdown_event(const struct SCTP_association *asoc,
uint16_t flags,
int priority);
sctp_ulpevent_t *sctp_ulpevent_make_shutdown_event(
const struct SCTP_association *asoc,
__u16 flags,
int priority);
sctp_ulpevent_t *
sctp_ulpevent_make_rcvmsg(struct SCTP_association *asoc,
struct SCTP_chunk *chunk,
int priority);
sctp_ulpevent_t *sctp_ulpevent_make_rcvmsg(struct SCTP_association *asoc,
struct SCTP_chunk *chunk,
int priority);
void
sctp_ulpevent_read_sndrcvinfo(const sctp_ulpevent_t *event,
struct msghdr *msghdr);
void sctp_ulpevent_read_sndrcvinfo(const sctp_ulpevent_t *event,
struct msghdr *msghdr);
uint16_t
sctp_ulpevent_get_notification_type(const sctp_ulpevent_t *event);
__u16 sctp_ulpevent_get_notification_type(const sctp_ulpevent_t *event);
/* Given an event subscription, is this event enabled? */
static inline int
sctp_ulpevent_is_enabled(const sctp_ulpevent_t *event,
const struct sctp_event_subscribe *mask)
static inline int sctp_ulpevent_is_enabled(const sctp_ulpevent_t *event,
const struct sctp_event_subscribe *mask)
{
const char *amask = (const char *)mask;
uint16_t sn_type;
const char *amask = (const char *) mask;
__u16 sn_type;
int enabled = 1;
if (sctp_ulpevent_is_notification(event)) {
sn_type = sctp_ulpevent_get_notification_type(event);
enabled = amask[sn_type - SCTP_SN_TYPE_BASE];
}
return(enabled);
} /* sctp_ulpevent_is_enabled() */
return enabled;
}
#endif /* __sctp_ulpevent_h__ */
......
......@@ -50,47 +50,40 @@ typedef struct sctp_ulpqueue {
sctp_association_t *asoc;
struct sk_buff_head reasm;
struct sk_buff_head lobby;
uint16_t ssn[0];
__u16 ssn[0];
} sctp_ulpqueue_t;
/* This macro assists in creation of external storage for variable length
* internal buffers.
/* This macro assists in creation of external storage for variable length
* internal buffers.
*/
#define sctp_ulpqueue_storage_size(inbound) (sizeof(uint16_t) * (inbound))
#define sctp_ulpqueue_storage_size(inbound) (sizeof(__u16) * (inbound))
sctp_ulpqueue_t *
sctp_ulpqueue_new(sctp_association_t *asoc,
uint16_t inbound,
int priority);
sctp_ulpqueue_t *sctp_ulpqueue_new(sctp_association_t *asoc,
__u16 inbound,
int priority);
sctp_ulpqueue_t *
sctp_ulpqueue_init(sctp_ulpqueue_t *ulpq,
sctp_association_t *asoc,
uint16_t inbound);
sctp_ulpqueue_t *sctp_ulpqueue_init(sctp_ulpqueue_t *ulpq,
sctp_association_t *asoc,
__u16 inbound);
void
sctp_ulpqueue_free(sctp_ulpqueue_t *);
void sctp_ulpqueue_free(sctp_ulpqueue_t *);
/* Add a new DATA chunk for processing. */
int
sctp_ulpqueue_tail_data(sctp_ulpqueue_t *,
sctp_chunk_t *chunk,
int priority);
int sctp_ulpqueue_tail_data(sctp_ulpqueue_t *,
sctp_chunk_t *chunk,
int priority);
/* Add a new event for propogation to the ULP. */
int
sctp_ulpqueue_tail_event(sctp_ulpqueue_t *,
sctp_ulpevent_t *event);
int sctp_ulpqueue_tail_event(sctp_ulpqueue_t *,
sctp_ulpevent_t *event);
/* Is the ulpqueue empty. */
int
sctp_ulpqueue_is_empty(sctp_ulpqueue_t *);
int sctp_ulpqueue_is_empty(sctp_ulpqueue_t *);
int
sctp_ulpqueue_is_data_empty(sctp_ulpqueue_t *);
int sctp_ulpqueue_is_data_empty(sctp_ulpqueue_t *);
#endif /* __sctp_ulpqueue_h__ */
......
This diff is collapsed.
......@@ -17,6 +17,11 @@ CONFIG_IP_SCTP
-- network-level fault tolerance through supporting of multi-
homing at either or both ends of an association."
This protocol support is also available as a module ( = code which
can be inserted in and removed from the running kernel whenever you
want). The module will be called sctp.o. If you want to compile it
as a module, say M here and read <file:Documentation/modules.txt>.
If in doubt, say N.
CONFIG_SCTP_ADLER32
......
......@@ -4,25 +4,25 @@
obj-$(CONFIG_IP_SCTP) += sctp.o
obj-y := sctp_sm_statetable.o sctp_sm_statefuns.o sctp_sm_sideeffect.o \
sctp_protocol.o sctp_endpointola.o sctp_associola.o \
sctp_transport.o sctp_sm_make_chunk.o sctp_ulpevent.o \
sctp_inqueue.o sctp_outqueue.o sctp_ulpqueue.o sctp_command.o \
sctp_tsnmap.o sctp_bind_addr.o sctp_socket.o sctp_primitive.o \
sctp_output.o sctp_input.o sctp_hashdriver.o sctp_sla1.o \
sctp_debug.o
sctp-y := sctp_sm_statetable.o sctp_sm_statefuns.o sctp_sm_sideeffect.o \
sctp_protocol.o sctp_endpointola.o sctp_associola.o \
sctp_transport.o sctp_sm_make_chunk.o sctp_ulpevent.o \
sctp_inqueue.o sctp_outqueue.o sctp_ulpqueue.o sctp_command.o \
sctp_tsnmap.o sctp_bind_addr.o sctp_socket.o sctp_primitive.o \
sctp_output.o sctp_input.o sctp_hashdriver.o sctp_sla1.o \
sctp_debug.o
ifeq ($(CONFIG_SCTP_ADLER32), y)
obj-y += sctp_adler32.o
sctp-y += sctp_adler32.o
else
obj-y += sctp_crc32c.o
sctp-y += sctp_crc32c.o
endif
obj-$(CONFIG_SCTP_DBG_OBJCNT) += sctp_objcnt.o
obj-$(CONFIG_SYSCTL) += sctp_sysctl.o
sctp-$(CONFIG_SCTP_DBG_OBJCNT) += sctp_objcnt.o
sctp-$(CONFIG_SYSCTL) += sctp_sysctl.o
obj-$(subst m,y,$(CONFIG_IPV6)) += sctp_ipv6.o
sctp-$(subst m,y,$(CONFIG_IPV6)) += sctp_ipv6.o
sctp-objs := $(obj-y)
sctp-objs := $(sctp-y)
include $(TOPDIR)/Rules.make
......@@ -47,21 +47,21 @@ static char *cvs_id __attribute__ ((unused)) = "$Id: sctp_adler32.c,v 1.5 2002/0
/* This is an entry point for external calls
* Define this function in the header file. This is
* direct from rfc1950, ...
*
* The following C code computes the Adler-32 checksum of a data buffer.
It is written for clarity, not for speed. The sample code is in the
ANSI C programming language. Non C users may find it easier to read
with these hints:
& Bitwise AND operator.
>> Bitwise right shift operator. When applied to an
unsigned quantity, as here, right shift inserts zero bit(s)
at the left.
<< Bitwise left shift operator. Left shift inserts zero
bit(s) at the right.
++ "n++" increments the variable n.
% modulo operator: a % b is the remainder of a divided by b.
* It is written for clarity, not for speed. The sample code is in the
* ANSI C programming language. Non C users may find it easier to read
* with these hints:
*
* & Bitwise AND operator.
* >> Bitwise right shift operator. When applied to an
* unsigned quantity, as here, right shift inserts zero bit(s)
* at the left.
* << Bitwise left shift operator. Left shift inserts zero
* bit(s) at the right.
* ++ "n++" increments the variable n.
* % modulo operator: a % b is the remainder of a divided by b.
*
* Well, the above is a bit of a lie, I have optimized this a small
* tad, but I have commented the original lines below
*/
......@@ -81,71 +81,70 @@ static char *cvs_id __attribute__ ((unused)) = "$Id: sctp_adler32.c,v 1.5 2002/0
* it back and we will incorporate it :-)
*/
unsigned long update_adler32(unsigned long adler,
unsigned char *buf, int len)
{
uint32_t s1 = adler & 0xffff;
uint32_t s2 = (adler >> 16) & 0xffff;
__u32 s1 = adler & 0xffff;
__u32 s2 = (adler >> 16) & 0xffff;
int n;
for (n = 0; n < len; n++,buf++) {
/* s1 = (s1 + buf[n]) % BASE */
/* first we add */
s1 = (s1 + *buf);
/* Now if we need to, we do a mod by
* subtracting. It seems a bit faster
* since I really will only ever do
* one subtract at the MOST, since buf[n]
* is a max of 255.
*/
if(s1 >= BASE){
s1 -= BASE;
}
/* s2 = (s2 + s1) % BASE */
/* first we add */
s2 = (s2 + s1);
/* again, it is more efficent (it seems) to
* subtract since the most s2 will ever be
* is (BASE-1 + BASE-1) in the worse case.
* This would then be (2 * BASE) - 2, which
* will still only do one subtract. On Intel
* this is much better to do this way and
* avoid the divide. Have not -pg'd on
* sparc.
*/
if(s2 >= BASE){
/* s2 %= BASE;*/
s2 -= BASE;
}
}
/* Return the adler32 of the bytes buf[0..len-1] */
return (s2 << 16) + s1;
for (n = 0; n < len; n++,buf++) {
/* s1 = (s1 + buf[n]) % BASE */
/* first we add */
s1 = (s1 + *buf);
/* Now if we need to, we do a mod by
* subtracting. It seems a bit faster
* since I really will only ever do
* one subtract at the MOST, since buf[n]
* is a max of 255.
*/
if(s1 >= BASE)
s1 -= BASE;
/* s2 = (s2 + s1) % BASE */
/* first we add */
s2 = (s2 + s1);
/* again, it is more efficent (it seems) to
* subtract since the most s2 will ever be
* is (BASE-1 + BASE-1) in the worse case.
* This would then be (2 * BASE) - 2, which
* will still only do one subtract. On Intel
* this is much better to do this way and
* avoid the divide. Have not -pg'd on
* sparc.
*/
if (s2 >= BASE) {
/* s2 %= BASE;*/
s2 -= BASE;
}
}
/* Return the adler32 of the bytes buf[0..len-1] */
return (s2 << 16) + s1;
}
uint32_t
count_crc(uint8_t *ptr,
uint16_t count)
__u32 count_crc(__u8 *ptr, __u16 count)
{
/*
* Update a running Adler-32 checksum with the bytes
* buf[0..len-1] and return the updated checksum. The Adler-32
* checksum should be initialized to 1.
*/
uint32_t adler = 1L;
uint32_t zero = 0L;
/*
* Update a running Adler-32 checksum with the bytes
* buf[0..len-1] and return the updated checksum. The Adler-32
* checksum should be initialized to 1.
*/
__u32 adler = 1L;
__u32 zero = 0L;
/* Calculate the CRC up to the checksum field. */
adler = update_adler32(adler, ptr,
sizeof(struct sctphdr) - sizeof(uint32_t));
adler = update_adler32(adler, ptr,
sizeof(struct sctphdr) - sizeof(__u32));
/* Skip over the checksum field. */
adler = update_adler32(adler, &zero, sizeof(uint32_t));
adler = update_adler32(adler, &zero, sizeof(__u32));
ptr += sizeof(struct sctphdr);
count -= sizeof(struct sctphdr);
/* Calculate the rest of the Adler-32. */
adler = update_adler32(adler, ptr, count);
return(adler);
}
return adler;
}
This diff is collapsed.
This diff is collapsed.
......@@ -42,82 +42,67 @@
static char *cvs_id __attribute__ ((unused)) = "$Id: sctp_command.c,v 1.4 2002/04/24 16:33:39 jgrimm Exp $";
#include <linux/config.h>
#include <linux/types.h>
#include <net/sctp/sctp.h>
#include <net/sctp/sctp_sm.h>
/* Create a new sctp_command_sequence. */
sctp_cmd_seq_t *
sctp_new_cmd_seq(int priority)
sctp_cmd_seq_t *sctp_new_cmd_seq(int priority)
{
sctp_cmd_seq_t *retval;
retval = t_new(sctp_cmd_seq_t, priority);
sctp_cmd_seq_t *retval = t_new(sctp_cmd_seq_t, priority);
/* XXX Check for NULL? -DaveM */
sctp_init_cmd_seq(retval);
return retval;
} /* sctp_new_cmd_seq() */
}
/* Initialize a block of memory as a command sequence. */
int
sctp_init_cmd_seq(sctp_cmd_seq_t *seq)
int sctp_init_cmd_seq(sctp_cmd_seq_t *seq)
{
memset(seq, 0, sizeof(sctp_cmd_seq_t));
return 1; /* We always succeed. */
} /* sctp_init_cmd_seq() */
}
/* Add a command to a sctp_cmd_seq_t.
* Return 0 if the command sequence is full.
*/
int
sctp_add_cmd(sctp_cmd_seq_t *seq, sctp_verb_t verb, sctp_arg_t obj)
int sctp_add_cmd(sctp_cmd_seq_t *seq, sctp_verb_t verb, sctp_arg_t obj)
{
if (seq->next_free_slot >= SCTP_MAX_NUM_COMMANDS) {
if (seq->next_free_slot >= SCTP_MAX_NUM_COMMANDS)
goto fail;
}
seq->cmds[seq->next_free_slot].verb = verb;
seq->cmds[seq->next_free_slot++].obj = obj;
return 1;
fail:
return 0;
} /* sctp_add_cmd() */
fail:
return 0;
}
/* Rewind an sctp_cmd_seq_t to iterate from the start. */
int
sctp_rewind_sequence(sctp_cmd_seq_t *seq)
int sctp_rewind_sequence(sctp_cmd_seq_t *seq)
{
seq->next_cmd = 0;
return 1; /* We always succeed. */
} /* sctp_rewind_sequence() */
}
/* Return the next command structure in a sctp_cmd_seq.
* Returns NULL at the end of the sequence.
*/
sctp_cmd_t *
sctp_next_cmd(sctp_cmd_seq_t *seq)
sctp_cmd_t *sctp_next_cmd(sctp_cmd_seq_t *seq)
{
sctp_cmd_t *retval = NULL;
if (seq->next_cmd < seq->next_free_slot) {
if (seq->next_cmd < seq->next_free_slot)
retval = &seq->cmds[seq->next_cmd++];
}
return retval;
} /* sctp_next_cmd() */
}
/* Dispose of a command sequence. */
void
sctp_free_cmd_seq(sctp_cmd_seq_t *seq)
void sctp_free_cmd_seq(sctp_cmd_seq_t *seq)
{
kfree(seq);
} /* sctp_free_cmd_seq() */
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment