struct sctp_transport *peer;
struct sctp_sock *sp;
unsigned short port;
- union sctp_addr tmp;
- flip_to_n(&tmp, addr);
sp = sctp_sk(asoc->base.sk);
/* AF_INET and AF_INET6 share common port field. */
- port = addr->v4.sin_port;
+ port = ntohs(addr->v4.sin_port);
SCTP_DEBUG_PRINTK_IPADDR("sctp_assoc_add_peer:association %p addr: ",
" port: %d state:%d\n",
asoc,
addr,
- addr->v4.sin_port,
+ port,
peer_state);
/* Set the port if it has not been set yet. */
asoc->peer.port = port;
/* Check to see if this is a duplicate. */
- peer = sctp_assoc_lookup_paddr(asoc, &tmp);
+ peer = sctp_assoc_lookup_paddr(asoc, addr);
if (peer) {
if (peer->state == SCTP_UNKNOWN) {
if (peer_state == SCTP_ACTIVE)
return peer;
}
- peer = sctp_transport_new(&tmp, gfp);
+ peer = sctp_transport_new(addr, gfp);
if (!peer)
return NULL;
trans = list_entry(pos, struct sctp_transport,
transports);
if (!sctp_assoc_lookup_paddr(asoc, &trans->ipaddr))
- sctp_assoc_add_peer(asoc, &trans->ipaddr_h,
+ sctp_assoc_add_peer(asoc, &trans->ipaddr,
GFP_ATOMIC, trans->state);
}
struct sctp_transport *transport;
struct list_head *pos, *temp;
char *cookie;
+ union sctp_addr tmp;
/* We must include the address that the INIT packet came from.
* This is the only address that matters for an INIT packet.
* added as the primary transport. The source address seems to
* be a a better choice than any of the embedded addresses.
*/
- if (peer_addr)
- if(!sctp_assoc_add_peer(asoc, peer_addr, gfp, SCTP_ACTIVE))
+ if (peer_addr) {
+ flip_to_n(&tmp, peer_addr);
+ if(!sctp_assoc_add_peer(asoc, &tmp, gfp, SCTP_ACTIVE))
goto nomem;
+ }
/* Process the initialization parameters. */
sctp_scope_t scope;
time_t stale;
struct sctp_af *af;
+ union sctp_addr tmp;
/* We maintain all INIT parameters in network byte order all the
* time. This allows us to not worry about whether the parameters
case SCTP_PARAM_IPV4_ADDRESS:
af = sctp_get_af_specific(param_type2af(param.p->type));
af->from_addr_param(&addr, param.addr, asoc->peer.port, 0);
+ flip_to_n(&tmp, &addr);
scope = sctp_scope(peer_addr);
- if (sctp_in_scope(&addr, scope))
- if (!sctp_assoc_add_peer(asoc, &addr, gfp, SCTP_UNCONFIRMED))
+ if (sctp_in_scope(&tmp, scope))
+ if (!sctp_assoc_add_peer(asoc, &tmp, gfp, SCTP_UNCONFIRMED))
return 0;
break;
* Due to Resource Shortage'.
*/
- peer = sctp_assoc_add_peer(asoc, &addr, GFP_ATOMIC, SCTP_UNCONFIRMED);
+ peer = sctp_assoc_add_peer(asoc, &tmp_addr, GFP_ATOMIC, SCTP_UNCONFIRMED);
if (!peer)
return SCTP_ERROR_RSRC_LOW;
int err = 0;
int addrcnt = 0;
int walk_size = 0;
- struct sockaddr *sa_addr;
+ union sctp_addr *sa_addr;
void *addr_buf;
sp = sctp_sk(sk);
/* Walk through the addrs buffer and count the number of addresses. */
addr_buf = kaddrs;
while (walk_size < addrs_size) {
- sa_addr = (struct sockaddr *)addr_buf;
- af = sctp_get_af_specific(sa_addr->sa_family);
+ sa_addr = (union sctp_addr *)addr_buf;
+ af = sctp_get_af_specific(sa_addr->sa.sa_family);
/* If the address family is not supported or if this address
* causes the address buffer to overflow return EINVAL.
goto out_free;
}
- err = sctp_verify_addr(sk, (union sctp_addr *)sa_addr,
- af->sockaddr_len);
+ err = sctp_verify_addr(sk, sa_addr, af->sockaddr_len);
if (err)
goto out_free;
}
/* Prime the peer's transport structures. */
- transport = sctp_assoc_add_peer(asoc, &to, GFP_KERNEL,
+ transport = sctp_assoc_add_peer(asoc, sa_addr, GFP_KERNEL,
SCTP_UNKNOWN);
if (!transport) {
err = -ENOMEM;
}
/* Prime the peer's transport structures. */
- transport = sctp_assoc_add_peer(asoc, &to, GFP_KERNEL, SCTP_UNKNOWN);
+ transport = sctp_assoc_add_peer(asoc, &tmp, GFP_KERNEL, SCTP_UNKNOWN);
if (!transport) {
err = -ENOMEM;
goto out_free;