static void handle_card(struct sstate *ss) { unsigned char buf[2048]; int rd; struct rx_info *ri = (struct rx_info*) buf; struct client *c; rd = card_read(ss, ri + 1, sizeof(buf) - sizeof(*ri), ri); if (rd >= 0) rd += sizeof(*ri); #ifdef __MACH__ ri->ri_mactime = OSSwapHostToBigInt64(ri->ri_mactime); ri->ri_power = OSSwapHostToBigInt32(ri->ri_power); ri->ri_noise = OSSwapHostToBigInt32(ri->ri_noise); ri->ri_channel = OSSwapHostToBigInt32(ri->ri_channel); ri->ri_rate = OSSwapHostToBigInt32(ri->ri_rate); ri->ri_antenna = OSSwapHostToBigInt32(ri->ri_antenna); #elif defined(__FreeBSD__) #if BYTE_ORDER == BIG_ENDIAN # define __be32_to_cpu(x) (x) # define __be64_to_cpu(x) (x) #elif BYTE_ORDER == LITTLE_ENDIAN # define __be32_to_cpu(x) __bswap32(x) # define __be64_to_cpu(x) __bswap64(x) #endif #else ri->ri_mactime = __cpu_to_be64(ri->ri_mactime); ri->ri_power = __cpu_to_be32(ri->ri_power); ri->ri_noise = __cpu_to_be32(ri->ri_noise); ri->ri_channel = __cpu_to_be32(ri->ri_channel); ri->ri_rate = __cpu_to_be32(ri->ri_rate); ri->ri_antenna = __cpu_to_be32(ri->ri_antenna); #endif /* __MACH__ */ c = ss->ss_clients.c_next; while (c != &ss->ss_clients) { client_send_packet(ss, c, buf, rd); c = c->c_next; } }
static bool_t xdr_CSSM_DATA_FLIPPED(XDR *xdrs, CSSM_DATA *objp) { bool_t size_alloc = sec_xdr_arena_size_allocator(xdrs); if ((xdrs->x_op == XDR_ENCODE) && !size_alloc) { switch (objp->Length) { case sizeof(uint32_t): *(uint32_t*)objp->Data = htonl(*(uint32_t*)objp->Data); break; case sizeof(uint64_t): *(uint64_t*)objp->Data = OSSwapHostToBigInt64(*(uint64_t*)objp->Data); break; case sizeof(uint8_t): break; default: assert(FALSE); break; } } if (!xdr_CSSM_DATA(xdrs, objp)) return (FALSE); if ((xdrs->x_op == XDR_DECODE) && !size_alloc) { switch (objp->Length) { case sizeof(uint32_t): *(uint32_t*)objp->Data = ntohl(*(uint32_t*)objp->Data); break; case sizeof(uint64_t): *(uint64_t*)objp->Data = OSSwapBigToHostInt64(*(uint64_t*)objp->Data); break; case sizeof(uint8_t): break; default: assert(FALSE); break; } } return (TRUE); }
uint64_t tobe64(uint64_t x) { return OSSwapHostToBigInt64(x); }