}
storeAppendPrintf(sentry, "\t%s:\n", label);
- storeAppendPrintf(sentry, "\t\tMax: %d\n", max_bytes);
+ storeAppendPrintf(sentry, "\t\tMax: %"PRId64"\n", max_bytes);
storeAppendPrintf(sentry, "\t\tRestore: %d\n", restore_bps);
}
void
DelaySpec::dump (StoreEntry *entry) const
{
- storeAppendPrintf(entry, " %d/%d", restore_bps, max_bytes);
+ storeAppendPrintf(entry, " %d/%"PRId64"", restore_bps, max_bytes);
}
void
DelaySpec::parse()
{
- int i;
+ int r;
char *token;
token = strtok(NULL, "/");
if (token == NULL)
self_destruct();
- if (sscanf(token, "%d", &i) != 1)
+ if (sscanf(token, "%d", &r) != 1)
self_destruct();
- restore_bps = i;
+ restore_bps = r;
- i = GetInteger();
-
- max_bytes = i;
+ max_bytes = GetInteger64();
}
#endif
-
delay pools, one of class 2 and one of class 3, the settings above
and here would be:
-Example:
- delay_pools 4 # 4 delay pools
- delay_class 1 2 # pool 1 is a class 2 pool
- delay_class 2 3 # pool 2 is a class 3 pool
- delay_class 3 4 # pool 3 is a class 4 pool
- delay_class 4 5 # pool 4 is a class 5 pool
+ Example:
+ delay_pools 4 # 4 delay pools
+ delay_class 1 2 # pool 1 is a class 2 pool
+ delay_class 2 3 # pool 2 is a class 3 pool
+ delay_class 3 4 # pool 3 is a class 4 pool
+ delay_class 4 5 # pool 4 is a class 5 pool
The delay pool classes are:
class 2 Everything is limited by a single aggregate
bucket as well as an "individual" bucket chosen
- from bits 25 through 32 of the IP address.
+ from bits 25 through 32 of the IPv4 address.
class 3 Everything is limited by a single aggregate
bucket as well as a "network" bucket chosen
from bits 17 through 24 of the IP address and a
"individual" bucket chosen from bits 17 through
- 32 of the IP address.
+ 32 of the IPv4 address.
class 4 Everything in a class 3 delay pool, with an
additional limit on a per user basis. This
-> bits 25 through 32 are "d"
-> bits 17 through 24 are "c"
-> bits 17 through 32 are "c * 256 + d"
+
+ NOTE-2: Due to the use of bitmasks in class 2,3,4 pools they only apply to
+ IPv4 traffic. Class 1 and 5 pools may be used with IPv6 traffic.
DOC_END
NAME: delay_access
virtual char const *label() const = 0;
- virtual unsigned int makeKey (IpAddress &src_addr) const = 0;
+ virtual unsigned int makeKey(IpAddress &src_addr) const = 0;
DelaySpec spec;
public:
void *operator new(size_t);
- void operator delete (void *);
+ void operator delete(void *);
protected:
virtual char const *label() const {return "Individual";}
-
- virtual unsigned int makeKey (IpAddress &src_addr) const;
-
+ virtual unsigned int makeKey(IpAddress &src_addr) const;
};
/// \ingroup DelayPoolsInternal
protected:
virtual char const *label() const {return "Network";}
-
virtual unsigned int makeKey (IpAddress &src_addr) const;
};
}
void
-CommonPool::operator delete (void *address)
+CommonPool::operator delete(void *address)
{
- DelayPools::MemoryUsed -= sizeof (CommonPool);
- ::operator delete (address);
+ DelayPools::MemoryUsed -= sizeof(CommonPool);
+ ::operator delete(address);
}
CommonPool *
temp->push_back (new Aggregate);
temp->push_back(new IndividualPool);
}
-
break;
case 3:
temp->push_back (new ClassCNetPool);
temp->push_back (new ClassCHostPool);
}
-
break;
case 4:
temp->push_back (new ClassCHostPool);
temp->push_back (new DelayUser);
}
-
break;
case 5:
}
DelayIdComposite::Pointer
-
Aggregate::id(CompositeSelectionDetails &details)
{
if (rate()->restore_bps != -1)
VectorMap<Key,Value>::findKeyIndex (Key const key) const
{
for (unsigned int index = 0; index < size(); ++index) {
- assert (indexUsed (index));
+ assert(indexUsed(index));
if (key_map[index] == key)
return index;
}
DelayIdComposite::Pointer
-
VectorPool::id(CompositeSelectionDetails &details)
{
if (rate()->restore_bps == -1)
return new NullDelayId;
- unsigned int key = makeKey (details.src_addr);
+ /* non-IPv4 are not able to provide IPv4-bitmask for this pool type key. */
+ if ( !details.src_addr.IsIPv4() )
+ return new NullDelayId;
- if (keyAllocated (key))
- return new Id (this, buckets.findKeyIndex(key));
+ unsigned int key = makeKey(details.src_addr);
+
+ if (keyAllocated(key))
+ return new Id(this, buckets.findKeyIndex(key));
unsigned char const resultIndex = buckets.insert(key);
- buckets.values[resultIndex].init (*rate());
+ buckets.values[resultIndex].init(*rate());
return new Id(this, resultIndex);
}
}
void
-VectorPool::Id::operator delete (void *address)
+VectorPool::Id::operator delete(void *address)
{
DelayPools::MemoryUsed -= sizeof (Id);
::operator delete (address);
}
-VectorPool::Id::Id (VectorPool::Pointer aPool, int anIndex) : theVector (aPool), theIndex (anIndex)
+VectorPool::Id::Id(VectorPool::Pointer aPool, int anIndex) : theVector (aPool), theIndex (anIndex)
{}
int
unsigned int
IndividualPool::makeKey (IpAddress &src_addr) const
{
- /* FIXME INET6 : IPv6 requires a 64-128 bit result from this function */
+ /* IPv4 required for this pool */
if ( !src_addr.IsIPv4() )
return 1;
- /* Temporary bypass for IPv4-only */
struct in_addr host;
src_addr.GetInAddr(host);
return (ntohl(host.s_addr) & 0xff);
unsigned int
ClassCNetPool::makeKey (IpAddress &src_addr) const
{
- /* FIXME INET6 : IPv6 requires a 64-128 bit result from this function */
+ /* IPv4 required for this pool */
if ( !src_addr.IsIPv4() )
return 1;
- /* Temporary bypass for IPv4-only */
struct in_addr net;
src_addr.GetInAddr(net);
return ( (ntohl(net.s_addr) >> 8) & 0xff);
unsigned char
ClassCHostPool::makeHostKey (IpAddress &src_addr) const
{
- /* FIXME INET6 : IPv6 requires a 64-128 bit result from this function */
+ /* IPv4 required for this pool */
if ( !src_addr.IsIPv4() )
return 1;
unsigned int
ClassCHostPool::makeKey (IpAddress &src_addr) const
{
- /* FIXME INET6 : IPv6 requires a 64-128 bit result from this function */
+ /* IPv4 required for this pool */
if ( !src_addr.IsIPv4() )
return 1;
- /* Temporary bypass for IPv4-only */
struct in_addr net;
src_addr.GetInAddr(net);
return ( (ntohl(net.s_addr) >> 8) & 0xff);
}
DelayIdComposite::Pointer
-
ClassCHostPool::id(CompositeSelectionDetails &details)
{
if (rate()->restore_bps == -1)
return new NullDelayId;
+ /* non-IPv4 are not able to provide IPv4-bitmask for this pool type key. */
+ if ( !details.src_addr.IsIPv4() )
+ return new NullDelayId;
+
unsigned int key = makeKey (details.src_addr);
unsigned char host = makeHostKey (details.src_addr);