summaryrefslogtreecommitdiff
path: root/include/net
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2006-11-20 17:02:01 -0800
committerDavid S. Miller <davem@sunset.davemloft.net>2006-12-02 21:26:24 -0800
commit04afd8b282d702bc122051751466000e9513ef96 (patch)
tree1a5bc840fbc322daaf71b1e9fdd83b27274f9cc9 /include/net
parentdbc16db1e58da6c346ca3e63870c17b93fbed0f0 (diff)
downloadlinux-3.10-04afd8b282d702bc122051751466000e9513ef96.tar.gz
linux-3.10-04afd8b282d702bc122051751466000e9513ef96.tar.bz2
linux-3.10-04afd8b282d702bc122051751466000e9513ef96.zip
[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>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/sctp/structs.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index ca77bc5b7ff..2aa61ac9a9f 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -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;