cpu_to_le32()

http://www.csse.uwa.edu.au/~chris/uwasp/endian.html

NAME
Functions to manipulate the byte-ordering (the endianness) of captured data
SYNOPSIS
#include <uwasp.h>
uint16_t le16_to_cpu( uint16_t value );
uint16_t cpu_to_le16( uint16_t value );
uint32_t le32_to_cpu( uint32_t value );
uint32_t cpu_to_le32( uint32_t value );
uint64_t le64_to_cpu( uint64_t value );
uint64_t cpu_to_le64( uint64_t value );

uint16_t be16_to_cpu( uint16_t value );
uint16_t cpu_to_be16( uint16_t value );
uint32_t be32_to_cpu( uint32_t value );
uint32_t cpu_to_be32( uint32_t value );
uint64_t be64_to_cpu( uint64_t value );
uint64_t cpu_to_be64( uint64_t value );

DESCRIPTION
To maintain platform independence of captured data, both when it is transmitted through networks and when stored on disk, all 16-, 32-, and 64-bit integer values are stored in little-endian order.
Little-endian is chosen because the data is most likely to be accessed on little-endian machines, such as the Intel x86 architecture. These functions provide conversions between little-endian, big-endian, and the byte ordering of the CPU on which the data is being processed.

le16_to_cpu(), for example, converts a 16-bit little-endian integer to its 16-bit representation on the current CPU. Similarly, cpu_to_be32() converts the current CPU's 32-bit representation of a integer, to its 32-bit big-endian representation.

As an example, to extract the frame-control field from a captured frame so that it be used in subsequent arithmetic expressions, we would use:

    uint16_t  frame_control  = le16_to_cpu( capture->h.fc );
RETURN VALUE
Each function returns a 16, 32, or 64 bit integer in the requested byte-ordering.
As all 16, 32, and 64 bit patterns are valid integers in each representation, no errors are possible.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值