summaryrefslogtreecommitdiff
path: root/include/uint_t.h
blob: 7bf32c8458bee1fc3cbe8848b55c06fe57ea28ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <stdint.h>

/**
  @file uint_t.h
  @author djb, kp, feh
  @source qmail, djbdns6
  @brief additional types and pack routines
  @brief define basic integer types and size through <stdint.h>
*/

#ifndef UINT8_H
  #define UINT8_H

  #ifdef HAS_UINT8_H
typedef uint8_t uint8;
  #else
typedef unsigned char uint8;
  #endif

#endif

#ifndef UINT16_H
  #define UINT16_H

typedef uint16_t uint16;

extern void uint16_pack(char *, uint16);
extern void uint16_pack_big(char *, uint16);
extern void uint16_unpack(char *, uint16 *);
extern void uint16_unpack_big(char *, uint16 *);
#endif

#ifndef UINT32_H
  #define UINT32_H

typedef uint32_t uint32;

extern void uint32_pack(char *, uint32);
extern void uint32_pack_big(char *, uint32);
extern void uint32_unpack(char *, uint32 *);
extern void uint32_unpack_big(char *, uint32 *);
#endif

#ifndef UINT64_H
  #define UINT64_H

  #ifdef HAS_UINT64_H
typedef uint64_t uint64;
  #else
typedef unsigned long long uint64;
  #endif

extern void uint64_pack(char *, uint64);
extern void uint64_pack_big(char *, uint64);
extern void uint64_unpack(char *, uint64 *);
extern void uint64_unpack_big(char *, uint64 *);
#endif

#ifndef UINT128_H
  #define UINT128_H

/* uint128 used for native IPv6 address presentation */

struct uint128_t {
  uint64_t hi; /* routing area */
  uint64_t lo; /* local area */
};

typedef struct uint128_t uint128;

extern void uint128_pack(char *, uint128);
extern void uint128_pack_big(char *, uint128);
extern void uint128_unpack(char *, uint128 *);
extern void uint128_unpack_big(char *, uint128 *);
#endif