cpu_to_le32()
2015-12-21 13:47
323 查看
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.
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.
相关文章推荐
- redis keys 命令
- 【字符串】poj1961
- this call和apply
- 余额宝 vs. P2P网贷,谁更有生命力?
- Android 打造万能的ListView GridView 适配器
- Android ListView分页显示简单模拟实现
- CentOS 上面安装redis3.0.5
- online_judge_1129
- 素数及素数筛选算法训练基础题(一)
- ABP理论学习之审计日志
- UIView---汇总
- BUAA 更大公约数
- 企业年金
- Jenkins进阶系列之——18Jenkins语言本地化
- 产品策划六:App界面交互设计规范
- 【蓝桥第七周】安排会议室
- windows2008 R2访问php网站慢怎么办?
- 浅析python的metaclass
- MYSQL--存储过程-触发器-事务
- oracle简单写文件