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
00038
00039
00045 #ifndef PROTLIB__TYPES_H
00046 #define PROTLIB__TYPES_H
00047
00048 #include <iostream>
00049 #include <fstream>
00050 #include <exception>
00051
00052 #include <cassert>
00053
00054 #include <netinet/in.h>
00055
00056 #include <sys/types.h>
00057
00058
00059 #define _THREADS
00060
00061
00062 namespace protlib {
00063 using namespace std;
00064 using namespace __gnu_cxx;
00065
00074 class ProtLibException : public std::exception {
00075 public:
00076 virtual ~ProtLibException() throw() { }
00077
00087 virtual const char *what() const throw() { return error_msg.c_str(); }
00088
00092 virtual const char *getstr() const { return what(); }
00093
00094
00095 protected:
00096 ProtLibException() throw() { }
00097 ProtLibException(std::string msg) throw() : error_msg(msg) { }
00098
00099 std::string error_msg;
00100 };
00101
00102 inline ostream& operator<<(ostream& os, const ProtLibException &err) {
00103 return os << err.what();
00104 }
00105
00106
00107 typedef unsigned char uchar;
00108
00109 typedef char int8;
00110 typedef unsigned char uint8;
00111
00112 typedef short int int16;
00113 typedef unsigned short int uint16;
00114
00115
00116
00117
00118
00119
00120 typedef int32_t int32;
00121 typedef u_int32_t uint32;
00122
00123 typedef int64_t int64;
00124 typedef u_int64_t uint64;
00125
00126
00127 class uint128 {
00128 public:
00129 uint32 w1;
00130 uint32 w2;
00131 uint32 w3;
00132 uint32 w4;
00133 uint128() : w1(0),w2(0),w3(0),w4(0) {};
00134 uint128(uint32 w1, uint32 w2, uint32 w3, uint32 w4) : w1(w1),w2(w2),w3(w3),w4(w4) {};
00135 bool operator==(const uint128& val) const { return w1==val.w1 && w2==val.w2 && w3==val.w3 && w4==val.w4; }
00136 };
00137
00138
00140 typedef uint8 prefix_length_t;
00141
00143 typedef uint8 protocol_t;
00144
00151 const protocol_t prot_tls_tcp = 254;
00152 const protocol_t prot_query_encap= 255;
00153 const protocol_t prot_tcp = IPPROTO_TCP;
00154 const protocol_t prot_udp = IPPROTO_UDP;
00155 const protocol_t prot_sctp = IPPROTO_SCTP;
00156
00158 typedef uint16 port_t;
00159
00161 typedef uint64 gp_id_t;
00162
00164 #define catch_all(x) try { x; } catch(...) { }
00165
00166
00167
00168 }
00169
00170 #endif // PROTLIB__TYPES_H