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