@ -266,12 +266,20 @@ public:
* nwid = < hex network ID > ( required )
* nwid = < hex network ID > ( required )
* name = short name
* name = short name
* desc = long ( er ) description
* desc = long ( er ) description
* com = Certificate ( serialized dictionary )
* com = Serialized certificate of membership
* mr = MulticastRates ( serialized dictionary )
* mr = MulticastRates ( serialized dictionary )
* md = multicast propagation depth
* mpb = multicast propagation prefix bits ( 2 ^ mpb packets are sent by origin )
* o = open network ? ( 1 or 0 , default false if missing )
* o = open network ? ( 1 or 0 , default false if missing )
* et = ethertype whitelist ( comma - delimited list of ethertypes in decimal )
* et = ethertype whitelist ( comma - delimited list of ethertypes in decimal )
* v4s = IPv4 static assignments / netmasks ( comma - delimited )
* v4s = IPv4 static assignments / netmasks ( comma - delimited )
* v6s = IPv6 static assignments / netmasks ( comma - delimited )
* v6s = IPv6 static assignments / netmasks ( comma - delimited )
*
* Notes :
*
* If zero appears in the ' et ' list , the sense is inverted . It becomes an
* ethertype blacklist instead of a whitelist and anything not blacklisted
* is permitted .
*/
*/
class Config : private Dictionary
class Config : private Dictionary
{
{
@ -339,6 +347,34 @@ public:
else return MulticastRates ( mr - > second ) ;
else return MulticastRates ( mr - > second ) ;
}
}
/**
* @ return Number of bits in propagation prefix for this network
*/
inline unsigned int multicastPrefixBits ( ) const
{
const_iterator mpb ( find ( " mpb " ) ) ;
if ( mpb = = end ( ) )
return ZT_DEFAULT_MULTICAST_PREFIX_BITS ;
unsigned int tmp = Utils : : hexStrToUInt ( mpb - > second . c_str ( ) ) ;
if ( tmp )
return tmp ;
else return ZT_DEFAULT_MULTICAST_PREFIX_BITS ;
}
/**
* @ return Maximum multicast propagation depth for this network
*/
inline unsigned int multicastDepth ( ) const
{
const_iterator md ( find ( " md " ) ) ;
if ( md = = end ( ) )
return ZT_DEFAULT_MULTICAST_DEPTH ;
unsigned int tmp = Utils : : hexStrToUInt ( md - > second . c_str ( ) ) ;
if ( tmp )
return tmp ;
else return ZT_DEFAULT_MULTICAST_DEPTH ;
}
/**
/**
* @ return True if this is an open non - access - controlled network
* @ return True if this is an open non - access - controlled network
*/
*/
@ -557,7 +593,9 @@ public:
return false ;
return false ;
else if ( etherType > 65535 )
else if ( etherType > 65535 )
return false ;
return false ;
else return ( ( _etWhitelist [ etherType / 8 ] & ( unsigned char ) ( 1 < < ( etherType % 8 ) ) ) ! = 0 ) ;
else if ( ( _etWhitelist [ 0 ] & 1 ) ) // if type 0 is in the whitelist, sense is inverted from whitelist to blacklist
return ( ( _etWhitelist [ etherType / 8 ] & ( unsigned char ) ( 1 < < ( etherType & 7 ) ) ) = = 0 ) ;
else return ( ( _etWhitelist [ etherType / 8 ] & ( unsigned char ) ( 1 < < ( etherType & 7 ) ) ) ! = 0 ) ;
}
}
/**
/**
@ -592,6 +630,24 @@ public:
return false ; // TODO: bridging not implemented yet
return false ; // TODO: bridging not implemented yet
}
}
/**
* @ return Bits in multicast restriciton prefix
*/
inline unsigned int multicastPrefixBits ( ) const
throw ( )
{
return _multicastPrefixBits ;
}
/**
* @ return Max depth ( TTL ) for a multicast frame
*/
inline unsigned int multicastDepth ( ) const
throw ( )
{
return _multicastDepth ;
}
private :
private :
static void _CBhandleTapData ( void * arg , const MAC & from , const MAC & to , unsigned int etherType , const Buffer < 4096 > & data ) ;
static void _CBhandleTapData ( void * arg , const MAC & from , const MAC & to , unsigned int etherType , const Buffer < 4096 > & data ) ;
void _restoreState ( ) ;
void _restoreState ( ) ;
@ -614,6 +670,8 @@ private:
MulticastRates _mcRates ; // memoized from _configuration
MulticastRates _mcRates ; // memoized from _configuration
std : : set < InetAddress > _staticAddresses ; // memoized from _configuration
std : : set < InetAddress > _staticAddresses ; // memoized from _configuration
bool _isOpen ; // memoized from _configuration
bool _isOpen ; // memoized from _configuration
unsigned int _multicastPrefixBits ; // memoized from _configuration
unsigned int _multicastDepth ; // memoized from _configuration
// Ethertype whitelist bit field, set from config, for really fast lookup
// Ethertype whitelist bit field, set from config, for really fast lookup
unsigned char _etWhitelist [ 65536 / 8 ] ;
unsigned char _etWhitelist [ 65536 / 8 ] ;