⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 marshall.h

📁 ns2.1b5版本中cbrp碼
💻 H
字号:
/* -*- c++ -*-   marshall.h   $Id: marshall.h,v 1.1 1998/09/21 19:26:32 dmaltz Exp $   safely marshall and unmarshall 2 and 4 byte quantities into    possibly unaligned feilds   NOTE: unlike the normal version of marshall, we marshall the bytes   in *HOST*BYTE*ORDER* and *not* network byte order.  we do this since   all the other quanities in the packets will be in host byte order, and   we want consistency.   */#ifndef _cmu_marshall_h_#define _cmu_marshall_h_#ifdef sparc#define GET4BYTE(x) (  (*(((unsigned char *)(x))  ) << 24) \                    | (*(((unsigned char *)(x))+1) << 16) \                    | (*(((unsigned char *)(x))+2) << 8) \                    | (*(((unsigned char *)(x))+3)     ))#define GET2BYTE(x) (  (*(((unsigned char *)(x))  ) << 8) \                      | (*(((unsigned char *)(x))+1)     ))/* let x,y be ptrs to ints, copy *x into *y */#define STORE4BYTE(x,y) (((unsigned char *)y)[0] = ((unsigned char *)x)[0] ,\		       ((unsigned char *)y)[1] = ((unsigned char *)x)[1] ,\		       ((unsigned char *)y)[2] = ((unsigned char *)x)[2] ,\		       ((unsigned char *)y)[3] = ((unsigned char *)x)[3] )#define STORE2BYTE(x,y) (((unsigned char *)y)[0] = ((unsigned char *)x)[0] ,\			 ((unsigned char *)y)[1] = ((unsigned char *)x)[1] )		      #else#include <sys/types.h>#define GET4BYTE(x) *((u_int32_t*) (x))#define GET2BYTE(x) *((u_int16_t*) (x))/* let x,y be ptrs to ints, copy *x into *y */#define STORE4BYTE(x,y) (*((u_int32_t*) (x)) = *y)#define STORE2BYTE(x,y) (*((u_int16_t*) (x)) = *y)#endif#endif /* _cmu_marshall_h_ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -