Commit e025484e authored by Jon Grimm's avatar Jon Grimm

Merge touki.austin.ibm.com:/home/jgrimm/bk/lksctp-2.5

into touki.austin.ibm.com:/home/jgrimm/bk/lksctp-2.5.work
parents c03e61bb 3e780f7b
/* SCTP kernel reference Implementation /* SCTP kernel reference Implementation
* Copyright (c) 1999-2000 Cisco, Inc. * Copyright (c) 1999-2000 Cisco, Inc.
* Copyright (c) 1999-2001 Motorola, Inc. * Copyright (c) 1999-2001 Motorola, Inc.
* Copyright (c) 2001 International Business Machines, Corp. * Copyright (c) 2001-2002 International Business Machines, Corp.
* Copyright (c) 2001 Intel Corp. * Copyright (c) 2001 Intel Corp.
* *
* This file is part of the SCTP kernel reference Implementation * This file is part of the SCTP kernel reference Implementation
...@@ -473,6 +473,26 @@ static inline sctp_protocol_t *sctp_get_protocol(void) ...@@ -473,6 +473,26 @@ static inline sctp_protocol_t *sctp_get_protocol(void)
return &sctp_proto; return &sctp_proto;
} }
/* Convert from an IP version number to an Address Family symbol. */
static inline int ipver2af(__u8 ipver)
{
int family;
switch (ipver) {
case 4:
family = AF_INET;
break;
case 6:
family = AF_INET6;
break;
default:
family = 0;
break;
};
return family;
}
/* 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(__u16 lport) static inline int sctp_phashfn(__u16 lport)
......
...@@ -332,10 +332,10 @@ __u32 sctp_generate_tag(const sctp_endpoint_t *); ...@@ -332,10 +332,10 @@ __u32 sctp_generate_tag(const sctp_endpoint_t *);
__u32 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, sctp_addr_param_t *, void sctp_param2sockaddr(union sctp_addr *addr, sctp_addr_param_t *,
__u16 port); __u16 port);
int sctp_addr2sockaddr(const union sctp_params, sockaddr_storage_t *); int sctp_addr2sockaddr(const union sctp_params, union sctp_addr *);
int sockaddr2sctp_addr(const sockaddr_storage_t *, sctp_addr_param_t *); int sockaddr2sctp_addr(const union sctp_addr *, sctp_addr_param_t *);
/* Extern declarations for major data structures. */ /* Extern declarations for major data structures. */
sctp_sm_table_entry_t *sctp_chunk_event_lookup(sctp_cid_t, sctp_state_t); sctp_sm_table_entry_t *sctp_chunk_event_lookup(sctp_cid_t, sctp_state_t);
......
...@@ -95,11 +95,11 @@ struct sockaddr_storage { ...@@ -95,11 +95,11 @@ struct sockaddr_storage {
/* A convenience structure for handling sockaddr structures. /* A convenience structure for handling sockaddr structures.
* We should wean ourselves off this. * We should wean ourselves off this.
*/ */
typedef union { union sctp_addr {
struct sockaddr_in v4; struct sockaddr_in v4;
struct sockaddr_in6 v6; struct sockaddr_in6 v6;
struct sockaddr sa; struct sockaddr sa;
} sockaddr_storage_t; };
/* Forward declarations for data structures. */ /* Forward declarations for data structures. */
...@@ -246,17 +246,24 @@ typedef struct sctp_func { ...@@ -246,17 +246,24 @@ typedef struct sctp_func {
int optname, int optname,
char *optval, char *optval,
int *optlen); int *optlen);
struct dst_entry *(*get_dst) (sockaddr_storage_t *daddr, struct dst_entry *(*get_dst) (union sctp_addr *daddr,
sockaddr_storage_t *saddr); union sctp_addr *saddr);
void (*copy_addrlist) (struct list_head *,
struct net_device *);
int (*cmp_saddr) (struct dst_entry *dst, int (*cmp_saddr) (struct dst_entry *dst,
sockaddr_storage_t *saddr); union sctp_addr *saddr);
void (*addr_copy) (union sctp_addr *dst,
union sctp_addr *src);
void (*from_skb) (union sctp_addr *,
struct sk_buff *skb,
int saddr);
__u16 net_header_len; __u16 net_header_len;
int sockaddr_len; int sockaddr_len;
sa_family_t sa_family; sa_family_t sa_family;
struct list_head list; struct list_head list;
} sctp_func_t; } sctp_func_t;
sctp_func_t *sctp_get_af_specific(const sockaddr_storage_t *address); sctp_func_t *sctp_get_af_specific(sa_family_t);
/* Protocol family functions. */ /* Protocol family functions. */
typedef struct sctp_pf { typedef struct sctp_pf {
...@@ -339,7 +346,7 @@ typedef struct sctp_cookie { ...@@ -339,7 +346,7 @@ typedef struct sctp_cookie {
__u32 initial_tsn; __u32 initial_tsn;
/* This holds the originating address of the INIT packet. */ /* This holds the originating address of the INIT packet. */
sockaddr_storage_t peer_addr; union sctp_addr peer_addr;
/* This is a shim for my peer's INIT packet, followed by /* This is a shim for my peer's INIT packet, followed by
* a copy of the raw address list of the association. * a copy of the raw address list of the association.
...@@ -393,7 +400,7 @@ union sctp_params { ...@@ -393,7 +400,7 @@ union sctp_params {
*/ */
typedef struct sctp_sender_hb_info { typedef struct sctp_sender_hb_info {
sctp_paramhdr_t param_hdr; sctp_paramhdr_t param_hdr;
sockaddr_storage_t daddr; union sctp_addr daddr;
unsigned long sent_at; unsigned long sent_at;
} sctp_sender_hb_info_t __attribute__((packed)); } sctp_sender_hb_info_t __attribute__((packed));
...@@ -479,9 +486,9 @@ struct SCTP_chunk { ...@@ -479,9 +486,9 @@ struct SCTP_chunk {
__u8 tsn_missing_report; /* Data chunk missing counter. */ __u8 tsn_missing_report; /* Data chunk missing counter. */
/* What is the origin IP address for this chunk? */ /* What is the origin IP address for this chunk? */
sockaddr_storage_t source; union sctp_addr source;
/* Destination address for this chunk. */ /* Destination address for this chunk. */
sockaddr_storage_t dest; union sctp_addr dest;
/* For an inbound chunk, this tells us where it came from. /* For an inbound chunk, this tells us where it came from.
* For an outbound chunk, it tells us where we'd like it to * For an outbound chunk, it tells us where we'd like it to
...@@ -499,7 +506,7 @@ int sctp_user_addto_chunk(sctp_chunk_t *chunk, int len, struct iovec *data); ...@@ -499,7 +506,7 @@ int sctp_user_addto_chunk(sctp_chunk_t *chunk, int len, struct iovec *data);
sctp_chunk_t *sctp_chunkify(struct sk_buff *, const sctp_association_t *, sctp_chunk_t *sctp_chunkify(struct sk_buff *, const sctp_association_t *,
struct sock *); struct sock *);
void sctp_init_addrs(sctp_chunk_t *chunk); void sctp_init_addrs(sctp_chunk_t *chunk);
const sockaddr_storage_t *sctp_source(const sctp_chunk_t *chunk); const union sctp_addr *sctp_source(const sctp_chunk_t *chunk);
/* This is a structure for holding either an IPv6 or an IPv4 address. */ /* This is a structure for holding either an IPv6 or an IPv4 address. */
/* sin_family -- AF_INET or AF_INET6 /* sin_family -- AF_INET or AF_INET6
...@@ -508,7 +515,7 @@ const sockaddr_storage_t *sctp_source(const sctp_chunk_t *chunk); ...@@ -508,7 +515,7 @@ const sockaddr_storage_t *sctp_source(const sctp_chunk_t *chunk);
*/ */
struct sockaddr_storage_list { struct sockaddr_storage_list {
struct list_head list; struct list_head list;
sockaddr_storage_t a; union sctp_addr a;
}; };
typedef sctp_chunk_t *(sctp_packet_phandler_t)(sctp_association_t *); typedef sctp_chunk_t *(sctp_packet_phandler_t)(sctp_association_t *);
...@@ -574,7 +581,7 @@ void sctp_packet_free(sctp_packet_t *); ...@@ -574,7 +581,7 @@ void sctp_packet_free(sctp_packet_t *);
/* This represents a remote transport address. /* This represents a remote transport address.
* For local transport addresses, we just use sockaddr_storage_t. * For local transport addresses, we just use union sctp_addr.
* *
* RFC2960 Section 1.4 Key Terms * RFC2960 Section 1.4 Key Terms
* *
...@@ -602,7 +609,7 @@ struct SCTP_transport { ...@@ -602,7 +609,7 @@ struct SCTP_transport {
int dead; int dead;
/* This is the peer's IP address and port. */ /* This is the peer's IP address and port. */
sockaddr_storage_t ipaddr; union sctp_addr ipaddr;
/* These are the functions we call to handle LLP stuff. */ /* These are the functions we call to handle LLP stuff. */
sctp_func_t *af_specific; sctp_func_t *af_specific;
...@@ -742,11 +749,11 @@ struct SCTP_transport { ...@@ -742,11 +749,11 @@ struct SCTP_transport {
int malloced; /* Is this structure kfree()able? */ int malloced; /* Is this structure kfree()able? */
}; };
extern sctp_transport_t *sctp_transport_new(const sockaddr_storage_t *, int); extern sctp_transport_t *sctp_transport_new(const union sctp_addr *, int);
extern sctp_transport_t *sctp_transport_init(sctp_transport_t *, extern sctp_transport_t *sctp_transport_init(sctp_transport_t *,
const sockaddr_storage_t *, int); const union sctp_addr *, int);
extern void sctp_transport_set_owner(sctp_transport_t *, sctp_association_t *); extern void sctp_transport_set_owner(sctp_transport_t *, sctp_association_t *);
extern void sctp_transport_route(sctp_transport_t *, sockaddr_storage_t *); extern void sctp_transport_route(sctp_transport_t *, union sctp_addr *);
extern void sctp_transport_free(sctp_transport_t *); extern void sctp_transport_free(sctp_transport_t *);
extern void sctp_transport_destroy(sctp_transport_t *); extern void sctp_transport_destroy(sctp_transport_t *);
extern void sctp_transport_reset_timers(sctp_transport_t *); extern void sctp_transport_reset_timers(sctp_transport_t *);
...@@ -893,10 +900,10 @@ void sctp_bind_addr_init(sctp_bind_addr_t *, __u16 port); ...@@ -893,10 +900,10 @@ void sctp_bind_addr_init(sctp_bind_addr_t *, __u16 port);
void sctp_bind_addr_free(sctp_bind_addr_t *); void sctp_bind_addr_free(sctp_bind_addr_t *);
int sctp_bind_addr_copy(sctp_bind_addr_t *dest, const sctp_bind_addr_t *src, int sctp_bind_addr_copy(sctp_bind_addr_t *dest, const sctp_bind_addr_t *src,
sctp_scope_t scope, int priority,int flags); sctp_scope_t scope, int priority,int flags);
int sctp_add_bind_addr(sctp_bind_addr_t *, sockaddr_storage_t *, int sctp_add_bind_addr(sctp_bind_addr_t *, union sctp_addr *,
int priority); int priority);
int sctp_del_bind_addr(sctp_bind_addr_t *, sockaddr_storage_t *); int sctp_del_bind_addr(sctp_bind_addr_t *, union sctp_addr *);
int sctp_bind_addr_has_addr(sctp_bind_addr_t *, const sockaddr_storage_t *); int sctp_bind_addr_has_addr(sctp_bind_addr_t *, const union sctp_addr *);
union sctp_params sctp_bind_addrs_to_raw(const sctp_bind_addr_t *bp, union sctp_params sctp_bind_addrs_to_raw(const sctp_bind_addr_t *bp,
int *addrs_len, int *addrs_len,
int priority); int priority);
...@@ -906,10 +913,10 @@ int sctp_raw_to_bind_addrs(sctp_bind_addr_t *bp, ...@@ -906,10 +913,10 @@ int sctp_raw_to_bind_addrs(sctp_bind_addr_t *bp,
unsigned short port, unsigned short port,
int priority); int priority);
sctp_scope_t sctp_scope(const sockaddr_storage_t *); sctp_scope_t sctp_scope(const union sctp_addr *);
int sctp_in_scope(const sockaddr_storage_t *addr, const sctp_scope_t scope); int sctp_in_scope(const union sctp_addr *addr, const sctp_scope_t scope);
int sctp_is_any(const sockaddr_storage_t *addr); int sctp_is_any(const union sctp_addr *addr);
int sctp_addr_is_valid(const sockaddr_storage_t *addr); int sctp_addr_is_valid(const union sctp_addr *addr);
/* What type of sctp_endpoint_common? */ /* What type of sctp_endpoint_common? */
...@@ -1051,13 +1058,13 @@ void sctp_endpoint_put(sctp_endpoint_t *); ...@@ -1051,13 +1058,13 @@ void sctp_endpoint_put(sctp_endpoint_t *);
void sctp_endpoint_hold(sctp_endpoint_t *); void sctp_endpoint_hold(sctp_endpoint_t *);
void sctp_endpoint_add_asoc(sctp_endpoint_t *, sctp_association_t *asoc); void sctp_endpoint_add_asoc(sctp_endpoint_t *, sctp_association_t *asoc);
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, const union sctp_addr *paddr,
sctp_transport_t **); sctp_transport_t **);
sctp_endpoint_t *sctp_endpoint_is_match(sctp_endpoint_t *, sctp_endpoint_t *sctp_endpoint_is_match(sctp_endpoint_t *,
const sockaddr_storage_t *); const union sctp_addr *);
int sctp_has_association(const sockaddr_storage_t *laddr, int sctp_has_association(const union sctp_addr *laddr,
const sockaddr_storage_t *paddr); const union sctp_addr *paddr);
int sctp_verify_init(const sctp_association_t *asoc, int sctp_verify_init(const sctp_association_t *asoc,
sctp_cid_t cid, sctp_cid_t cid,
...@@ -1065,10 +1072,10 @@ int sctp_verify_init(const sctp_association_t *asoc, ...@@ -1065,10 +1072,10 @@ int sctp_verify_init(const sctp_association_t *asoc,
sctp_chunk_t *chunk, sctp_chunk_t *chunk,
sctp_chunk_t **err_chunk); sctp_chunk_t **err_chunk);
int sctp_process_init(sctp_association_t *asoc, sctp_cid_t cid, int sctp_process_init(sctp_association_t *asoc, sctp_cid_t cid,
const sockaddr_storage_t *peer_addr, const union sctp_addr *peer_addr,
sctp_init_chunk_t *peer_init, int priority); sctp_init_chunk_t *peer_init, int priority);
int sctp_process_param(sctp_association_t *asoc, union sctp_params param, int sctp_process_param(sctp_association_t *asoc, union sctp_params param,
const sockaddr_storage_t *peer_addr, int priority); const union sctp_addr *peer_addr, int priority);
__u32 sctp_generate_tag(const sctp_endpoint_t *ep); __u32 sctp_generate_tag(const sctp_endpoint_t *ep);
__u32 sctp_generate_tsn(const sctp_endpoint_t *ep); __u32 sctp_generate_tsn(const sctp_endpoint_t *ep);
...@@ -1157,7 +1164,7 @@ struct SCTP_association { ...@@ -1157,7 +1164,7 @@ struct SCTP_association {
/* Cache the primary path address here, when we /* Cache the primary path address here, when we
* need a an address for msg_name. * need a an address for msg_name.
*/ */
sockaddr_storage_t primary_addr; union sctp_addr primary_addr;
/* active_path /* active_path
* The path that we are currently using to * The path that we are currently using to
...@@ -1535,16 +1542,16 @@ void sctp_association_hold(sctp_association_t *); ...@@ -1535,16 +1542,16 @@ void sctp_association_hold(sctp_association_t *);
sctp_transport_t *sctp_assoc_choose_shutdown_transport(sctp_association_t *); sctp_transport_t *sctp_assoc_choose_shutdown_transport(sctp_association_t *);
sctp_transport_t *sctp_assoc_lookup_paddr(const sctp_association_t *, sctp_transport_t *sctp_assoc_lookup_paddr(const sctp_association_t *,
const sockaddr_storage_t *); const union sctp_addr *);
sctp_transport_t *sctp_assoc_add_peer(sctp_association_t *, sctp_transport_t *sctp_assoc_add_peer(sctp_association_t *,
const sockaddr_storage_t *address, const union sctp_addr *address,
const int priority); const int priority);
void sctp_assoc_control_transport(sctp_association_t *, sctp_transport_t *, void sctp_assoc_control_transport(sctp_association_t *, sctp_transport_t *,
sctp_transport_cmd_t, sctp_sn_error_t); sctp_transport_cmd_t, sctp_sn_error_t);
sctp_transport_t *sctp_assoc_lookup_tsn(sctp_association_t *, __u32); sctp_transport_t *sctp_assoc_lookup_tsn(sctp_association_t *, __u32);
sctp_transport_t *sctp_assoc_is_match(sctp_association_t *, sctp_transport_t *sctp_assoc_is_match(sctp_association_t *,
const sockaddr_storage_t *, const union sctp_addr *,
const sockaddr_storage_t *); const union sctp_addr *);
void sctp_assoc_migrate(sctp_association_t *, struct sock *); void sctp_assoc_migrate(sctp_association_t *, struct sock *);
void sctp_assoc_update(sctp_association_t *dst, sctp_association_t *src); void sctp_assoc_update(sctp_association_t *dst, sctp_association_t *src);
...@@ -1552,10 +1559,10 @@ __u32 __sctp_association_get_next_tsn(sctp_association_t *); ...@@ -1552,10 +1559,10 @@ __u32 __sctp_association_get_next_tsn(sctp_association_t *);
__u32 __sctp_association_get_tsn_block(sctp_association_t *, int); __u32 __sctp_association_get_tsn_block(sctp_association_t *, int);
__u16 __sctp_association_get_next_ssn(sctp_association_t *, __u16 sid); __u16 __sctp_association_get_next_ssn(sctp_association_t *, __u16 sid);
int sctp_cmp_addr(const sockaddr_storage_t *ss1, int sctp_cmp_addr(const union sctp_addr *ss1,
const sockaddr_storage_t *ss2); const union sctp_addr *ss2);
int sctp_cmp_addr_exact(const sockaddr_storage_t *ss1, int sctp_cmp_addr_exact(const union sctp_addr *ss1,
const sockaddr_storage_t *ss2); const union sctp_addr *ss2);
sctp_chunk_t *sctp_get_ecne_prepend(sctp_association_t *asoc); sctp_chunk_t *sctp_get_ecne_prepend(sctp_association_t *asoc);
sctp_chunk_t *sctp_get_no_prepend(sctp_association_t *asoc); sctp_chunk_t *sctp_get_no_prepend(sctp_association_t *asoc);
......
...@@ -364,7 +364,7 @@ static void sctp_association_destroy(sctp_association_t *asoc) ...@@ -364,7 +364,7 @@ static void sctp_association_destroy(sctp_association_t *asoc)
/* Add a transport address to an association. */ /* Add a transport address to an association. */
sctp_transport_t *sctp_assoc_add_peer(sctp_association_t *asoc, sctp_transport_t *sctp_assoc_add_peer(sctp_association_t *asoc,
const sockaddr_storage_t *addr, const union sctp_addr *addr,
int priority) int priority)
{ {
sctp_transport_t *peer; sctp_transport_t *peer;
...@@ -424,7 +424,7 @@ sctp_transport_t *sctp_assoc_add_peer(sctp_association_t *asoc, ...@@ -424,7 +424,7 @@ sctp_transport_t *sctp_assoc_add_peer(sctp_association_t *asoc,
asoc->frag_point = asoc->pmtu - asoc->frag_point = asoc->pmtu -
(SCTP_IP_OVERHEAD + sizeof(sctp_data_chunk_t)); (SCTP_IP_OVERHEAD + sizeof(sctp_data_chunk_t));
/* The asoc->peer.port might not be meaningful as of now, but /* The asoc->peer.port might not be meaningful yet, but
* initialize the packet structure anyway. * initialize the packet structure anyway.
*/ */
(asoc->outqueue.init_output)(&peer->packet, (asoc->outqueue.init_output)(&peer->packet,
...@@ -478,7 +478,7 @@ sctp_transport_t *sctp_assoc_add_peer(sctp_association_t *asoc, ...@@ -478,7 +478,7 @@ sctp_transport_t *sctp_assoc_add_peer(sctp_association_t *asoc,
asoc->peer.primary_path = peer; asoc->peer.primary_path = peer;
/* Set a default msg_name for events. */ /* Set a default msg_name for events. */
memcpy(&asoc->peer.primary_addr, &peer->ipaddr, memcpy(&asoc->peer.primary_addr, &peer->ipaddr,
sizeof(sockaddr_storage_t)); sizeof(union sctp_addr));
asoc->peer.active_path = peer; asoc->peer.active_path = peer;
asoc->peer.retran_path = peer; asoc->peer.retran_path = peer;
} }
...@@ -491,7 +491,7 @@ sctp_transport_t *sctp_assoc_add_peer(sctp_association_t *asoc, ...@@ -491,7 +491,7 @@ sctp_transport_t *sctp_assoc_add_peer(sctp_association_t *asoc,
/* Lookup a transport by address. */ /* Lookup a transport by address. */
sctp_transport_t *sctp_assoc_lookup_paddr(const sctp_association_t *asoc, sctp_transport_t *sctp_assoc_lookup_paddr(const sctp_association_t *asoc,
const sockaddr_storage_t *address) const union sctp_addr *address)
{ {
sctp_transport_t *t; sctp_transport_t *t;
struct list_head *pos; struct list_head *pos;
...@@ -654,7 +654,7 @@ __u16 __sctp_association_get_next_ssn(sctp_association_t *asoc, __u16 sid) ...@@ -654,7 +654,7 @@ __u16 __sctp_association_get_next_ssn(sctp_association_t *asoc, __u16 sid)
* *
* FIXME: We do not match address scopes correctly. * FIXME: We do not match address scopes correctly.
*/ */
int sctp_cmp_addr(const sockaddr_storage_t *ss1, const sockaddr_storage_t *ss2) int sctp_cmp_addr(const union sctp_addr *ss1, const union sctp_addr *ss2)
{ {
int len; int len;
const void *base1; const void *base1;
...@@ -710,8 +710,8 @@ int sctp_cmp_addr(const sockaddr_storage_t *ss1, const sockaddr_storage_t *ss2) ...@@ -710,8 +710,8 @@ int sctp_cmp_addr(const sockaddr_storage_t *ss1, const sockaddr_storage_t *ss2)
* *
* FIXME: We do not match address scopes correctly. * FIXME: We do not match address scopes correctly.
*/ */
int sctp_cmp_addr_exact(const sockaddr_storage_t *ss1, int sctp_cmp_addr_exact(const union sctp_addr *ss1,
const sockaddr_storage_t *ss2) const union sctp_addr *ss2)
{ {
int len; int len;
const void *base1; const void *base1;
...@@ -846,8 +846,8 @@ sctp_transport_t *sctp_assoc_lookup_tsn(sctp_association_t *asoc, __u32 tsn) ...@@ -846,8 +846,8 @@ sctp_transport_t *sctp_assoc_lookup_tsn(sctp_association_t *asoc, __u32 tsn)
/* Is this the association we are looking for? */ /* Is this the association we are looking for? */
sctp_transport_t *sctp_assoc_is_match(sctp_association_t *asoc, sctp_transport_t *sctp_assoc_is_match(sctp_association_t *asoc,
const sockaddr_storage_t *laddr, const union sctp_addr *laddr,
const sockaddr_storage_t *paddr) const union sctp_addr *paddr)
{ {
sctp_transport_t *transport; sctp_transport_t *transport;
......
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
#include <net/sctp/sm.h> #include <net/sctp/sm.h>
/* Forward declarations for internal helpers. */ /* Forward declarations for internal helpers. */
static int sctp_copy_one_addr(sctp_bind_addr_t *, sockaddr_storage_t *, static int sctp_copy_one_addr(sctp_bind_addr_t *, union sctp_addr *,
sctp_scope_t scope, int priority, int flags); sctp_scope_t scope, int priority, int flags);
static void sctp_bind_addr_clean(sctp_bind_addr_t *); static void sctp_bind_addr_clean(sctp_bind_addr_t *);
...@@ -143,7 +143,7 @@ void sctp_bind_addr_free(sctp_bind_addr_t *bp) ...@@ -143,7 +143,7 @@ void sctp_bind_addr_free(sctp_bind_addr_t *bp)
} }
/* Add an address to the bind address list in the SCTP_bind_addr structure. */ /* Add an address to the bind address list in the SCTP_bind_addr structure. */
int sctp_add_bind_addr(sctp_bind_addr_t *bp, sockaddr_storage_t *new, int sctp_add_bind_addr(sctp_bind_addr_t *bp, union sctp_addr *new,
int priority) int priority)
{ {
struct sockaddr_storage_list *addr; struct sockaddr_storage_list *addr;
...@@ -171,7 +171,7 @@ int sctp_add_bind_addr(sctp_bind_addr_t *bp, sockaddr_storage_t *new, ...@@ -171,7 +171,7 @@ int sctp_add_bind_addr(sctp_bind_addr_t *bp, sockaddr_storage_t *new,
/* Delete an address from the bind address list in the SCTP_bind_addr /* Delete an address from the bind address list in the SCTP_bind_addr
* structure. * structure.
*/ */
int sctp_del_bind_addr(sctp_bind_addr_t *bp, sockaddr_storage_t *del_addr) int sctp_del_bind_addr(sctp_bind_addr_t *bp, union sctp_addr *del_addr)
{ {
struct list_head *pos, *temp; struct list_head *pos, *temp;
struct sockaddr_storage_list *addr; struct sockaddr_storage_list *addr;
...@@ -242,7 +242,7 @@ int sctp_raw_to_bind_addrs(sctp_bind_addr_t *bp, __u8 *raw_addr_list, ...@@ -242,7 +242,7 @@ int sctp_raw_to_bind_addrs(sctp_bind_addr_t *bp, __u8 *raw_addr_list,
{ {
sctp_addr_param_t *rawaddr; sctp_addr_param_t *rawaddr;
sctp_paramhdr_t *param; sctp_paramhdr_t *param;
sockaddr_storage_t addr; union sctp_addr addr;
int retval = 0; int retval = 0;
int len; int len;
...@@ -283,7 +283,7 @@ int sctp_raw_to_bind_addrs(sctp_bind_addr_t *bp, __u8 *raw_addr_list, ...@@ -283,7 +283,7 @@ int sctp_raw_to_bind_addrs(sctp_bind_addr_t *bp, __u8 *raw_addr_list,
********************************************************************/ ********************************************************************/
/* Does this contain a specified address? */ /* Does this contain a specified address? */
int sctp_bind_addr_has_addr(sctp_bind_addr_t *bp, const sockaddr_storage_t *addr) int sctp_bind_addr_has_addr(sctp_bind_addr_t *bp, const union sctp_addr *addr)
{ {
struct sockaddr_storage_list *laddr; struct sockaddr_storage_list *laddr;
struct list_head *pos; struct list_head *pos;
...@@ -298,7 +298,7 @@ int sctp_bind_addr_has_addr(sctp_bind_addr_t *bp, const sockaddr_storage_t *addr ...@@ -298,7 +298,7 @@ int sctp_bind_addr_has_addr(sctp_bind_addr_t *bp, const sockaddr_storage_t *addr
} }
/* Copy out addresses from the global local address list. */ /* Copy out addresses from the global local address list. */
static int sctp_copy_one_addr(sctp_bind_addr_t *dest, sockaddr_storage_t *addr, static int sctp_copy_one_addr(sctp_bind_addr_t *dest, union sctp_addr *addr,
sctp_scope_t scope, int priority, int flags) sctp_scope_t scope, int priority, int flags)
{ {
sctp_protocol_t *proto = sctp_get_protocol(); sctp_protocol_t *proto = sctp_get_protocol();
...@@ -324,7 +324,7 @@ static int sctp_copy_one_addr(sctp_bind_addr_t *dest, sockaddr_storage_t *addr, ...@@ -324,7 +324,7 @@ static int sctp_copy_one_addr(sctp_bind_addr_t *dest, sockaddr_storage_t *addr,
} }
/* Is addr one of the wildcards? */ /* Is addr one of the wildcards? */
int sctp_is_any(const sockaddr_storage_t *addr) int sctp_is_any(const union sctp_addr *addr)
{ {
int retval = 0; int retval = 0;
...@@ -350,7 +350,7 @@ int sctp_is_any(const sockaddr_storage_t *addr) ...@@ -350,7 +350,7 @@ int sctp_is_any(const sockaddr_storage_t *addr)
} }
/* Is 'addr' valid for 'scope'? */ /* Is 'addr' valid for 'scope'? */
int sctp_in_scope(const sockaddr_storage_t *addr, sctp_scope_t scope) int sctp_in_scope(const union sctp_addr *addr, sctp_scope_t scope)
{ {
sctp_scope_t addr_scope = sctp_scope(addr); sctp_scope_t addr_scope = sctp_scope(addr);
...@@ -420,7 +420,7 @@ int sctp_in_scope(const sockaddr_storage_t *addr, sctp_scope_t scope) ...@@ -420,7 +420,7 @@ int sctp_in_scope(const sockaddr_storage_t *addr, sctp_scope_t scope)
********************************************************************/ ********************************************************************/
/* What is the scope of 'addr'? */ /* What is the scope of 'addr'? */
sctp_scope_t sctp_scope(const sockaddr_storage_t *addr) sctp_scope_t sctp_scope(const union sctp_addr *addr)
{ {
sctp_scope_t retval = SCTP_SCOPE_GLOBAL; sctp_scope_t retval = SCTP_SCOPE_GLOBAL;
...@@ -501,7 +501,7 @@ sctp_scope_t sctp_scope(const sockaddr_storage_t *addr) ...@@ -501,7 +501,7 @@ sctp_scope_t sctp_scope(const sockaddr_storage_t *addr)
* Return 0 - If the address is a non-unicast or an illegal address. * Return 0 - If the address is a non-unicast or an illegal address.
* Return 1 - If the address is a unicast. * Return 1 - If the address is a unicast.
*/ */
int sctp_addr_is_valid(const sockaddr_storage_t *addr) int sctp_addr_is_valid(const union sctp_addr *addr)
{ {
unsigned short sa_family = addr->sa.sa_family; unsigned short sa_family = addr->sa.sa_family;
......
...@@ -237,7 +237,7 @@ void sctp_endpoint_put(sctp_endpoint_t *ep) ...@@ -237,7 +237,7 @@ void sctp_endpoint_put(sctp_endpoint_t *ep)
/* Is this the endpoint we are looking for? */ /* Is this the endpoint we are looking for? */
sctp_endpoint_t *sctp_endpoint_is_match(sctp_endpoint_t *ep, sctp_endpoint_t *sctp_endpoint_is_match(sctp_endpoint_t *ep,
const sockaddr_storage_t *laddr) const union sctp_addr *laddr)
{ {
sctp_endpoint_t *retval; sctp_endpoint_t *retval;
...@@ -262,7 +262,7 @@ sctp_endpoint_t *sctp_endpoint_is_match(sctp_endpoint_t *ep, ...@@ -262,7 +262,7 @@ sctp_endpoint_t *sctp_endpoint_is_match(sctp_endpoint_t *ep,
*/ */
sctp_association_t *__sctp_endpoint_lookup_assoc( sctp_association_t *__sctp_endpoint_lookup_assoc(
const sctp_endpoint_t *endpoint, const sctp_endpoint_t *endpoint,
const sockaddr_storage_t *paddr, const union sctp_addr *paddr,
sctp_transport_t **transport) sctp_transport_t **transport)
{ {
int rport; int rport;
...@@ -289,7 +289,7 @@ sctp_association_t *__sctp_endpoint_lookup_assoc( ...@@ -289,7 +289,7 @@ sctp_association_t *__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_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, const union sctp_addr *paddr,
sctp_transport_t **transport) sctp_transport_t **transport)
{ {
sctp_association_t *asoc; sctp_association_t *asoc;
......
...@@ -60,64 +60,11 @@ ...@@ -60,64 +60,11 @@
/* Forward declarations for internal helpers. */ /* Forward declarations for internal helpers. */
static int sctp_rcv_ootb(struct sk_buff *); static int sctp_rcv_ootb(struct sk_buff *);
sctp_association_t *__sctp_rcv_lookup(struct sk_buff *skb, sctp_association_t *__sctp_rcv_lookup(struct sk_buff *skb,
const sockaddr_storage_t *laddr, const union sctp_addr *laddr,
const sockaddr_storage_t *paddr, const union sctp_addr *paddr,
sctp_transport_t **transportp); sctp_transport_t **transportp);
sctp_endpoint_t *__sctp_rcv_lookup_endpoint(const sockaddr_storage_t *laddr); sctp_endpoint_t *__sctp_rcv_lookup_endpoint(const union sctp_addr *laddr);
/* Initialize a sockaddr_storage from in incoming skb.
* FIXME: This belongs with AF specific sctp_func_t. --jgrimm
*/
static sockaddr_storage_t *sctp_sockaddr_storage_init(sockaddr_storage_t *addr,
const struct sk_buff *skb,
int is_saddr)
{
sockaddr_storage_t *ret = NULL;
void *to, *saddr, *daddr;
__u16 *port;
size_t len;
struct sctphdr *sh;
switch (skb->nh.iph->version) {
case 4:
to = &addr->v4.sin_addr.s_addr;
port = &addr->v4.sin_port;
saddr = &skb->nh.iph->saddr;
daddr = &skb->nh.iph->daddr;
len = sizeof(struct in_addr);
addr->v4.sin_family = AF_INET;
break;
case 6:
SCTP_V6(
to = &addr->v6.sin6_addr;
port = &addr->v6.sin6_port;
saddr = &skb->nh.ipv6h->saddr;
daddr = &skb->nh.ipv6h->daddr;
len = sizeof(struct in6_addr);
addr->v6.sin6_family = AF_INET6;
addr->v6.sin6_flowinfo = 0; /* FIXME */
addr->v6.sin6_scope_id = 0; /* FIXME */
break;
)
default:
goto out;
};
sh = (struct sctphdr *) skb->h.raw;
if (is_saddr) {
*port = ntohs(sh->source);
memcpy(to, saddr, len);
} else {
*port = ntohs(sh->dest);
memcpy(to, daddr, len);
}
ret = addr;
out:
return ret;
}
/* Calculate the SCTP checksum of an SCTP packet. */ /* Calculate the SCTP checksum of an SCTP packet. */
static inline int sctp_rcv_checksum(struct sk_buff *skb) static inline int sctp_rcv_checksum(struct sk_buff *skb)
...@@ -147,8 +94,9 @@ int sctp_rcv(struct sk_buff *skb) ...@@ -147,8 +94,9 @@ int sctp_rcv(struct sk_buff *skb)
sctp_transport_t *transport = NULL; sctp_transport_t *transport = NULL;
sctp_chunk_t *chunk; sctp_chunk_t *chunk;
struct sctphdr *sh; struct sctphdr *sh;
sockaddr_storage_t src; union sctp_addr src;
sockaddr_storage_t dest; union sctp_addr dest;
struct sctp_func *af;
int ret = 0; int ret = 0;
if (skb->pkt_type!=PACKET_HOST) if (skb->pkt_type!=PACKET_HOST)
...@@ -165,8 +113,13 @@ int sctp_rcv(struct sk_buff *skb) ...@@ -165,8 +113,13 @@ int sctp_rcv(struct sk_buff *skb)
skb_pull(skb, sizeof(struct sctphdr)); skb_pull(skb, sizeof(struct sctphdr));
sctp_sockaddr_storage_init(&src, skb, 1); af = sctp_get_af_specific(ipver2af(skb->nh.iph->version));
sctp_sockaddr_storage_init(&dest, skb, 0); if (unlikely(!af))
goto bad_packet;
/* Initialize local addresses for lookups. */
af->from_skb(&src, skb, 1);
af->from_skb(&dest, skb, 0);
/* If the packet is to or from a non-unicast address, /* If the packet is to or from a non-unicast address,
* silently discard the packet. * silently discard the packet.
...@@ -431,7 +384,7 @@ void sctp_unhash_endpoint(sctp_endpoint_t *ep) ...@@ -431,7 +384,7 @@ void sctp_unhash_endpoint(sctp_endpoint_t *ep)
} }
/* Look up an endpoint. */ /* Look up an endpoint. */
sctp_endpoint_t *__sctp_rcv_lookup_endpoint(const sockaddr_storage_t *laddr) sctp_endpoint_t *__sctp_rcv_lookup_endpoint(const union sctp_addr *laddr)
{ {
sctp_hashbucket_t *head; sctp_hashbucket_t *head;
sctp_endpoint_common_t *epb; sctp_endpoint_common_t *epb;
...@@ -523,8 +476,8 @@ void __sctp_unhash_established(sctp_association_t *asoc) ...@@ -523,8 +476,8 @@ void __sctp_unhash_established(sctp_association_t *asoc)
} }
/* Look up an association. */ /* Look up an association. */
sctp_association_t *__sctp_lookup_association(const sockaddr_storage_t *laddr, sctp_association_t *__sctp_lookup_association(const union sctp_addr *laddr,
const sockaddr_storage_t *paddr, const union sctp_addr *paddr,
sctp_transport_t **transportp) sctp_transport_t **transportp)
{ {
sctp_hashbucket_t *head; sctp_hashbucket_t *head;
...@@ -559,8 +512,8 @@ sctp_association_t *__sctp_lookup_association(const sockaddr_storage_t *laddr, ...@@ -559,8 +512,8 @@ sctp_association_t *__sctp_lookup_association(const sockaddr_storage_t *laddr,
} }
/* Look up an association. BH-safe. */ /* Look up an association. BH-safe. */
sctp_association_t *sctp_lookup_association(const sockaddr_storage_t *laddr, sctp_association_t *sctp_lookup_association(const union sctp_addr *laddr,
const sockaddr_storage_t *paddr, const union sctp_addr *paddr,
sctp_transport_t **transportp) sctp_transport_t **transportp)
{ {
sctp_association_t *asoc; sctp_association_t *asoc;
...@@ -573,8 +526,8 @@ sctp_association_t *sctp_lookup_association(const sockaddr_storage_t *laddr, ...@@ -573,8 +526,8 @@ sctp_association_t *sctp_lookup_association(const sockaddr_storage_t *laddr,
} }
/* Is there an association matching the given local and peer addresses? */ /* Is there an association matching the given local and peer addresses? */
int sctp_has_association(const sockaddr_storage_t *laddr, int sctp_has_association(const union sctp_addr *laddr,
const sockaddr_storage_t *paddr) const union sctp_addr *paddr)
{ {
sctp_association_t *asoc; sctp_association_t *asoc;
sctp_transport_t *transport; sctp_transport_t *transport;
...@@ -606,12 +559,12 @@ int sctp_has_association(const sockaddr_storage_t *laddr, ...@@ -606,12 +559,12 @@ int sctp_has_association(const sockaddr_storage_t *laddr,
* in certain circumstances. * in certain circumstances.
* *
*/ */
static sctp_association_t *__sctp_rcv_initack_lookup(struct sk_buff *skb, static sctp_association_t *__sctp_rcv_init_lookup(struct sk_buff *skb,
const sockaddr_storage_t *laddr, sctp_transport_t **transportp) const union sctp_addr *laddr, sctp_transport_t **transportp)
{ {
sctp_association_t *asoc; sctp_association_t *asoc;
sockaddr_storage_t addr; union sctp_addr addr;
sockaddr_storage_t *paddr = &addr; union sctp_addr *paddr = &addr;
struct sctphdr *sh = (struct sctphdr *) skb->h.raw; struct sctphdr *sh = (struct sctphdr *) skb->h.raw;
sctp_chunkhdr_t *ch; sctp_chunkhdr_t *ch;
union sctp_params params; union sctp_params params;
...@@ -665,20 +618,20 @@ static sctp_association_t *__sctp_rcv_initack_lookup(struct sk_buff *skb, ...@@ -665,20 +618,20 @@ static sctp_association_t *__sctp_rcv_initack_lookup(struct sk_buff *skb,
/* Lookup an association for an inbound skb. */ /* Lookup an association for an inbound skb. */
sctp_association_t *__sctp_rcv_lookup(struct sk_buff *skb, sctp_association_t *__sctp_rcv_lookup(struct sk_buff *skb,
const sockaddr_storage_t *paddr, const union sctp_addr *paddr,
const sockaddr_storage_t *laddr, const union sctp_addr *laddr,
sctp_transport_t **transportp) sctp_transport_t **transportp)
{ {
sctp_association_t *asoc; sctp_association_t *asoc;
asoc = __sctp_lookup_association(laddr, paddr, transportp); asoc = __sctp_lookup_association(laddr, paddr, transportp);
/* Further lookup for INIT-ACK packet. /* Further lookup for INIT/INIT-ACK packets.
* SCTP Implementors Guide, 2.18 Handling of address * SCTP Implementors Guide, 2.18 Handling of address
* parameters within the INIT or INIT-ACK. * parameters within the INIT or INIT-ACK.
*/ */
if (!asoc) if (!asoc)
asoc = __sctp_rcv_initack_lookup(skb, laddr, transportp); asoc = __sctp_rcv_init_lookup(skb, laddr, transportp);
return asoc; return asoc;
} }
......
...@@ -172,8 +172,8 @@ static inline int sctp_v6_xmit(struct sk_buff *skb) ...@@ -172,8 +172,8 @@ static inline int sctp_v6_xmit(struct sk_buff *skb)
/* Returns the dst cache entry for the given source and destination ip /* Returns the dst cache entry for the given source and destination ip
* addresses. * addresses.
*/ */
struct dst_entry *sctp_v6_get_dst(sockaddr_storage_t *daddr, struct dst_entry *sctp_v6_get_dst(union sctp_addr *daddr,
sockaddr_storage_t *saddr) union sctp_addr *saddr)
{ {
struct dst_entry *dst; struct dst_entry *dst;
struct flowi fl = { .nl_u = { .ip6_u = { .daddr = &daddr->v6.sin6_addr, struct flowi fl = { .nl_u = { .ip6_u = { .daddr = &daddr->v6.sin6_addr,
...@@ -206,8 +206,63 @@ struct dst_entry *sctp_v6_get_dst(sockaddr_storage_t *daddr, ...@@ -206,8 +206,63 @@ struct dst_entry *sctp_v6_get_dst(sockaddr_storage_t *daddr,
return dst; return dst;
} }
/* Make a copy of all potential local addresses. */
static void sctp_v6_copy_addrlist(struct list_head *addrlist,
struct net_device *dev)
{
struct inet6_dev *in6_dev;
struct inet6_ifaddr *ifp;
struct sockaddr_storage_list *addr;
read_lock(&addrconf_lock);
if ((in6_dev = __in6_dev_get(dev)) == NULL) {
read_unlock(&addrconf_lock);
return;
}
read_lock(&in6_dev->lock);
for (ifp = in6_dev->addr_list; ifp; ifp = ifp->if_next) {
/* Add the address to the local list. */
addr = t_new(struct sockaddr_storage_list, GFP_ATOMIC);
if (addr) {
addr->a.v6.sin6_family = AF_INET6;
addr->a.v6.sin6_port = 0;
addr->a.v6.sin6_addr = ifp->addr;
INIT_LIST_HEAD(&addr->list);
list_add_tail(&addr->list, addrlist);
}
}
read_unlock(&in6_dev->lock);
read_unlock(&addrconf_lock);
}
/* Initialize a sockaddr_storage from in incoming skb. */
static void sctp_v6_from_skb(union sctp_addr *addr,struct sk_buff *skb,
int is_saddr)
{
void *from;
__u16 *port;
struct sctphdr *sh;
port = &addr->v6.sin6_port;
addr->v6.sin6_family = AF_INET6;
addr->v6.sin6_flowinfo = 0; /* FIXME */
addr->v6.sin6_scope_id = 0; /* FIXME */
sh = (struct sctphdr *) skb->h.raw;
if (is_saddr) {
*port = ntohs(sh->source);
from = &skb->nh.ipv6h->saddr;
} else {
*port = ntohs(sh->dest);
from = &skb->nh.ipv6h->daddr;
}
ipv6_addr_copy(&addr->v6.sin6_addr, from);
}
/* Check if the dst entry's source addr matches the given source addr. */ /* Check if the dst entry's source addr matches the given source addr. */
int sctp_v6_cmp_saddr(struct dst_entry *dst, sockaddr_storage_t *saddr) int sctp_v6_cmp_saddr(struct dst_entry *dst, union sctp_addr *saddr)
{ {
struct rt6_info *rt = (struct rt6_info *)dst; struct rt6_info *rt = (struct rt6_info *)dst;
...@@ -227,12 +282,13 @@ static void sctp_inet6_msgname(char *msgname, int *addr_len) ...@@ -227,12 +282,13 @@ static void sctp_inet6_msgname(char *msgname, int *addr_len)
} }
/* Initialize a PF_INET msgname from a ulpevent. */ /* Initialize a PF_INET msgname from a ulpevent. */
static void sctp_inet6_event_msgname(sctp_ulpevent_t *event, char *msgname, int *addrlen) static void sctp_inet6_event_msgname(sctp_ulpevent_t *event, char *msgname,
int *addrlen)
{ {
struct sockaddr_in6 *sin6, *sin6from; struct sockaddr_in6 *sin6, *sin6from;
if (msgname) { if (msgname) {
sockaddr_storage_t *addr; union sctp_addr *addr;
sctp_inet6_msgname(msgname, addrlen); sctp_inet6_msgname(msgname, addrlen);
sin6 = (struct sockaddr_in6 *)msgname; sin6 = (struct sockaddr_in6 *)msgname;
...@@ -327,6 +383,8 @@ static sctp_func_t sctp_ipv6_specific = { ...@@ -327,6 +383,8 @@ static sctp_func_t sctp_ipv6_specific = {
.setsockopt = ipv6_setsockopt, .setsockopt = ipv6_setsockopt,
.getsockopt = ipv6_getsockopt, .getsockopt = ipv6_getsockopt,
.get_dst = sctp_v6_get_dst, .get_dst = sctp_v6_get_dst,
.copy_addrlist = sctp_v6_copy_addrlist,
.from_skb = sctp_v6_from_skb,
.cmp_saddr = sctp_v6_cmp_saddr, .cmp_saddr = sctp_v6_cmp_saddr,
.net_header_len = sizeof(struct ipv6hdr), .net_header_len = sizeof(struct ipv6hdr),
.sockaddr_len = sizeof(struct sockaddr_in6), .sockaddr_len = sizeof(struct sockaddr_in6),
......
...@@ -366,18 +366,13 @@ int sctp_packet_transmit(sctp_packet_t *packet) ...@@ -366,18 +366,13 @@ int sctp_packet_transmit(sctp_packet_t *packet)
*/ */
sh->checksum = htonl(crc32); sh->checksum = htonl(crc32);
/* FIXME: Delete the rest of this switch statement once phase 2
* of address selection (ipv6 support) drops in.
*/
switch (transport->ipaddr.sa.sa_family) { switch (transport->ipaddr.sa.sa_family) {
case AF_INET:
inet_sk(sk)->daddr = transport->ipaddr.v4.sin_addr.s_addr;
break;
case AF_INET6: case AF_INET6:
SCTP_V6(inet6_sk(sk)->daddr = transport->ipaddr.v6.sin6_addr;) SCTP_V6(inet6_sk(sk)->daddr = transport->ipaddr.v6.sin6_addr;)
break; break;
default:
/* This is bogus address type, just bail. */
break;
}; };
/* IP layer ECN support /* IP layer ECN support
......
/* SCTP kernel reference Implementation /* SCTP kernel reference Implementation
* Copyright (c) 1999-2000 Cisco, Inc. * Copyright (c) 1999-2000 Cisco, Inc.
* Copyright (c) 1999-2001 Motorola, Inc. * Copyright (c) 1999-2001 Motorola, Inc.
* Copyright (c) 2001 International Business Machines, Corp. * Copyright (c) 2001-2002 International Business Machines, Corp.
* Copyright (c) 2001 Intel Corp. * Copyright (c) 2001 Intel Corp.
* Copyright (c) 2001 Nokia, Inc. * Copyright (c) 2001 Nokia, Inc.
* Copyright (c) 2001 La Monte H.P. Yarroll * Copyright (c) 2001 La Monte H.P. Yarroll
...@@ -103,7 +103,7 @@ void sctp_proc_exit(void) ...@@ -103,7 +103,7 @@ void sctp_proc_exit(void)
/* Private helper to extract ipv4 address and stash them in /* Private helper to extract ipv4 address and stash them in
* the protocol structure. * the protocol structure.
*/ */
static inline void sctp_v4_get_local_addr_list(sctp_protocol_t *proto, static void sctp_v4_copy_addrlist(struct list_head *addrlist,
struct net_device *dev) struct net_device *dev)
{ {
struct in_device *in_dev; struct in_device *in_dev;
...@@ -117,7 +117,6 @@ static inline void sctp_v4_get_local_addr_list(sctp_protocol_t *proto, ...@@ -117,7 +117,6 @@ static inline void sctp_v4_get_local_addr_list(sctp_protocol_t *proto,
} }
read_lock(&in_dev->lock); read_lock(&in_dev->lock);
for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) { for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) {
/* Add the address to the local list. */ /* Add the address to the local list. */
addr = t_new(struct sockaddr_storage_list, GFP_ATOMIC); addr = t_new(struct sockaddr_storage_list, GFP_ATOMIC);
...@@ -126,7 +125,7 @@ static inline void sctp_v4_get_local_addr_list(sctp_protocol_t *proto, ...@@ -126,7 +125,7 @@ static inline void sctp_v4_get_local_addr_list(sctp_protocol_t *proto,
addr->a.v4.sin_family = AF_INET; addr->a.v4.sin_family = AF_INET;
addr->a.v4.sin_port = 0; addr->a.v4.sin_port = 0;
addr->a.v4.sin_addr.s_addr = ifa->ifa_local; addr->a.v4.sin_addr.s_addr = ifa->ifa_local;
list_add_tail(&addr->list, &proto->local_addr_list); list_add_tail(&addr->list, addrlist);
} }
} }
...@@ -134,56 +133,21 @@ static inline void sctp_v4_get_local_addr_list(sctp_protocol_t *proto, ...@@ -134,56 +133,21 @@ static inline void sctp_v4_get_local_addr_list(sctp_protocol_t *proto,
read_unlock(&inetdev_lock); read_unlock(&inetdev_lock);
} }
/* Private helper to extract ipv6 address and stash them in
* the protocol structure.
* FIXME: Make this an address family function.
*/
static inline void sctp_v6_get_local_addr_list(sctp_protocol_t *proto,
struct net_device *dev)
{
#ifdef SCTP_V6_SUPPORT
/* FIXME: The testframe doesn't support this function. */
#ifndef TEST_FRAME
struct inet6_dev *in6_dev;
struct inet6_ifaddr *ifp;
struct sockaddr_storage_list *addr;
read_lock(&addrconf_lock);
if ((in6_dev = __in6_dev_get(dev)) == NULL) {
read_unlock(&addrconf_lock);
return;
}
read_lock_bh(&in6_dev->lock);
for (ifp = in6_dev->addr_list; ifp; ifp = ifp->if_next) {
/* Add the address to the local list. */
addr = t_new(struct sockaddr_storage_list, GFP_ATOMIC);
if (addr) {
addr->a.v6.sin6_family = AF_INET6;
addr->a.v6.sin6_port = 0;
addr->a.v6.sin6_addr = ifp->addr;
INIT_LIST_HEAD(&addr->list);
list_add_tail(&addr->list, &proto->local_addr_list);
}
}
read_unlock_bh(&in6_dev->lock);
read_unlock(&addrconf_lock);
#endif /* TEST_FRAME */
#endif /* SCTP_V6_SUPPORT */
}
/* Extract our IP addresses from the system and stash them in the /* Extract our IP addresses from the system and stash them in the
* protocol structure. * protocol structure.
*/ */
static void __sctp_get_local_addr_list(sctp_protocol_t *proto) static void __sctp_get_local_addr_list(sctp_protocol_t *proto)
{ {
struct net_device *dev; struct net_device *dev;
struct list_head *pos;
struct sctp_func *af;
read_lock(&dev_base_lock); read_lock(&dev_base_lock);
for (dev = dev_base; dev; dev = dev->next) { for (dev = dev_base; dev; dev = dev->next) {
sctp_v4_get_local_addr_list(proto, dev); list_for_each(pos, &proto->address_families) {
sctp_v6_get_local_addr_list(proto, dev); af = list_entry(pos, sctp_func_t, list);
af->copy_addrlist(&proto->local_addr_list, dev);
}
} }
read_unlock(&dev_base_lock); read_unlock(&dev_base_lock);
} }
...@@ -259,8 +223,8 @@ int sctp_copy_local_addr_list(sctp_protocol_t *proto, sctp_bind_addr_t *bp, ...@@ -259,8 +223,8 @@ int sctp_copy_local_addr_list(sctp_protocol_t *proto, sctp_bind_addr_t *bp,
/* Returns the dst cache entry for the given source and destination ip /* Returns the dst cache entry for the given source and destination ip
* addresses. * addresses.
*/ */
struct dst_entry *sctp_v4_get_dst(sockaddr_storage_t *daddr, struct dst_entry *sctp_v4_get_dst(union sctp_addr *daddr,
sockaddr_storage_t *saddr) union sctp_addr *saddr)
{ {
struct rtable *rt; struct rtable *rt;
struct flowi fl = { .nl_u = { .ip4_u = { .daddr = struct flowi fl = { .nl_u = { .ip4_u = { .daddr =
...@@ -285,8 +249,31 @@ struct dst_entry *sctp_v4_get_dst(sockaddr_storage_t *daddr, ...@@ -285,8 +249,31 @@ struct dst_entry *sctp_v4_get_dst(sockaddr_storage_t *daddr,
return &rt->u.dst; return &rt->u.dst;
} }
/* Initialize a sctp_addr from in incoming skb. */
static void sctp_v4_from_skb(union sctp_addr *addr, struct sk_buff *skb,
int is_saddr)
{
void *from;
__u16 *port;
struct sctphdr *sh;
port = &addr->v4.sin_port;
addr->v4.sin_family = AF_INET;
sh = (struct sctphdr *) skb->h.raw;
if (is_saddr) {
*port = ntohs(sh->source);
from = &skb->nh.iph->saddr;
} else {
*port = ntohs(sh->dest);
from = &skb->nh.iph->daddr;
}
memcpy(&addr->v4.sin_addr.s_addr, from, sizeof(struct in_addr));
}
/* Check if the dst entry's source addr matches the given source addr. */ /* Check if the dst entry's source addr matches the given source addr. */
int sctp_v4_cmp_saddr(struct dst_entry *dst, sockaddr_storage_t *saddr) int sctp_v4_cmp_saddr(struct dst_entry *dst, union sctp_addr *saddr)
{ {
struct rtable *rt = (struct rtable *)dst; struct rtable *rt = (struct rtable *)dst;
...@@ -336,11 +323,11 @@ int sctp_ctl_sock_init(void) ...@@ -336,11 +323,11 @@ int sctp_ctl_sock_init(void)
/* Get the table of functions for manipulating a particular address /* Get the table of functions for manipulating a particular address
* family. * family.
*/ */
sctp_func_t *sctp_get_af_specific(const sockaddr_storage_t *address) sctp_func_t *sctp_get_af_specific(sa_family_t family)
{ {
struct list_head *pos; struct list_head *pos;
sctp_protocol_t *proto = sctp_get_protocol(); sctp_protocol_t *proto = sctp_get_protocol();
sctp_func_t *retval, *af; struct sctp_func *retval, *af;
retval = NULL; retval = NULL;
...@@ -349,7 +336,7 @@ sctp_func_t *sctp_get_af_specific(const sockaddr_storage_t *address) ...@@ -349,7 +336,7 @@ sctp_func_t *sctp_get_af_specific(const sockaddr_storage_t *address)
*/ */
list_for_each(pos, &proto->address_families) { list_for_each(pos, &proto->address_families) {
af = list_entry(pos, sctp_func_t, list); af = list_entry(pos, sctp_func_t, list);
if (address->sa.sa_family == af->sa_family) { if (family == af->sa_family) {
retval = af; retval = af;
break; break;
} }
...@@ -448,11 +435,13 @@ static struct inet_protocol sctp_protocol = { ...@@ -448,11 +435,13 @@ static struct inet_protocol sctp_protocol = {
}; };
/* IPv4 address related functions. */ /* IPv4 address related functions. */
sctp_func_t sctp_ipv4_specific = { struct sctp_func sctp_ipv4_specific = {
.queue_xmit = ip_queue_xmit, .queue_xmit = ip_queue_xmit,
.setsockopt = ip_setsockopt, .setsockopt = ip_setsockopt,
.getsockopt = ip_getsockopt, .getsockopt = ip_getsockopt,
.get_dst = sctp_v4_get_dst, .get_dst = sctp_v4_get_dst,
.copy_addrlist = sctp_v4_copy_addrlist,
.from_skb = sctp_v4_from_skb,
.cmp_saddr = sctp_v4_cmp_saddr, .cmp_saddr = sctp_v4_cmp_saddr,
.net_header_len = sizeof(struct iphdr), .net_header_len = sizeof(struct iphdr),
.sockaddr_len = sizeof(struct sockaddr_in), .sockaddr_len = sizeof(struct sockaddr_in),
......
...@@ -1033,7 +1033,7 @@ sctp_chunk_t *sctp_chunkify(struct sk_buff *skb, const sctp_association_t *asoc, ...@@ -1033,7 +1033,7 @@ sctp_chunk_t *sctp_chunkify(struct sk_buff *skb, const sctp_association_t *asoc,
/* Set chunk->source and dest based on the IP header in chunk->skb. */ /* Set chunk->source and dest based on the IP header in chunk->skb. */
void sctp_init_addrs(sctp_chunk_t *chunk) void sctp_init_addrs(sctp_chunk_t *chunk)
{ {
sockaddr_storage_t *source, *dest; union sctp_addr *source, *dest;
struct sk_buff *skb; struct sk_buff *skb;
struct sctphdr *sh; struct sctphdr *sh;
struct iphdr *ih4; struct iphdr *ih4;
...@@ -1075,7 +1075,7 @@ void sctp_init_addrs(sctp_chunk_t *chunk) ...@@ -1075,7 +1075,7 @@ void sctp_init_addrs(sctp_chunk_t *chunk)
} }
/* Extract the source address from a chunk. */ /* Extract the source address from a chunk. */
const sockaddr_storage_t *sctp_source(const sctp_chunk_t *chunk) const union sctp_addr *sctp_source(const sctp_chunk_t *chunk)
{ {
/* If we have a known transport, use that. */ /* If we have a known transport, use that. */
if (chunk->transport) { if (chunk->transport) {
...@@ -1661,7 +1661,7 @@ int sctp_verify_init(const sctp_association_t *asoc, ...@@ -1661,7 +1661,7 @@ int sctp_verify_init(const sctp_association_t *asoc,
* Returns 0 on failure, else success. * Returns 0 on failure, else success.
*/ */
int sctp_process_init(sctp_association_t *asoc, sctp_cid_t cid, int sctp_process_init(sctp_association_t *asoc, sctp_cid_t cid,
const sockaddr_storage_t *peer_addr, const union sctp_addr *peer_addr,
sctp_init_chunk_t *peer_init, sctp_init_chunk_t *peer_init,
int priority) int priority)
{ {
...@@ -1780,9 +1780,9 @@ int sctp_process_init(sctp_association_t *asoc, sctp_cid_t cid, ...@@ -1780,9 +1780,9 @@ int sctp_process_init(sctp_association_t *asoc, sctp_cid_t cid,
* structures for the addresses. * structures for the addresses.
*/ */
int sctp_process_param(sctp_association_t *asoc, union sctp_params param, int sctp_process_param(sctp_association_t *asoc, union sctp_params param,
const sockaddr_storage_t *peer_addr, int priority) const union sctp_addr *peer_addr, int priority)
{ {
sockaddr_storage_t addr; union sctp_addr addr;
int i; int i;
__u16 sat; __u16 sat;
int retval = 1; int retval = 1;
...@@ -1906,8 +1906,8 @@ __u32 sctp_generate_tsn(const sctp_endpoint_t *ep) ...@@ -1906,8 +1906,8 @@ __u32 sctp_generate_tsn(const sctp_endpoint_t *ep)
* 4th Level Abstractions * 4th Level Abstractions
********************************************************************/ ********************************************************************/
/* Convert from an SCTP IP parameter to a sockaddr_storage_t. */ /* Convert from an SCTP IP parameter to a union sctp_addr. */
void sctp_param2sockaddr(sockaddr_storage_t *addr, sctp_addr_param_t *param, void sctp_param2sockaddr(union sctp_addr *addr, sctp_addr_param_t *param,
__u16 port) __u16 port)
{ {
switch(param->v4.param_hdr.type) { switch(param->v4.param_hdr.type) {
...@@ -1934,7 +1934,7 @@ void sctp_param2sockaddr(sockaddr_storage_t *addr, sctp_addr_param_t *param, ...@@ -1934,7 +1934,7 @@ void sctp_param2sockaddr(sockaddr_storage_t *addr, sctp_addr_param_t *param,
/* Convert an IP address in an SCTP param into a sockaddr_in. */ /* Convert an IP address in an SCTP param into a sockaddr_in. */
/* Returns true if a valid conversion was possible. */ /* Returns true if a valid conversion was possible. */
int sctp_addr2sockaddr(union sctp_params p, sockaddr_storage_t *sa) int sctp_addr2sockaddr(union sctp_params p, union sctp_addr *sa)
{ {
switch (p.p->type) { switch (p.p->type) {
case SCTP_PARAM_IPV4_ADDRESS: case SCTP_PARAM_IPV4_ADDRESS:
...@@ -1955,30 +1955,10 @@ int sctp_addr2sockaddr(union sctp_params p, sockaddr_storage_t *sa) ...@@ -1955,30 +1955,10 @@ int sctp_addr2sockaddr(union sctp_params p, sockaddr_storage_t *sa)
return 1; return 1;
} }
/* Convert from an IP version number to an Address Family symbol. */
int ipver2af(__u8 ipver)
{
int family;
switch (ipver) {
case 4:
family = AF_INET;
break;
case 6:
family = AF_INET6;
break;
default:
family = 0;
break;
};
return family;
}
/* Convert a sockaddr_in to an IP address in an SCTP param. /* Convert a sockaddr_in to an IP address in an SCTP param.
* Returns len if a valid conversion was possible. * Returns len if a valid conversion was possible.
*/ */
int sockaddr2sctp_addr(const sockaddr_storage_t *sa, sctp_addr_param_t *p) int sockaddr2sctp_addr(const union sctp_addr *sa, sctp_addr_param_t *p)
{ {
int len = 0; int len = 0;
......
...@@ -832,7 +832,7 @@ sctp_disposition_t sctp_sf_backbeat_8_3(const sctp_endpoint_t *ep, ...@@ -832,7 +832,7 @@ sctp_disposition_t sctp_sf_backbeat_8_3(const sctp_endpoint_t *ep,
sctp_cmd_seq_t *commands) sctp_cmd_seq_t *commands)
{ {
sctp_chunk_t *chunk = arg; sctp_chunk_t *chunk = arg;
sockaddr_storage_t from_addr; union sctp_addr from_addr;
sctp_transport_t *link; sctp_transport_t *link;
sctp_sender_hb_info_t *hbinfo; sctp_sender_hb_info_t *hbinfo;
unsigned long max_interval; unsigned long max_interval;
...@@ -881,7 +881,7 @@ sctp_disposition_t sctp_sf_backbeat_8_3(const sctp_endpoint_t *ep, ...@@ -881,7 +881,7 @@ sctp_disposition_t sctp_sf_backbeat_8_3(const sctp_endpoint_t *ep,
/* Helper function to send out an abort for the restart /* Helper function to send out an abort for the restart
* condition. * condition.
*/ */
static int sctp_sf_send_restart_abort(sockaddr_storage_t *ssa, static int sctp_sf_send_restart_abort(union sctp_addr *ssa,
sctp_chunk_t *init, sctp_chunk_t *init,
sctp_cmd_seq_t *commands) sctp_cmd_seq_t *commands)
{ {
...@@ -4313,7 +4313,7 @@ sctp_packet_t *sctp_ootb_pkt_new(const sctp_association_t *asoc, ...@@ -4313,7 +4313,7 @@ sctp_packet_t *sctp_ootb_pkt_new(const sctp_association_t *asoc,
/* Cache a route for the transport with the chunk's destination as /* Cache a route for the transport with the chunk's destination as
* the source address. * the source address.
*/ */
sctp_transport_route(transport, (sockaddr_storage_t *)&chunk->dest); sctp_transport_route(transport, (union sctp_addr *)&chunk->dest);
packet = sctp_packet_init(packet, transport, sport, dport); packet = sctp_packet_init(packet, transport, sport, dport);
packet = sctp_packet_config(packet, vtag, 0, NULL); packet = sctp_packet_config(packet, vtag, 0, NULL);
......
...@@ -87,14 +87,14 @@ static int sctp_wait_for_sndbuf(sctp_association_t *asoc, long *timeo_p, ...@@ -87,14 +87,14 @@ static int sctp_wait_for_sndbuf(sctp_association_t *asoc, long *timeo_p,
int msg_len); int msg_len);
static int sctp_wait_for_packet(struct sock * sk, int *err, long *timeo_p); static int sctp_wait_for_packet(struct sock * sk, int *err, long *timeo_p);
static inline void sctp_sk_addr_set(struct sock *, static inline void sctp_sk_addr_set(struct sock *,
const sockaddr_storage_t *newaddr, const union sctp_addr *newaddr,
sockaddr_storage_t *saveaddr); union sctp_addr *saveaddr);
static inline void sctp_sk_addr_restore(struct sock *, static inline void sctp_sk_addr_restore(struct sock *,
const sockaddr_storage_t *); const union sctp_addr *);
static inline int sctp_sendmsg_verify_name(struct sock *, struct msghdr *); static inline int sctp_sendmsg_verify_name(struct sock *, struct msghdr *);
static int sctp_bindx_add(struct sock *, struct sockaddr_storage *, int); static int sctp_bindx_add(struct sock *, struct sockaddr_storage *, int);
static int sctp_bindx_rem(struct sock *, struct sockaddr_storage *, int); static int sctp_bindx_rem(struct sock *, struct sockaddr_storage *, int);
static int sctp_do_bind(struct sock *, sockaddr_storage_t *, int); static int sctp_do_bind(struct sock *, union sctp_addr *, int);
static int sctp_autobind(struct sock *sk); static int sctp_autobind(struct sock *sk);
...@@ -122,7 +122,7 @@ int sctp_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) ...@@ -122,7 +122,7 @@ int sctp_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
/* Disallow binding twice. */ /* Disallow binding twice. */
if (!sctp_sk(sk)->ep->base.bind_addr.port) if (!sctp_sk(sk)->ep->base.bind_addr.port)
retval = sctp_do_bind(sk, (sockaddr_storage_t *)uaddr, retval = sctp_do_bind(sk, (union sctp_addr *)uaddr,
addr_len); addr_len);
else else
retval = -EINVAL; retval = -EINVAL;
...@@ -135,14 +135,14 @@ int sctp_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len) ...@@ -135,14 +135,14 @@ int sctp_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
static long sctp_get_port_local(struct sock *, unsigned short); static long sctp_get_port_local(struct sock *, unsigned short);
/* Bind a local address either to an endpoint or to an association. */ /* Bind a local address either to an endpoint or to an association. */
SCTP_STATIC int sctp_do_bind(struct sock *sk, sockaddr_storage_t *newaddr, SCTP_STATIC int sctp_do_bind(struct sock *sk, union sctp_addr *newaddr,
int addr_len) int addr_len)
{ {
sctp_opt_t *sp = sctp_sk(sk); sctp_opt_t *sp = sctp_sk(sk);
sctp_endpoint_t *ep = sp->ep; sctp_endpoint_t *ep = sp->ep;
sctp_bind_addr_t *bp = &ep->base.bind_addr; sctp_bind_addr_t *bp = &ep->base.bind_addr;
unsigned short sa_family = newaddr->sa.sa_family; unsigned short sa_family = newaddr->sa.sa_family;
sockaddr_storage_t tmpaddr, saveaddr; union sctp_addr tmpaddr, saveaddr;
unsigned short *snum; unsigned short *snum;
int ret = 0; int ret = 0;
...@@ -403,7 +403,7 @@ int sctp_bindx_add(struct sock *sk, struct sockaddr_storage *addrs, int addrcnt) ...@@ -403,7 +403,7 @@ int sctp_bindx_add(struct sock *sk, struct sockaddr_storage *addrs, int addrcnt)
goto err_bindx_add; goto err_bindx_add;
}; };
retval = sctp_do_bind(sk, (sockaddr_storage_t *)&addrs[cnt], retval = sctp_do_bind(sk, (union sctp_addr *)&addrs[cnt],
addr_len); addr_len);
err_bindx_add: err_bindx_add:
...@@ -481,7 +481,7 @@ int sctp_bindx_rem(struct sock *sk, struct sockaddr_storage *addrs, int addrcnt) ...@@ -481,7 +481,7 @@ int sctp_bindx_rem(struct sock *sk, struct sockaddr_storage *addrs, int addrcnt)
int cnt; int cnt;
sctp_bind_addr_t *bp = &ep->base.bind_addr; sctp_bind_addr_t *bp = &ep->base.bind_addr;
int retval = 0; int retval = 0;
sockaddr_storage_t saveaddr; union sctp_addr saveaddr;
SCTP_DEBUG_PRINTK("sctp_bindx_rem (sk: %p, addrs: %p, addrcnt: %d)\n", SCTP_DEBUG_PRINTK("sctp_bindx_rem (sk: %p, addrs: %p, addrcnt: %d)\n",
sk, addrs, addrcnt); sk, addrs, addrcnt);
...@@ -500,7 +500,7 @@ int sctp_bindx_rem(struct sock *sk, struct sockaddr_storage *addrs, int addrcnt) ...@@ -500,7 +500,7 @@ int sctp_bindx_rem(struct sock *sk, struct sockaddr_storage *addrs, int addrcnt)
*/ */
switch (((struct sockaddr *)&addrs[cnt])->sa_family) { switch (((struct sockaddr *)&addrs[cnt])->sa_family) {
case AF_INET: case AF_INET:
saveaddr = *((sockaddr_storage_t *) saveaddr = *((union sctp_addr *)
&addrs[cnt]); &addrs[cnt]);
saveaddr.v4.sin_port = ntohs(saveaddr.v4.sin_port); saveaddr.v4.sin_port = ntohs(saveaddr.v4.sin_port);
/* Verify the port. */ /* Verify the port. */
...@@ -511,7 +511,7 @@ int sctp_bindx_rem(struct sock *sk, struct sockaddr_storage *addrs, int addrcnt) ...@@ -511,7 +511,7 @@ int sctp_bindx_rem(struct sock *sk, struct sockaddr_storage *addrs, int addrcnt)
break; break;
case AF_INET6: case AF_INET6:
saveaddr = *((sockaddr_storage_t *) saveaddr = *((union sctp_addr *)
&addrs[cnt]); &addrs[cnt]);
saveaddr.v6.sin6_port = saveaddr.v6.sin6_port =
ntohs(saveaddr.v6.sin6_port); ntohs(saveaddr.v6.sin6_port);
...@@ -741,7 +741,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -741,7 +741,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
sctp_association_t *new_asoc=NULL, *asoc=NULL; sctp_association_t *new_asoc=NULL, *asoc=NULL;
sctp_transport_t *transport; sctp_transport_t *transport;
sctp_chunk_t *chunk = NULL; sctp_chunk_t *chunk = NULL;
sockaddr_storage_t to; union sctp_addr to;
struct sockaddr *msg_name = NULL; struct sockaddr *msg_name = NULL;
struct sctp_sndrcvinfo default_sinfo = { 0 }; struct sctp_sndrcvinfo default_sinfo = { 0 };
struct sctp_sndrcvinfo *sinfo; struct sctp_sndrcvinfo *sinfo;
...@@ -1258,7 +1258,7 @@ static inline int sctp_setsockopt_set_peer_addr_params(struct sock *sk, ...@@ -1258,7 +1258,7 @@ static inline int sctp_setsockopt_set_peer_addr_params(struct sock *sk,
{ {
struct sctp_paddrparams params; struct sctp_paddrparams params;
sctp_association_t *asoc; sctp_association_t *asoc;
sockaddr_storage_t *addr; union sctp_addr *addr;
sctp_transport_t *trans; sctp_transport_t *trans;
int error; int error;
...@@ -1271,7 +1271,7 @@ static inline int sctp_setsockopt_set_peer_addr_params(struct sock *sk, ...@@ -1271,7 +1271,7 @@ static inline int sctp_setsockopt_set_peer_addr_params(struct sock *sk,
if (!asoc) if (!asoc)
return -EINVAL; return -EINVAL;
addr = (sockaddr_storage_t *) &(params.spp_address); addr = (union sctp_addr *) &(params.spp_address);
trans = sctp_assoc_lookup_paddr(asoc, addr); trans = sctp_assoc_lookup_paddr(asoc, addr);
if (!trans) if (!trans)
...@@ -1606,7 +1606,7 @@ static int sctp_getsockopt_sctp_status(struct sock *sk, int len, char *optval, ...@@ -1606,7 +1606,7 @@ static int sctp_getsockopt_sctp_status(struct sock *sk, int len, char *optval,
status.sstat_fragmentation_point = assoc->frag_point; status.sstat_fragmentation_point = assoc->frag_point;
status.sstat_primary.spinfo_assoc_id = sctp_assoc2id(transport->asoc); status.sstat_primary.spinfo_assoc_id = sctp_assoc2id(transport->asoc);
memcpy(&status.sstat_primary.spinfo_address, memcpy(&status.sstat_primary.spinfo_address,
&(transport->ipaddr), sizeof(sockaddr_storage_t)); &(transport->ipaddr), sizeof(union sctp_addr));
status.sstat_primary.spinfo_state = transport->active; status.sstat_primary.spinfo_state = transport->active;
status.sstat_primary.spinfo_cwnd = transport->cwnd; status.sstat_primary.spinfo_cwnd = transport->cwnd;
status.sstat_primary.spinfo_srtt = transport->srtt; status.sstat_primary.spinfo_srtt = transport->srtt;
...@@ -1781,7 +1781,7 @@ static inline int sctp_getsockopt_get_peer_addr_params(struct sock *sk, ...@@ -1781,7 +1781,7 @@ static inline int sctp_getsockopt_get_peer_addr_params(struct sock *sk,
{ {
struct sctp_paddrparams params; struct sctp_paddrparams params;
sctp_association_t *asoc; sctp_association_t *asoc;
sockaddr_storage_t *addr; union sctp_addr *addr;
sctp_transport_t *trans; sctp_transport_t *trans;
if (len != sizeof(struct sctp_paddrparams)) if (len != sizeof(struct sctp_paddrparams))
...@@ -1793,7 +1793,7 @@ static inline int sctp_getsockopt_get_peer_addr_params(struct sock *sk, ...@@ -1793,7 +1793,7 @@ static inline int sctp_getsockopt_get_peer_addr_params(struct sock *sk,
if (!asoc) if (!asoc)
return -EINVAL; return -EINVAL;
addr = (sockaddr_storage_t *) &(params.spp_address); addr = (union sctp_addr *) &(params.spp_address);
trans = sctp_assoc_lookup_paddr(asoc, addr); trans = sctp_assoc_lookup_paddr(asoc, addr);
if (!trans) if (!trans)
...@@ -1990,7 +1990,7 @@ static long sctp_get_port_local(struct sock *sk, unsigned short snum) ...@@ -1990,7 +1990,7 @@ static long sctp_get_port_local(struct sock *sk, unsigned short snum)
* socket is going to be sk2. * socket is going to be sk2.
*/ */
int sk_reuse = sk->reuse; int sk_reuse = sk->reuse;
sockaddr_storage_t tmpaddr; union sctp_addr tmpaddr;
struct sock *sk2 = pp->sk; struct sock *sk2 = pp->sk;
SCTP_DEBUG_PRINTK("sctp_get_port() found a " SCTP_DEBUG_PRINTK("sctp_get_port() found a "
...@@ -2293,10 +2293,10 @@ void sctp_put_port(struct sock *sk) ...@@ -2293,10 +2293,10 @@ void sctp_put_port(struct sock *sk)
*/ */
static int sctp_autobind(struct sock *sk) static int sctp_autobind(struct sock *sk)
{ {
sockaddr_storage_t autoaddr; union sctp_addr autoaddr;
int addr_len = 0; int addr_len = 0;
memset(&autoaddr, 0, sizeof(sockaddr_storage_t)); memset(&autoaddr, 0, sizeof(union sctp_addr));
switch (sk->family) { switch (sk->family) {
case PF_INET: case PF_INET:
...@@ -2437,8 +2437,8 @@ SCTP_STATIC int sctp_msghdr_parse(const struct msghdr *msg, ...@@ -2437,8 +2437,8 @@ SCTP_STATIC int sctp_msghdr_parse(const struct msghdr *msg,
/* Setup sk->rcv_saddr before calling get_port(). */ /* Setup sk->rcv_saddr before calling get_port(). */
static inline void sctp_sk_addr_set(struct sock *sk, static inline void sctp_sk_addr_set(struct sock *sk,
const sockaddr_storage_t *newaddr, const union sctp_addr *newaddr,
sockaddr_storage_t *saveaddr) union sctp_addr *saveaddr)
{ {
struct inet_opt *inet = inet_sk(sk); struct inet_opt *inet = inet_sk(sk);
...@@ -2465,7 +2465,7 @@ static inline void sctp_sk_addr_set(struct sock *sk, ...@@ -2465,7 +2465,7 @@ static inline void sctp_sk_addr_set(struct sock *sk,
} }
/* Restore sk->rcv_saddr after failing get_port(). */ /* Restore sk->rcv_saddr after failing get_port(). */
static inline void sctp_sk_addr_restore(struct sock *sk, const sockaddr_storage_t *addr) static inline void sctp_sk_addr_restore(struct sock *sk, const union sctp_addr *addr)
{ {
struct inet_opt *inet = inet_sk(sk); struct inet_opt *inet = inet_sk(sk);
...@@ -2610,12 +2610,12 @@ static struct sk_buff *sctp_skb_recv_datagram(struct sock *sk, int flags, int no ...@@ -2610,12 +2610,12 @@ static struct sk_buff *sctp_skb_recv_datagram(struct sock *sk, int flags, int no
static inline int sctp_sendmsg_verify_name(struct sock *sk, struct msghdr *msg) static inline int sctp_sendmsg_verify_name(struct sock *sk, struct msghdr *msg)
{ {
sockaddr_storage_t *sa; union sctp_addr *sa;
if (msg->msg_namelen < sizeof (struct sockaddr)) if (msg->msg_namelen < sizeof (struct sockaddr))
return -EINVAL; return -EINVAL;
sa = (sockaddr_storage_t *) msg->msg_name; sa = (union sctp_addr *) msg->msg_name;
switch (sa->sa.sa_family) { switch (sa->sa.sa_family) {
case AF_INET: case AF_INET:
if (msg->msg_namelen < sizeof(struct sockaddr_in)) if (msg->msg_namelen < sizeof(struct sockaddr_in))
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* This module provides the abstraction for an SCTP tranport representing * This module provides the abstraction for an SCTP tranport representing
* a remote transport address. For local transport addresses, we just use * a remote transport address. For local transport addresses, we just use
* sockaddr_storage_t. * union sctp_addr.
* *
* The SCTP reference implementation is free software; * The SCTP reference implementation is free software;
* you can redistribute it and/or modify it under the terms of * you can redistribute it and/or modify it under the terms of
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
/* 1st Level Abstractions. */ /* 1st Level Abstractions. */
/* Allocate and initialize a new transport. */ /* Allocate and initialize a new transport. */
sctp_transport_t *sctp_transport_new(const sockaddr_storage_t *addr, int priority) sctp_transport_t *sctp_transport_new(const union sctp_addr *addr, int priority)
{ {
sctp_transport_t *transport; sctp_transport_t *transport;
...@@ -78,14 +78,14 @@ sctp_transport_t *sctp_transport_new(const sockaddr_storage_t *addr, int priorit ...@@ -78,14 +78,14 @@ sctp_transport_t *sctp_transport_new(const sockaddr_storage_t *addr, int priorit
/* Intialize a new transport from provided memory. */ /* Intialize a new transport from provided memory. */
sctp_transport_t *sctp_transport_init(sctp_transport_t *peer, sctp_transport_t *sctp_transport_init(sctp_transport_t *peer,
const sockaddr_storage_t *addr, const union sctp_addr *addr,
int priority) int priority)
{ {
sctp_protocol_t *proto = sctp_get_protocol(); sctp_protocol_t *proto = sctp_get_protocol();
/* Copy in the address. */ /* Copy in the address. */
peer->ipaddr = *addr; peer->ipaddr = *addr;
peer->af_specific = sctp_get_af_specific(addr); peer->af_specific = sctp_get_af_specific(addr->sa.sa_family);
peer->asoc = NULL; peer->asoc = NULL;
/* From 6.3.1 RTO Calculation: /* From 6.3.1 RTO Calculation:
...@@ -204,11 +204,11 @@ void sctp_transport_set_owner(sctp_transport_t *transport, ...@@ -204,11 +204,11 @@ void sctp_transport_set_owner(sctp_transport_t *transport,
* souce address. * souce address.
*/ */
void sctp_transport_route(sctp_transport_t *transport, void sctp_transport_route(sctp_transport_t *transport,
sockaddr_storage_t *saddr) union sctp_addr *saddr)
{ {
sctp_association_t *asoc = transport->asoc; sctp_association_t *asoc = transport->asoc;
sctp_func_t *af = transport->af_specific; sctp_func_t *af = transport->af_specific;
sockaddr_storage_t *daddr = &transport->ipaddr; union sctp_addr *daddr = &transport->ipaddr;
sctp_bind_addr_t *bp; sctp_bind_addr_t *bp;
rwlock_t *addr_lock; rwlock_t *addr_lock;
struct sockaddr_storage_list *laddr; struct sockaddr_storage_list *laddr;
......
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