]> git.saurik.com Git - apple/mdnsresponder.git/blob - mDNSMacOSX/BonjourTop/source/bjtypes.h
mDNSResponder-878.1.1.tar.gz
[apple/mdnsresponder.git] / mDNSMacOSX / BonjourTop / source / bjtypes.h
1 //
2 // bjtypes.h
3 // TestTB
4 //
5 // Created by Terrin Eager on 4/24/12.
6 //
7 //
8
9
10 #ifndef TestTB_bjtypes_h
11 #define TestTB_bjtypes_h
12 typedef bool BJ_BOOL;
13
14 typedef char BJ_INT8;
15 typedef unsigned char BJ_UINT8;
16
17 typedef short int BJ_INT16;
18 typedef unsigned short int BJ_UINT16;
19
20 typedef int BJ_INT32;
21 typedef unsigned int BJ_UINT32;
22
23 typedef long long BJ_INT64;
24 typedef unsigned long long BJ_UINT64;
25
26 #define DNS_NAME_OFFSET_MASK 0xc0
27
28 #define MAX_FRAME_SIZE 0x2800
29
30
31 enum BJ_COMPARE {BJ_GT,BJ_LT,BJ_EQUAL};
32
33 #define PF_GET_UINT8(pBuffer,offset) ( (BJ_UINT8)pBuffer[offset] )
34 #define PF_GET_UINT16(pBuffer,offset) ((((BJ_UINT16)pBuffer[offset]) << 8) | ((BJ_UINT16)pBuffer[offset+1]))
35 #define PF_GET_UINT32(pBuffer,offset) ((pBuffer[offset] << 24) | (pBuffer[offset+1] << 16) | (pBuffer[offset+2] << 8) | (pBuffer[offset+3]))
36
37
38 inline void endian_swap(BJ_UINT8& x)
39 {
40 x = (x>>8) |(x<<8);
41 }
42
43 inline void endian_swap(BJ_UINT32& x)
44 {
45 x = (x>>24) |
46 ((x<<8) & 0x00FF0000) |
47 ((x>>8) & 0x0000FF00) |
48 (x<<24);
49 }
50
51
52 inline void endian_swap(BJ_UINT64& x)
53 {
54 x = (x>>56) |
55 ((x<<40) & 0x00FF000000000000) |
56 ((x<<24) & 0x0000FF0000000000) |
57 ((x<<8) & 0x000000FF00000000) |
58 ((x>>8) & 0x00000000FF000000) |
59 ((x>>24) & 0x0000000000FF0000) |
60 ((x>>40) & 0x000000000000FF00) |
61 (x<<56);
62 }
63
64 #endif