-// ANNA - Anna is Not 'N' Anymore
-//
-// (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo
-//
-// https://bitbucket.org/testillano/anna
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions
-// are met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Authors: eduardo.ramos.testillano@gmail.com
-// cisco.tierra@gmail.com
+// ANNA - Anna is Not Nothingness Anymore //
+// //
+// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
+// //
+// See project site at http://redmine.teslayout.com/projects/anna-suite //
+// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
#ifndef anna_core_util_defines_hpp
#include <string>
#include <vector>
+#include <stdio.h>
+
// Decoding helpers
/** Alias for int: signed integer with 32 bits */
typedef int S32;
+///** Alias for unsigned long long: unsigned integer with 64 bits */
+//typedef unsigned long long int U64;
+//
+///** Alias for long long: signed integer with 64 bits */
+//typedef long long int S64;
+#ifndef __x86_64__
+#undef __anna64__
+/** Alias for long long: signed integer with 64 bits */
+typedef int64_t S64
/** Alias for unsigned long long: unsigned integer with 64 bits */
-typedef unsigned long long int U64;
-
+typedef u_int64_t U64;
+#else
+#define __anna64__
/** Alias for long long: signed integer with 64 bits */
typedef long long int S64;
+/** Alias for unsigned long long: unsigned integer with 64 bits */
+typedef unsigned long long int U64;
+#endif
/** Alias for float: floating number with 32 bits (1-8-23) */
typedef float F32;
/**
- Struct for IANA Addresses
+* IANA Address Family Numbers
+* @see http://www.iana.org/assignments/address-family-numbers/address-family-numbers.xml
*/
typedef struct {
+ enum _v {
+ //Number Description Reference
+ //------ ---------------------------------------------------- ---------
+ // 0 Reserved
+ IPv4 = 1, //IP (IP version 4)
+ IPv6 = 2, //IP6 (IP version 6)
+ // 3 NSAP
+ // 4 HDLC (8-bit multidrop)
+ // 5 BBN 1822
+ // 6 802 (includes all 802 media plus Ethernet "canonical format")
+ // 7 E.163
+ E164 = 8 //E.164 (SMDS, Frame Relay, ATM)
+ // 9 F.69 (Telex)
+ // 10 X.121 (X.25, Frame Relay)
+ // 11 IPX
+ // 12 Appletalk
+ // 13 Decnet IV
+ // 14 Banyan Vines
+ // 15 E.164 with NSAP format subaddress [UNI-3.1] [Andy_Malis]
+ // 16 DNS (Domain Name System)
+ // 17 Distinguished Name [Charles_Lynn]
+ // 18 AS Number [Charles_Lynn]
+ // 19 XTP over IP version 4 [Mike_Saul]
+ // 20 XTP over IP version 6 [Mike_Saul]
+ // 21 XTP native mode XTP [Mike_Saul]
+ // 22 Fibre Channel World-Wide Port Name [Mark_Bakke]
+ // 23 Fibre Channel World-Wide Node Name [Mark_Bakke]
+ // 24 GWID [Subra_Hegde]
+ // 25 AFI for L2VPN information [RFC4761][RFC6074]
+ // 26-16383 Unassigned
+ // 16384 EIGRP Common Service Family [Donnie_Savage] 2008-05-13
+ // 16385 EIGRP IPv4 Service Family [Donnie_Savage] 2008-05-13
+ // 16386 EIGRP IPv6 Service Family [Donnie_Savage] 2008-05-13
+ // 16387 LISP Canonical Address Format (LCAF) [David_Meyer] 2009-11-12
+ // 16388-32767 Unassigned
+ // 32768-65534 Unassigned
+ // 65535 Reserved
+ };
/**
- * IANA Address Family Numbers
- * @see http://www.iana.org/assignments/address-family-numbers/address-family-numbers.xml
+ * Version description
+ * @param v Version type
+ * @return Version description
*/
- struct version {
- enum _v {
- //Number Description Reference
- //------ ---------------------------------------------------- ---------
- // 0 Reserved
- IPv4 = 1, //IP (IP version 4)
- IPv6 = 2, //IP6 (IP version 6)
- // 3 NSAP
- // 4 HDLC (8-bit multidrop)
- // 5 BBN 1822
- // 6 802 (includes all 802 media plus Ethernet "canonical format")
- // 7 E.163
- E164 = 8 //E.164 (SMDS, Frame Relay, ATM)
- // 9 F.69 (Telex)
- // 10 X.121 (X.25, Frame Relay)
- // 11 IPX
- // 12 Appletalk
- // 13 Decnet IV
- // 14 Banyan Vines
- // 15 E.164 with NSAP format subaddress [UNI-3.1] [Andy_Malis]
- // 16 DNS (Domain Name System)
- // 17 Distinguished Name [Charles_Lynn]
- // 18 AS Number [Charles_Lynn]
- // 19 XTP over IP version 4 [Mike_Saul]
- // 20 XTP over IP version 6 [Mike_Saul]
- // 21 XTP native mode XTP [Mike_Saul]
- // 22 Fibre Channel World-Wide Port Name [Mark_Bakke]
- // 23 Fibre Channel World-Wide Node Name [Mark_Bakke]
- // 24 GWID [Subra_Hegde]
- // 25 AFI for L2VPN information [RFC4761][RFC6074]
- // 26-16383 Unassigned
- // 16384 EIGRP Common Service Family [Donnie_Savage] 2008-05-13
- // 16385 EIGRP IPv4 Service Family [Donnie_Savage] 2008-05-13
- // 16386 EIGRP IPv6 Service Family [Donnie_Savage] 2008-05-13
- // 16387 LISP Canonical Address Format (LCAF) [David_Meyer] 2009-11-12
- // 16388-32767 Unassigned
- // 32768-65534 Unassigned
- // 65535 Reserved
- };
-
- /**
- * Version description
- * @param v Version type
- * @return Version description
- */
- static const char* asText(const version::_v v) throw() { // anna_declare_enum is not safe, because labels don't have to match a sequence
- if(v == version::IPv4) return "IPv4";
-
- if(v == version::IPv6) return "IPv6";
-
- if(v == version::E164) return "E164";
-
- return NULL;
- }
- };
+ static const char* asText(const _v v) throw() { // anna_declare_enum is not safe, because labels don't have to match a sequence
+ if(v == IPv4) return "IPv4";
+
+ if(v == IPv6) return "IPv6";
+
+ if(v == E164) return "E164";
+
+ return NULL;
+ }
+
+} iana_address_version_t;
+
+
+/**
+ Struct for IANA Addresses
+*/
+typedef struct {
/** address version */
U16 Version;
// Helpers
/** Return true when is an IPv4 address */
- bool isIPv4() const throw() { return ((version::_v)Version == version::IPv4); }
+ bool isIPv4() const throw() { return ((iana_address_version_t::_v)Version == iana_address_version_t::IPv4); }
/** Return true when is an IPv6 address */
- bool isIPv6() const throw() { return ((version::_v)Version == version::IPv6); }
+ bool isIPv6() const throw() { return ((iana_address_version_t::_v)Version == iana_address_version_t::IPv6); }
/** Return true when is an E164 (SMDS, Frame Relay, ATM) address */
- bool isE164() const throw() { return ((version::_v)Version == version::E164); }
+ bool isE164() const throw() { return ((iana_address_version_t::_v)Version == iana_address_version_t::E164); }
/** Sets version for IPv4 address and address itself. Checking is not performed (could assign IPv6 instead ...) */
- void setIPv4(const char *value) throw() { Version = version::IPv4; Value = value ? value : ""; }
+ void setIPv4(const char *value) throw() { Version = iana_address_version_t::IPv4; Value = value ? value : ""; }
/** Sets version for IPv6 address and address itself. Checking is not performed (could assign IPv4 instead ...) */
- void setIPv6(const char *value) throw() { Version = version::IPv6; Value = value ? value : ""; }
+ void setIPv6(const char *value) throw() { Version = iana_address_version_t::IPv6; Value = value ? value : ""; }
/** Sets version for E164 address and address itself. Checking is not performed ... */
- void setE164(const char *value) throw() { Version = version::E164; Value = value ? value : ""; }
+ void setE164(const char *value) throw() { Version = iana_address_version_t::E164; Value = value ? value : ""; }
/**
std::string result;
result += Value.c_str(); // assume that all IANA addresses have a printable representation
result += " (";
- const char *versionAsText = version::asText((version::_v)Version);
+ const char *versionAsText = iana_address_version_t::asText((iana_address_version_t::_v)Version);
if(versionAsText) {
result += versionAsText;