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

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

parent f82c185f
...@@ -140,7 +140,7 @@ extern int sctp_primitive_SEND(sctp_association_t *, void *arg); ...@@ -140,7 +140,7 @@ extern int sctp_primitive_SEND(sctp_association_t *, void *arg);
/* /*
* sctp_crc32c.c * sctp_crc32c.c
*/ */
extern uint32_t count_crc(uint8_t *ptr, uint16_t count); extern __u32 count_crc(__u8 *ptr, __u16 count);
/* /*
* sctp_input.c * sctp_input.c
...@@ -161,7 +161,7 @@ extern void __sctp_unhash_endpoint(sctp_endpoint_t *); ...@@ -161,7 +161,7 @@ extern void __sctp_unhash_endpoint(sctp_endpoint_t *);
*/ */
extern void sctp_hash_digest(const char *secret, const int secret_len, extern void sctp_hash_digest(const char *secret, const int secret_len,
const char *text, const int text_len, const char *text, const int text_len,
uint8_t *digest); __u8 *digest);
/* /*
* Section: Macros, externs, and inlines * Section: Macros, externs, and inlines
...@@ -197,29 +197,23 @@ extern void sctp_hash_digest(const char *secret, const int secret_len, ...@@ -197,29 +197,23 @@ extern void sctp_hash_digest(const char *secret, const int secret_len,
#define SCTP_SOCK_SLEEP_POST(sk) SOCK_SLEEP_POST(sk) #define SCTP_SOCK_SLEEP_POST(sk) SOCK_SLEEP_POST(sk)
/* Determine if this is a valid kernel address. /* Determine if this is a valid kernel address. */
*/ static inline int sctp_is_valid_kaddr(unsigned long addr)
static inline int
sctp_is_valid_kaddr(unsigned long addr)
{ {
struct page *page; struct page *page;
/* Make sure the address is not in the user address space. */ /* Make sure the address is not in the user address space. */
if (addr < PAGE_OFFSET) { if (addr < PAGE_OFFSET)
return 0; return 0;
}
page = virt_to_page(addr); page = virt_to_page(addr);
/* Is this page valid? */ /* Is this page valid? */
if (!virt_addr_valid(addr) || PageReserved(page)) { if (!virt_addr_valid(addr) || PageReserved(page))
return 0; return 0;
}
return 1; return 1;
}
} /* sctp_is_valid_kaddr() */
#endif /* !TEST_FRAME */ #endif /* !TEST_FRAME */
...@@ -262,8 +256,7 @@ extern atomic_t sctp_dbg_objcnt_chunk; ...@@ -262,8 +256,7 @@ extern atomic_t sctp_dbg_objcnt_chunk;
extern atomic_t sctp_dbg_objcnt_bind_addr; extern atomic_t sctp_dbg_objcnt_bind_addr;
extern atomic_t sctp_dbg_objcnt_addr; extern atomic_t sctp_dbg_objcnt_addr;
/* Macros to atomically increment/decrement objcnt counters. /* Macros to atomically increment/decrement objcnt counters. */
*/
#define SCTP_DBG_OBJCNT_INC(name) \ #define SCTP_DBG_OBJCNT_INC(name) \
atomic_inc(&sctp_dbg_objcnt_## name) atomic_inc(&sctp_dbg_objcnt_## name)
#define SCTP_DBG_OBJCNT_DEC(name) \ #define SCTP_DBG_OBJCNT_DEC(name) \
...@@ -304,13 +297,12 @@ static inline void sctp_sysctl_unregister(void) { return; } ...@@ -304,13 +297,12 @@ static inline void sctp_sysctl_unregister(void) { return; }
extern int sctp_v6_init(void); extern int sctp_v6_init(void);
extern void sctp_v6_exit(void); extern void sctp_v6_exit(void);
static inline int static inline int sctp_ipv6_addr_type(const struct in6_addr *addr)
sctp_ipv6_addr_type(const struct in6_addr* addr)
{ {
return(ipv6_addr_type((struct in6_addr*)addr)); return ipv6_addr_type((struct in6_addr*) addr);
} }
#define SCTP_SAT_LEN (sizeof(sctp_paramhdr_t) + 2 * sizeof(uint16_t)) #define SCTP_SAT_LEN (sizeof(sctp_paramhdr_t) + 2 * sizeof(__u16))
/* Note: These V6 macros are obsolescent. */ /* Note: These V6 macros are obsolescent. */
/* Use this macro to enclose code fragments which are V6-dependent. */ /* Use this macro to enclose code fragments which are V6-dependent. */
...@@ -320,49 +312,41 @@ sctp_ipv6_addr_type(const struct in6_addr* addr) ...@@ -320,49 +312,41 @@ sctp_ipv6_addr_type(const struct in6_addr* addr)
#else /* #ifdef defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ #else /* #ifdef defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */
#define sctp_ipv6_addr_type(a) 0 #define sctp_ipv6_addr_type(a) 0
#define SCTP_SAT_LEN (sizeof(sctp_paramhdr_t) + 1 * sizeof(uint16_t)) #define SCTP_SAT_LEN (sizeof(sctp_paramhdr_t) + 1 * sizeof(__u16))
#define SCTP_V6(m...) /* Do nothing. */ #define SCTP_V6(m...) /* Do nothing. */
#undef SCTP_V6_SUPPORT #undef SCTP_V6_SUPPORT
static inline int sctp_v6_init(void) { return 0; } static inline int sctp_v6_init(void) { return 0; }
static inline void sctp_v6_exit(void) {return; } static inline void sctp_v6_exit(void) { return; }
#endif /* #ifdef defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ #endif /* #ifdef defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */
/* Map an association to an assoc_id. */ /* Map an association to an assoc_id. */
static inline sctp_assoc_t static inline sctp_assoc_t sctp_assoc2id(const sctp_association_t *asoc)
sctp_assoc2id(const sctp_association_t *asoc)
{ {
return ((sctp_assoc_t)asoc); return (sctp_assoc_t) asoc;
}
} /* sctp_assoc2id() */
/* Look up the association by its id. /* Look up the association by its id. */
*/ static inline sctp_association_t *sctp_id2assoc(const struct sock *sk, sctp_assoc_t id)
static inline sctp_association_t *
sctp_id2assoc(const struct sock *sk, sctp_assoc_t id)
{ {
sctp_association_t *asoc = NULL; sctp_association_t *asoc = NULL;
/* First, verify that this is a kernel address. */ /* First, verify that this is a kernel address. */
if (sctp_is_valid_kaddr((unsigned long)id)) { if (sctp_is_valid_kaddr((unsigned long) id)) {
sctp_association_t *temp; sctp_association_t *temp = (sctp_association_t *) id;
temp = (sctp_association_t *)id;
/* Verify that this _is_ an sctp_association_t /* Verify that this _is_ an sctp_association_t
* data structure and if so, that the socket matches. * data structure and if so, that the socket matches.
*/ */
if ((SCTP_ASSOC_EYECATCHER == temp->eyecatcher) if ((SCTP_ASSOC_EYECATCHER == temp->eyecatcher) &&
&& (temp->base.sk == sk)) { (temp->base.sk == sk))
asoc = temp; asoc = temp;
} }
}
return(asoc);
} /* sctp_id2assoc() */ return asoc;
}
/* A macro to walk a list of skbs. */ /* A macro to walk a list of skbs. */
#define sctp_skb_for_each(pos, head, tmp) \ #define sctp_skb_for_each(pos, head, tmp) \
...@@ -372,8 +356,7 @@ for (pos = (head)->next;\ ...@@ -372,8 +356,7 @@ for (pos = (head)->next;\
/* A helper to append an entire skb list (list) to another (head). */ /* A helper to append an entire skb list (list) to another (head). */
static inline void static inline void sctp_skb_list_tail(struct sk_buff_head *list,
sctp_skb_list_tail(struct sk_buff_head *list,
struct sk_buff_head *head) struct sk_buff_head *head)
{ {
int flags __attribute__ ((unused)); int flags __attribute__ ((unused));
...@@ -388,8 +371,7 @@ sctp_skb_list_tail(struct sk_buff_head *list, ...@@ -388,8 +371,7 @@ sctp_skb_list_tail(struct sk_buff_head *list,
sctp_spin_unlock(&list->lock); sctp_spin_unlock(&list->lock);
sctp_spin_unlock_irqrestore(&head->lock, flags); sctp_spin_unlock_irqrestore(&head->lock, flags);
}
} /* sctp_skb_list_tail() */
/** /**
* sctp_list_dequeue - remove from the head of the queue * sctp_list_dequeue - remove from the head of the queue
...@@ -399,38 +381,31 @@ sctp_skb_list_tail(struct sk_buff_head *list, ...@@ -399,38 +381,31 @@ sctp_skb_list_tail(struct sk_buff_head *list,
* returned or %NULL if the list is empty. * returned or %NULL if the list is empty.
*/ */
static inline struct list_head * static inline struct list_head *sctp_list_dequeue(struct list_head *list)
sctp_list_dequeue(struct list_head *list)
{ {
struct list_head *result; struct list_head *result = NULL;
result = (void *) 0; if (list->next != list) {
if ( list->next != list ) {
result = list->next; result = list->next;
list->next = result->next; list->next = result->next;
list->next->prev = list; list->next->prev = list;
INIT_LIST_HEAD(result); INIT_LIST_HEAD(result);
} }
return result; return result;
}
} /* sctp_list_dequeue() */
/* Calculate the size (in bytes) occupied by the data of an iovec. */ /* Calculate the size (in bytes) occupied by the data of an iovec. */
static inline size_t static inline size_t get_user_iov_size(struct iovec *iov, int iovlen)
get_user_iov_size(struct iovec *iov, int iovlen) { {
size_t retval; size_t retval = 0;
retval = 0;
for (; iovlen > 0; --iovlen) { for (; iovlen > 0; --iovlen) {
retval += iov->iov_len; retval += iov->iov_len;
iov++; iov++;
} }
return(retval); return retval;
}
} /* get_user_iov_size() */
/* Round an int up to the next multiple of 4. */ /* Round an int up to the next multiple of 4. */
...@@ -446,8 +421,7 @@ get_user_iov_size(struct iovec *iov, int iovlen) { ...@@ -446,8 +421,7 @@ get_user_iov_size(struct iovec *iov, int iovlen) {
/* Stolen from net/profile.h. Using it from there is more grief than /* Stolen from net/profile.h. Using it from there is more grief than
* it is worth. * it is worth.
*/ */
static inline void static inline void tv_add(const struct timeval *entered, struct timeval *leaved)
tv_add(const struct timeval *entered, struct timeval *leaved)
{ {
time_t usecs = leaved->tv_usec + entered->tv_usec; time_t usecs = leaved->tv_usec + entered->tv_usec;
time_t secs = leaved->tv_sec + entered->tv_sec; time_t secs = leaved->tv_sec + entered->tv_sec;
...@@ -458,8 +432,7 @@ tv_add(const struct timeval *entered, struct timeval *leaved) ...@@ -458,8 +432,7 @@ tv_add(const struct timeval *entered, struct timeval *leaved)
} }
leaved->tv_sec = secs; leaved->tv_sec = secs;
leaved->tv_usec = usecs; leaved->tv_usec = usecs;
}
} /* tv_add() */
/* External references. */ /* External references. */
...@@ -473,51 +446,44 @@ extern void sctp_put_port(struct sock *sk); ...@@ -473,51 +446,44 @@ extern void sctp_put_port(struct sock *sk);
/* Return the SCTP protocol structure. */ /* Return the SCTP protocol structure. */
static inline sctp_protocol_t *sctp_get_protocol(void) static inline sctp_protocol_t *sctp_get_protocol(void)
{ {
return(&sctp_proto); return &sctp_proto;
}
} /* sctp_get_protocol() */
/* Warning: The following hash functions assume a power of two 'size'. */ /* Warning: The following hash functions assume a power of two 'size'. */
/* This is the hash function for the SCTP port hash table. */ /* This is the hash function for the SCTP port hash table. */
static inline int sctp_phashfn(uint16_t lport) static inline int sctp_phashfn(__u16 lport)
{ {
sctp_protocol_t *sctp_proto = sctp_get_protocol(); sctp_protocol_t *sctp_proto = sctp_get_protocol();
return (lport & (sctp_proto->port_hashsize - 1)); return (lport & (sctp_proto->port_hashsize - 1));
}
} /* sctp_phashfn() */
/* This is the hash function for the endpoint hash table. */ /* This is the hash function for the endpoint hash table. */
static inline int sctp_ep_hashfn(uint16_t lport) static inline int sctp_ep_hashfn(__u16 lport)
{ {
sctp_protocol_t *sctp_proto = sctp_get_protocol(); sctp_protocol_t *sctp_proto = sctp_get_protocol();
return (lport & (sctp_proto->ep_hashsize - 1)); return (lport & (sctp_proto->ep_hashsize - 1));
}
} /* sctp_ep_hashfn() */
/* This is the hash function for the association hash table. */ /* This is the hash function for the association hash table. */
static inline int sctp_assoc_hashfn(uint16_t lport, uint16_t rport) static inline int sctp_assoc_hashfn(__u16 lport, __u16 rport)
{ {
sctp_protocol_t *sctp_proto = sctp_get_protocol(); sctp_protocol_t *sctp_proto = sctp_get_protocol();
int h = (lport << 16) + rport; int h = (lport << 16) + rport;
h ^= h>>8; h ^= h>>8;
return (h & (sctp_proto->assoc_hashsize-1)); return (h & (sctp_proto->assoc_hashsize - 1));
}
} /* sctp_ep_hashfn() */
/* This is the hash function for the association hash table. This is /* This is the hash function for the association hash table. This is
* not used yet, but could be used as a better hash function when * not used yet, but could be used as a better hash function when
* we have a vtag. * we have a vtag.
*/ */
static inline int sctp_vtag_hashfn(uint16_t lport, uint16_t rport, static inline int sctp_vtag_hashfn(__u16 lport, __u16 rport, __u32 vtag)
uint32_t vtag)
{ {
sctp_protocol_t *sctp_proto = sctp_get_protocol(); sctp_protocol_t *sctp_proto = sctp_get_protocol();
int h = (lport << 16) + rport; int h = (lport << 16) + rport;
h ^= vtag; h ^= vtag;
return (h & (sctp_proto->assoc_hashsize-1)); return (h & (sctp_proto->assoc_hashsize-1));
}
} /* sctp_vtag_hashfn() */
/* WARNING: Do not change the layout of the members in sctp_sock! */ /* WARNING: Do not change the layout of the members in sctp_sock! */
struct sctp_sock { struct sctp_sock {
......
...@@ -87,7 +87,7 @@ typedef enum { ...@@ -87,7 +87,7 @@ typedef enum {
SCTP_CMD_SETUP_T2, /* Hi-level, setup T2-shutdown parms. */ SCTP_CMD_SETUP_T2, /* Hi-level, setup T2-shutdown parms. */
SCTP_CMD_LAST SCTP_CMD_LAST
} sctp_verb_t; /* enum */ } sctp_verb_t;
#define SCTP_CMD_MAX (SCTP_CMD_LAST - 1) #define SCTP_CMD_MAX (SCTP_CMD_LAST - 1)
#define SCTP_CMD_NUM_VERBS (SCTP_CMD_MAX + 1) #define SCTP_CMD_NUM_VERBS (SCTP_CMD_MAX + 1)
...@@ -100,10 +100,10 @@ typedef enum { ...@@ -100,10 +100,10 @@ typedef enum {
#define SCTP_MAX_NUM_COMMANDS 14 #define SCTP_MAX_NUM_COMMANDS 14
typedef union { typedef union {
int32_t i32; __s32 i32;
uint32_t u32; __u32 u32;
uint16_t u16; __u16 u16;
uint8_t u8; __u8 u8;
int error; int error;
sctp_state_t state; sctp_state_t state;
sctp_event_timeout_t to; sctp_event_timeout_t to;
...@@ -126,35 +126,32 @@ typedef union { ...@@ -126,35 +126,32 @@ typedef union {
* sctp_arg_t. It does this by inserting the sole argument into the * sctp_arg_t. It does this by inserting the sole argument into the
* ELT union element of a local sctp_arg_t. * ELT union element of a local sctp_arg_t.
* *
* E.g., SCTP_ARG_CONSTRUCTOR(I32, int32_t, i32) builds SCTP_I32(arg), * E.g., SCTP_ARG_CONSTRUCTOR(I32, __s32, i32) builds SCTP_I32(arg),
* which takes an int32_t and returns a sctp_arg_t containing the * which takes an __s32 and returns a sctp_arg_t containing the
* int32_t. So, after foo = SCTP_I32(arg), foo.i32 == arg. * __s32. So, after foo = SCTP_I32(arg), foo.i32 == arg.
*/ */
static inline sctp_arg_t static inline sctp_arg_t SCTP_NULL(void)
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 static inline sctp_arg_t SCTP_NOFORCE(void)
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 static inline sctp_arg_t SCTP_FORCE(void)
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) \ #define SCTP_ARG_CONSTRUCTOR(name, type, elt) \
static inline sctp_arg_t \ static inline sctp_arg_t \
SCTP_## name (type arg) \ 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(I32, __s32, i32)
SCTP_ARG_CONSTRUCTOR(U32, int32_t, u32) SCTP_ARG_CONSTRUCTOR(U32, __u32, u32)
SCTP_ARG_CONSTRUCTOR(U16, int32_t, u16) SCTP_ARG_CONSTRUCTOR(U16, __u16, u16)
SCTP_ARG_CONSTRUCTOR(U8, int32_t, u8) SCTP_ARG_CONSTRUCTOR(U8, __u8, u8)
SCTP_ARG_CONSTRUCTOR(ERROR, int, error) SCTP_ARG_CONSTRUCTOR(ERROR, int, error)
SCTP_ARG_CONSTRUCTOR(STATE, sctp_state_t, state) SCTP_ARG_CONSTRUCTOR(STATE, sctp_state_t, state)
SCTP_ARG_CONSTRUCTOR(COUNTER, sctp_counter_t, counter) SCTP_ARG_CONSTRUCTOR(COUNTER, sctp_counter_t, counter)
...@@ -176,8 +173,8 @@ typedef struct { ...@@ -176,8 +173,8 @@ typedef struct {
typedef struct { typedef struct {
sctp_cmd_t cmds[SCTP_MAX_NUM_COMMANDS]; sctp_cmd_t cmds[SCTP_MAX_NUM_COMMANDS];
uint8_t next_free_slot; __u8 next_free_slot;
uint8_t next_cmd; __u8 next_cmd;
} sctp_cmd_seq_t; } sctp_cmd_seq_t;
......
...@@ -178,7 +178,7 @@ typedef union { ...@@ -178,7 +178,7 @@ typedef union {
#define SCTP_SUBTYPE_CONSTRUCTOR(_name, _type, _elt) \ #define SCTP_SUBTYPE_CONSTRUCTOR(_name, _type, _elt) \
static inline sctp_subtype_t \ static inline sctp_subtype_t \
SCTP_ST_## _name (_type _arg) \ 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(CHUNK, sctp_cid_t, chunk)
SCTP_SUBTYPE_CONSTRUCTOR(TIMEOUT, sctp_event_timeout_t, timeout) SCTP_SUBTYPE_CONSTRUCTOR(TIMEOUT, sctp_event_timeout_t, timeout)
...@@ -215,7 +215,7 @@ typedef enum { ...@@ -215,7 +215,7 @@ typedef enum {
SCTP_IERROR_BIG_GAP, SCTP_IERROR_BIG_GAP,
SCTP_IERROR_DUP_TSN, SCTP_IERROR_DUP_TSN,
} sctp_ierror_t; /* enum */ } sctp_ierror_t;
...@@ -232,7 +232,7 @@ typedef enum { ...@@ -232,7 +232,7 @@ typedef enum {
SCTP_STATE_SHUTDOWN_RECEIVED = 7, SCTP_STATE_SHUTDOWN_RECEIVED = 7,
SCTP_STATE_SHUTDOWN_ACK_SENT = 8, 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_MAX SCTP_STATE_SHUTDOWN_ACK_SENT
#define SCTP_STATE_NUM_STATES (SCTP_STATE_MAX + 1) #define SCTP_STATE_NUM_STATES (SCTP_STATE_MAX + 1)
...@@ -301,8 +301,7 @@ typedef enum { ...@@ -301,8 +301,7 @@ typedef enum {
#define SCTP_NUMBER_COUNTERS 5 #define SCTP_NUMBER_COUNTERS 5
/* Here we define the default timers. /* Here we define the default timers. */
*/
/* cookie timer def = ? seconds */ /* cookie timer def = ? seconds */
#define SCTP_DEFAULT_TIMEOUT_T1_COOKIE (3 * HZ) #define SCTP_DEFAULT_TIMEOUT_T1_COOKIE (3 * HZ)
......
...@@ -31,11 +31,7 @@ ...@@ -31,11 +31,7 @@
#ifndef __SLA1_h__ #ifndef __SLA1_h__
#define __SLA1_h__ #define __SLA1_h__
#ifdef __cplusplus struct SLA_1_Context {
extern "C" {
#endif
struct SLA_1_Context{
unsigned int A; unsigned int A;
unsigned int B; unsigned int B;
unsigned int C; unsigned int C;
...@@ -48,8 +44,10 @@ struct SLA_1_Context{ ...@@ -48,8 +44,10 @@ struct SLA_1_Context{
unsigned int H4; unsigned int H4;
unsigned int words[80]; unsigned int words[80];
unsigned int TEMP; unsigned int TEMP;
/* block I am collecting to process */ /* block I am collecting to process */
char SLAblock[64]; char SLAblock[64];
/* collected so far */ /* collected so far */
int howManyInBlock; int howManyInBlock;
unsigned int runningTotal; unsigned int runningTotal;
...@@ -79,9 +77,4 @@ extern void SLA1_Init(struct SLA_1_Context *); ...@@ -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_Process(struct SLA_1_Context *, const unsigned char *, int);
extern void SLA1_Final(struct SLA_1_Context *, unsigned char *); extern void SLA1_Final(struct SLA_1_Context *, unsigned char *);
#ifdef __cplusplus
}
#endif
#endif #endif
...@@ -52,7 +52,6 @@ ...@@ -52,7 +52,6 @@
*/ */
#include <linux/config.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/sched.h> #include <linux/sched.h>
...@@ -113,7 +112,7 @@ sctp_state_fn_t sctp_sf_cookie_echoed_abort; ...@@ -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_1B_init;
sctp_state_fn_t sctp_sf_do_5_1C_ack; 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_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_do_4_C;
sctp_state_fn_t sctp_sf_eat_data_6_2; sctp_state_fn_t sctp_sf_eat_data_6_2;
sctp_state_fn_t sctp_sf_eat_data_fast_4_4; sctp_state_fn_t sctp_sf_eat_data_fast_4_4;
...@@ -189,7 +188,7 @@ sctp_state_fn_t sctp_addip_do_asconf; ...@@ -189,7 +188,7 @@ sctp_state_fn_t sctp_addip_do_asconf;
sctp_state_fn_t sctp_addip_do_asconf_ack; sctp_state_fn_t sctp_addip_do_asconf_ack;
/* Prototypes for utility support functions. */ /* 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_sm_table_entry_t *sctp_sm_lookup_event(sctp_event_t event_type,
sctp_state_t state, sctp_state_t state,
sctp_subtype_t event_subtype); sctp_subtype_t event_subtype);
...@@ -198,13 +197,11 @@ time_t timeval_sub(struct timeval *, struct timeval *); ...@@ -198,13 +197,11 @@ time_t timeval_sub(struct timeval *, struct timeval *);
sctp_association_t *sctp_make_temp_asoc(const sctp_endpoint_t *, sctp_association_t *sctp_make_temp_asoc(const sctp_endpoint_t *,
sctp_chunk_t *, sctp_chunk_t *,
const int priority); 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 *, sctpParam_t sctp_get_my_addrs_raw(const sctp_association_t *,
const int priority, int *addrs_len); 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. */ /* Prototypes for chunk-building functions. */
sctp_chunk_t *sctp_make_init(const sctp_association_t *, 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 *, ...@@ -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 *, sctp_chunk_t *sctp_make_cookie_ack(const sctp_association_t *,
const sctp_chunk_t *); const sctp_chunk_t *);
sctp_chunk_t *sctp_make_cwr(const sctp_association_t *, sctp_chunk_t *sctp_make_cwr(const sctp_association_t *,
const uint32_t lowest_tsn, const __u32 lowest_tsn,
const sctp_chunk_t *); const sctp_chunk_t *);
sctp_chunk_t *sctp_make_datafrag(sctp_association_t *, sctp_chunk_t *sctp_make_datafrag(sctp_association_t *,
const struct sctp_sndrcvinfo *sinfo, const struct sctp_sndrcvinfo *sinfo,
int len, const uint8_t *data, int len, const __u8 *data,
uint8_t flags, uint16_t ssn); __u8 flags, __u16 ssn);
sctp_chunk_t * sctp_make_datafrag_empty(sctp_association_t *, sctp_chunk_t * sctp_make_datafrag_empty(sctp_association_t *,
const struct sctp_sndrcvinfo *sinfo, const struct sctp_sndrcvinfo *sinfo,
int len, const uint8_t flags, int len, const __u8 flags,
uint16_t ssn); __u16 ssn);
sctp_chunk_t *sctp_make_data(sctp_association_t *, sctp_chunk_t *sctp_make_data(sctp_association_t *,
const struct sctp_sndrcvinfo *sinfo, 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 *, sctp_chunk_t *sctp_make_data_empty(sctp_association_t *,
const struct sctp_sndrcvinfo *, int len); const struct sctp_sndrcvinfo *, int len);
sctp_chunk_t *sctp_make_ecne(const sctp_association_t *, 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_sack(const sctp_association_t *);
sctp_chunk_t *sctp_make_shutdown(const sctp_association_t *asoc); sctp_chunk_t *sctp_make_shutdown(const sctp_association_t *asoc);
sctp_chunk_t *sctp_make_shutdown_ack(const sctp_association_t *asoc, sctp_chunk_t *sctp_make_shutdown_ack(const sctp_association_t *asoc,
const sctp_chunk_t *); const sctp_chunk_t *);
sctp_chunk_t *sctp_make_shutdown_complete(const sctp_association_t *, sctp_chunk_t *sctp_make_shutdown_complete(const sctp_association_t *,
const sctp_chunk_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 *, sctp_chunk_t *sctp_make_abort(const sctp_association_t *,
const sctp_chunk_t *, const sctp_chunk_t *,
const size_t hint); const size_t hint);
sctp_chunk_t *sctp_make_abort_no_data(const sctp_association_t *, sctp_chunk_t *sctp_make_abort_no_data(const sctp_association_t *,
const sctp_chunk_t *, const sctp_chunk_t *,
uint32_t tsn); __u32 tsn);
sctp_chunk_t *sctp_make_heartbeat(const sctp_association_t *, sctp_chunk_t *sctp_make_heartbeat(const sctp_association_t *,
const sctp_transport_t *, const sctp_transport_t *,
const void *payload, const void *payload,
...@@ -258,7 +255,7 @@ sctp_chunk_t *sctp_make_heartbeat_ack(const sctp_association_t *, ...@@ -258,7 +255,7 @@ sctp_chunk_t *sctp_make_heartbeat_ack(const sctp_association_t *,
const size_t paylen); const size_t paylen);
sctp_chunk_t *sctp_make_op_error(const sctp_association_t *, sctp_chunk_t *sctp_make_op_error(const sctp_association_t *,
const sctp_chunk_t *chunk, const sctp_chunk_t *chunk,
uint16_t cause_code, __u16 cause_code,
const void *payload, const void *payload,
size_t paylen); size_t paylen);
void sctp_chunk_assign_tsn(sctp_chunk_t *); void sctp_chunk_assign_tsn(sctp_chunk_t *);
...@@ -305,7 +302,7 @@ sctp_sackhdr_t *sctp_sm_pull_sack(sctp_chunk_t *); ...@@ -305,7 +302,7 @@ sctp_sackhdr_t *sctp_sm_pull_sack(sctp_chunk_t *);
sctp_cookie_param_t * sctp_cookie_param_t *
sctp_pack_cookie(const sctp_endpoint_t *, const sctp_association_t *, sctp_pack_cookie(const sctp_endpoint_t *, const sctp_association_t *,
const sctp_chunk_t *, int *cookie_len, const sctp_chunk_t *, int *cookie_len,
const uint8_t *, int addrs_len); const __u8 *, int addrs_len);
sctp_association_t *sctp_unpack_cookie(const sctp_endpoint_t *, sctp_association_t *sctp_unpack_cookie(const sctp_endpoint_t *,
const sctp_association_t *, const sctp_association_t *,
sctp_chunk_t *, int priority, int *err); sctp_chunk_t *, int priority, int *err);
...@@ -313,12 +310,12 @@ int sctp_addip_addr_config(sctp_association_t *, sctp_param_t, ...@@ -313,12 +310,12 @@ int sctp_addip_addr_config(sctp_association_t *, sctp_param_t,
struct sockaddr_storage*, int); struct sockaddr_storage*, int);
/* 3rd level prototypes */ /* 3rd level prototypes */
uint32_t sctp_generate_tag(const sctp_endpoint_t *); __u32 sctp_generate_tag(const sctp_endpoint_t *);
uint32_t sctp_generate_tsn(const sctp_endpoint_t *); __u32 sctp_generate_tsn(const sctp_endpoint_t *);
/* 4th level prototypes */ /* 4th level prototypes */
void sctp_param2sockaddr(sockaddr_storage_t *addr, const sctpParam_t param, 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 sctp_addr2sockaddr(const sctpParam_t, sockaddr_storage_t *);
int sockaddr2sctp_addr(const sockaddr_storage_t *, sctpParam_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]; ...@@ -336,17 +333,15 @@ extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
/* Get the size of a DATA chunk payload. */ /* Get the size of a DATA chunk payload. */
static inline uint16_t static inline __u16 sctp_data_size(sctp_chunk_t *chunk)
sctp_data_size(sctp_chunk_t *chunk)
{ {
uint16_t size; __u16 size;
size = ntohs(chunk->chunk_hdr->length); size = ntohs(chunk->chunk_hdr->length);
size -= sizeof(sctp_data_chunk_t); size -= sizeof(sctp_data_chunk_t);
return(size); return size;
}
} /* sctp_data_size( ) */
/* Compare two TSNs */ /* Compare two TSNs */
...@@ -381,14 +376,12 @@ enum { ...@@ -381,14 +376,12 @@ enum {
TSN_SIGN_BIT = (1<<31) TSN_SIGN_BIT = (1<<31)
}; };
static inline int static inline int TSN_lt(__u32 s, __u32 t)
TSN_lt(__u32 s, __u32 t)
{ {
return (((s) - (t)) & TSN_SIGN_BIT); return (((s) - (t)) & TSN_SIGN_BIT);
} }
static inline int static inline int TSN_lte(__u32 s, __u32 t)
TSN_lte(__u32 s, __u32 t)
{ {
return (((s) == (t)) || (((s) - (t)) & TSN_SIGN_BIT)); return (((s) == (t)) || (((s) - (t)) & TSN_SIGN_BIT));
} }
...@@ -407,27 +400,21 @@ enum { ...@@ -407,27 +400,21 @@ enum {
SSN_SIGN_BIT = (1<<15) SSN_SIGN_BIT = (1<<15)
}; };
static inline int static inline int SSN_lt(__u16 s, __u16 t)
SSN_lt(__u16 s, __u16 t)
{ {
return (((s) - (t)) & SSN_SIGN_BIT); return (((s) - (t)) & SSN_SIGN_BIT);
} }
static inline int static inline int SSN_lte(__u16 s, __u16 t)
SSN_lte(__u16 s, __u16 t)
{ {
return (((s) == (t)) || (((s) - (t)) & SSN_SIGN_BIT)); return (((s) == (t)) || (((s) - (t)) & SSN_SIGN_BIT));
} }
/* Run sctp_add_cmd() generating a BUG() if there is a failure. */ /* Run sctp_add_cmd() generating a BUG() if there is a failure. */
static inline void static inline void sctp_add_cmd_sf(sctp_cmd_seq_t *seq, sctp_verb_t verb, sctp_arg_t obj)
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(); BUG();
} }
} /* sctp_add_cmd_sf() */
#endif /* __sctp_sm_h__ */ #endif /* __sctp_sm_h__ */
This diff is collapsed.
...@@ -57,21 +57,21 @@ typedef struct sctp_tsnmap { ...@@ -57,21 +57,21 @@ typedef struct sctp_tsnmap {
* It points at one of the two buffers with which we will * 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 /* This marks the tsn which overflows the tsn_map, when the
* cumulative ack point reaches this point we know we can switch * cumulative ack point reaches this point we know we can switch
* maps (tsn_map and overflow_map swap). * maps (tsn_map and overflow_map swap).
*/ */
uint32_t overflow_tsn; __u32 overflow_tsn;
/* This is the overflow array for tsn_map. /* This is the overflow array for tsn_map.
* It points at one of the other ping-pong buffers. * 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]. */ /* 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 * TSN : sequence. This value is set initially by
...@@ -84,32 +84,32 @@ typedef struct sctp_tsnmap { ...@@ -84,32 +84,32 @@ typedef struct sctp_tsnmap {
* ignore the advice in 12.2 in favour of the term * ignore the advice in 12.2 in favour of the term
* used in the bulk of the text. * 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 /* 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 * to the size of tsn_map. Note: the overflow_map allows us to
* potentially track more than this quantity. * potentially track more than this quantity.
*/ */
uint16_t len; __u16 len;
/* This is the highest TSN we've marked. */ /* 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 */ /* No. of data chunks pending receipt. used by SCTP_STATUS sockopt */
uint16_t pending_data; __u16 pending_data;
int malloced; int malloced;
uint8_t raw_map[0]; __u8 raw_map[0];
} sctp_tsnmap_t; } sctp_tsnmap_t;
typedef struct sctp_tsnmap_iter { typedef struct sctp_tsnmap_iter {
uint32_t start; __u32 start;
} sctp_tsnmap_iter_t; } sctp_tsnmap_iter_t;
/* Create a new tsnmap. */ /* 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); int priority);
/* Dispose of a tsnmap. */ /* Dispose of a tsnmap. */
...@@ -118,11 +118,10 @@ void sctp_tsnmap_free(sctp_tsnmap_t *map); ...@@ -118,11 +118,10 @@ 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. * 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. */ /* Initialize a block of memory as a tsnmap. */
sctp_tsnmap_t *sctp_tsnmap_init(sctp_tsnmap_t *map, uint16_t len, sctp_tsnmap_t *sctp_tsnmap_init(sctp_tsnmap_t *map, __u16 len, __u32 initial_tsn);
uint32_t initial_tsn);
...@@ -132,16 +131,16 @@ sctp_tsnmap_t *sctp_tsnmap_init(sctp_tsnmap_t *map, uint16_t len, ...@@ -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 has been seen (duplicate)
* <0 if the TSN is invalid (too large to track) * <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. */ /* 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. */ /* 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. */ /* 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? */ /* Is there a gap in the TSN map? */
int sctp_tsnmap_has_gap(const sctp_tsnmap_t *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); ...@@ -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 /* Get the next gap ack blocks. We return 0 if there are no more
* gap ack blocks. * gap ack blocks.
*/ */
int int sctp_tsnmap_next_gap_ack(const sctp_tsnmap_t *map, sctp_tsnmap_iter_t *iter,
sctp_tsnmap_next_gap_ack(const sctp_tsnmap_t *map, sctp_tsnmap_iter_t *iter, __u16 *start, __u16 *end);
uint16_t *start, uint16_t *end);
#endif /* __sctp_tsnmap_h__ */ #endif /* __sctp_tsnmap_h__ */
......
...@@ -58,83 +58,73 @@ typedef struct sctp_ulpevent { ...@@ -58,83 +58,73 @@ typedef struct sctp_ulpevent {
} sctp_ulpevent_t; } sctp_ulpevent_t;
sctp_ulpevent_t * sctp_ulpevent_t *sctp_ulpevent_new(int size, int msg_flags, int priority);
sctp_ulpevent_new(int size, int msg_flags, int priority);
sctp_ulpevent_t * sctp_ulpevent_t *sctp_ulpevent_init(sctp_ulpevent_t *event, struct sk_buff *skb, int msg_flags);
sctp_ulpevent_init(sctp_ulpevent_t *event, struct sk_buff *skb, int msg_flags);
void void sctp_ulpevent_free(sctp_ulpevent_t *event);
sctp_ulpevent_free(sctp_ulpevent_t *event);
int sctp_ulpevent_is_notification(const sctp_ulpevent_t *event);
int sctp_ulpevent_t *sctp_ulpevent_make_assoc_change(
sctp_ulpevent_is_notification(const sctp_ulpevent_t *event); const struct SCTP_association *asoc,
__u16 flags,
sctp_ulpevent_t * __u16 state,
sctp_ulpevent_make_assoc_change(const struct SCTP_association *asoc, __u16 error,
uint16_t flags, __u16 outbound,
uint16_t state, __u16 inbound,
uint16_t error,
uint16_t outbound,
uint16_t inbound,
int priority); int priority);
sctp_ulpevent_t * sctp_ulpevent_t *sctp_ulpevent_make_peer_addr_change(
sctp_ulpevent_make_peer_addr_change(const struct SCTP_association *asoc, const struct SCTP_association *asoc,
const struct sockaddr_storage *aaddr, const struct sockaddr_storage *aaddr,
int flags, int flags,
int state, int state,
int error, int error,
int priority); int priority);
sctp_ulpevent_t * sctp_ulpevent_t *sctp_ulpevent_make_remote_error(
sctp_ulpevent_make_remote_error(const struct SCTP_association *asoc, const struct SCTP_association *asoc,
struct SCTP_chunk *chunk, struct SCTP_chunk *chunk,
uint16_t flags, __u16 flags,
int priority); int priority);
sctp_ulpevent_t * sctp_ulpevent_t *sctp_ulpevent_make_send_failed(
sctp_ulpevent_make_send_failed(const struct SCTP_association *asoc, const struct SCTP_association *asoc,
struct SCTP_chunk *chunk, struct SCTP_chunk *chunk,
uint16_t flags, __u16 flags,
uint32_t error, __u32 error,
int priority); int priority);
sctp_ulpevent_t * sctp_ulpevent_t *sctp_ulpevent_make_shutdown_event(
sctp_ulpevent_make_shutdown_event(const struct SCTP_association *asoc, const struct SCTP_association *asoc,
uint16_t flags, __u16 flags,
int priority); int priority);
sctp_ulpevent_t * sctp_ulpevent_t *sctp_ulpevent_make_rcvmsg(struct SCTP_association *asoc,
sctp_ulpevent_make_rcvmsg(struct SCTP_association *asoc,
struct SCTP_chunk *chunk, struct SCTP_chunk *chunk,
int priority); int priority);
void void sctp_ulpevent_read_sndrcvinfo(const sctp_ulpevent_t *event,
sctp_ulpevent_read_sndrcvinfo(const sctp_ulpevent_t *event,
struct msghdr *msghdr); struct msghdr *msghdr);
uint16_t __u16 sctp_ulpevent_get_notification_type(const sctp_ulpevent_t *event);
sctp_ulpevent_get_notification_type(const sctp_ulpevent_t *event);
/* Given an event subscription, is this event enabled? */ /* Given an event subscription, is this event enabled? */
static inline int static inline int sctp_ulpevent_is_enabled(const sctp_ulpevent_t *event,
sctp_ulpevent_is_enabled(const sctp_ulpevent_t *event,
const struct sctp_event_subscribe *mask) const struct sctp_event_subscribe *mask)
{ {
const char *amask = (const char *)mask; const char *amask = (const char *) mask;
uint16_t sn_type; __u16 sn_type;
int enabled = 1; int enabled = 1;
if (sctp_ulpevent_is_notification(event)) { if (sctp_ulpevent_is_notification(event)) {
sn_type = sctp_ulpevent_get_notification_type(event); sn_type = sctp_ulpevent_get_notification_type(event);
enabled = amask[sn_type - SCTP_SN_TYPE_BASE]; enabled = amask[sn_type - SCTP_SN_TYPE_BASE];
} }
return(enabled); return enabled;
}
} /* sctp_ulpevent_is_enabled() */
#endif /* __sctp_ulpevent_h__ */ #endif /* __sctp_ulpevent_h__ */
......
...@@ -50,47 +50,40 @@ typedef struct sctp_ulpqueue { ...@@ -50,47 +50,40 @@ typedef struct sctp_ulpqueue {
sctp_association_t *asoc; sctp_association_t *asoc;
struct sk_buff_head reasm; struct sk_buff_head reasm;
struct sk_buff_head lobby; struct sk_buff_head lobby;
uint16_t ssn[0]; __u16 ssn[0];
} sctp_ulpqueue_t; } sctp_ulpqueue_t;
/* This macro assists in creation of external storage for variable length /* This macro assists in creation of external storage for variable length
* internal buffers. * 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_t *sctp_ulpqueue_new(sctp_association_t *asoc,
sctp_ulpqueue_new(sctp_association_t *asoc, __u16 inbound,
uint16_t inbound,
int priority); int priority);
sctp_ulpqueue_t * sctp_ulpqueue_t *sctp_ulpqueue_init(sctp_ulpqueue_t *ulpq,
sctp_ulpqueue_init(sctp_ulpqueue_t *ulpq,
sctp_association_t *asoc, sctp_association_t *asoc,
uint16_t inbound); __u16 inbound);
void void sctp_ulpqueue_free(sctp_ulpqueue_t *);
sctp_ulpqueue_free(sctp_ulpqueue_t *);
/* Add a new DATA chunk for processing. */ /* Add a new DATA chunk for processing. */
int int sctp_ulpqueue_tail_data(sctp_ulpqueue_t *,
sctp_ulpqueue_tail_data(sctp_ulpqueue_t *,
sctp_chunk_t *chunk, sctp_chunk_t *chunk,
int priority); int priority);
/* Add a new event for propogation to the ULP. */ /* Add a new event for propogation to the ULP. */
int int sctp_ulpqueue_tail_event(sctp_ulpqueue_t *,
sctp_ulpqueue_tail_event(sctp_ulpqueue_t *,
sctp_ulpevent_t *event); sctp_ulpevent_t *event);
/* Is the ulpqueue empty. */ /* Is the ulpqueue empty. */
int int sctp_ulpqueue_is_empty(sctp_ulpqueue_t *);
sctp_ulpqueue_is_empty(sctp_ulpqueue_t *);
int int sctp_ulpqueue_is_data_empty(sctp_ulpqueue_t *);
sctp_ulpqueue_is_data_empty(sctp_ulpqueue_t *);
#endif /* __sctp_ulpqueue_h__ */ #endif /* __sctp_ulpqueue_h__ */
......
...@@ -102,7 +102,7 @@ enum sctp_optname { ...@@ -102,7 +102,7 @@ enum sctp_optname {
#define SCTP_SOCKOPT_BINDX_REM SCTP_SOCKOPT_BINDX_REM #define SCTP_SOCKOPT_BINDX_REM SCTP_SOCKOPT_BINDX_REM
SCTP_SOCKOPT_PEELOFF, /* peel off association. */ SCTP_SOCKOPT_PEELOFF, /* peel off association. */
#define SCTP_SOCKOPT_PEELOFF SCTP_SOCKOPT_PEELOFF #define SCTP_SOCKOPT_PEELOFF SCTP_SOCKOPT_PEELOFF
}; /* enum sctp_optname */ };
/* /*
...@@ -133,11 +133,11 @@ enum sctp_optname { ...@@ -133,11 +133,11 @@ enum sctp_optname {
* *
*/ */
struct sctp_initmsg { struct sctp_initmsg {
uint16_t sinit_num_ostreams; __u16 sinit_num_ostreams;
uint16_t sinit_max_instreams; __u16 sinit_max_instreams;
uint16_t sinit_max_attempts; __u16 sinit_max_attempts;
uint16_t sinit_max_init_timeo; __u16 sinit_max_init_timeo;
}; /* struct sctp_initmsg */ };
/* /*
...@@ -153,15 +153,15 @@ struct sctp_initmsg { ...@@ -153,15 +153,15 @@ struct sctp_initmsg {
* *
*/ */
struct sctp_sndrcvinfo { struct sctp_sndrcvinfo {
uint16_t sinfo_stream; __u16 sinfo_stream;
uint16_t sinfo_ssn; __u16 sinfo_ssn;
uint16_t sinfo_flags; __u16 sinfo_flags;
uint32_t sinfo_ppid; __u32 sinfo_ppid;
uint32_t sinfo_context; __u32 sinfo_context;
uint32_t sinfo_timetolive; __u32 sinfo_timetolive;
uint32_t sinfo_tsn; __u32 sinfo_tsn;
sctp_assoc_t sinfo_assoc_id; sctp_assoc_t sinfo_assoc_id;
}; /* struct sctp_sndrcvinfo */ };
/* /*
* sinfo_flags: 16 bits (unsigned integer) * sinfo_flags: 16 bits (unsigned integer)
...@@ -175,11 +175,11 @@ enum sctp_sinfo_flags { ...@@ -175,11 +175,11 @@ enum sctp_sinfo_flags {
MSG_ADDR_OVER = 2, /* Override the primary destination. */ MSG_ADDR_OVER = 2, /* Override the primary destination. */
MSG_ABORT=4, /* Send an ABORT message to the peer. */ MSG_ABORT=4, /* Send an ABORT message to the peer. */
/* MSG_EOF is already defined per socket.h */ /* MSG_EOF is already defined per socket.h */
}; /* enum sctp_sinfo_flags */ };
typedef union { typedef union {
u_int8_t raw; __u8 raw;
struct sctp_initmsg init; struct sctp_initmsg init;
struct sctp_sndrcvinfo sndrcv; struct sctp_sndrcvinfo sndrcv;
} sctp_cmsg_data_t; } sctp_cmsg_data_t;
...@@ -202,15 +202,15 @@ typedef enum sctp_cmsg_type { ...@@ -202,15 +202,15 @@ typedef enum sctp_cmsg_type {
*/ */
struct sctp_assoc_change { struct sctp_assoc_change {
uint16_t sac_type; __u16 sac_type;
uint16_t sac_flags; __u16 sac_flags;
uint32_t sac_length; __u32 sac_length;
uint16_t sac_state; __u16 sac_state;
uint16_t sac_error; __u16 sac_error;
uint16_t sac_outbound_streams; __u16 sac_outbound_streams;
uint16_t sac_inbound_streams; __u16 sac_inbound_streams;
sctp_assoc_t sac_assoc_id; sctp_assoc_t sac_assoc_id;
}; /* sctp_assoc_change */ };
/* /*
* sac_state: 32 bits (signed integer) * sac_state: 32 bits (signed integer)
...@@ -227,7 +227,7 @@ enum sctp_sac_state { ...@@ -227,7 +227,7 @@ enum sctp_sac_state {
SCTP_RESTART, SCTP_RESTART,
SCTP_SHUTDOWN_COMP, SCTP_SHUTDOWN_COMP,
SCTP_CANT_STR_ASSOC, SCTP_CANT_STR_ASSOC,
}; /* sctp_sac_state */ };
/* /*
* 5.3.1.2 SCTP_PEER_ADDR_CHANGE * 5.3.1.2 SCTP_PEER_ADDR_CHANGE
...@@ -236,15 +236,15 @@ enum sctp_sac_state { ...@@ -236,15 +236,15 @@ enum sctp_sac_state {
* an interface details event is sent. The information has the * an interface details event is sent. The information has the
* following structure: * following structure:
*/ */
struct sctp_paddr_change{ struct sctp_paddr_change {
uint16_t spc_type; __u16 spc_type;
uint16_t spc_flags; __u16 spc_flags;
uint32_t spc_length; __u32 spc_length;
struct sockaddr_storage spc_aaddr; struct sockaddr_storage spc_aaddr;
int spc_state; int spc_state;
int spc_error; int spc_error;
sctp_assoc_t spc_assoc_id; sctp_assoc_t spc_assoc_id;
}; /* sctp_paddr_change */ };
/* /*
* spc_state: 32 bits (signed integer) * spc_state: 32 bits (signed integer)
...@@ -258,7 +258,7 @@ enum sctp_spc_state { ...@@ -258,7 +258,7 @@ enum sctp_spc_state {
ADDRESS_REMOVED, ADDRESS_REMOVED,
ADDRESS_ADDED, ADDRESS_ADDED,
ADDRESS_MADE_PRIM, ADDRESS_MADE_PRIM,
}; /* sctp_spc_state */ };
/* /*
...@@ -272,13 +272,13 @@ enum sctp_spc_state { ...@@ -272,13 +272,13 @@ enum sctp_spc_state {
* error formats. SCTP error TLVs have the format: * error formats. SCTP error TLVs have the format:
*/ */
struct sctp_remote_error { struct sctp_remote_error {
uint16_t sre_type; __u16 sre_type;
uint16_t sre_flags; __u16 sre_flags;
uint32_t sre_length; __u32 sre_length;
uint16_t sre_error; __u16 sre_error;
uint16_t sre_len; __u16 sre_len;
sctp_assoc_t sre_assoc_id; sctp_assoc_t sre_assoc_id;
uint8_t sre_data[0]; __u8 sre_data[0];
}; };
...@@ -289,13 +289,13 @@ struct sctp_remote_error { ...@@ -289,13 +289,13 @@ struct sctp_remote_error {
* notification. * notification.
*/ */
struct sctp_send_failed { struct sctp_send_failed {
uint16_t ssf_type; __u16 ssf_type;
uint16_t ssf_flags; __u16 ssf_flags;
uint32_t ssf_length; __u32 ssf_length;
uint32_t ssf_error; __u32 ssf_error;
struct sctp_sndrcvinfo ssf_info; struct sctp_sndrcvinfo ssf_info;
sctp_assoc_t ssf_assoc_id; sctp_assoc_t ssf_assoc_id;
uint8_t ssf_data[0]; __u8 ssf_data[0];
}; };
/* /*
...@@ -324,9 +324,9 @@ enum sctp_ssf_flags { ...@@ -324,9 +324,9 @@ enum sctp_ssf_flags {
*/ */
struct sctp_shutdown_event { struct sctp_shutdown_event {
uint16_t sse_type; __u16 sse_type;
uint16_t sse_flags; __u16 sse_flags;
uint32_t sse_length; __u32 sse_length;
sctp_assoc_t sse_assoc_id; sctp_assoc_t sse_assoc_id;
}; };
...@@ -338,10 +338,10 @@ struct sctp_shutdown_event { ...@@ -338,10 +338,10 @@ struct sctp_shutdown_event {
* that of the peers requested adaption layer. * that of the peers requested adaption layer.
*/ */
struct sctp_adaption_event { struct sctp_adaption_event {
uint16_t sai_type; __u16 sai_type;
uint16_t sai_flags; __u16 sai_flags;
uint32_t sai_length; __u32 sai_length;
uint32_t sai_adaptation_bits; __u32 sai_adaptation_bits;
sctp_assoc_t sse_assoc_id; sctp_assoc_t sse_assoc_id;
}; };
...@@ -354,10 +354,10 @@ struct sctp_adaption_event { ...@@ -354,10 +354,10 @@ struct sctp_adaption_event {
*/ */
struct sctp_rcv_pdapi_event { struct sctp_rcv_pdapi_event {
uint16_t pdapi_type; __u16 pdapi_type;
uint16_t pdapi_flags; __u16 pdapi_flags;
uint32_t pdapi_length; __u32 pdapi_length;
uint32_t pdapi_indication; __u32 pdapi_indication;
sctp_assoc_t pdapi_assoc_id; sctp_assoc_t pdapi_assoc_id;
}; };
...@@ -367,15 +367,15 @@ struct sctp_rcv_pdapi_event { ...@@ -367,15 +367,15 @@ struct sctp_rcv_pdapi_event {
* Ancillary Data and Notification Interest Options * Ancillary Data and Notification Interest Options
*/ */
struct sctp_event_subscribe { struct sctp_event_subscribe {
uint8_t sctp_data_io_event; __u8 sctp_data_io_event;
uint8_t sctp_association_event; __u8 sctp_association_event;
uint8_t sctp_address_event; __u8 sctp_address_event;
uint8_t sctp_send_failure_event; __u8 sctp_send_failure_event;
uint8_t sctp_peer_error_event; __u8 sctp_peer_error_event;
uint8_t sctp_shutdown_event; __u8 sctp_shutdown_event;
uint8_t sctp_partial_delivery_event; __u8 sctp_partial_delivery_event;
uint8_t sctp_adaption_layer_event; __u8 sctp_adaption_layer_event;
}; /* struct sctp_event_subscribe */ };
/* /*
* 5.3.1 SCTP Notification Structure * 5.3.1 SCTP Notification Structure
...@@ -386,9 +386,9 @@ struct sctp_event_subscribe { ...@@ -386,9 +386,9 @@ struct sctp_event_subscribe {
*/ */
union sctp_notification { union sctp_notification {
struct { struct {
uint16_t sn_type; /* Notification type. */ __u16 sn_type; /* Notification type. */
uint16_t sn_flags; __u16 sn_flags;
uint32_t sn_length; __u32 sn_length;
} h; } h;
struct sctp_assoc_change sn_assoc_change; struct sctp_assoc_change sn_assoc_change;
struct sctp_paddr_change sn_padr_change; struct sctp_paddr_change sn_padr_change;
...@@ -446,8 +446,8 @@ typedef enum sctp_sn_error { ...@@ -446,8 +446,8 @@ typedef enum sctp_sn_error {
struct sctp_paddrparams { struct sctp_paddrparams {
struct sockaddr_storage spp_address; struct sockaddr_storage spp_address;
uint32_t spp_hbinterval; __u32 spp_hbinterval;
uint16_t spp_pathmaxrxt; __u16 spp_pathmaxrxt;
sctp_assoc_t spp_assoc_id; sctp_assoc_t spp_assoc_id;
}; };
...@@ -464,11 +464,11 @@ struct sctp_paddrparams { ...@@ -464,11 +464,11 @@ struct sctp_paddrparams {
struct sctp_paddrinfo { struct sctp_paddrinfo {
sctp_assoc_t spinfo_assoc_id; sctp_assoc_t spinfo_assoc_id;
struct sockaddr_storage spinfo_address; struct sockaddr_storage spinfo_address;
int32_t spinfo_state; __s32 spinfo_state;
uint32_t spinfo_cwnd; __u32 spinfo_cwnd;
uint32_t spinfo_srtt; __u32 spinfo_srtt;
uint32_t spinfo_rto; __u32 spinfo_rto;
uint32_t spinfo_mtu; __u32 spinfo_mtu;
}; };
...@@ -482,9 +482,9 @@ struct sctp_paddrinfo { ...@@ -482,9 +482,9 @@ struct sctp_paddrinfo {
*/ */
struct sctp_rtoinfo { struct sctp_rtoinfo {
uint32_t srto_initial; __u32 srto_initial;
uint32_t srto_max; __u32 srto_max;
uint32_t srto_min; __u32 srto_min;
sctp_assoc_t srto_assoc_id; sctp_assoc_t srto_assoc_id;
}; };
...@@ -498,7 +498,7 @@ struct sctp_rtoinfo { ...@@ -498,7 +498,7 @@ struct sctp_rtoinfo {
*/ */
struct sctp_assocparams { struct sctp_assocparams {
uint16_t sasoc_asocmaxrxt; __u16 sasoc_asocmaxrxt;
sctp_assoc_t sasoc_assoc_id; sctp_assoc_t sasoc_assoc_id;
}; };
...@@ -542,13 +542,13 @@ struct sctp_setpeerprim { ...@@ -542,13 +542,13 @@ struct sctp_setpeerprim {
*/ */
struct sctp_status { struct sctp_status {
sctp_assoc_t sstat_assoc_id; sctp_assoc_t sstat_assoc_id;
int32_t sstat_state; __s32 sstat_state;
uint32_t sstat_rwnd; __u32 sstat_rwnd;
uint16_t sstat_unackdata; __u16 sstat_unackdata;
uint16_t sstat_penddata; __u16 sstat_penddata;
uint16_t sstat_instrms; __u16 sstat_instrms;
uint16_t sstat_outstrms; __u16 sstat_outstrms;
uint32_t sstat_fragmentation_point; __u32 sstat_fragmentation_point;
struct sctp_paddrinfo sstat_primary; struct sctp_paddrinfo sstat_primary;
}; };
...@@ -562,7 +562,7 @@ struct sctp_status { ...@@ -562,7 +562,7 @@ struct sctp_status {
*/ */
struct sctp_setadaption { struct sctp_setadaption {
u_int32_t ssb_adaption_ind; __u32 ssb_adaption_ind;
}; };
/* /*
...@@ -573,9 +573,9 @@ struct sctp_setadaption { ...@@ -573,9 +573,9 @@ struct sctp_setadaption {
*/ */
struct sctp_setstrm_timeout { struct sctp_setstrm_timeout {
sctp_assoc_t ssto_assoc_id; sctp_assoc_t ssto_assoc_id;
u_int32_t ssto_timeout; __u32 ssto_timeout;
u_int16_t ssto_streamid_start; __u16 ssto_streamid_start;
u_int16_t ssto_streamid_end; __u16 ssto_streamid_end;
}; };
...@@ -584,7 +584,7 @@ struct sctp_setstrm_timeout { ...@@ -584,7 +584,7 @@ struct sctp_setstrm_timeout {
enum sctp_msg_flags { enum sctp_msg_flags {
MSG_NOTIFICATION = 0x8000, MSG_NOTIFICATION = 0x8000,
#define MSG_NOTIFICATION MSG_NOTIFICATION #define MSG_NOTIFICATION MSG_NOTIFICATION
}; /* enum sctp_msg_flags */ };
/* /*
* 8.1 sctp_bindx() * 8.1 sctp_bindx()
......
...@@ -17,6 +17,11 @@ CONFIG_IP_SCTP ...@@ -17,6 +17,11 @@ CONFIG_IP_SCTP
-- network-level fault tolerance through supporting of multi- -- network-level fault tolerance through supporting of multi-
homing at either or both ends of an association." 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. If in doubt, say N.
CONFIG_SCTP_ADLER32 CONFIG_SCTP_ADLER32
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
obj-$(CONFIG_IP_SCTP) += sctp.o obj-$(CONFIG_IP_SCTP) += sctp.o
obj-y := sctp_sm_statetable.o sctp_sm_statefuns.o sctp_sm_sideeffect.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_protocol.o sctp_endpointola.o sctp_associola.o \
sctp_transport.o sctp_sm_make_chunk.o sctp_ulpevent.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_inqueue.o sctp_outqueue.o sctp_ulpqueue.o sctp_command.o \
...@@ -13,16 +13,16 @@ obj-y := sctp_sm_statetable.o sctp_sm_statefuns.o sctp_sm_sideeffect.o \ ...@@ -13,16 +13,16 @@ obj-y := sctp_sm_statetable.o sctp_sm_statefuns.o sctp_sm_sideeffect.o \
sctp_debug.o sctp_debug.o
ifeq ($(CONFIG_SCTP_ADLER32), y) ifeq ($(CONFIG_SCTP_ADLER32), y)
obj-y += sctp_adler32.o sctp-y += sctp_adler32.o
else else
obj-y += sctp_crc32c.o sctp-y += sctp_crc32c.o
endif endif
obj-$(CONFIG_SCTP_DBG_OBJCNT) += sctp_objcnt.o sctp-$(CONFIG_SCTP_DBG_OBJCNT) += sctp_objcnt.o
obj-$(CONFIG_SYSCTL) += sctp_sysctl.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 include $(TOPDIR)/Rules.make
...@@ -47,21 +47,21 @@ static char *cvs_id __attribute__ ((unused)) = "$Id: sctp_adler32.c,v 1.5 2002/0 ...@@ -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 /* This is an entry point for external calls
* Define this function in the header file. This is * Define this function in the header file. This is
* direct from rfc1950, ... * direct from rfc1950, ...
*
* The following C code computes the Adler-32 checksum of a data buffer. * 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 * 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 * ANSI C programming language. Non C users may find it easier to read
with these hints: * with these hints:
*
& Bitwise AND operator. * & Bitwise AND operator.
>> Bitwise right shift operator. When applied to an * >> Bitwise right shift operator. When applied to an
unsigned quantity, as here, right shift inserts zero bit(s) * unsigned quantity, as here, right shift inserts zero bit(s)
at the left. * at the left.
<< Bitwise left shift operator. Left shift inserts zero * << Bitwise left shift operator. Left shift inserts zero
bit(s) at the right. * bit(s) at the right.
++ "n++" increments the variable n. * ++ "n++" increments the variable n.
% modulo operator: a % b is the remainder of a divided by b. * % 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 * Well, the above is a bit of a lie, I have optimized this a small
* tad, but I have commented the original lines below * tad, but I have commented the original lines below
*/ */
...@@ -81,31 +81,31 @@ static char *cvs_id __attribute__ ((unused)) = "$Id: sctp_adler32.c,v 1.5 2002/0 ...@@ -81,31 +81,31 @@ static char *cvs_id __attribute__ ((unused)) = "$Id: sctp_adler32.c,v 1.5 2002/0
* it back and we will incorporate it :-) * it back and we will incorporate it :-)
*/ */
unsigned long update_adler32(unsigned long adler, unsigned long update_adler32(unsigned long adler,
unsigned char *buf, int len) unsigned char *buf, int len)
{ {
uint32_t s1 = adler & 0xffff; __u32 s1 = adler & 0xffff;
uint32_t s2 = (adler >> 16) & 0xffff; __u32 s2 = (adler >> 16) & 0xffff;
int n; int n;
for (n = 0; n < len; n++,buf++) { for (n = 0; n < len; n++,buf++) {
/* s1 = (s1 + buf[n]) % BASE */ /* s1 = (s1 + buf[n]) % BASE */
/* first we add */ /* first we add */
s1 = (s1 + *buf); s1 = (s1 + *buf);
/* Now if we need to, we do a mod by /* Now if we need to, we do a mod by
* subtracting. It seems a bit faster * subtracting. It seems a bit faster
* since I really will only ever do * since I really will only ever do
* one subtract at the MOST, since buf[n] * one subtract at the MOST, since buf[n]
* is a max of 255. * is a max of 255.
*/ */
if(s1 >= BASE){ if(s1 >= BASE)
s1 -= BASE; s1 -= BASE;
}
/* s2 = (s2 + s1) % BASE */ /* s2 = (s2 + s1) % BASE */
/* first we add */ /* first we add */
s2 = (s2 + s1); s2 = (s2 + s1);
/* again, it is more efficent (it seems) to /* again, it is more efficent (it seems) to
* subtract since the most s2 will ever be * subtract since the most s2 will ever be
* is (BASE-1 + BASE-1) in the worse case. * is (BASE-1 + BASE-1) in the worse case.
...@@ -115,37 +115,36 @@ unsigned long update_adler32(unsigned long adler, ...@@ -115,37 +115,36 @@ unsigned long update_adler32(unsigned long adler,
* avoid the divide. Have not -pg'd on * avoid the divide. Have not -pg'd on
* sparc. * sparc.
*/ */
if(s2 >= BASE){ if (s2 >= BASE) {
/* s2 %= BASE;*/ /* s2 %= BASE;*/
s2 -= BASE; s2 -= BASE;
} }
} }
/* Return the adler32 of the bytes buf[0..len-1] */ /* Return the adler32 of the bytes buf[0..len-1] */
return (s2 << 16) + s1; return (s2 << 16) + s1;
} }
uint32_t __u32 count_crc(__u8 *ptr, __u16 count)
count_crc(uint8_t *ptr,
uint16_t count)
{ {
/* /*
* Update a running Adler-32 checksum with the bytes * Update a running Adler-32 checksum with the bytes
* buf[0..len-1] and return the updated checksum. The Adler-32 * buf[0..len-1] and return the updated checksum. The Adler-32
* checksum should be initialized to 1. * checksum should be initialized to 1.
*/ */
uint32_t adler = 1L; __u32 adler = 1L;
uint32_t zero = 0L; __u32 zero = 0L;
/* Calculate the CRC up to the checksum field. */ /* Calculate the CRC up to the checksum field. */
adler = update_adler32(adler, ptr, adler = update_adler32(adler, ptr,
sizeof(struct sctphdr) - sizeof(uint32_t)); sizeof(struct sctphdr) - sizeof(__u32));
/* Skip over the checksum field. */ /* Skip over the checksum field. */
adler = update_adler32(adler, &zero, sizeof(uint32_t)); adler = update_adler32(adler, &zero, sizeof(__u32));
ptr += sizeof(struct sctphdr); ptr += sizeof(struct sctphdr);
count -= sizeof(struct sctphdr); count -= sizeof(struct sctphdr);
/* Calculate the rest of the Adler-32. */ /* Calculate the rest of the Adler-32. */
adler = update_adler32(adler, ptr, count); adler = update_adler32(adler, ptr, count);
return(adler); return adler;
} }
This diff is collapsed.
This diff is collapsed.
...@@ -42,82 +42,67 @@ ...@@ -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 $"; 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 <linux/types.h>
#include <net/sctp/sctp.h> #include <net/sctp/sctp.h>
#include <net/sctp/sctp_sm.h> #include <net/sctp/sctp_sm.h>
/* Create a new sctp_command_sequence. */ /* Create a new sctp_command_sequence. */
sctp_cmd_seq_t * sctp_cmd_seq_t *sctp_new_cmd_seq(int priority)
sctp_new_cmd_seq(int priority)
{ {
sctp_cmd_seq_t *retval; sctp_cmd_seq_t *retval = t_new(sctp_cmd_seq_t, priority);
retval = t_new(sctp_cmd_seq_t, priority);
/* XXX Check for NULL? -DaveM */
sctp_init_cmd_seq(retval); sctp_init_cmd_seq(retval);
return retval; return retval;
}
} /* sctp_new_cmd_seq() */
/* Initialize a block of memory as a command sequence. */ /* Initialize a block of memory as a command sequence. */
int int sctp_init_cmd_seq(sctp_cmd_seq_t *seq)
sctp_init_cmd_seq(sctp_cmd_seq_t *seq)
{ {
memset(seq, 0, sizeof(sctp_cmd_seq_t)); memset(seq, 0, sizeof(sctp_cmd_seq_t));
return 1; /* We always succeed. */ return 1; /* We always succeed. */
}
} /* sctp_init_cmd_seq() */
/* Add a command to a sctp_cmd_seq_t. /* Add a command to a sctp_cmd_seq_t.
* Return 0 if the command sequence is full. * Return 0 if the command sequence is full.
*/ */
int int sctp_add_cmd(sctp_cmd_seq_t *seq, sctp_verb_t verb, sctp_arg_t obj)
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; goto fail;
}
seq->cmds[seq->next_free_slot].verb = verb; seq->cmds[seq->next_free_slot].verb = verb;
seq->cmds[seq->next_free_slot++].obj = obj; seq->cmds[seq->next_free_slot++].obj = obj;
return 1; return 1;
fail:
return 0;
} /* sctp_add_cmd() */ fail:
return 0;
}
/* Rewind an sctp_cmd_seq_t to iterate from the start. */ /* Rewind an sctp_cmd_seq_t to iterate from the start. */
int int sctp_rewind_sequence(sctp_cmd_seq_t *seq)
sctp_rewind_sequence(sctp_cmd_seq_t *seq)
{ {
seq->next_cmd = 0; seq->next_cmd = 0;
return 1; /* We always succeed. */ return 1; /* We always succeed. */
}
} /* sctp_rewind_sequence() */
/* Return the next command structure in a sctp_cmd_seq. /* Return the next command structure in a sctp_cmd_seq.
* Returns NULL at the end of the sequence. * Returns NULL at the end of the sequence.
*/ */
sctp_cmd_t * sctp_cmd_t *sctp_next_cmd(sctp_cmd_seq_t *seq)
sctp_next_cmd(sctp_cmd_seq_t *seq)
{ {
sctp_cmd_t *retval = NULL; 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++]; retval = &seq->cmds[seq->next_cmd++];
}
return retval; return retval;
}
} /* sctp_next_cmd() */
/* Dispose of a command sequence. */ /* Dispose of a command sequence. */
void void sctp_free_cmd_seq(sctp_cmd_seq_t *seq)
sctp_free_cmd_seq(sctp_cmd_seq_t *seq)
{ {
kfree(seq); kfree(seq);
}
} /* sctp_free_cmd_seq() */
...@@ -47,7 +47,6 @@ static char *cvs_id __attribute__ ((unused)) = "$Id: sctp_crc32c.c,v 1.9 2002/07 ...@@ -47,7 +47,6 @@ static char *cvs_id __attribute__ ((unused)) = "$Id: sctp_crc32c.c,v 1.9 2002/07
* The code has now been modified specifically for SCTP knowledge. * The code has now been modified specifically for SCTP knowledge.
*/ */
#include <linux/types.h> #include <linux/types.h>
#include <net/sctp/sctp.h> #include <net/sctp/sctp.h>
...@@ -72,101 +71,94 @@ static char *cvs_id __attribute__ ((unused)) = "$Id: sctp_crc32c.c,v 1.9 2002/07 ...@@ -72,101 +71,94 @@ static char *cvs_id __attribute__ ((unused)) = "$Id: sctp_crc32c.c,v 1.9 2002/07
/* with 24 and 32 Parity Bits", */ /* with 24 and 32 Parity Bits", */
/* IEEE Transactions on Communications, Vol.41, No.6, June 1993 */ /* IEEE Transactions on Communications, Vol.41, No.6, June 1993 */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
unsigned long crc_c[256] = __u32 crc_c[256] = {
{ 0x00000000, 0xF26B8303, 0xE13B70F7, 0x1350F3F4,
0x00000000L, 0xF26B8303L, 0xE13B70F7L, 0x1350F3F4L, 0xC79A971F, 0x35F1141C, 0x26A1E7E8, 0xD4CA64EB,
0xC79A971FL, 0x35F1141CL, 0x26A1E7E8L, 0xD4CA64EBL, 0x8AD958CF, 0x78B2DBCC, 0x6BE22838, 0x9989AB3B,
0x8AD958CFL, 0x78B2DBCCL, 0x6BE22838L, 0x9989AB3BL, 0x4D43CFD0, 0xBF284CD3, 0xAC78BF27, 0x5E133C24,
0x4D43CFD0L, 0xBF284CD3L, 0xAC78BF27L, 0x5E133C24L, 0x105EC76F, 0xE235446C, 0xF165B798, 0x030E349B,
0x105EC76FL, 0xE235446CL, 0xF165B798L, 0x030E349BL, 0xD7C45070, 0x25AFD373, 0x36FF2087, 0xC494A384,
0xD7C45070L, 0x25AFD373L, 0x36FF2087L, 0xC494A384L, 0x9A879FA0, 0x68EC1CA3, 0x7BBCEF57, 0x89D76C54,
0x9A879FA0L, 0x68EC1CA3L, 0x7BBCEF57L, 0x89D76C54L, 0x5D1D08BF, 0xAF768BBC, 0xBC267848, 0x4E4DFB4B,
0x5D1D08BFL, 0xAF768BBCL, 0xBC267848L, 0x4E4DFB4BL, 0x20BD8EDE, 0xD2D60DDD, 0xC186FE29, 0x33ED7D2A,
0x20BD8EDEL, 0xD2D60DDDL, 0xC186FE29L, 0x33ED7D2AL, 0xE72719C1, 0x154C9AC2, 0x061C6936, 0xF477EA35,
0xE72719C1L, 0x154C9AC2L, 0x061C6936L, 0xF477EA35L, 0xAA64D611, 0x580F5512, 0x4B5FA6E6, 0xB93425E5,
0xAA64D611L, 0x580F5512L, 0x4B5FA6E6L, 0xB93425E5L, 0x6DFE410E, 0x9F95C20D, 0x8CC531F9, 0x7EAEB2FA,
0x6DFE410EL, 0x9F95C20DL, 0x8CC531F9L, 0x7EAEB2FAL, 0x30E349B1, 0xC288CAB2, 0xD1D83946, 0x23B3BA45,
0x30E349B1L, 0xC288CAB2L, 0xD1D83946L, 0x23B3BA45L, 0xF779DEAE, 0x05125DAD, 0x1642AE59, 0xE4292D5A,
0xF779DEAEL, 0x05125DADL, 0x1642AE59L, 0xE4292D5AL, 0xBA3A117E, 0x4851927D, 0x5B016189, 0xA96AE28A,
0xBA3A117EL, 0x4851927DL, 0x5B016189L, 0xA96AE28AL, 0x7DA08661, 0x8FCB0562, 0x9C9BF696, 0x6EF07595,
0x7DA08661L, 0x8FCB0562L, 0x9C9BF696L, 0x6EF07595L, 0x417B1DBC, 0xB3109EBF, 0xA0406D4B, 0x522BEE48,
0x417B1DBCL, 0xB3109EBFL, 0xA0406D4BL, 0x522BEE48L, 0x86E18AA3, 0x748A09A0, 0x67DAFA54, 0x95B17957,
0x86E18AA3L, 0x748A09A0L, 0x67DAFA54L, 0x95B17957L, 0xCBA24573, 0x39C9C670, 0x2A993584, 0xD8F2B687,
0xCBA24573L, 0x39C9C670L, 0x2A993584L, 0xD8F2B687L, 0x0C38D26C, 0xFE53516F, 0xED03A29B, 0x1F682198,
0x0C38D26CL, 0xFE53516FL, 0xED03A29BL, 0x1F682198L, 0x5125DAD3, 0xA34E59D0, 0xB01EAA24, 0x42752927,
0x5125DAD3L, 0xA34E59D0L, 0xB01EAA24L, 0x42752927L, 0x96BF4DCC, 0x64D4CECF, 0x77843D3B, 0x85EFBE38,
0x96BF4DCCL, 0x64D4CECFL, 0x77843D3BL, 0x85EFBE38L, 0xDBFC821C, 0x2997011F, 0x3AC7F2EB, 0xC8AC71E8,
0xDBFC821CL, 0x2997011FL, 0x3AC7F2EBL, 0xC8AC71E8L, 0x1C661503, 0xEE0D9600, 0xFD5D65F4, 0x0F36E6F7,
0x1C661503L, 0xEE0D9600L, 0xFD5D65F4L, 0x0F36E6F7L, 0x61C69362, 0x93AD1061, 0x80FDE395, 0x72966096,
0x61C69362L, 0x93AD1061L, 0x80FDE395L, 0x72966096L, 0xA65C047D, 0x5437877E, 0x4767748A, 0xB50CF789,
0xA65C047DL, 0x5437877EL, 0x4767748AL, 0xB50CF789L, 0xEB1FCBAD, 0x197448AE, 0x0A24BB5A, 0xF84F3859,
0xEB1FCBADL, 0x197448AEL, 0x0A24BB5AL, 0xF84F3859L, 0x2C855CB2, 0xDEEEDFB1, 0xCDBE2C45, 0x3FD5AF46,
0x2C855CB2L, 0xDEEEDFB1L, 0xCDBE2C45L, 0x3FD5AF46L, 0x7198540D, 0x83F3D70E, 0x90A324FA, 0x62C8A7F9,
0x7198540DL, 0x83F3D70EL, 0x90A324FAL, 0x62C8A7F9L, 0xB602C312, 0x44694011, 0x5739B3E5, 0xA55230E6,
0xB602C312L, 0x44694011L, 0x5739B3E5L, 0xA55230E6L, 0xFB410CC2, 0x092A8FC1, 0x1A7A7C35, 0xE811FF36,
0xFB410CC2L, 0x092A8FC1L, 0x1A7A7C35L, 0xE811FF36L, 0x3CDB9BDD, 0xCEB018DE, 0xDDE0EB2A, 0x2F8B6829,
0x3CDB9BDDL, 0xCEB018DEL, 0xDDE0EB2AL, 0x2F8B6829L, 0x82F63B78, 0x709DB87B, 0x63CD4B8F, 0x91A6C88C,
0x82F63B78L, 0x709DB87BL, 0x63CD4B8FL, 0x91A6C88CL, 0x456CAC67, 0xB7072F64, 0xA457DC90, 0x563C5F93,
0x456CAC67L, 0xB7072F64L, 0xA457DC90L, 0x563C5F93L, 0x082F63B7, 0xFA44E0B4, 0xE9141340, 0x1B7F9043,
0x082F63B7L, 0xFA44E0B4L, 0xE9141340L, 0x1B7F9043L, 0xCFB5F4A8, 0x3DDE77AB, 0x2E8E845F, 0xDCE5075C,
0xCFB5F4A8L, 0x3DDE77ABL, 0x2E8E845FL, 0xDCE5075CL, 0x92A8FC17, 0x60C37F14, 0x73938CE0, 0x81F80FE3,
0x92A8FC17L, 0x60C37F14L, 0x73938CE0L, 0x81F80FE3L, 0x55326B08, 0xA759E80B, 0xB4091BFF, 0x466298FC,
0x55326B08L, 0xA759E80BL, 0xB4091BFFL, 0x466298FCL, 0x1871A4D8, 0xEA1A27DB, 0xF94AD42F, 0x0B21572C,
0x1871A4D8L, 0xEA1A27DBL, 0xF94AD42FL, 0x0B21572CL, 0xDFEB33C7, 0x2D80B0C4, 0x3ED04330, 0xCCBBC033,
0xDFEB33C7L, 0x2D80B0C4L, 0x3ED04330L, 0xCCBBC033L, 0xA24BB5A6, 0x502036A5, 0x4370C551, 0xB11B4652,
0xA24BB5A6L, 0x502036A5L, 0x4370C551L, 0xB11B4652L, 0x65D122B9, 0x97BAA1BA, 0x84EA524E, 0x7681D14D,
0x65D122B9L, 0x97BAA1BAL, 0x84EA524EL, 0x7681D14DL, 0x2892ED69, 0xDAF96E6A, 0xC9A99D9E, 0x3BC21E9D,
0x2892ED69L, 0xDAF96E6AL, 0xC9A99D9EL, 0x3BC21E9DL, 0xEF087A76, 0x1D63F975, 0x0E330A81, 0xFC588982,
0xEF087A76L, 0x1D63F975L, 0x0E330A81L, 0xFC588982L, 0xB21572C9, 0x407EF1CA, 0x532E023E, 0xA145813D,
0xB21572C9L, 0x407EF1CAL, 0x532E023EL, 0xA145813DL, 0x758FE5D6, 0x87E466D5, 0x94B49521, 0x66DF1622,
0x758FE5D6L, 0x87E466D5L, 0x94B49521L, 0x66DF1622L, 0x38CC2A06, 0xCAA7A905, 0xD9F75AF1, 0x2B9CD9F2,
0x38CC2A06L, 0xCAA7A905L, 0xD9F75AF1L, 0x2B9CD9F2L, 0xFF56BD19, 0x0D3D3E1A, 0x1E6DCDEE, 0xEC064EED,
0xFF56BD19L, 0x0D3D3E1AL, 0x1E6DCDEEL, 0xEC064EEDL, 0xC38D26C4, 0x31E6A5C7, 0x22B65633, 0xD0DDD530,
0xC38D26C4L, 0x31E6A5C7L, 0x22B65633L, 0xD0DDD530L, 0x0417B1DB, 0xF67C32D8, 0xE52CC12C, 0x1747422F,
0x0417B1DBL, 0xF67C32D8L, 0xE52CC12CL, 0x1747422FL, 0x49547E0B, 0xBB3FFD08, 0xA86F0EFC, 0x5A048DFF,
0x49547E0BL, 0xBB3FFD08L, 0xA86F0EFCL, 0x5A048DFFL, 0x8ECEE914, 0x7CA56A17, 0x6FF599E3, 0x9D9E1AE0,
0x8ECEE914L, 0x7CA56A17L, 0x6FF599E3L, 0x9D9E1AE0L, 0xD3D3E1AB, 0x21B862A8, 0x32E8915C, 0xC083125F,
0xD3D3E1ABL, 0x21B862A8L, 0x32E8915CL, 0xC083125FL, 0x144976B4, 0xE622F5B7, 0xF5720643, 0x07198540,
0x144976B4L, 0xE622F5B7L, 0xF5720643L, 0x07198540L, 0x590AB964, 0xAB613A67, 0xB831C993, 0x4A5A4A90,
0x590AB964L, 0xAB613A67L, 0xB831C993L, 0x4A5A4A90L, 0x9E902E7B, 0x6CFBAD78, 0x7FAB5E8C, 0x8DC0DD8F,
0x9E902E7BL, 0x6CFBAD78L, 0x7FAB5E8CL, 0x8DC0DD8FL, 0xE330A81A, 0x115B2B19, 0x020BD8ED, 0xF0605BEE,
0xE330A81AL, 0x115B2B19L, 0x020BD8EDL, 0xF0605BEEL, 0x24AA3F05, 0xD6C1BC06, 0xC5914FF2, 0x37FACCF1,
0x24AA3F05L, 0xD6C1BC06L, 0xC5914FF2L, 0x37FACCF1L, 0x69E9F0D5, 0x9B8273D6, 0x88D28022, 0x7AB90321,
0x69E9F0D5L, 0x9B8273D6L, 0x88D28022L, 0x7AB90321L, 0xAE7367CA, 0x5C18E4C9, 0x4F48173D, 0xBD23943E,
0xAE7367CAL, 0x5C18E4C9L, 0x4F48173DL, 0xBD23943EL, 0xF36E6F75, 0x0105EC76, 0x12551F82, 0xE03E9C81,
0xF36E6F75L, 0x0105EC76L, 0x12551F82L, 0xE03E9C81L, 0x34F4F86A, 0xC69F7B69, 0xD5CF889D, 0x27A40B9E,
0x34F4F86AL, 0xC69F7B69L, 0xD5CF889DL, 0x27A40B9EL, 0x79B737BA, 0x8BDCB4B9, 0x988C474D, 0x6AE7C44E,
0x79B737BAL, 0x8BDCB4B9L, 0x988C474DL, 0x6AE7C44EL, 0xBE2DA0A5, 0x4C4623A6, 0x5F16D052, 0xAD7D5351,
0xBE2DA0A5L, 0x4C4623A6L, 0x5F16D052L, 0xAD7D5351L,
}; };
__u32 count_crc(__u8 *buffer, __u16 length)
uint32_t
count_crc(uint8_t *buffer, uint16_t length)
{ {
unsigned int i; __u32 crc32 = ~(__u32) 0;
unsigned long crc32 = ~0L; __u32 i, result;
unsigned long result; __u8 byte0, byte1, byte2, byte3;
unsigned char byte0, byte1, byte2, byte3;
/* Optimize this routine to be SCTP specific, knowing how /* Optimize this routine to be SCTP specific, knowing how
* to skip the checksum field of the SCTP header. * to skip the checksum field of the SCTP header.
*/ */
/* Calculate CRC up to the checksum. */ /* Calculate CRC up to the checksum. */
for (i = 0; i < (sizeof(struct sctphdr) - sizeof(uint32_t)); i++) { for (i = 0; i < (sizeof(struct sctphdr) - sizeof(__u32)); i++)
CRC32C(crc32, buffer[i]); CRC32C(crc32, buffer[i]);
}
/* Skip checksum field of the header. */ /* Skip checksum field of the header. */
for (i = 0; i < sizeof(uint32_t); i++){ for (i = 0; i < sizeof(__u32); i++)
CRC32C(crc32, 0); CRC32C(crc32, 0);
}
/* Calculate the rest of the CRC. */ /* Calculate the rest of the CRC. */
for (i = sizeof(struct sctphdr); i < length ; i++){ for (i = sizeof(struct sctphdr); i < length ; i++)
CRC32C(crc32, buffer[i]); CRC32C(crc32, buffer[i]);
}
result = ~crc32; result = ~crc32;
...@@ -192,8 +184,7 @@ count_crc(uint8_t *buffer, uint16_t length) ...@@ -192,8 +184,7 @@ count_crc(uint8_t *buffer, uint16_t length)
(byte1 << 16) | (byte1 << 16) |
(byte2 << 8) | (byte2 << 8) |
byte3); byte3);
return(crc32); return crc32;
}
} /* count_crc() */
...@@ -57,7 +57,6 @@ static char *cvs_id __attribute__ ((unused)) = "$Id: sctp_debug.c,v 1.10 2002/07 ...@@ -57,7 +57,6 @@ static char *cvs_id __attribute__ ((unused)) = "$Id: sctp_debug.c,v 1.10 2002/07
int sctp_debug_flag = 1; /* Initially enable DEBUG */ int sctp_debug_flag = 1; /* Initially enable DEBUG */
#endif /* SCTP_DEBUG */ #endif /* SCTP_DEBUG */
/* These are printable forms of Chunk ID's from section 3.1. */ /* These are printable forms of Chunk ID's from section 3.1. */
static const char *sctp_cid_tbl[SCTP_NUM_BASE_CHUNK_TYPES] = { static const char *sctp_cid_tbl[SCTP_NUM_BASE_CHUNK_TYPES] = {
"DATA", "DATA",
...@@ -75,33 +74,31 @@ static const char *sctp_cid_tbl[SCTP_NUM_BASE_CHUNK_TYPES] = { ...@@ -75,33 +74,31 @@ static const char *sctp_cid_tbl[SCTP_NUM_BASE_CHUNK_TYPES] = {
"ECN_ECNE", "ECN_ECNE",
"ECN_CWR", "ECN_CWR",
"SHUTDOWN_COMPLETE", "SHUTDOWN_COMPLETE",
}; /* char *sctp_cid_tbl[] */ };
/* Lookup "chunk type" debug name. */ /* Lookup "chunk type" debug name. */
const char * const char *sctp_cname(const sctp_subtype_t cid)
sctp_cname(const sctp_subtype_t cid)
{ {
if ( cid.chunk < 0 ) { if (cid.chunk < 0)
return "illegal chunk id"; return "illegal chunk id";
} if (cid.chunk <= SCTP_CID_BASE_MAX)
if ( cid.chunk <= SCTP_CID_BASE_MAX ) {
return sctp_cid_tbl[cid.chunk]; return sctp_cid_tbl[cid.chunk];
}
switch ( cid.chunk ) { switch (cid.chunk) {
case SCTP_CID_ASCONF : return "ASCONF"; case SCTP_CID_ASCONF:
case SCTP_CID_ASCONF_ACK : return "ASCONF_ACK"; return "ASCONF";
case SCTP_CID_ASCONF_ACK:
return "ASCONF_ACK";
default: default:
return "unknown chunk"; return "unknown chunk";
} };
return "unknown chunk"; return "unknown chunk";
}
} /* sctp_cname() */
/* These are printable form of variable-length parameters. */ /* These are printable form of variable-length parameters. */
const char *sctp_param_tbl[SCTP_PARAM_ECN_CAPABLE+1] = { const char *sctp_param_tbl[SCTP_PARAM_ECN_CAPABLE + 1] = {
"", "",
"PARAM_HEATBEAT_INFO", "PARAM_HEATBEAT_INFO",
"", "",
...@@ -115,8 +112,7 @@ const char *sctp_param_tbl[SCTP_PARAM_ECN_CAPABLE+1] = { ...@@ -115,8 +112,7 @@ const char *sctp_param_tbl[SCTP_PARAM_ECN_CAPABLE+1] = {
"", "",
"PARAM_HOST_NAME_ADDRESS", "PARAM_HOST_NAME_ADDRESS",
"PARAM_SUPPORTED_ADDRESS_TYPES", "PARAM_SUPPORTED_ADDRESS_TYPES",
}; /* char *sctp_param_tbl[] */ };
/* These are printable forms of the states. */ /* These are printable forms of the states. */
const char *sctp_state_tbl[SCTP_STATE_NUM_STATES] = { const char *sctp_state_tbl[SCTP_STATE_NUM_STATES] = {
...@@ -129,7 +125,7 @@ const char *sctp_state_tbl[SCTP_STATE_NUM_STATES] = { ...@@ -129,7 +125,7 @@ const char *sctp_state_tbl[SCTP_STATE_NUM_STATES] = {
"STATE_SHUTDOWN_SENT", "STATE_SHUTDOWN_SENT",
"STATE_SHUTDOWN_RECEIVED", "STATE_SHUTDOWN_RECEIVED",
"STATE_SHUTDOWN_ACK_SENT", "STATE_SHUTDOWN_ACK_SENT",
}; /* char *sctp_state_tbl[] */ };
/* Events that could change the state of an association. */ /* Events that could change the state of an association. */
const char *sctp_evttype_tbl[] = { const char *sctp_evttype_tbl[] = {
...@@ -174,20 +170,14 @@ static const char *sctp_primitive_tbl[SCTP_NUM_PRIMITIVE_TYPES] = { ...@@ -174,20 +170,14 @@ static const char *sctp_primitive_tbl[SCTP_NUM_PRIMITIVE_TYPES] = {
}; };
/* Lookup primitive debug name. */ /* Lookup primitive debug name. */
const char * const char *sctp_pname(const sctp_subtype_t id)
sctp_pname(const sctp_subtype_t id)
{ {
if ( id.primitive < 0 ) { if (id.primitive < 0)
return "illegal primitive"; return "illegal primitive";
} if (id.primitive <= SCTP_EVENT_PRIMITIVE_MAX)
if ( id.primitive <= SCTP_EVENT_PRIMITIVE_MAX ) {
return sctp_primitive_tbl[id.primitive]; return sctp_primitive_tbl[id.primitive];
}
return "unknown_primitive"; return "unknown_primitive";
}
} /* sctp_pname() */
static const char *sctp_other_tbl[] = { static const char *sctp_other_tbl[] = {
"NO_PENDING_TSN", "NO_PENDING_TSN",
...@@ -195,19 +185,14 @@ static const char *sctp_other_tbl[] = { ...@@ -195,19 +185,14 @@ static const char *sctp_other_tbl[] = {
}; };
/* Lookup "other" debug name. */ /* Lookup "other" debug name. */
const char * const char *sctp_oname(const sctp_subtype_t id)
sctp_oname(const sctp_subtype_t id)
{ {
if ( id.other < 0 ) { if (id.other < 0)
return "illegal 'other' event"; return "illegal 'other' event";
} if (id.other < SCTP_EVENT_OTHER_MAX)
if ( id.other < SCTP_EVENT_OTHER_MAX ) {
return sctp_other_tbl[id.other]; return sctp_other_tbl[id.other];
}
return "unknown 'other' event"; return "unknown 'other' event";
} /* sctp_oname() */ }
static const char *sctp_timer_tbl[] = { static const char *sctp_timer_tbl[] = {
"TIMEOUT_NONE", "TIMEOUT_NONE",
...@@ -223,19 +208,11 @@ static const char *sctp_timer_tbl[] = { ...@@ -223,19 +208,11 @@ static const char *sctp_timer_tbl[] = {
}; };
/* Lookup timer debug name. */ /* Lookup timer debug name. */
const char * const char *sctp_tname(const sctp_subtype_t id)
sctp_tname(const sctp_subtype_t id)
{ {
if ( id.timeout < 0 ) { if (id.timeout < 0)
return "illegal 'timer' event"; return "illegal 'timer' event";
} if (id.timeout <= SCTP_EVENT_TIMEOUT_MAX)
if ( id.timeout <= SCTP_EVENT_TIMEOUT_MAX ) {
return sctp_timer_tbl[id.timeout]; return sctp_timer_tbl[id.timeout];
}
return "unknown_timer"; return "unknown_timer";
}
} /* sctp_tname() */
...@@ -52,7 +52,6 @@ ...@@ -52,7 +52,6 @@
*/ */
static char *cvs_id __attribute__ ((unused)) = "$Id: sctp_endpointola.c,v 1.26 2002/08/16 19:30:49 jgrimm Exp $"; static char *cvs_id __attribute__ ((unused)) = "$Id: sctp_endpointola.c,v 1.26 2002/08/16 19:30:49 jgrimm Exp $";
#include <linux/config.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -63,28 +62,23 @@ static char *cvs_id __attribute__ ((unused)) = "$Id: sctp_endpointola.c,v 1.26 2 ...@@ -63,28 +62,23 @@ static char *cvs_id __attribute__ ((unused)) = "$Id: sctp_endpointola.c,v 1.26 2
#include <net/sctp/sctp.h> #include <net/sctp/sctp.h>
#include <net/sctp/sctp_sm.h> #include <net/sctp/sctp_sm.h>
/* Forward declarations for internal helpers. */ /* Forward declarations for internal helpers. */
static void sctp_endpoint_bh_rcv(sctp_endpoint_t *ep); static void sctp_endpoint_bh_rcv(sctp_endpoint_t *ep);
/* Create a sctp_endpoint_t with all that boring stuff initialized. /* Create a sctp_endpoint_t with all that boring stuff initialized.
* Returns NULL if there isn't enough memory. * Returns NULL if there isn't enough memory.
*/ */
sctp_endpoint_t * sctp_endpoint_t *sctp_endpoint_new(sctp_protocol_t *proto,
sctp_endpoint_new(sctp_protocol_t *proto, struct sock *sk, int priority) struct sock *sk, int priority)
{ {
sctp_endpoint_t *ep; sctp_endpoint_t *ep;
/* Build a local endpoint. */ /* Build a local endpoint. */
ep = t_new(sctp_endpoint_t, priority); ep = t_new(sctp_endpoint_t, priority);
if (NULL == ep) { if (!ep)
goto fail; goto fail;
} if (!sctp_endpoint_init(ep, proto, sk, priority))
if (NULL == sctp_endpoint_init(ep, proto, sk, priority)) {
goto fail_init; goto fail_init;
}
ep->base.malloced = 1; ep->base.malloced = 1;
SCTP_DBG_OBJCNT_INC(ep); SCTP_DBG_OBJCNT_INC(ep);
return ep; return ep;
...@@ -93,18 +87,14 @@ sctp_endpoint_new(sctp_protocol_t *proto, struct sock *sk, int priority) ...@@ -93,18 +87,14 @@ sctp_endpoint_new(sctp_protocol_t *proto, struct sock *sk, int priority)
kfree(ep); kfree(ep);
fail: fail:
return NULL; return NULL;
}
} /* sctp_endpoint_new() */
/* /*
* Initialize the base fields of the endpoint structure. * Initialize the base fields of the endpoint structure.
*/ */
sctp_endpoint_t * sctp_endpoint_t *sctp_endpoint_init(sctp_endpoint_t *ep, sctp_protocol_t *proto,
sctp_endpoint_init(sctp_endpoint_t *ep, sctp_protocol_t *proto,
struct sock *sk, int priority) struct sock *sk, int priority)
{ {
memset(ep, 0, sizeof(sctp_endpoint_t)); memset(ep, 0, sizeof(sctp_endpoint_t));
/* Initialize the base structure. */ /* Initialize the base structure. */
...@@ -160,6 +150,7 @@ sctp_endpoint_init(sctp_endpoint_t *ep, sctp_protocol_t *proto, ...@@ -160,6 +150,7 @@ sctp_endpoint_init(sctp_endpoint_t *ep, sctp_protocol_t *proto,
= SCTP_DEFAULT_TIMEOUT_PMTU_RAISE; = SCTP_DEFAULT_TIMEOUT_PMTU_RAISE;
/* Set up the default send/receive buffer space. */ /* Set up the default send/receive buffer space. */
/* FIXME - Should the min and max window size be configurable /* FIXME - Should the min and max window size be configurable
* sysctl parameters as opposed to be constants? * sysctl parameters as opposed to be constants?
*/ */
...@@ -176,33 +167,24 @@ sctp_endpoint_init(sctp_endpoint_t *ep, sctp_protocol_t *proto, ...@@ -176,33 +167,24 @@ sctp_endpoint_init(sctp_endpoint_t *ep, sctp_protocol_t *proto,
ep->key_changed_at = jiffies; ep->key_changed_at = jiffies;
ep->debug_name = "unnamedEndpoint"; ep->debug_name = "unnamedEndpoint";
return ep; return ep;
}
} /* sctp_endpoint_init() */ /* Add an association to an endpoint. */
void sctp_endpoint_add_asoc(sctp_endpoint_t *ep, sctp_association_t *asoc)
/* Add an association to an endpoint.
*/
void
sctp_endpoint_add_asoc(sctp_endpoint_t *ep, sctp_association_t *asoc)
{ {
/* Now just add it to our list of asocs */ /* Now just add it to our list of asocs */
list_add_tail(&asoc->asocs, &ep->asocs); list_add_tail(&asoc->asocs, &ep->asocs);
}
} /* sctp_endpoint_add_asoc() */
/* Free the endpoint structure. Delay cleanup until /* Free the endpoint structure. Delay cleanup until
* all users have released their reference count on this structure. * all users have released their reference count on this structure.
*/ */
void void sctp_endpoint_free(sctp_endpoint_t *ep)
sctp_endpoint_free(sctp_endpoint_t *ep)
{ {
ep->base.dead = 1; ep->base.dead = 1;
sctp_endpoint_put(ep); sctp_endpoint_put(ep);
}
} /* sctp_free_endpoint() */
/* Final destructor for endpoint. */ /* Final destructor for endpoint. */
void sctp_endpoint_destroy(sctp_endpoint_t *ep) void sctp_endpoint_destroy(sctp_endpoint_t *ep)
...@@ -218,48 +200,38 @@ void sctp_endpoint_destroy(sctp_endpoint_t *ep) ...@@ -218,48 +200,38 @@ void sctp_endpoint_destroy(sctp_endpoint_t *ep)
sctp_bind_addr_free(&ep->base.bind_addr); sctp_bind_addr_free(&ep->base.bind_addr);
/* Remove and free the port */ /* Remove and free the port */
if (ep->base.sk->prev != NULL) { if (ep->base.sk->prev != NULL)
sctp_put_port(ep->base.sk); sctp_put_port(ep->base.sk);
}
/* Give up our hold on the sock. */ /* Give up our hold on the sock. */
if (ep->base.sk) { if (ep->base.sk)
sock_put(ep->base.sk); sock_put(ep->base.sk);
}
/* Finally, free up our memory. */ /* Finally, free up our memory. */
if (ep->base.malloced) { if (ep->base.malloced) {
kfree(ep); kfree(ep);
SCTP_DBG_OBJCNT_DEC(ep); SCTP_DBG_OBJCNT_DEC(ep);
} }
return; }
} /* sctp_endpoint_destroy() */
/* Hold a reference to an endpoint. */ /* Hold a reference to an endpoint. */
void sctp_endpoint_hold(sctp_endpoint_t *ep) void sctp_endpoint_hold(sctp_endpoint_t *ep)
{ {
atomic_inc(&ep->base.refcnt); atomic_inc(&ep->base.refcnt);
}
} /* sctp_endpoint_hold() */
/* Release a reference to an endpoint and clean up if there are /* Release a reference to an endpoint and clean up if there are
* no more references. * no more references.
*/ */
void sctp_endpoint_put(sctp_endpoint_t *ep) void sctp_endpoint_put(sctp_endpoint_t *ep)
{ {
if (atomic_dec_and_test(&ep->base.refcnt)) { if (atomic_dec_and_test(&ep->base.refcnt))
sctp_endpoint_destroy(ep); sctp_endpoint_destroy(ep);
} }
} /* sctp_endpoint_put() */
/* Is this the endpoint we are looking for? */ /* Is this the endpoint we are looking for? */
sctp_endpoint_t * sctp_endpoint_t *sctp_endpoint_is_match(sctp_endpoint_t *ep,
sctp_endpoint_is_match(sctp_endpoint_t *ep, const sockaddr_storage_t *laddr) const sockaddr_storage_t *laddr)
{ {
sctp_endpoint_t *retval; sctp_endpoint_t *retval;
...@@ -276,17 +248,13 @@ sctp_endpoint_is_match(sctp_endpoint_t *ep, const sockaddr_storage_t *laddr) ...@@ -276,17 +248,13 @@ sctp_endpoint_is_match(sctp_endpoint_t *ep, const sockaddr_storage_t *laddr)
out: out:
sctp_read_unlock(&ep->base.addr_lock); sctp_read_unlock(&ep->base.addr_lock);
return retval; return retval;
}
} /* sctp_endpoint_is_match() */
/* Find the association that goes with this chunk. /* Find the association that goes with this chunk.
* We do a linear search of the associations for this endpoint. * We do a linear search of the associations for this endpoint.
* We return the matching transport address too. * We return the matching transport address too.
*/ */
sctp_association_t *__sctp_endpoint_lookup_assoc(const sctp_endpoint_t *endpoint,
sctp_association_t *
__sctp_endpoint_lookup_assoc(const sctp_endpoint_t *endpoint,
const sockaddr_storage_t *paddr, const sockaddr_storage_t *paddr,
sctp_transport_t **transport) sctp_transport_t **transport)
{ {
...@@ -299,25 +267,21 @@ __sctp_endpoint_lookup_assoc(const sctp_endpoint_t *endpoint, ...@@ -299,25 +267,21 @@ __sctp_endpoint_lookup_assoc(const sctp_endpoint_t *endpoint,
list_for_each(pos, &endpoint->asocs) { list_for_each(pos, &endpoint->asocs) {
asoc = list_entry(pos, sctp_association_t, asocs); asoc = list_entry(pos, sctp_association_t, asocs);
if (rport == asoc->peer.port) { if (rport == asoc->peer.port) {
sctp_read_lock(&asoc->base.addr_lock); sctp_read_lock(&asoc->base.addr_lock);
*transport = sctp_assoc_lookup_paddr(asoc, paddr); *transport = sctp_assoc_lookup_paddr(asoc, paddr);
sctp_read_unlock(&asoc->base.addr_lock); sctp_read_unlock(&asoc->base.addr_lock);
if (*transport) { if (*transport)
return asoc; return asoc;
} }
} }
} /* for (all associations on endpoint) */
*transport = NULL; *transport = NULL;
return NULL; return NULL;
}
} /* __sctp_endpoint_lookup_assoc() */
/* Lookup association on an endpoint based on a peer address. BH-safe. */ /* Lookup association on an endpoint based on a peer address. BH-safe. */
sctp_association_t * sctp_association_t *sctp_endpoint_lookup_assoc(const sctp_endpoint_t *ep,
sctp_endpoint_lookup_assoc(const sctp_endpoint_t *ep,
const sockaddr_storage_t *paddr, const sockaddr_storage_t *paddr,
sctp_transport_t **transport) sctp_transport_t **transport)
{ {
...@@ -328,16 +292,12 @@ sctp_endpoint_lookup_assoc(const sctp_endpoint_t *ep, ...@@ -328,16 +292,12 @@ sctp_endpoint_lookup_assoc(const sctp_endpoint_t *ep,
sctp_local_bh_enable(); sctp_local_bh_enable();
return asoc; return asoc;
}
} /* sctp_endpoint_lookup_assoc() */
/* Do delayed input processing. This is scheduled by sctp_rcv(). /* Do delayed input processing. This is scheduled by sctp_rcv().
* This may be called on BH or task time. * This may be called on BH or task time.
*/ */
static void static void sctp_endpoint_bh_rcv(sctp_endpoint_t *ep)
sctp_endpoint_bh_rcv(sctp_endpoint_t *ep)
{ {
sctp_association_t *asoc; sctp_association_t *asoc;
struct sock *sk; struct sock *sk;
...@@ -348,7 +308,8 @@ sctp_endpoint_bh_rcv(sctp_endpoint_t *ep) ...@@ -348,7 +308,8 @@ sctp_endpoint_bh_rcv(sctp_endpoint_t *ep)
sctp_state_t state; sctp_state_t state;
int error = 0; int error = 0;
if (ep->base.dead) { goto out; } if (ep->base.dead)
goto out;
asoc = NULL; asoc = NULL;
inqueue = &ep->base.inqueue; inqueue = &ep->base.inqueue;
...@@ -376,15 +337,11 @@ sctp_endpoint_bh_rcv(sctp_endpoint_t *ep) ...@@ -376,15 +337,11 @@ sctp_endpoint_bh_rcv(sctp_endpoint_t *ep)
/* Remember where the last DATA chunk came from so we /* Remember where the last DATA chunk came from so we
* know where to send the SACK. * know where to send the SACK.
*/ */
if ( asoc != NULL && sctp_chunk_is_data(chunk) ) { if (asoc && sctp_chunk_is_data(chunk))
asoc->peer.last_data_from = asoc->peer.last_data_from = chunk->transport;
chunk->transport;
}
if (chunk->transport) { if (chunk->transport)
chunk->transport->last_time_heard = jiffies; chunk->transport->last_time_heard = jiffies;
}
/* FIX ME We really would rather NOT have to use /* FIX ME We really would rather NOT have to use
* GFP_ATOMIC. * GFP_ATOMIC.
...@@ -392,25 +349,23 @@ sctp_endpoint_bh_rcv(sctp_endpoint_t *ep) ...@@ -392,25 +349,23 @@ sctp_endpoint_bh_rcv(sctp_endpoint_t *ep)
error = sctp_do_sm(SCTP_EVENT_T_CHUNK, subtype, state, error = sctp_do_sm(SCTP_EVENT_T_CHUNK, subtype, state,
ep, asoc, chunk, GFP_ATOMIC); ep, asoc, chunk, GFP_ATOMIC);
if (error != 0)
if (error != 0) { goto err_out; } goto err_out;
/* Check to see if the endpoint is freed in response to /* Check to see if the endpoint is freed in response to
* the incoming chunk. If so, get out of the while loop. * the incoming chunk. If so, get out of the while loop.
*/ */
if (NULL == sctp_sk(sk)->ep) { goto out; } if (!sctp_sk(sk)->ep)
goto out;
} /* while (we have more chunks to receive) */ }
err_out: err_out:
/* Is this the right way to pass errors up to the ULP? */ /* Is this the right way to pass errors up to the ULP? */
if (error) { if (error)
ep->base.sk->err = -error; ep->base.sk->err = -error;
}
out:
return;
} /* sctp_bh_rcv_ep() */ out:
}
......
...@@ -44,39 +44,38 @@ static char *cvs_id __attribute__ ((unused)) = "$Id: sctp_hashdriver.c,v 1.2 200 ...@@ -44,39 +44,38 @@ static char *cvs_id __attribute__ ((unused)) = "$Id: sctp_hashdriver.c,v 1.2 200
#include <net/sctp/sctp.h> #include <net/sctp/sctp.h>
#include <net/sctp/sctp_sla1.h> #include <net/sctp/sctp_sla1.h>
/* SCTP Main driver. /* SCTP Main driver.
passing a two pointers and two lengths, * passing a two pointers and two lengths,
returning a digest pointer filled. The md5 code * returning a digest pointer filled. The md5 code
was taken directly from the RFC (2104) so to understand it * was taken directly from the RFC (2104) so to understand it
you may want to go look at the RFC referenced in the * you may want to go look at the RFC referenced in the
SCTP spec. We did modify this code to either user OUR * SCTP spec. We did modify this code to either user OUR
implementation of SLA1 or the MD5 that comes from its * implementation of SLA1 or the MD5 that comes from its
RFC. SLA1 may have IPR issues so you need to check in * RFC. SLA1 may have IPR issues so you need to check in
to this if you wish to use it... Or at least that is * to this if you wish to use it... Or at least that is
what the FIP-180.1 web page says. * what the FIP-180.1 web page says.
*/ */
void void sctp_hash_digest(const char *key, const int in_key_len,
sctp_hash_digest(const char *key, const int in_key_len,
const char *text, const int text_len, const char *text, const int text_len,
uint8_t *digest) __u8 *digest)
{ {
int key_len = in_key_len; int key_len = in_key_len;
unsigned long *p;
struct SLA_1_Context context; struct SLA_1_Context context;
uint8_t k_ipad[65]; /* inner padding - __u8 k_ipad[65]; /* inner padding -
* key XORd with ipad * key XORd with ipad
*/ */
uint8_t k_opad[65]; /* outer padding - __u8 k_opad[65]; /* outer padding -
* key XORd with opad * key XORd with opad
*/ */
uint8_t tk[20]; __u8 tk[20];
int i; int i;
/* if key is longer than 64 bytes reset it to key=MD5(key) */ /* if key is longer than 64 bytes reset it to key=MD5(key) */
if (key_len > 64) { if (key_len > 64) {
struct SLA_1_Context tctx; struct SLA_1_Context tctx;
SLA1_Init(&tctx); SLA1_Init(&tctx);
SLA1_Process(&tctx, key, key_len); SLA1_Process(&tctx, key, key_len);
SLA1_Final(&tctx,tk); SLA1_Final(&tctx,tk);
...@@ -96,20 +95,18 @@ sctp_hash_digest(const char *key, const int in_key_len, ...@@ -96,20 +95,18 @@ sctp_hash_digest(const char *key, const int in_key_len,
*/ */
/* start out by storing key in pads */ /* start out by storing key in pads */
memset( k_ipad, 0, sizeof k_ipad); memset(k_ipad, 0, sizeof k_ipad);
memset( k_opad, 0, sizeof k_opad); memset(k_opad, 0, sizeof k_opad);
memcpy( k_ipad, key, key_len); memcpy(k_ipad, key, key_len);
memcpy( k_opad, key, key_len); memcpy(k_opad, key, key_len);
/* XOR key with ipad and opad values */ /* XOR key with ipad and opad values */
for (i=0; i<64; i++) { for (i = 0; i < 64; i++) {
k_ipad[i] ^= 0x36; k_ipad[i] ^= 0x36;
k_opad[i] ^= 0x5c; k_opad[i] ^= 0x5c;
} }
/* /* perform inner hash */
* perform inner hash
*/
SLA1_Init(&context); /* init context for 1st SLA1_Init(&context); /* init context for 1st
* pass * pass
*/ */
...@@ -120,7 +117,6 @@ sctp_hash_digest(const char *key, const int in_key_len, ...@@ -120,7 +117,6 @@ sctp_hash_digest(const char *key, const int in_key_len,
/* /*
* perform outer hash * perform outer hash
*/ */
SLA1_Init(&context); /* init context for 2nd SLA1_Init(&context); /* init context for 2nd
* pass * pass
*/ */
...@@ -129,7 +125,5 @@ sctp_hash_digest(const char *key, const int in_key_len, ...@@ -129,7 +125,5 @@ sctp_hash_digest(const char *key, const int in_key_len,
* hash * hash
*/ */
SLA1_Final(&context, digest); /* finish up 2nd pass */ SLA1_Final(&context, digest); /* finish up 2nd pass */
p = (unsigned long *)digest;
} }
This diff is collapsed.
...@@ -51,8 +51,7 @@ static char *cvs_id __attribute__ ((unused)) = "$Id: sctp_inqueue.c,v 1.10 2002/ ...@@ -51,8 +51,7 @@ static char *cvs_id __attribute__ ((unused)) = "$Id: sctp_inqueue.c,v 1.10 2002/
#include <linux/interrupt.h> #include <linux/interrupt.h>
/* Initialize an SCTP_inqueue. */ /* Initialize an SCTP_inqueue. */
void void sctp_inqueue_init(sctp_inqueue_t *queue)
sctp_inqueue_init(sctp_inqueue_t *queue)
{ {
skb_queue_head_init(&queue->in); skb_queue_head_init(&queue->in);
queue->in_progress = NULL; queue->in_progress = NULL;
...@@ -64,75 +63,64 @@ sctp_inqueue_init(sctp_inqueue_t *queue) ...@@ -64,75 +63,64 @@ sctp_inqueue_init(sctp_inqueue_t *queue)
queue->immediate.data = NULL; queue->immediate.data = NULL;
queue->malloced = 0; queue->malloced = 0;
}
} /* sctp_inqueue_init() */
/* Create an initialized SCTP_inqueue. */ /* Create an initialized SCTP_inqueue. */
sctp_inqueue_t * sctp_inqueue_t *sctp_inqueue_new(void)
sctp_inqueue_new()
{ {
sctp_inqueue_t *retval; sctp_inqueue_t *retval;
retval = t_new(sctp_inqueue_t, GFP_ATOMIC); retval = t_new(sctp_inqueue_t, GFP_ATOMIC);
if (NULL == retval) { return(NULL); } if (retval) {
sctp_inqueue_init(retval); sctp_inqueue_init(retval);
retval->malloced = 1; retval->malloced = 1;
}
return(retval); return retval;
}
} /* sctp_inqueue_new() */
/* Release the memory associated with an SCTP inqueue. */ /* Release the memory associated with an SCTP inqueue. */
void void sctp_inqueue_free(sctp_inqueue_t *queue)
sctp_inqueue_free(sctp_inqueue_t *queue)
{ {
sctp_chunk_t *chunk; sctp_chunk_t *chunk;
/* Empty the queue. */ /* Empty the queue. */
while ((chunk=(sctp_chunk_t *)skb_dequeue(&queue->in))!=NULL) { while ((chunk = (sctp_chunk_t *) skb_dequeue(&queue->in)) != NULL)
sctp_free_chunk(chunk); sctp_free_chunk(chunk);
}
/* If there is a packet which is currently being worked on, /* If there is a packet which is currently being worked on,
* free it as well. * free it as well.
*/ */
if (queue->in_progress) { if (queue->in_progress)
sctp_free_chunk(queue->in_progress); sctp_free_chunk(queue->in_progress);
}
if (queue->malloced) { if (queue->malloced) {
/* Dump the master memory segment. */ /* Dump the master memory segment. */
kfree(queue); kfree(queue);
} }
}
} /* sctp_inqueue_free() */
/* Put a new packet in an SCTP inqueue. /* Put a new packet in an SCTP inqueue.
* We assume that packet->sctp_hdr is set and in host byte order. * We assume that packet->sctp_hdr is set and in host byte order.
*/ */
void void sctp_push_inqueue(sctp_inqueue_t *q, sctp_chunk_t *packet)
sctp_push_inqueue(sctp_inqueue_t *q, sctp_chunk_t *packet)
{ {
/* Directly call the packet handling routine. */ /* Directly call the packet handling routine. */
/* We are now calling this either from the soft interrupt /* We are now calling this either from the soft interrupt
* or from the backlog processing. * or from the backlog processing.
* Eventually, we should clean up inqueue to not rely * Eventually, we should clean up inqueue to not rely
* on the BH related data structures. * on the BH related data structures.
*/ */
skb_queue_tail(&(q->in), (struct sk_buff *)packet); skb_queue_tail(&(q->in), (struct sk_buff *) packet);
q->immediate.routine(q->immediate.data); q->immediate.routine(q->immediate.data);
}
} /* sctp_push_inqueue() */
/* Extract a chunk from an SCTP inqueue. /* Extract a chunk from an SCTP inqueue.
* *
* WARNING: If you need to put the chunk on another queue, you need to * WARNING: If you need to put the chunk on another queue, you need to
* make a shallow copy (clone) of it. * make a shallow copy (clone) of it.
*/ */
sctp_chunk_t * sctp_chunk_t *sctp_pop_inqueue(sctp_inqueue_t *queue)
sctp_pop_inqueue(sctp_inqueue_t *queue)
{ {
sctp_chunk_t *chunk; sctp_chunk_t *chunk;
sctp_chunkhdr_t *ch = NULL; sctp_chunkhdr_t *ch = NULL;
...@@ -141,17 +129,18 @@ sctp_pop_inqueue(sctp_inqueue_t *queue) ...@@ -141,17 +129,18 @@ sctp_pop_inqueue(sctp_inqueue_t *queue)
* at this time. * at this time.
*/ */
if (NULL != (chunk = queue->in_progress)) { if ((chunk = queue->in_progress) != NULL) {
/* There is a packet that we have been working on. /* There is a packet that we have been working on.
* Any post processing work to do before we move on? * Any post processing work to do before we move on?
*/ */
if (chunk->singleton || chunk->end_of_packet if (chunk->singleton ||
|| chunk->pdiscard) { chunk->end_of_packet ||
chunk->pdiscard) {
sctp_free_chunk(chunk); sctp_free_chunk(chunk);
chunk = queue->in_progress = NULL; chunk = queue->in_progress = NULL;
} else { } else {
/* Nothing to do. Next chunk in the packet, please. */ /* Nothing to do. Next chunk in the packet, please. */
ch = (sctp_chunkhdr_t *)chunk->chunk_end; ch = (sctp_chunkhdr_t *) chunk->chunk_end;
/* Force chunk->skb->data to chunk->chunk_end. */ /* Force chunk->skb->data to chunk->chunk_end. */
skb_pull(chunk->skb, skb_pull(chunk->skb,
...@@ -160,15 +149,13 @@ sctp_pop_inqueue(sctp_inqueue_t *queue) ...@@ -160,15 +149,13 @@ sctp_pop_inqueue(sctp_inqueue_t *queue)
} }
/* Do we need to take the next packet out of the queue to process? */ /* Do we need to take the next packet out of the queue to process? */
if (NULL == chunk) { if (!chunk) {
/* Is the queue empty? */ /* Is the queue empty? */
if (skb_queue_empty(&queue->in)) { if (skb_queue_empty(&queue->in))
return(NULL); return NULL;
}
chunk = queue->in_progress = chunk = queue->in_progress =
(sctp_chunk_t *)skb_dequeue(&queue->in); (sctp_chunk_t *) skb_dequeue(&queue->in);
/* This is the first chunk in the packet. */ /* This is the first chunk in the packet. */
chunk->singleton = 1; chunk->singleton = 1;
...@@ -176,7 +163,7 @@ sctp_pop_inqueue(sctp_inqueue_t *queue) ...@@ -176,7 +163,7 @@ sctp_pop_inqueue(sctp_inqueue_t *queue)
} }
chunk->chunk_hdr = ch; chunk->chunk_hdr = ch;
chunk->chunk_end = ((uint8_t *)ch) chunk->chunk_end = ((__u8 *) ch)
+ WORD_ROUND(ntohs(ch->length)); + WORD_ROUND(ntohs(ch->length));
skb_pull(chunk->skb, sizeof(sctp_chunkhdr_t)); skb_pull(chunk->skb, sizeof(sctp_chunkhdr_t));
chunk->subh.v = NULL; /* Subheader is no longer valid. */ chunk->subh.v = NULL; /* Subheader is no longer valid. */
...@@ -191,14 +178,12 @@ sctp_pop_inqueue(sctp_inqueue_t *queue) ...@@ -191,14 +178,12 @@ sctp_pop_inqueue(sctp_inqueue_t *queue)
chunk->end_of_packet = 1; chunk->end_of_packet = 1;
} }
SCTP_DEBUG_PRINTK("+++sctp_pop_inqueue+++ chunk %p[%s]," SCTP_DEBUG_PRINTK("+++sctp_pop_inqueue+++ chunk %p[%s],"
" length %d, skb->len %d\n",chunk, " length %d, skb->len %d\n",chunk,
sctp_cname(SCTP_ST_CHUNK(chunk->chunk_hdr->type)), sctp_cname(SCTP_ST_CHUNK(chunk->chunk_hdr->type)),
ntohs(chunk->chunk_hdr->length), chunk->skb->len); ntohs(chunk->chunk_hdr->length), chunk->skb->len);
return(chunk); return chunk;
}
} /* sctp_pop_inqueue() */
/* Set a top-half handler. /* Set a top-half handler.
* *
...@@ -208,12 +193,10 @@ sctp_pop_inqueue(sctp_inqueue_t *queue) ...@@ -208,12 +193,10 @@ sctp_pop_inqueue(sctp_inqueue_t *queue)
* The intent is that this routine will pull stuff out of the * The intent is that this routine will pull stuff out of the
* inqueue and process it. * inqueue and process it.
*/ */
void void sctp_inqueue_set_th_handler(sctp_inqueue_t *q,
sctp_inqueue_set_th_handler(sctp_inqueue_t *q,
void (*callback)(void *), void *arg) void (*callback)(void *), void *arg)
{ {
q->immediate.routine = callback; q->immediate.routine = callback;
q->immediate.data = arg; q->immediate.data = arg;
}
} /* sctp_inqueue_set_th_handler() */
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