00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef __utils_h
00038 #define __utils_h
00039
00040 #ifdef __cplusplus
00041 extern "C" {
00042 #endif
00043
00044 #include"common.h"
00045
00046
00047 # define STRINGIFY(x) # x
00048 # define TOSTRING(x) STRINGIFY(x)
00049
00050
00051 #define hton64(x) ((uint64_t)((htonl(((uint32_t)((x)>>32)&0xFFFFFFFF))))|((uint64_t)(htonl((uint32_t)((x)&0xFFFFFFFF)))<<32))
00052 #define ntoh64(x) ((uint64_t)((ntohl(((uint32_t)((x)>>32)&0xFFFFFFFF))))|((uint64_t)(ntohl((uint32_t)((x)&0xFFFFFFFF)))<<32))
00053
00054
00055 #define Attribute_GetType(x) ((x)>>1)
00056 #define Attribute_GetHF(x) ((x)&1)
00057 #define Attribute_GetTypeHF(x,y) (((x)<<1)|((y)&1))
00058
00059
00060 #define hextobin(x) ((x)>'9'?((x)>'Z'?(((x)-0x27)&0x0F):(((x)-0x07)&0x0F)):((x)&0x0F))
00061 #define ishex(x) ((((x)>='0')&&((x)<='9'))||(((x)>='A')&&((x)<='Z'))||(((x)>='a')&&((x)<='z')))
00062
00063
00064
00065 unsigned hex2bytes(char *s, uint8_t **dest);
00066 const char* bin2str(const uint8_t *data,uint32_t len);
00067 void hexalize(uint8_t **data,unsigned *len);
00068 BIGNUM *HexToBignum( const uint8_t *hex, uint32_t len );
00069 uint8_t *Clone( const uint8_t *data, uint32_t len );
00070 void PrintBuffer( unsigned char *buf, unsigned long len );
00071 void PrintBignum(const BIGNUM *a);
00072 uint32_t StringToIP( char *str_ip );
00073 char *IPToString( uint32_t ip );
00074
00075 #ifdef __cplusplus
00076 }
00077 #endif
00078
00079 #endif