diff options
author | Sage Weil <sage@newdream.net> | 2009-11-03 15:17:56 -0800 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2009-11-03 15:17:56 -0800 |
commit | 63f2d211954b790fea0a9caeae605c7956535af6 (patch) | |
tree | b49257aa54d9657539eeba014f9ff5f91f8495de /fs/ceph/decode.h | |
parent | 859e7b149362475672e2a996f29b8f45cbb34d82 (diff) |
ceph: use fixed endian encoding for ceph_entity_addr
We exchange struct ceph_entity_addr over the wire and store it on disk.
The sockaddr_storage.ss_family field, however, is host endianness. So,
fix ss_family endianness to big endian when sending/receiving over the
wire.
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph/decode.h')
-rw-r--r-- | fs/ceph/decode.h | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/fs/ceph/decode.h b/fs/ceph/decode.h index 91179fb2cc3..a382aecc55b 100644 --- a/fs/ceph/decode.h +++ b/fs/ceph/decode.h @@ -76,19 +76,31 @@ static inline void ceph_decode_copy(void **p, void *pv, size_t n) * struct ceph_timespec <-> struct timespec */ static inline void ceph_decode_timespec(struct timespec *ts, - struct ceph_timespec *tv) + const struct ceph_timespec *tv) { ts->tv_sec = le32_to_cpu(tv->tv_sec); ts->tv_nsec = le32_to_cpu(tv->tv_nsec); } static inline void ceph_encode_timespec(struct ceph_timespec *tv, - struct timespec *ts) + const struct timespec *ts) { tv->tv_sec = cpu_to_le32(ts->tv_sec); tv->tv_nsec = cpu_to_le32(ts->tv_nsec); } /* + * sockaddr_storage <-> ceph_sockaddr + */ +static inline void ceph_encode_addr(struct ceph_entity_addr *a) +{ + a->in_addr.ss_family = htons(a->in_addr.ss_family); +} +static inline void ceph_decode_addr(struct ceph_entity_addr *a) +{ + a->in_addr.ss_family = ntohs(a->in_addr.ss_family); +} + +/* * encoders */ static inline void ceph_encode_64(void **p, u64 v) |