[SCTP]: Beginning of sin_port fixes.

That's going to be a long series.  Introduced temporary helpers
doing copy-and-convert for sctp_addr; they are used to kill
flip-in-place in global data structures and will be used
to gradually push host-endian uses of sctp_addr out of existence.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Al Viro
2006-11-20 17:02:01 -08:00
committed by David S. Miller
parent dbc16db1e5
commit 04afd8b282
2 changed files with 34 additions and 17 deletions

View File

@@ -74,6 +74,28 @@ union sctp_addr {
struct sockaddr sa;
};
static inline void flip_to_n(union sctp_addr *to, const union sctp_addr *from)
{
size_t len;
if (from->sa.sa_family == AF_INET6)
len = sizeof(struct sockaddr_in6);
else
len = sizeof(struct sockaddr);
memcpy(to, from, len);
to->v4.sin_port = htons(from->v4.sin_port);
}
static inline void flip_to_h(union sctp_addr *to, const union sctp_addr *from)
{
size_t len;
if (from->sa.sa_family == AF_INET6)
len = sizeof(struct sockaddr_in6);
else
len = sizeof(struct sockaddr);
memcpy(to, from, len);
to->v4.sin_port = ntohs(from->v4.sin_port);
}
/* Forward declarations for data structures. */
struct sctp_globals;
struct sctp_endpoint;