#include <stdio.h> #include <stdint.h> uint16_t stun_make_type(uint16_t method) { method = method & 0x0FFF; return ((method & 0x000F) | ((method & 0x0070)<<1) |((method & 0x0380)<<2) | ((method & 0x0C00)<<2)); } int main(){ printf("%#X",stun_make_type(0xFFFF)); return 0; }
输出: 0X3EEF
这个函数stun_make_type()的作用是取出16位参数的个别位置!