You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2015/03/23 21:32:36 UTC
[03/52] [partial] trafficserver git commit: TS-3419 Fix some enum's
such that clang-format can handle it the way we want. Basically this means
having a trailing ,
on short enum's. TS-3419 Run clang-format over most of the source
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/wccp/WccpLocal.h
----------------------------------------------------------------------
diff --git a/lib/wccp/WccpLocal.h b/lib/wccp/WccpLocal.h
index 89bab24..aefc526 100644
--- a/lib/wccp/WccpLocal.h
+++ b/lib/wccp/WccpLocal.h
@@ -1,5 +1,5 @@
-# if !defined(TS_WCCP_LOCAL_HEADER)
-# define TS_WCCP_LOCAL_HEADER
+#if !defined(TS_WCCP_LOCAL_HEADER)
+#define TS_WCCP_LOCAL_HEADER
/** @file
WCCP (v2) support for Apache Traffic Server.
@@ -23,20 +23,22 @@
limitations under the License.
*/
-# include "Wccp.h"
-# include "WccpUtil.h"
-# include <ts/TsBuffer.h>
+#include "Wccp.h"
+#include "WccpUtil.h"
+#include <ts/TsBuffer.h>
// Needed for template use of byte ordering functions.
-# include <netinet/in.h>
-# include <memory.h>
-# include <map>
-
-namespace wccp {
+#include <netinet/in.h>
+#include <memory.h>
+#include <map>
+namespace wccp
+{
// Forward declares
-namespace detail {
+namespace detail
+{
class Assignment;
- namespace cache {
+ namespace cache
+ {
struct RouterData;
}
}
@@ -89,48 +91,45 @@ static int const PARSE_DATA_OVERRUN = 10;
Takes the basic ATS buffer and adds a count field to track
the amount of buffer in use.
*/
-class MsgBuffer : protected ts::Buffer {
+class MsgBuffer : protected ts::Buffer
+{
public:
- typedef MsgBuffer self; ///< Self reference type.
+ typedef MsgBuffer self; ///< Self reference type.
typedef ts::Buffer super; ///< Parent type.
MsgBuffer(); ///< Default construct empty buffer.
/// Construct from ATS buffer.
- MsgBuffer(
- super const& that ///< Instance to copy.
- );
+ MsgBuffer(super const &that ///< Instance to copy.
+ );
/// Construct from pointer and size.
- MsgBuffer(
- void* ptr, ///< Pointer to buffer.
- size_t n ///< Size of buffer.
- );
+ MsgBuffer(void *ptr, ///< Pointer to buffer.
+ size_t n ///< Size of buffer.
+ );
/// Assign a buffer.
- MsgBuffer& set(
- void* ptr, ///< Pointer to buffer.
- size_t n ///< Size of buffer.
- );
+ MsgBuffer &set(void *ptr, ///< Pointer to buffer.
+ size_t n ///< Size of buffer.
+ );
/// Get the buffer size.
size_t getSize() const;
/// Get the content size (use count).
size_t getCount() const;
/// Get address of first unused byte.
- char* getTail();
+ char *getTail();
/// Get address of first byte.
- char* getBase();
+ char *getBase();
/// Get address of first byte.
- char const* getBase() const;
+ char const *getBase() const;
/// Get the remaining space in the buffer.
size_t getSpace() const;
/// Mark additional space in use.
- self& use(
- size_t n ///< Additional space to mark in use.
- );
+ self &use(size_t n ///< Additional space to mark in use.
+ );
/// Mark all space as unused.
- self& reset();
+ self &reset();
/// Reset and zero the buffer.
- self& zero();
+ self &zero();
size_t _count; ///< Number of bytes in use.
};
@@ -138,16 +137,16 @@ public:
/// Sect 4.4: Cache assignment method.
enum CacheAssignmentType {
ASSIGNMENT_BY_HASH = 0,
- ASSIGNMENT_BY_MASK = 1
+ ASSIGNMENT_BY_MASK = 1,
};
/// Top level message types.
enum message_type_t {
INVALID_MSG_TYPE = 0,
- HERE_I_AM = 10,
- I_SEE_YOU = 11,
+ HERE_I_AM = 10,
+ I_SEE_YOU = 11,
REDIRECT_ASSIGN = 12,
- REMOVAL_QUERY = 13
+ REMOVAL_QUERY = 13,
};
/// Message component type.
@@ -176,12 +175,11 @@ struct RouterId {
RouterId(); ///< Default constructor.
/// Construct from address and sequence number.
- RouterId(
- uint32_t addr, ///< Router address.
- uint32_t recv_id ///< Receive ID (sequence number).
- );
+ RouterId(uint32_t addr, ///< Router address.
+ uint32_t recv_id ///< Receive ID (sequence number).
+ );
- uint32_t m_addr; ///< Identifying router IP address.
+ uint32_t m_addr; ///< Identifying router IP address.
uint32_t m_recv_id; ///< Recieve ID (sequence #).
};
@@ -192,7 +190,8 @@ struct RouterId {
@internal A @c RouterId with accessors to guarantee correct memory
layout.
*/
-class RouterIdElt : protected RouterId {
+class RouterIdElt : protected RouterId
+{
protected:
typedef RouterId super; ///< Parent type.
public:
@@ -201,70 +200,69 @@ public:
/// Default constructor, members zero initialized.
RouterIdElt();
/// Construct from address and sequence number.
- RouterIdElt(
- uint32_t addr, ///< Router address.
- uint32_t recv_id ///< Receive ID (sequence number).
- );
+ RouterIdElt(uint32_t addr, ///< Router address.
+ uint32_t recv_id ///< Receive ID (sequence number).
+ );
/// @name Accessors
//@{
- uint32_t getAddr() const; ///< Get the address field.
- self& setAddr(uint32_t addr); ///< Set the address field to @a addr.
- uint32_t getRecvId() const; ///< Get the receive ID field.
- self& setRecvId(uint32_t id); ///< Set the receive ID field to @a id.
+ uint32_t getAddr() const; ///< Get the address field.
+ self &setAddr(uint32_t addr); ///< Set the address field to @a addr.
+ uint32_t getRecvId() const; ///< Get the receive ID field.
+ self &setRecvId(uint32_t id); ///< Set the receive ID field to @a id.
//@}
/// Assign from non-serialized variant.
- self& operator = (super const& that);
+ self &operator=(super const &that);
};
/// Sect 5.7.3: Assignment Key Element
/// @note This maps directly on to message content.
/// @internal: At top level because it is used in more than one component.
-class AssignmentKeyElt {
+class AssignmentKeyElt
+{
public:
typedef AssignmentKeyElt self; ///< Self reference type.
AssignmentKeyElt(); ///< Default constructor. No member initialization.
/// Construct from address and sequence number.
- AssignmentKeyElt(
- uint32_t addr, ///< Key address.
- uint32_t generation ///< Change number.
- );
+ AssignmentKeyElt(uint32_t addr, ///< Key address.
+ uint32_t generation ///< Change number.
+ );
/// @name Accessors
//@{
- uint32_t getAddr() const; ///< Get the address field.
- self& setAddr(uint32_t addr); ///< Set the address field to @a addr.
- uint32_t getChangeNumber() const; ///< Get change number field.
- self& setChangeNumber(uint32_t n); ///< Set change number field to @a n.
+ uint32_t getAddr() const; ///< Get the address field.
+ self &setAddr(uint32_t addr); ///< Set the address field to @a addr.
+ uint32_t getChangeNumber() const; ///< Get change number field.
+ self &setChangeNumber(uint32_t n); ///< Set change number field to @a n.
//@}
protected:
- uint32_t m_addr; ///< Identifying router IP address.
+ uint32_t m_addr; ///< Identifying router IP address.
uint32_t m_change_number; ///< Change number (sequence #).
};
/// Sect 5.7.4: Router Assignment Element
/// @note This maps directly on to message content.
/// @internal: At top level because it is used in more than one component.
-class RouterAssignElt : public RouterIdElt {
+class RouterAssignElt : public RouterIdElt
+{
public:
typedef RouterAssignElt self; ///< Self reference type.
- typedef RouterIdElt super; ///< Parent type.
+ typedef RouterIdElt super; ///< Parent type.
/// Default constructor, members zero initialized.
RouterAssignElt();
/// Construct from address and sequence number.
- RouterAssignElt(
- uint32_t addr, ///< Router address.
- uint32_t recv_id, ///< Receive ID (sequence number).
- uint32_t change_number ///< Change number (sequence number).
- );
+ RouterAssignElt(uint32_t addr, ///< Router address.
+ uint32_t recv_id, ///< Receive ID (sequence number).
+ uint32_t change_number ///< Change number (sequence number).
+ );
/// @name Accessors
//@{
- uint32_t getChangeNumber() const; ///< Get change number field.
- self& setChangeNumber(uint32_t n); ///< Set change number field to @a n.
+ uint32_t getChangeNumber() const; ///< Get change number field.
+ self &setChangeNumber(uint32_t n); ///< Set change number field to @a n.
//@}
protected:
uint32_t m_change_number; ///< Change number (sequence #).
@@ -274,37 +272,34 @@ protected:
@note Not explicitly part of the spec, but it shows up in multiple
places.
*/
-class RouterAssignListElt {
+class RouterAssignListElt
+{
public:
typedef RouterAssignListElt self; ///< Self reference type.
/// Default constructor - @b no initialization.
RouterAssignListElt();
/// Construct with @n elements.
- RouterAssignListElt(
- int n ///< Number of elements.
- );
+ RouterAssignListElt(int n ///< Number of elements.
+ );
/// @name Accessors
//@{
/// Access element.
- RouterAssignElt& elt(
- int idx ///< Index of target element.
- );
+ RouterAssignElt &elt(int idx ///< Index of target element.
+ );
/// Access const element.
- RouterAssignElt const& elt(
- int idx ///< Index of target element.
- ) const;
+ RouterAssignElt const &elt(int idx ///< Index of target element.
+ ) const;
/// Get the number of elements.
uint32_t getCount() const;
//@}
/// Update ID for a router.
- self& updateRouterId(
- uint32_t addr, ///< Identifying IP address of router.
- uint32_t rcvid, ///< New receive ID value.
- uint32_t cno ///< New change number.
- );
+ self &updateRouterId(uint32_t addr, ///< Identifying IP address of router.
+ uint32_t rcvid, ///< New receive ID value.
+ uint32_t cno ///< New change number.
+ );
/// Get size in bytes of this structure.
size_t getSize() const;
@@ -313,89 +308,86 @@ public:
/// stub structure.
size_t getVarSize() const;
/// Calculate size in bytes for @a n elements.
- static size_t calcSize(
- int n ///< Number of elements.
- );
+ static size_t calcSize(int n ///< Number of elements.
+ );
/// Calculate size of variable data in bytes for @a n elements.
- static size_t calcVarSize(
- int n ///< Number of elements.
- );
+ static size_t calcVarSize(int n ///< Number of elements.
+ );
+
protected:
uint32_t m_count; ///< # of elements (network order).
};
/// Sect 5.7.5: Capability Element
/// @note This maps directly on to message content.
-class CapabilityElt {
+class CapabilityElt
+{
public:
typedef CapabilityElt self; ///< Self reference type.
/// Capability types.
enum Type {
- PACKET_FORWARD_METHOD = 1, ///< Packet forwarding methods.
+ PACKET_FORWARD_METHOD = 1, ///< Packet forwarding methods.
CACHE_ASSIGNMENT_METHOD = 2, ///< Cache assignment methods.
- PACKET_RETURN_METHOD = 3 ///< Packet return methods.
+ PACKET_RETURN_METHOD = 3 ///< Packet return methods.
};
CapabilityElt(); ///< Default constructor.
/// Construct from address and sequence number.
- CapabilityElt(
- Type type, ///< Capability type.
- uint32_t data ///< Capability data.
- );
+ CapabilityElt(Type type, ///< Capability type.
+ uint32_t data ///< Capability data.
+ );
/// @name Accessors
//@{
Type getCapType() const; ///< Get the capability type.
/// Set capability type.
- self& setCapType(
- Type cap ///< Capability type.
- );
+ self &setCapType(Type cap ///< Capability type.
+ );
uint32_t getCapData() const; ///< Get capability data.
/// Set capability data.
- self& setCapData(
- uint32_t data ///< Data value.
- );
+ self &setCapData(uint32_t data ///< Data value.
+ );
//@}
protected:
- uint16_t m_cap_type; ///< Capability type.
+ uint16_t m_cap_type; ///< Capability type.
uint16_t m_cap_length; ///< Length of capability data.
- uint32_t m_cap_data; ///< Capability data.
+ uint32_t m_cap_data; ///< Capability data.
};
/// Sect 5.7.7: Mask element
-class MaskElt {
+class MaskElt
+{
public:
typedef MaskElt self; ///< Self reference type.
/// Default constructor - @b no initialization.
MaskElt();
/// Construct with specific values.
- MaskElt(
- uint32_t srcAddr, ///< Mask for source address.
- uint32_t dstAddr, ///< Mask for destination address.
- uint16_t srcPort, ///< Mask for source port.
- uint16_t dstPort ///< Mask for destination port.
- );
+ MaskElt(uint32_t srcAddr, ///< Mask for source address.
+ uint32_t dstAddr, ///< Mask for destination address.
+ uint16_t srcPort, ///< Mask for source port.
+ uint16_t dstPort ///< Mask for destination port.
+ );
/// @name Accessors
//@{
/// Get source address mask field.
uint32_t getSrcAddr() const;
/// Set source address mask field to @a mask.
- self& setSrcAddr(uint32_t mask);
+ self &setSrcAddr(uint32_t mask);
/// Get destination address field.
uint32_t getDstAddr() const;
/// Set destination address field to @a mask.
- self& setDstAddr(uint32_t mask);
+ self &setDstAddr(uint32_t mask);
/// Get source port mask field.
uint16_t getSrcPort() const;
/// Set source port mask field to @a mask.
- self& setSrcPort(uint16_t mask);
+ self &setSrcPort(uint16_t mask);
/// Get destination port mask field.
uint16_t getDstPort() const;
/// Set destination port mask field to @a mask.
- self& setDstPort(uint16_t mask);
+ self &setDstPort(uint16_t mask);
//@}
protected:
@@ -406,155 +398,149 @@ protected:
};
/// Sect 5.7.8: Value element.
-class ValueElt {
+class ValueElt
+{
public:
typedef ValueElt self; ///< Self reference type.
/// Default constructor - @b no initialization.
ValueElt();
/// Construct a specific value.
- ValueElt(
- uint32_t cacheAddr, ///< Address of cache for this value.
- uint32_t srcAddr, ///< Value for source address.
- uint32_t dstAddr, ///< Value for destination address.
- uint16_t srcPort, ///< Value for source port.
- uint16_t dstPort ///< Value for destination port.
- );
+ ValueElt(uint32_t cacheAddr, ///< Address of cache for this value.
+ uint32_t srcAddr, ///< Value for source address.
+ uint32_t dstAddr, ///< Value for destination address.
+ uint16_t srcPort, ///< Value for source port.
+ uint16_t dstPort ///< Value for destination port.
+ );
/// @name Accessors
//@{
- uint32_t getf_src_addr() const; ///< Get source address field.
- self& setf_src_addr(uint32_t addr); ///< Set source address field to @a addr.
- uint32_t getDstAddr() const; ///< Get destination address field.
- self& setf_dst_addr(uint32_t addr); ///< Set destination address field to @a addr.
- uint16_t getf_src_port() const; ///< Get source port field.
- self& setf_src_port(uint16_t port); ///< Set source port field to @a port.
- uint16_t getDstPort() const; ///< Get destination port field.
- self& setf_dst_port(uint16_t port); ///< Set destination port field to @a port.
- uint32_t getCacheAddr() const; ///< Get cache address field.
- self& setCacheAddr(uint32_t addr); ///< Set cache address field to @a addr
+ uint32_t getf_src_addr() const; ///< Get source address field.
+ self &setf_src_addr(uint32_t addr); ///< Set source address field to @a addr.
+ uint32_t getDstAddr() const; ///< Get destination address field.
+ self &setf_dst_addr(uint32_t addr); ///< Set destination address field to @a addr.
+ uint16_t getf_src_port() const; ///< Get source port field.
+ self &setf_src_port(uint16_t port); ///< Set source port field to @a port.
+ uint16_t getDstPort() const; ///< Get destination port field.
+ self &setf_dst_port(uint16_t port); ///< Set destination port field to @a port.
+ uint32_t getCacheAddr() const; ///< Get cache address field.
+ self &setCacheAddr(uint32_t addr); ///< Set cache address field to @a addr
//@}
protected:
- uint32_t m_src_addr; ///< Source address.
- uint32_t m_dst_addr; ///< Destination address.
- uint16_t m_src_port; ///< Source port.
- uint16_t m_dst_port; ///< Destination port.
+ uint32_t m_src_addr; ///< Source address.
+ uint32_t m_dst_addr; ///< Destination address.
+ uint16_t m_src_port; ///< Source port.
+ uint16_t m_dst_port; ///< Destination port.
uint32_t m_cache_addr; ///< Cache address.
};
/** Sect 5.7.6: Mask/Value Set Element
This is a variable sized element.
*/
-class MaskValueSetElt {
+class MaskValueSetElt
+{
public:
typedef MaskValueSetElt self; ///< Self reference type.
MaskValueSetElt(); ///< Default constructor.
/// Construct from address and sequence number.
- MaskValueSetElt(
- uint32_t n ///< Value count.
- );
+ MaskValueSetElt(uint32_t n ///< Value count.
+ );
/// @name Accessors
//@{
/// Directly access contained mask element.
- MaskElt& maskElt();
+ MaskElt &maskElt();
/// Get source address mask field.
uint32_t getSrcAddrMask() const;
/// Set source address mask field to @a mask.
- self& setSrcAddrMask(uint32_t mask);
+ self &setSrcAddrMask(uint32_t mask);
/// Get destination address field.
uint32_t getDstAddrMask() const;
/// Set destination address field to @a mask.
- self& setDstAddrMask(uint32_t mask);
+ self &setDstAddrMask(uint32_t mask);
/// Get source port mask field.
uint16_t getSrcPortMask() const;
/// Set source port mask field to @a mask.
- self& setSrcPortMask(uint16_t mask);
+ self &setSrcPortMask(uint16_t mask);
/// Get destination port mask field.
uint16_t getDstPortMask() const;
/// Set destination port mask field to @a mask.
- self& setDstPortMask(uint16_t mask);
+ self &setDstPortMask(uint16_t mask);
/// Append a value to this set.
- self& addValue(
- uint32_t cacheAddr, ///< Address of cache for this value.
- uint32_t srcAddr, ///< Value for source address.
- uint32_t dstAddr, ///< Value for destination address.
- uint16_t srcPort, ///< Value for source port.
- uint16_t dstPort ///< Value for destination port.
- );
+ self &addValue(uint32_t cacheAddr, ///< Address of cache for this value.
+ uint32_t srcAddr, ///< Value for source address.
+ uint32_t dstAddr, ///< Value for destination address.
+ uint16_t srcPort, ///< Value for source port.
+ uint16_t dstPort ///< Value for destination port.
+ );
/// Get the value count.
/// @note No corresponding @c set because this cannot be directly changed.
uint32_t getCount() const;
/// Access value element.
- ValueElt& operator [] (
- int idx ///< Index of target element.
- );
+ ValueElt &operator[](int idx ///< Index of target element.
+ );
//@}
/// Calcuate the size of an element with @a n values.
- static size_t calcSize(
- uint32_t n ///< Number of values.
- );
+ static size_t calcSize(uint32_t n ///< Number of values.
+ );
/// Get the size (length) of this element.
size_t getSize() const;
+
protected:
// All members are kept in network order.
- MaskElt m_mask; ///< Base mask element.
+ MaskElt m_mask; ///< Base mask element.
uint32_t m_count; ///< Number of value elements.
/// Get base address of Value elements.
- ValueElt* values();
+ ValueElt *values();
/// Get base address of Value elements.
- ValueElt const* values() const;
+ ValueElt const *values() const;
};
/// Assignment of caches by hash.
/// Not in specification.
-class HashAssignElt {
+class HashAssignElt
+{
public:
typedef HashAssignElt self; ///< Self reference type.
/// Hash assignment bucket.
struct Bucket {
- unsigned int m_idx:7; ///< Cache index.
- unsigned int m_alt:1; ///< Alternate hash flag.
+ unsigned int m_idx : 7; ///< Cache index.
+ unsigned int m_alt : 1; ///< Alternate hash flag.
/// Test for unassigned value in bucket.
bool is_unassigned() const;
- } __attribute__((aligned(1),packed));
+ } __attribute__((aligned(1), packed));
/// Default constructor - @b no initialization.
HashAssignElt();
/// Construct with @n elements.
- HashAssignElt(
- int n ///< Number of elements.
- );
+ HashAssignElt(int n ///< Number of elements.
+ );
/// @name Accessors
//@{
/// Get the number of caches.
uint32_t getCount() const;
/// Get a cache address.
- uint32_t getAddr(
- int idx ///< Index of target address.
- ) const;
+ uint32_t getAddr(int idx ///< Index of target address.
+ ) const;
/// Set a cache address.
- self& setAddr(
- int idx, ///< Index of target address.
- uint32_t addr ///< Address value to set.
- );
+ self &setAddr(int idx, ///< Index of target address.
+ uint32_t addr ///< Address value to set.
+ );
/// Access a bucket.
- Bucket& operator [] (
- size_t idx ///< Bucket index (0..N_BUCKETS-1)
- );
+ Bucket &operator[](size_t idx ///< Bucket index (0..N_BUCKETS-1)
+ );
/// Access a const bucket.
- Bucket const& operator [] (
- size_t idx ///< Bucket index (0..N_BUCKETS-1)
- ) const;
+ Bucket const &operator[](size_t idx ///< Bucket index (0..N_BUCKETS-1)
+ ) const;
//@}
/** Do a round robin assignment.
@@ -562,18 +548,18 @@ public:
index of the last cache.
@return @c this.
*/
- self& round_robin_assign();
+ self &round_robin_assign();
/// Get size in bytes of this structure.
size_t getSize() const;
/// Calculate size in bytes for @a n caches.
- static size_t calcSize(
- int n ///< Number of caches.
- );
+ static size_t calcSize(int n ///< Number of caches.
+ );
+
protected:
uint32_t m_count; ///< # of caches (network order).
- Bucket* getBucketBase();
+ Bucket *getBucketBase();
};
/** Assignment of caches by mask.
@@ -585,7 +571,8 @@ protected:
for that, which functions in a manner similar to an iterator.
*/
-class MaskAssignElt {
+class MaskAssignElt
+{
public:
typedef MaskAssignElt self; ///< Self reference type.
@@ -597,25 +584,23 @@ public:
struct appender {
typedef appender self; ///< Self reference type.
/// Get pointer to current set.
- MaskValueSetElt* operator -> ();
+ MaskValueSetElt *operator->();
/// Append a new mask/value set.
/// @return A pointer to the new set.
- MaskValueSetElt* mask(
- uint32_t srcAddr, ///< Mask for source address.
- uint32_t dstAddr, ///< Mask for destination address.
- uint16_t srcPort, ///< Mask for source port.
- uint16_t dstPort ///< Mask for destination port.
- );
+ MaskValueSetElt *mask(uint32_t srcAddr, ///< Mask for source address.
+ uint32_t dstAddr, ///< Mask for destination address.
+ uint16_t srcPort, ///< Mask for source port.
+ uint16_t dstPort ///< Mask for destination port.
+ );
/// Initialize the current set to empty with specific mask values.
/// @return A pointer to the new set.
- MaskValueSetElt* initSet(
- uint32_t srcAddr, ///< Mask for source address.
- uint32_t dstAddr, ///< Mask for destination address.
- uint16_t srcPort, ///< Mask for source port.
- uint16_t dstPort ///< Mask for destination port.
- );
- MaskValueSetElt* m_set; ///< Current set.
- MaskAssignElt* m_elt; ///< Parent element.
+ MaskValueSetElt *initSet(uint32_t srcAddr, ///< Mask for source address.
+ uint32_t dstAddr, ///< Mask for destination address.
+ uint16_t srcPort, ///< Mask for source port.
+ uint16_t dstPort ///< Mask for destination port.
+ );
+ MaskValueSetElt *m_set; ///< Current set.
+ MaskAssignElt *m_elt; ///< Parent element.
};
/// @name Accessors
@@ -624,12 +609,11 @@ public:
uint32_t getCount() const;
//@}
- appender init(
- uint32_t srcAddr, ///< Mask for source address.
- uint32_t dstAddr, ///< Mask for destination address.
- uint16_t srcPort, ///< Mask for source port.
- uint16_t dstPort ///< Mask for destination port.
- );
+ appender init(uint32_t srcAddr, ///< Mask for source address.
+ uint32_t dstAddr, ///< Mask for destination address.
+ uint16_t srcPort, ///< Mask for source port.
+ uint16_t dstPort ///< Mask for destination port.
+ );
/// Get size in bytes of this structure.
/// @note This is not constant time. The mask/value sets must be traversed
@@ -639,6 +623,7 @@ public:
/// @note This is not constant time. The mask/value sets must be traversed
/// to get the total size.
size_t getVarSize() const;
+
protected:
uint32_t m_count; ///< # of sets (network order).
@@ -662,8 +647,10 @@ class CacheIdBox;
@see CacheHashIdElt
@see CacheMaskIdElt
*/
-class CacheIdElt {
+class CacheIdElt
+{
friend class CacheIdBox;
+
public:
typedef CacheIdElt self; ///< Self reference type.
@@ -672,43 +659,42 @@ public:
/// @name Accessors
//@{
- uint32_t getAddr() const; ///< Get address field.
- self& setAddr(uint32_t addr); ///< Set address field to @a addr.
- uint16_t getHashRev() const; ///< Get hash revision field.
- self& setHashRev(uint16_t rev); ///< Set hash revision field to @a rev.
- self& initHashRev(); ///< Set hash revision to default value.
- bool getUnassigned() const; ///< Get unassigned field.
- self& setUnassigned(bool state); ///< Set unassigned field to @a state.
- bool isMask() const; ///< @return @c true if this is a mask assignment.
- /** Set the maskiness of this structure.
- Be very careful with this, as different values change the
- memory layout of the object.
- */
- self& setMask(
- bool state ///< @c true to be mask, @c false to be hash.
- );
-
- self& clearReserved(); ///< Set reserved bits to zero.
+ uint32_t getAddr() const; ///< Get address field.
+ self &setAddr(uint32_t addr); ///< Set address field to @a addr.
+ uint16_t getHashRev() const; ///< Get hash revision field.
+ self &setHashRev(uint16_t rev); ///< Set hash revision field to @a rev.
+ self &initHashRev(); ///< Set hash revision to default value.
+ bool getUnassigned() const; ///< Get unassigned field.
+ self &setUnassigned(bool state); ///< Set unassigned field to @a state.
+ bool isMask() const; ///< @return @c true if this is a mask assignment.
+ /** Set the maskiness of this structure.
+ Be very careful with this, as different values change the
+ memory layout of the object.
+ */
+ self &setMask(bool state ///< @c true to be mask, @c false to be hash.
+ );
+
+ self &clearReserved(); ///< Set reserved bits to zero.
//@}
protected:
- uint32_t m_addr; ///< Identifying cache IP address.
- uint16_t m_hash_rev; ///< Hash revision.
- unsigned int m_reserved_0:7; ///< Reserved bits.
- /** Cache not assigned.
- If set the cache does not have an assignment in the redirection
- hash table and the data in @a m_buckets is historical. This allows
- a cache that was removed to be added back in the same buckets.
- */
- unsigned int m_unassigned:1;
- unsigned int m_reserved_1:1; ///< Reserved (unused).
- unsigned int m_is_mask:1; ///< Set -> mask, Clear -> hash.
- unsigned int m_reserved_2:6; ///< Reserved (unused).
- /** Trailing elements common to all cache ID variants.
- Unfortunately, although @c weight and @c status are common, they are
- after the variable data and so can't be put in the base class.
- Best we can do is declare a struct for them for later convenience.
- */
+ uint32_t m_addr; ///< Identifying cache IP address.
+ uint16_t m_hash_rev; ///< Hash revision.
+ unsigned int m_reserved_0 : 7; ///< Reserved bits.
+ /** Cache not assigned.
+ If set the cache does not have an assignment in the redirection
+ hash table and the data in @a m_buckets is historical. This allows
+ a cache that was removed to be added back in the same buckets.
+ */
+ unsigned int m_unassigned : 1;
+ unsigned int m_reserved_1 : 1; ///< Reserved (unused).
+ unsigned int m_is_mask : 1; ///< Set -> mask, Clear -> hash.
+ unsigned int m_reserved_2 : 6; ///< Reserved (unused).
+ /** Trailing elements common to all cache ID variants.
+ Unfortunately, although @c weight and @c status are common, they are
+ after the variable data and so can't be put in the base class.
+ Best we can do is declare a struct for them for later convenience.
+ */
struct Tail {
uint16_t m_weight; ///< Weight of assignment.
uint16_t m_status; ///< Cache status.
@@ -717,33 +703,36 @@ protected:
/** Cache ID for Hash assignment.
*/
-class CacheHashIdElt : public CacheIdElt {
+class CacheHashIdElt : public CacheIdElt
+{
friend class CacheIdBox;
+
public:
typedef CacheHashIdElt self; ///< Self reference type.
- typedef CacheIdElt super; ///< Parent type.
+ typedef CacheIdElt super; ///< Parent type.
/// Container for hash assignment.
typedef uint8_t HashBuckets[N_BUCKETS >> 3];
/// @name Accessors
//@{
bool getBucket(int idx) const; ///< Get bucket state at index @a idx.
/// Set bucket at index @a idx to @a state.
- self& setBucket(int idx, bool state);
- self& setBuckets(bool state); ///< Set all buckets to @a state.
- uint16_t getWeight() const; ///< Get weight field.
- self& setWeight(uint16_t w); ///< Set weight field to @a w.
- uint16_t getStatus() const; ///< Get status field.
- self& setStatus(uint16_t s); ///< Set status field to @a s.
+ self &setBucket(int idx, bool state);
+ self &setBuckets(bool state); ///< Set all buckets to @a state.
+ uint16_t getWeight() const; ///< Get weight field.
+ self &setWeight(uint16_t w); ///< Set weight field to @a w.
+ uint16_t getStatus() const; ///< Get status field.
+ self &setStatus(uint16_t s); ///< Set status field to @a s.
//@}
/// Get object size in bytes.
size_t getSize() const;
+
protected:
/// Bit vector of buckets assigned to this cache.
HashBuckets m_buckets;
Tail m_tail; /// Trailing values in element.
/// Get the address of the tail elements.
- Tail* getTailPtr();
+ Tail *getTailPtr();
};
/** Cache ID for Mask assignment.
@@ -757,28 +746,31 @@ protected:
- A single mask assign element with a mask set with one value seems to
work.
*/
-class CacheMaskIdElt : public CacheIdElt {
+class CacheMaskIdElt : public CacheIdElt
+{
friend class CacheIdBox;
+
public:
typedef CacheMaskIdElt self; ///< Self reference type.
- typedef CacheIdElt super; ///< Parent type.
+ typedef CacheIdElt super; ///< Parent type.
/// @name Accessors
//@{
- uint16_t getWeight() const; ///< Get weight field.
- self& setWeight(uint16_t w); ///< Set weight field to @a w.
- uint16_t getStatus() const; ///< Get status field.
- self& setStatus(uint16_t s); ///< Set status field to @a s.
+ uint16_t getWeight() const; ///< Get weight field.
+ self &setWeight(uint16_t w); ///< Set weight field to @a w.
+ uint16_t getStatus() const; ///< Get status field.
+ self &setStatus(uint16_t s); ///< Set status field to @a s.
/// Get the number of mask/value sets.
uint32_t getCount() const;
//@}
/// Get object size in bytes.
size_t getSize() const;
+
protected:
/// Mask assignment data.
MaskAssignElt m_assign;
/// Get a pointer to where the tail data is.
/// Presumes the assignment is filled out.
- Tail* getTailPtr();
+ Tail *getTailPtr();
};
/** Holder for a @c CacheIdElt.
@@ -787,7 +779,8 @@ protected:
instances of it in other classes. This box both holds an instance and
handles some of the memory allocation issues involved.
*/
-class CacheIdBox {
+class CacheIdBox
+{
public:
typedef CacheIdBox self; ///< Self reference type.
@@ -799,67 +792,60 @@ public:
/// Get the identifying cache address.
uint32_t getAddr() const;
/// Set the identifying cache address.
- self& setAddr(
- uint32_t ///< Identifying IP address.
- );
- uint16_t getHashRev() const; ///< Get hash revision field.
- self& setHashRev(uint16_t rev); ///< Set hash revision field to @a rev.
- self& initHashRev(); ///< Set hash revision to default value.
- bool getUnassigned() const; ///< Get unassigned field.
- self& setUnassigned(bool state); ///< Set unassigned field to @a state.
- bool isMask() const; ///< @return @c true if this is a mask assignment.
- /** Set the maskiness of this structure.
- Be very careful with this, as different values change the
- memory layout of the object.
- */
- self& setMask(
- bool state ///< @c true to be mask, @c false to be hash.
- );
-
- self& clearReserved(); ///< Set reserved bits to zero.
+ self &setAddr(uint32_t ///< Identifying IP address.
+ );
+ uint16_t getHashRev() const; ///< Get hash revision field.
+ self &setHashRev(uint16_t rev); ///< Set hash revision field to @a rev.
+ self &initHashRev(); ///< Set hash revision to default value.
+ bool getUnassigned() const; ///< Get unassigned field.
+ self &setUnassigned(bool state); ///< Set unassigned field to @a state.
+ bool isMask() const; ///< @return @c true if this is a mask assignment.
+ /** Set the maskiness of this structure.
+ Be very careful with this, as different values change the
+ memory layout of the object.
+ */
+ self &setMask(bool state ///< @c true to be mask, @c false to be hash.
+ );
+
+ self &clearReserved(); ///< Set reserved bits to zero.
//@}
/// Initialize to unassigned hash.
/// The cache address is set to @a addr.
- self& initDefaultHash(
- uint32_t addr ///< Identifying cache address.
- );
+ self &initDefaultHash(uint32_t addr ///< Identifying cache address.
+ );
/// Initialize to unassigned mask
/// The cache address is set to @a addr.
- self& initDefaultMask(
- uint32_t addr ///< Identifying cache address.
- );
+ self &initDefaultMask(uint32_t addr ///< Identifying cache address.
+ );
/** Fill in element from source copy.
Internal memory is allocated and the @a src copied.
*/
- self& fill(
- self const& src ///< Original source element
- );
+ self &fill(self const &src ///< Original source element
+ );
/** Fill in element from source copy.
This is used to write the element to memory that is allocated
independently of the box.
@note Caller is expected to have verified sufficient buffer space.
*/
- self& fill(
- void* base, ///< Target buffer.
- self const& src ///< Original source element
- );
+ self &fill(void *base, ///< Target buffer.
+ self const &src ///< Original source element
+ );
/// Initialize box from an existing element in memory.
- int parse(
- MsgBuffer base ///< Source memory.
- );
+ int parse(MsgBuffer base ///< Source memory.
+ );
/// Get the size in bytes of the contained element.
size_t getSize() const;
+
protected:
/// Force buffer to be at least @a n bytes
- self& require(
- size_t n ///< Minimum buffer size required.
- );
-
- CacheIdElt* m_base; ///< Base address of memory for element.
- CacheIdElt::Tail* m_tail; ///< Base address of trailing data elements.
- size_t m_size; ///< Size of element (valid data in buffer);
- size_t m_cap; ///< Size of allocated memory. Zero if external memory.
+ self &require(size_t n ///< Minimum buffer size required.
+ );
+
+ CacheIdElt *m_base; ///< Base address of memory for element.
+ CacheIdElt::Tail *m_tail; ///< Base address of trailing data elements.
+ size_t m_size; ///< Size of element (valid data in buffer);
+ size_t m_cap; ///< Size of allocated memory. Zero if external memory.
};
/** Base class for all components.
@@ -878,7 +864,8 @@ protected:
represented by a C++ structure (which is why we need this
indirection in the first place).
*/
-class ComponentBase {
+class ComponentBase
+{
public:
typedef ComponentBase self; ///< Self reference type.
/// Default constructor.
@@ -889,21 +876,22 @@ public:
protected:
/// Base of component in message data.
/// If this is @c NULL then the component is not in the message.
- char* m_base;
+ char *m_base;
};
/// Synthetic component to represent the overall message header.
-class MsgHeaderComp : public ComponentBase {
+class MsgHeaderComp : public ComponentBase
+{
public:
- typedef MsgHeaderComp self; ///< Self reference type.
+ typedef MsgHeaderComp self; ///< Self reference type.
typedef ComponentBase super; ///< Parent type.
/// Sect 5.5: Message Header
/// Serialized layout of message header.
struct raw_t {
- uint32_t m_type; ///< @c message_type_t
+ uint32_t m_type; ///< @c message_type_t
uint16_t m_version; ///< Implementation version of sender
- uint16_t m_length; ///< Message body length (excluding header)
+ uint16_t m_length; ///< Message body length (excluding header)
};
/// Default constructor.
@@ -911,26 +899,24 @@ public:
/// @name Accessors
//@{
- message_type_t getType(); ///< Get message type field.
- uint16_t getVersion(); ///< Get message version field.
- uint16_t getLength(); ///< Get message length field.
- self& setType(message_type_t type); ///< Set message type field to @a type.
- self& setVersion(uint16_t version); ///< Set version field to @a version.
- self& setLength(uint16_t length); ///< Set length field to @a length.
+ message_type_t getType(); ///< Get message type field.
+ uint16_t getVersion(); ///< Get message version field.
+ uint16_t getLength(); ///< Get message length field.
+ self &setType(message_type_t type); ///< Set message type field to @a type.
+ self &setVersion(uint16_t version); ///< Set version field to @a version.
+ self &setLength(uint16_t length); ///< Set length field to @a length.
//@}
/// Write initial values to message data.
/// @a base is updated to account for this component.
- self& fill(
- MsgBuffer& base, ///< [in,out] Buffer for component storage.
- message_type_t t ///< Message type.
- );
+ self &fill(MsgBuffer &base, ///< [in,out] Buffer for component storage.
+ message_type_t t ///< Message type.
+ );
/// Validate component for existing data.
/// @a base is updated to account for this component.
- int parse(
- MsgBuffer& base ///< [in,out] Base address for component data.
- );
+ int parse(MsgBuffer &base ///< [in,out] Base address for component data.
+ );
/// Compute size of a component of this type.
static size_t calcSize();
@@ -947,9 +933,8 @@ public:
@internal This saves some work getting around C++ co-variance issues
with return values.
*/
-template <
- typename T ///< Child class (CRT pattern)
- >
+template <typename T ///< Child class (CRT pattern)
+ >
struct CompWithHeader : public ComponentBase {
/** Serialized layout of per component header.
All components except the message header start with this structure.
@@ -957,7 +942,7 @@ struct CompWithHeader : public ComponentBase {
subclass this for their own @c raw_t.
*/
struct raw_t {
- uint16_t m_type; ///< Serialized @ref CompType.
+ uint16_t m_type; ///< Serialized @ref CompType.
uint16_t m_length; ///< length of rest of component (not including header).
};
/** Size of header.
@@ -968,11 +953,11 @@ struct CompWithHeader : public ComponentBase {
/// @name Accessors
//@{
- CompType getType() const; ///< Get component type field.
- uint16_t getLength() const; ///< Get component length field.
- T& setType(CompType type); ///< Set component type field to @a type.
- T& setLength(uint16_t length); ///< Set length field to @a length.
- //@}
+ CompType getType() const; ///< Get component type field.
+ uint16_t getLength() const; ///< Get component length field.
+ T &setType(CompType type); ///< Set component type field to @a type.
+ T &setLength(uint16_t length); ///< Set length field to @a length.
+ //@}
/** Check the component header for type and length sanity.
This requires the (subclass) client to
@@ -985,21 +970,19 @@ struct CompWithHeader : public ComponentBase {
@return A parse result.
*/
- int checkHeader(
- MsgBuffer const& buffer, ///< Message buffer.
- CompType t ///< Expected component type.
- );
+ int checkHeader(MsgBuffer const &buffer, ///< Message buffer.
+ CompType t ///< Expected component type.
+ );
};
/** Sect 5.6.1: Security Info Component
This is used for both security options. Clients should check
the @c m_option to see if the @a m_impl member is valid.
*/
-class SecurityComp
- : public CompWithHeader<SecurityComp> {
-
+class SecurityComp : public CompWithHeader<SecurityComp>
+{
public:
- typedef SecurityComp self; ///< Self reference type.
+ typedef SecurityComp self; ///< Self reference type.
typedef CompWithHeader<self> super; ///< Parent type.
/// Specify the type for this component.
static CompType const COMP_TYPE = SECURITY_INFO;
@@ -1030,14 +1013,14 @@ public:
/// @name Accessors
//@{
- Option getOption() const; ///< Get security option field.
- self& setOption(Option opt); ///< Set security option field to @a opt.
+ Option getOption() const; ///< Get security option field.
+ self &setOption(Option opt); ///< Set security option field to @a opt.
//@}
/// Write default values to the serialization buffer.
- self& fill(MsgBuffer& buffer, Option opt = m_default_opt);
+ self &fill(MsgBuffer &buffer, Option opt = m_default_opt);
/// Validate an existing structure.
- int parse(MsgBuffer& buffer);
+ int parse(MsgBuffer &buffer);
/// Compute the memory size of the component.
static size_t calcSize(Option opt);
@@ -1045,27 +1028,22 @@ public:
/// Set the global / default security key.
/// This is used for the security hash unless the local key is set.
/// @a key is copied to a global buffer and clipped to @c KEY_SIZE bytes.
- static void setDefaultKey(
- char const* key ///< Shared key.
- );
- static void setDefaultOption(
- Option opt ///< Type of security.
- );
+ static void setDefaultKey(char const *key ///< Shared key.
+ );
+ static void setDefaultOption(Option opt ///< Type of security.
+ );
/// Set messsage local security key.
- self& setKey(
- char const* key ///< Shared key.
- );
+ self &setKey(char const *key ///< Shared key.
+ );
/// Compute and set the security data.
/// @a msg must be a buffer that covers exactly the entire message.
- self& secure(
- MsgBuffer const& msg ///< Message data.
- );
+ self &secure(MsgBuffer const &msg ///< Message data.
+ );
- bool validate(
- MsgBuffer const& msg ///< Message data.
- ) const;
+ bool validate(MsgBuffer const &msg ///< Message data.
+ ) const;
protected:
/// Local to this message shared key / password.
@@ -1079,11 +1057,10 @@ protected:
};
/// Sect 5.6.2: Service Info Component
-class ServiceComp
- : public CompWithHeader<ServiceComp> {
-
+class ServiceComp : public CompWithHeader<ServiceComp>
+{
public:
- typedef ServiceComp self; ///< Self reference type.
+ typedef ServiceComp self; ///< Self reference type.
typedef CompWithHeader<self> super; ///< Parent type.
/// Specify the type for this component.
@@ -1098,64 +1075,60 @@ public:
/// @name Accessors
//@{
ServiceGroup::Type getSvcType() const; ///< Get service type field.
- /** Set the service type.
- If @a svc is @c SERVICE_STANDARD then all fields except the
- component header and service id are set to zero as required
- by the protocol.
- */
- self& setSvcType(ServiceGroup::Type svc);
+ /** Set the service type.
+ If @a svc is @c SERVICE_STANDARD then all fields except the
+ component header and service id are set to zero as required
+ by the protocol.
+ */
+ self &setSvcType(ServiceGroup::Type svc);
- uint8_t getSvcId() const; ///< Get service ID field.
- self& setSvcId(uint8_t id); ///< Set service ID field to @a id.
+ uint8_t getSvcId() const; ///< Get service ID field.
+ self &setSvcId(uint8_t id); ///< Set service ID field to @a id.
- uint8_t getPriority() const; ///< Get priority field.
- self& setPriority(uint8_t pri); ///< Set priority field to @a p.
+ uint8_t getPriority() const; ///< Get priority field.
+ self &setPriority(uint8_t pri); ///< Set priority field to @a p.
- uint8_t getProtocol() const; ///< Get protocol field.
- self& setProtocol(uint8_t p); ///< Set protocol field to @a p.
+ uint8_t getProtocol() const; ///< Get protocol field.
+ self &setProtocol(uint8_t p); ///< Set protocol field to @a p.
- uint32_t getFlags() const; ///< Get flags field.
- self& setFlags(uint32_t f); ///< Set the flags flags in field to @a f.
+ uint32_t getFlags() const; ///< Get flags field.
+ self &setFlags(uint32_t f); ///< Set the flags flags in field to @a f.
/// Set the flags in the flag field that are set in @a f.
/// Other flags are unchanged.
- self& enableFlags(uint32_t f);
+ self &enableFlags(uint32_t f);
/// Clear the flags in the flag field that are set in @a f.
/// Other flags are unchanged.
- self& disableFlags(uint32_t f);
+ self &disableFlags(uint32_t f);
/// Get a port value.
- uint16_t getPort(
- int idx ///< Index of target port.
- ) const;
+ uint16_t getPort(int idx ///< Index of target port.
+ ) const;
/// Set a port value.
- self& setPort(
- int idx, ///< Index of port.
- uint16_t port ///< Value for port.
- );
+ self &setPort(int idx, ///< Index of port.
+ uint16_t port ///< Value for port.
+ );
/// Zero (clear) all ports.
- self& clearPorts();
+ self &clearPorts();
/** Add a port to the service.
The first port which has not been set is set to @a port. It is an error
to add more than @c N_PORTS ports.
*/
- self& addPort(
- uint16_t port ///< Port value.
- );
+ self &addPort(uint16_t port ///< Port value.
+ );
//@}
/// Raw access to ServiceGroup.
- operator ServiceGroup const& () const;
+ operator ServiceGroup const &() const;
/** Fill from a service group definition.
*/
- self& fill(
- MsgBuffer& base, ///< Target storage.
- ServiceGroup const& svc ///< Service group definition.
- );
+ self &fill(MsgBuffer &base, ///< Target storage.
+ ServiceGroup const &svc ///< Service group definition.
+ );
/// Validate an existing structure.
/// @return Parse result.
- int parse(MsgBuffer& buffer);
+ int parse(MsgBuffer &buffer);
/// Compute the memory size of the component.
static size_t calcSize();
@@ -1164,19 +1137,18 @@ protected:
int m_port_count; ///< Number of ports in use.
/// Cast raw internal pointer to data type.
- raw_t* access();
+ raw_t *access();
/// Cast raw internal pointer to data type.
- raw_t const* access() const;
+ raw_t const *access() const;
};
/// Sect 5.6.3: RouterIdentity Info Component
/// @note An instance of this struct is followed by @a m_count
/// IP addresses.
-class RouterIdComp
- : public CompWithHeader<RouterIdComp> {
-
+class RouterIdComp : public CompWithHeader<RouterIdComp>
+{
public:
- typedef RouterIdComp self; ///< Self reference type.
+ typedef RouterIdComp self; ///< Self reference type.
typedef CompWithHeader<self> super; ///< Parent type.
/// Specify the type for this component.
@@ -1197,81 +1169,72 @@ public:
/// @name Accessors
//@{
/// Directly access router ID element.
- RouterIdElt& idElt();
+ RouterIdElt &idElt();
/// Directly access router ID element.
- RouterIdElt const& idElt() const;
+ RouterIdElt const &idElt() const;
/// Set the fields in the router ID element.
- self& setIdElt(
- uint32_t addr, ///< Identifying IP address for router.
- uint32_t recv_id ///< Receive count for router to target cache.
- );
- uint32_t getAddr() const; ///< Get the address field in the ID element.
- self& setAddr(uint32_t addr); ///< Set the address field in the ID element.
- uint32_t getRecvId() const; ///< Get the receive ID field in the ID element.
- self& setRecvId(uint32_t id); ///< Set the receive ID field in the ID element.
+ self &setIdElt(uint32_t addr, ///< Identifying IP address for router.
+ uint32_t recv_id ///< Receive count for router to target cache.
+ );
+ uint32_t getAddr() const; ///< Get the address field in the ID element.
+ self &setAddr(uint32_t addr); ///< Set the address field in the ID element.
+ uint32_t getRecvId() const; ///< Get the receive ID field in the ID element.
+ self &setRecvId(uint32_t id); ///< Set the receive ID field in the ID element.
/// Get the sent to address.
uint32_t getToAddr() const;
/// Set the sent to address.
- self& setToAddr(
- uint32_t addr ///< Address value.
- );
+ self &setToAddr(uint32_t addr ///< Address value.
+ );
/// Get router count field.
/// @note No @c setf method because this cannot be changed independently.
/// @see fill
uint32_t getFromCount() const;
/// Get received from address.
- uint32_t getFromAddr(
- int idx ///< Index of address.
- ) const;
+ uint32_t getFromAddr(int idx ///< Index of address.
+ ) const;
/// Set received from address.
- self& setFromAddr(
- int idx, ///< Index of address.
- uint32_t addr ///< Address value.
- );
+ self &setFromAddr(int idx, ///< Index of address.
+ uint32_t addr ///< Address value.
+ );
//@}
/// Find an address in the from list.
/// @return The index of the address, or -1 if not found.
- int findFromAddr(
- uint32_t addr ///< Search value.
- );
+ int findFromAddr(uint32_t addr ///< Search value.
+ );
/** Write serialization data for single cache target.
This completely fills the component.
*/
- self& fillSingleton(
- MsgBuffer& base, ///< Target storage.
- uint32_t addr, ///< Identifying IP address.
- uint32_t recv_count, ///< Receive count for target cache.
- uint32_t to_addr, ///< Destination address in initial packet.
- uint32_t from_addr ///< Identifying IP address of target cache.
- );
+ self &fillSingleton(MsgBuffer &base, ///< Target storage.
+ uint32_t addr, ///< Identifying IP address.
+ uint32_t recv_count, ///< Receive count for target cache.
+ uint32_t to_addr, ///< Destination address in initial packet.
+ uint32_t from_addr ///< Identifying IP address of target cache.
+ );
/** Write basic message structure.
The router and cache data must be filled in separately.
*/
- self& fill(
- MsgBuffer& base, ///< Target storage.
- size_t n_caches ///< Number of caches (fromAddr).
- );
+ self &fill(MsgBuffer &base, ///< Target storage.
+ size_t n_caches ///< Number of caches (fromAddr).
+ );
/// Validate an existing structure.
/// @return Parse result.
- int parse(MsgBuffer& buffer);
+ int parse(MsgBuffer &buffer);
/// Compute the memory size of the component.
- static size_t calcSize(
- int n ///< Receive address count
- );
+ static size_t calcSize(int n ///< Receive address count
+ );
};
/** Sect 5.6.4: Web-Cache Identity Info Component
*/
-class CacheIdComp
- : public CompWithHeader<CacheIdComp> {
-
+class CacheIdComp : public CompWithHeader<CacheIdComp>
+{
public:
- typedef CacheIdComp self; ///< Self reference type.
+ typedef CacheIdComp self; ///< Self reference type.
typedef CompWithHeader<self> super; ///< Parent type.
/// Component type ID for this component.
@@ -1285,49 +1248,48 @@ public:
/// @name Accessors
//@{
/// Direct access to the cache ID element.
- CacheIdBox& cacheId();
- CacheIdBox const& cacheId() const;
+ CacheIdBox &cacheId();
+ CacheIdBox const &cacheId() const;
// Only forward the common ones.
- uint32_t getAddr() const; ///< Get address field.
- self& setAddr(uint32_t addr); ///< Set address field to @a addr.
- uint16_t getHashRev() const; ///< Get hash revision field.
- self& setHashRev(uint16_t rev); ///< Set hash revision field to @a rev.
- bool getUnassigned() const; ///< Get unassigned field.
- self& setUnassigned(bool state); ///< Set unassigned field to @a state.
- uint16_t getWeight() const; ///< Get weight field.
- self& setWeight(uint16_t w); ///< Set weight field to @a w.
- uint16_t getStatus() const; ///< Get status field.
- self& setStatus(uint16_t s); ///< Set status field to @a s.
- //@}
+ uint32_t getAddr() const; ///< Get address field.
+ self &setAddr(uint32_t addr); ///< Set address field to @a addr.
+ uint16_t getHashRev() const; ///< Get hash revision field.
+ self &setHashRev(uint16_t rev); ///< Set hash revision field to @a rev.
+ bool getUnassigned() const; ///< Get unassigned field.
+ self &setUnassigned(bool state); ///< Set unassigned field to @a state.
+ uint16_t getWeight() const; ///< Get weight field.
+ self &setWeight(uint16_t w); ///< Set weight field to @a w.
+ uint16_t getStatus() const; ///< Get status field.
+ self &setStatus(uint16_t s); ///< Set status field to @a s.
+ //@}
/** Write serialization data.
- Sets required header fields for the component.
- Copies the data from @a src.
*/
- self& fill(
- MsgBuffer& base, ///< Target storage.
- CacheIdBox const& src ///< Cache descriptor
- );
+ self &fill(MsgBuffer &base, ///< Target storage.
+ CacheIdBox const &src ///< Cache descriptor
+ );
/// Validate an existing structure.
/// @return Parse result.
- int parse(MsgBuffer& buffer);
+ int parse(MsgBuffer &buffer);
/// Compute the memory size of the component.
/// Cannot be reliably computed statically.
size_t getSize();
+
protected:
CacheIdBox m_box; ///< Wrapper for cache id element.
};
/** Sect 5.6.5: Router View Info Component
*/
-class RouterViewComp
- : public CompWithHeader<RouterViewComp> {
-
+class RouterViewComp : public CompWithHeader<RouterViewComp>
+{
public:
- typedef RouterViewComp self; ///< Self reference type.
+ typedef RouterViewComp self; ///< Self reference type.
typedef CompWithHeader<self> super; ///< Parent type.
/// Component type ID for this component.
@@ -1337,8 +1299,8 @@ public:
/// There is more variable sized data that must be handled specially.
struct raw_t : public super::raw_t {
uint32_t m_change_number; ///< Sequence number.
- AssignmentKeyElt m_key; ///< Assignment data.
- uint32_t m_router_count; ///< # of router elements.
+ AssignmentKeyElt m_key; ///< Assignment data.
+ uint32_t m_router_count; ///< # of router elements.
};
RouterViewComp();
@@ -1346,46 +1308,42 @@ public:
/// @name Accessors
//@{
/// Directly access assignment key.
- AssignmentKeyElt& keyElt();
+ AssignmentKeyElt &keyElt();
/// Directly access assignment key.
- AssignmentKeyElt const& keyElt() const;
+ AssignmentKeyElt const &keyElt() const;
/// Get address in assignment key.
uint32_t getKeyAddr() const;
/// Set address in assignment key.
- self& setKeyAddr(uint32_t addr);
+ self &setKeyAddr(uint32_t addr);
/// Get change number in assignment key.
uint32_t getKeyChangeNumber() const;
/// Set change number in assignment key.
- self& setKeyChangeNumber(uint32_t n);
+ self &setKeyChangeNumber(uint32_t n);
- uint32_t getChangeNumber() const; ///< Get change number field.
- self& setChangeNumber(uint32_t n); ///< Set change number field to @a n
+ uint32_t getChangeNumber() const; ///< Get change number field.
+ self &setChangeNumber(uint32_t n); ///< Set change number field to @a n
/// Get cache count field.
/// @note No @c setf method because this cannot be changed independently.
/// @see fill
uint32_t getCacheCount() const;
/// Access cache element.
- CacheIdBox& cacheId(
- int idx ///< Index of target element.
- );
+ CacheIdBox &cacheId(int idx ///< Index of target element.
+ );
/// Access cache element.
- CacheIdBox const& cacheId(
- int idx ///< Index of target element.
- ) const;
+ CacheIdBox const &cacheId(int idx ///< Index of target element.
+ ) const;
/// Get router count field.
/// @note No @c setf method because this cannot be changed independently.
/// @see fill
uint32_t getRouterCount() const;
/// Get router address.
- uint32_t getRouterAddr(
- int idx ///< Index of router.
- ) const;
+ uint32_t getRouterAddr(int idx ///< Index of router.
+ ) const;
/// Set router address.
- self& setRouterAddr(
- int idx, ///< Index of router.
- uint32_t addr ///< Address value.
- );
+ self &setRouterAddr(int idx, ///< Index of router.
+ uint32_t addr ///< Address value.
+ );
//@}
/** Write serialization data.
@@ -1393,36 +1351,34 @@ public:
A client @b must call this method before writing any fields directly.
After invocation the client must fill in the router and cache elements.
*/
- self& fill(
- MsgBuffer& base, ///< Target storage.
- int n_routers, ///< Number of routers in view.
- int n_caches ///< Number of caches in view.
- );
+ self &fill(MsgBuffer &base, ///< Target storage.
+ int n_routers, ///< Number of routers in view.
+ int n_caches ///< Number of caches in view.
+ );
/// Validate an existing structure.
/// @return Parse result.
- int parse(MsgBuffer& buffer);
+ int parse(MsgBuffer &buffer);
protected:
/// Serialized count of cache addresses.
/// The actual addresses start immediate after this.
- uint32_t* m_cache_count;
+ uint32_t *m_cache_count;
/// Wrappers for cache identity elements.
/// These are variably sized in the general case.
CacheIdBox m_cache_ids[MAX_CACHES];
/// Compute the address of the cache count field.
/// Assumes the router count field is set.
- uint32_t* calc_cache_count_ptr();
+ uint32_t *calc_cache_count_ptr();
};
/** Sect 5.6.6: Web-Cache View Info Component
*/
-class CacheViewComp
- : public CompWithHeader<CacheViewComp> {
-
+class CacheViewComp : public CompWithHeader<CacheViewComp>
+{
public:
- typedef CacheViewComp self; ///< Self reference type.
+ typedef CacheViewComp self; ///< Self reference type.
typedef CompWithHeader<self> super; ///< Parent type.
/// Component type ID for this component.
@@ -1432,42 +1388,38 @@ public:
/// There is more variable sized data that must be handled specially.
struct raw_t : public super::raw_t {
uint32_t m_change_number; ///< Sequence number.
- uint32_t m_router_count; ///< # of router ID elements.
+ uint32_t m_router_count; ///< # of router ID elements.
};
/// @name Accessors
//@{
- uint32_t getChangeNumber() const; ///< Get change number field.
- self& setChangeNumber(uint32_t n); ///< Set change number field to @a n
+ uint32_t getChangeNumber() const; ///< Get change number field.
+ self &setChangeNumber(uint32_t n); ///< Set change number field to @a n
/// Get router count field.
/// @note No @c setf method because this cannot be changed independently.
/// @see fill
uint32_t getRouterCount() const;
/// Access a router ID element.
- RouterIdElt& routerElt(
- int idx ///< Index of target element.
- );
+ RouterIdElt &routerElt(int idx ///< Index of target element.
+ );
/** Find a router element by router IP address.
@return A pointer to the router element or @c NULL
if no router is identified by @a addr.
*/
- RouterIdElt* findf_router_elt(
- uint32_t addr ///< Router IP address.
- );
+ RouterIdElt *findf_router_elt(uint32_t addr ///< Router IP address.
+ );
/// Get cache count field.
/// @note No @c setf method because this cannot be changed independently.
/// @see fill
uint32_t getCacheCount() const;
/// Get a cache address.
- uint32_t getCacheAddr(
- int idx ///< Index of target address.
- ) const;
+ uint32_t getCacheAddr(int idx ///< Index of target address.
+ ) const;
/// Set a cache address.
- self& setCacheAddr(
- int idx, ///< Index of target address.
- uint32_t addr ///< Address value to set.
- );
+ self &setCacheAddr(int idx, ///< Index of target address.
+ uint32_t addr ///< Address value to set.
+ );
//@}
/** Write serialization data.
@@ -1475,37 +1427,34 @@ public:
A client @b must call this method before writing any fields directly.
After invocation the client must fill in the router and cache elements.
*/
- self& fill(
- MsgBuffer& buffer, ///< Target storage.
- detail::cache::GroupData const& group ///< Service group information.
- );
+ self &fill(MsgBuffer &buffer, ///< Target storage.
+ detail::cache::GroupData const &group ///< Service group information.
+ );
/// Validate an existing structure.
/// @return Parse result.
- int parse(MsgBuffer& buffer);
+ int parse(MsgBuffer &buffer);
/// Compute the total size of the component.
- static size_t calcSize(
- int n_routers, ///< Number of routers in view.
- int n_caches ///< Number of caches in view.
- );
+ static size_t calcSize(int n_routers, ///< Number of routers in view.
+ int n_caches ///< Number of caches in view.
+ );
protected:
/// Get router element array.
/// @return A pointer to the first router element.
- RouterIdElt* atf_router_array();
+ RouterIdElt *atf_router_array();
/// Serialized count of cache addresses.
/// The actual addresses start immediate after this.
- uint32_t* m_cache_count;
+ uint32_t *m_cache_count;
};
/** Sect 5.6.7: Assignment Info Component
*/
-class AssignInfoComp
- : public CompWithHeader<AssignInfoComp> {
-
+class AssignInfoComp : public CompWithHeader<AssignInfoComp>
+{
public:
- typedef AssignInfoComp self; ///< Self reference type.
+ typedef AssignInfoComp self; ///< Self reference type.
typedef CompWithHeader<self> super; ///< Parent type.
/// Component type ID for this component.
@@ -1514,7 +1463,7 @@ public:
/// Stub of the serialized data.
/// There is more variable sized data that must be handled specially.
struct raw_t : public super::raw_t {
- AssignmentKeyElt m_key; ///< Assignment key data.
+ AssignmentKeyElt m_key; ///< Assignment key data.
RouterAssignListElt m_routers; ///< Routers.
};
typedef HashAssignElt::Bucket Bucket; ///< Import type.
@@ -1522,84 +1471,76 @@ public:
/// @name Accessors
//@{
/// Directly access assignment key.
- AssignmentKeyElt& keyElt();
+ AssignmentKeyElt &keyElt();
/// Directly access assignment key.
- AssignmentKeyElt const& keyElt() const;
+ AssignmentKeyElt const &keyElt() const;
/// Get address in assignment key.
uint32_t getKeyAddr() const;
/// Set address in assignment key.
- self& setKeyAddr(uint32_t addr);
+ self &setKeyAddr(uint32_t addr);
/// Get change number in assignment key.
uint32_t getKeyChangeNumber() const;
/// Set change number in assignment key.
- self& setKeyChangeNumber(uint32_t n);
+ self &setKeyChangeNumber(uint32_t n);
/// Get router count field.
/// @note No @c setf method because this cannot be changed independently.
/// @see fill
uint32_t getRouterCount() const;
/// Access a router assignment element.
- RouterAssignElt& routerElt(
- int idx ///< Index of target element.
- );
+ RouterAssignElt &routerElt(int idx ///< Index of target element.
+ );
/// Get cache count field.
/// @note No @c setf method because this cannot be changed independently.
/// @see fill
uint32_t getCacheCount() const;
/// Get a cache address.
- uint32_t getCacheAddr(
- int idx ///< Index of target address.
- ) const;
+ uint32_t getCacheAddr(int idx ///< Index of target address.
+ ) const;
/// Set a cache address.
- self& setCacheAddr(
- int idx, ///< Index of target address.
- uint32_t addr ///< Address value to set.
- );
+ self &setCacheAddr(int idx, ///< Index of target address.
+ uint32_t addr ///< Address value to set.
+ );
/// Access a bucket.
- Bucket& bucket(
- int idx ///< Index of target bucket.
- );
+ Bucket &bucket(int idx ///< Index of target bucket.
+ );
/// Access a bucket.
- Bucket const& bucket(
- int idx ///< Index of target bucket.
- ) const;
+ Bucket const &bucket(int idx ///< Index of target bucket.
+ ) const;
//@}
/// Fill out the component from an @c Assignment.
- self& fill(
- MsgBuffer& buffer, ///< Target storage.
- detail::Assignment const& assign ///< Assignment data.
- );
+ self &fill(MsgBuffer &buffer, ///< Target storage.
+ detail::Assignment const &assign ///< Assignment data.
+ );
/// Validate an existing structure.
/// @return Parse result.
- int parse(MsgBuffer& buffer);
+ int parse(MsgBuffer &buffer);
/// Compute the total size of the component.
- static size_t calcSize(
- int n_routers, ///< Number of routers in view.
- int n_caches ///< Number of caches in view.
- );
+ static size_t calcSize(int n_routers, ///< Number of routers in view.
+ int n_caches ///< Number of caches in view.
+ );
protected:
/// Serialized count of cache addresses.
/// The actual addresses start immediate after this.
- uint32_t* m_cache_count;
+ uint32_t *m_cache_count;
/// Serialized bucket data.
- Bucket* m_buckets;
+ Bucket *m_buckets;
/// Calculate the address of the cache count.
- uint32_t* calcCacheCountPtr();
+ uint32_t *calcCacheCountPtr();
/// Calculate the address of the bucket array.
- Bucket* calcBucketPtr();
+ Bucket *calcBucketPtr();
};
/** Sect 5.6.9: Capabilities Info Component
*/
-class CapComp
- : public CompWithHeader<CapComp> {
-
+class CapComp : public CompWithHeader<CapComp>
+{
public:
- typedef CapComp self; ///< Self reference type.
+ typedef CapComp self; ///< Self reference type.
typedef CompWithHeader<self> super; ///< Parent type.
/// Component type ID for this component.
@@ -1613,12 +1554,10 @@ public:
/// @name Accessors.
//@{
/// Directly access mask value element.
- CapabilityElt& elt(
- int idx ///< Index of target element.
- );
- CapabilityElt const& elt(
- int idx ///< Index of target element.
- ) const;
+ CapabilityElt &elt(int idx ///< Index of target element.
+ );
+ CapabilityElt const &elt(int idx ///< Index of target element.
+ ) const;
/// Get the element count.
/// @note No corresponding @c setf_ because that cannot be changed once set.
/// @see fill
@@ -1630,19 +1569,17 @@ public:
The capability elements must be filled @b after invoking this method.
And, of course, do not fill more than @a n of them.
*/
- self& fill(
- MsgBuffer& buffer, ///< Target storage.
- int n ///< Number of capabilities.
- );
+ self &fill(MsgBuffer &buffer, ///< Target storage.
+ int n ///< Number of capabilities.
+ );
/// Validate an existing structure.
/// @return Parse result.
- int parse(MsgBuffer& buffer);
+ int parse(MsgBuffer &buffer);
/// Compute the total size of the component.
- static size_t calcSize(
- int n ///< Number of capabilities.
- );
+ static size_t calcSize(int n ///< Number of capabilities.
+ );
/// Find value for Cache Assignment.
ServiceGroup::CacheAssignmentStyle getCacheAssignmentStyle() const;
@@ -1652,17 +1589,17 @@ public:
ServiceGroup::PacketStyle getPacketReturnStyle() const;
/// Invalidate cached values.
/// Needed after modifying elements via the @c elt method.
- self& invalidate();
+ self &invalidate();
protected:
/// Fill the cached values.
void cache() const;
int m_count; ///< # of elements.
- /** Whether the style values are valid.
- We load all the values on the first request because we have to walk
- all the capabilities anyway, and cache them.
- */
+ /** Whether the style values are valid.
+ We load all the values on the first request because we have to walk
+ all the capabilities anyway, and cache them.
+ */
mutable bool m_cached;
/// Style used to forward packets to cache.
mutable ServiceGroup::PacketStyle m_packet_forward;
@@ -1675,11 +1612,10 @@ protected:
/** Sect 5.6.10: Alternate Assignment Component
This is an abstract base class. It is specialized for each alternate.
*/
-class AltAssignComp
- : public CompWithHeader<AltAssignComp> {
-
+class AltAssignComp : public CompWithHeader<AltAssignComp>
+{
public:
- typedef AltAssignComp self; ///< Self reference type.
+ typedef AltAssignComp self; ///< Self reference type.
typedef CompWithHeader<self> super; ///< Parent type.
/// Component type ID for this component.
@@ -1692,14 +1628,14 @@ public:
/// Component secondary header.
/// @internal Split out because we need to compute its size.
struct local_header_t {
- uint16_t m_assign_type; ///< Assignment body type.
+ uint16_t m_assign_type; ///< Assignment body type.
uint16_t m_assign_length; ///< Assignment body length.
};
/// Stub of the serialized data.
/// There is more variable sized data that must be handled specially.
struct raw_t : public super::raw_t, public local_header_t {
// These are the same in all current subclasses.
- AssignmentKeyElt m_key; ///< Assignment key data.
+ AssignmentKeyElt m_key; ///< Assignment key data.
RouterAssignListElt m_routers; ///< Routers.
};
@@ -1711,49 +1647,45 @@ public:
/// Get the assignment type.
uint16_t getAssignType() const;
/// Set the assignment type.
- self& setAssignType(
- uint16_t t ///< Assignment type.
- );
+ self &setAssignType(uint16_t t ///< Assignment type.
+ );
/// Get the assignment length.
uint16_t getAssignLength() const;
/// Set the assignment length.
- self& setAssignLength(
- uint16_t length ///< Length in bytes.
- );
+ self &setAssignLength(uint16_t length ///< Length in bytes.
+ );
/// Get router count field.
/// @note No @c setf method because this cannot be changed independently.
/// @see fill
uint32_t getRouterCount() const;
/// Directly access assignment key.
- AssignmentKeyElt& keyElt();
+ AssignmentKeyElt &keyElt();
/// Directly access assignment key.
- AssignmentKeyElt const& keyElt() const;
+ AssignmentKeyElt const &keyElt() const;
//@}
/// Fill out the component from an @c Assignment.
- virtual self& fill(
- MsgBuffer& buffer, ///< Target storage.
- detail::Assignment const& assign ///< Assignment data.
- ) = 0;
+ virtual self &fill(MsgBuffer &buffer, ///< Target storage.
+ detail::Assignment const &assign ///< Assignment data.
+ ) = 0;
/// Validate an existing structure.
/// @return Parse result.
- virtual int parse(MsgBuffer& buffer) = 0;
+ virtual int parse(MsgBuffer &buffer) = 0;
protected:
/// Calculate the first byte past the end of the variable data.
- void* calcVarPtr();
+ void *calcVarPtr();
};
/** Sect 5.6.10: Alternate Assignment Component
This is the hash based version.
*/
-class AltHashAssignComp
- : public AltAssignComp {
-
+class AltHashAssignComp : public AltAssignComp
+{
public:
typedef AltHashAssignComp self; ///< Self reference type.
- typedef AltAssignComp super; ///< Parent type.
+ typedef AltAssignComp super; ///< Parent type.
/// @name Accessors
//@{
@@ -1767,63 +1699,58 @@ public:
virtual ~AltHashAssignComp() {}
/// Fill out the component from an @c Assignment.
- virtual self& fill(
- MsgBuffer& buffer, ///< Target storage.
- detail::Assignment const& assign ///< Assignment data.
- );
+ virtual self &fill(MsgBuffer &buffer, ///< Target storage.
+ detail::Assignment const &assign ///< Assignment data.
+ );
/// Validate an existing structure.
/// @return Parse result.
- virtual int parse(MsgBuffer& buffer);
+ virtual int parse(MsgBuffer &buffer);
/// Compute the total size of the component.
- static size_t calcSize(
- int n_routers, ///< Number of routers in view.
- int n_caches ///< Number of caches in view.
- );
+ static size_t calcSize(int n_routers, ///< Number of routers in view.
+ int n_caches ///< Number of caches in view.
+ );
protected:
/// Serialized count of cache addresses.
/// The actual addresses start immediate after this.
- uint32_t* m_cache_count;
+ uint32_t *m_cache_count;
/// Calculate the address of the cache count.
- uint32_t* calcCacheCountPtr();
+ uint32_t *calcCacheCountPtr();
};
/** Sect 5.6.10: Alternate Assignment Component
This is the mask based version.
*/
-class AltMaskAssignComp
- : public AltAssignComp {
-
+class AltMaskAssignComp : public AltAssignComp
+{
public:
typedef AltMaskAssignComp self; ///< Self reference type.
- typedef AltAssignComp super; ///< Parent type.
+ typedef AltAssignComp super; ///< Parent type.
/// Force virtual desctructor.
virtual ~AltMaskAssignComp() {}
/// Fill out the component from an @c Assignment.
- virtual self& fill(
- MsgBuffer& buffer, ///< Target storage.
- detail::Assignment const& assign ///< Assignment data.
- );
+ virtual self &fill(MsgBuffer &buffer, ///< Target storage.
+ detail::Assignment const &assign ///< Assignment data.
+ );
/// Validate an existing structure.
/// @return Parse result.
- virtual int parse(MsgBuffer& buffer);
+ virtual int parse(MsgBuffer &buffer);
protected:
- MaskAssignElt* m_mask_elt; ///< Address of the mask assign element.
+ MaskAssignElt *m_mask_elt; ///< Address of the mask assign element.
};
/** Sect 5.6.12: Command Info Component
*/
-class CmdComp
- : public CompWithHeader<CmdComp> {
-
+class CmdComp : public CompWithHeader<CmdComp>
+{
public:
- typedef CmdComp self; ///< Self reference type.
+ typedef CmdComp self; ///< Self reference type.
typedef CompWithHeader<self> super; ///< Parent type.
/// Component type ID for this component.
@@ -1831,7 +1758,7 @@ public:
/// Command types.
enum cmd_t {
- SHUTDOWN = 1, ///< Cache is shutting down.
+ SHUTDOWN = 1, ///< Cache is shutting down.
SHUTDOWN_RESPONSE = 2 ///< SHUTDOWN ack.
};
@@ -1839,42 +1766,40 @@ public:
/// @internal Technically the command data is variable, but all currently
/// defined commands have the same 32 bit data element.
struct raw_t : public super::raw_t {
- uint16_t m_cmd; ///< Command type / code.
+ uint16_t m_cmd; ///< Command type / code.
uint16_t m_cmd_length; ///< Length of command data.
- uint32_t m_cmd_data; ///< Command data.
+ uint32_t m_cmd_data; ///< Command data.
};
/// @name Accessors.
//@{
/// Directly access mask value element.
- cmd_t getCmd() const; ///< Get command type.
- self& setCmd(cmd_t cmd); ///< Set command type.
- uint32_t getCmdData() const; ///< Get command data.
- self& setCmdData(uint32_t data); ///< Set command @a data.
+ cmd_t getCmd() const; ///< Get command type.
+ self &setCmd(cmd_t cmd); ///< Set command type.
+ uint32_t getCmdData() const; ///< Get command data.
+ self &setCmdData(uint32_t data); ///< Set command @a data.
//@}
/// Write basic serialization data.
/// Elements must be filled in seperately and after invoking this method.
- self& fill(
- MsgBuffer& buffer, ///< Component storage.
- cmd_t cmd, ///< Command type.
- uint32_t data ///< Command data.
- );
+ self &fill(MsgBuffer &buffer, ///< Component storage.
+ cmd_t cmd, ///< Command type.
+ uint32_t data ///< Command data.
+ );
/// Validate an existing structure.
/// @return Parse result.
- int parse(MsgBuffer& buffer);
+ int parse(MsgBuffer &buffer);
/// Compute the total size of the component.
static size_t calcSize();
};
/// Sect 5.6.11: Assignment Map Component
-class AssignMapComp
- : public CompWithHeader<AssignMapComp> {
-
+class AssignMapComp : public CompWithHeader<AssignMapComp>
+{
public:
- typedef AssignMapComp self; ///< Self reference type.
+ typedef AssignMapComp self; ///< Self reference type.
typedef CompWithHeader<self> super; ///< Parent type.
/// Component type ID for this component.
@@ -1896,21 +1821,20 @@ public:
//@}
/// Fill from assignment data.
- self& fill(
- MsgBuffer& buffer, ///< Component storage.
- detail::Assignment const& assign ///< Assignment data.
- );
+ self &fill(MsgBuffer &buffer, ///< Component storage.
+ detail::Assignment const &assign ///< Assignment data.
+ );
/// Validate an existing structure.
/// @return Parse result.
- int parse(MsgBuffer& buffer);
+ int parse(MsgBuffer &buffer);
};
/// Sect 5.6.8: Router Query Info Component.
-class QueryComp
- : public CompWithHeader<QueryComp> {
+class QueryComp : public CompWithHeader<QueryComp>
+{
public:
- typedef QueryComp self; ///< Self reference type.
+ typedef QueryComp self; ///< Self reference type.
typedef CompWithHeader<self> super; ///< Parent type.
/// Component type ID for this component.
@@ -1919,37 +1843,36 @@ public:
/// Internal layout.
struct raw_t : public super::raw_t {
uint32_t m_router_addr; ///< Identifying router address.
- uint32_t m_recv_id; ///< Receive ID router expects in reply.
- uint32_t m_to_addr; ///< Destination address of query.
- uint32_t m_cache_addr; ///< Identifying address of cache.
+ uint32_t m_recv_id; ///< Receive ID router expects in reply.
+ uint32_t m_to_addr; ///< Destination address of query.
+ uint32_t m_cache_addr; ///< Identifying address of cache.
};
/// @name Accessors.
//@{
/// Directly access mask value element.
- uint32_t getRouterAddr() const; ///< Get identifying router address.
- self& setRouterAddr(uint32_t addr); ///< Set identifying router address.
- uint32_t getToAddr() const; ///< Get target address.
- self& setToAddr(uint32_t addr); ///< Set target address.
- uint32_t getCacheAddr() const; ///< Get identifying cache address.
- self& setCacheAddr(uint32_t addr); ///< Set identifying cache address.
- uint32_t getRecvId() const; ///< Get receive ID.
- self& setRecvId(uint32_t data); ///< Set receive ID.
+ uint32_t getRouterAddr() const; ///< Get identifying router address.
+ self &setRouterAddr(uint32_t addr); ///< Set identifying router address.
+ uint32_t getToAddr() const; ///< Get target address.
+ self &setToAddr(uint32_t addr); ///< Set target address.
+ uint32_t getCacheAddr() const; ///< Get identifying cache address.
+ self &setCacheAddr(uint32_t addr); ///< Set identifying cache address.
+ uint32_t getRecvId() const; ///< Get receive ID.
+ self &setRecvId(uint32_t data); ///< Set receive ID.
//@}
/// Write serialization data.
/// This fills in all fields.
- self& fill(
- MsgBuffer& buffer, ///< Component storage.
- uint32_t routerAddr, ///< Router identifying address.
- uint32_t toAddr, ///< Destination address.
- uint32_t cacheAddr, ///< Cache identifying address.
- uint32_t recvId ///< Recieve ID.
- );
+ self &fill(MsgBuffer &buffer, ///< Component storage.
+ uint32_t routerAddr, ///< Router identifying address.
+ uint32_t toAddr, ///< Destination address.
+ uint32_t cacheAddr, ///< Cache identifying address.
+ uint32_t recvId ///< Recieve ID.
+ );
/// Validate an existing structure.
/// @return Parse result.
- int parse(MsgBuffer& buffer);
+ int parse(MsgBuffer &buffer);
/// Compute the total size of the component.
static size_t calcSize();
@@ -1957,9 +1880,9 @@ public:
/// Cache assignment hash function.
inline uint8_t
-assignment_hash(
- uint32_t key ///< Key to hash.
-) {
+assignment_hash(uint32_t key ///< Key to hash.
+ )
+{
key ^= key >> 16;
key ^= key >> 8;
return key & 0xFF;
@@ -1972,18 +1895,20 @@ struct IpHeader {
};
// Various static values.
-char const* const BUFFER_TOO_SMALL_FOR_COMP_TEXT = "Unable to write component -- buffer too small";
+char const *const BUFFER_TOO_SMALL_FOR_COMP_TEXT = "Unable to write component -- buffer too small";
// ------------------------------------------------------
-namespace detail {
+namespace detail
+{
/** Local storage for cache assignment data.
The maintenance of this data is sufficiently complex that it is better
to have a standard class to hold it, rather than updating a serialized
form.
*/
- class Assignment {
+ class Assignment
+ {
public:
- typedef Assignment self; ///< Self reference type.
+ typedef Assignment self; ///< Self reference type.
typedef AssignmentKeyElt Key; ///< Import assignment key type.
/// Import assignment bucket definition.
/// @internal Just one byte, no serialization issues.
@@ -2002,37 +1927,34 @@ namespace detail {
*/
bool isActive() const;
/// Control active flag.
- self& setActive(
- bool state ///< New active state.
- );
+ self &setActive(bool state ///< New active state.
+ );
/** Fill the assignment from cache service group data.
Caches that are obsolete are purged from the data.
@return @c true if a valid assignment was generated,
@c false otherwise.
*/
- bool fill(
- cache::GroupData& group, ///< Service group data.
- uint32_t addr ///< Identifying IP address of designated cache.
- );
+ bool fill(cache::GroupData &group, ///< Service group data.
+ uint32_t addr ///< Identifying IP address of designated cache.
+ );
/// Update the receive ID for a router.
- self& updateRouterId(
- uint32_t addr, ///< Identifying IP address of router.
- uint32_t rcvid, ///< New receive ID.
- uint32_t cno ///< New change number.
- );
+ self &updateRouterId(uint32_t addr, ///< Identifying IP address of router.
+ uint32_t rcvid, ///< New receive ID.
+ uint32_t cno ///< New change number.
+ );
/// Get the assignment key.
- AssignmentKeyElt const& getKey() const;
+ AssignmentKeyElt const &getKey() const;
/// Get the router assignment list.
- RouterAssignListElt const& getRouterList() const;
+ RouterAssignListElt const &getRouterList() const;
/// Get the hash assignment.
- HashAssignElt const& getHash() const;
+ HashAssignElt const &getHash() const;
/// Get the mask assignment.
- MaskAssignElt const& getMask() const;
+ MaskAssignElt const &getMask() const;
protected:
- Key m_key; ///< Assignment key.
+ Key m_key; ///< Assignment key.
bool m_active; ///< Active state.
// These store the serialized assignment chunks which are assembled
@@ -2049,19 +1971,20 @@ namespace detail {
MsgBuffer m_buffer;
};
- namespace endpoint {
+ namespace endpoint
+ {
/// Common service group data.
struct GroupData {
typedef GroupData self; ///< Self reference type.
- ServiceGroup m_svc; ///< The service definition.
- uint32_t m_generation; ///< Generation value (change number).
+ ServiceGroup m_svc; ///< The service definition.
+ uint32_t m_generation; ///< Generation value (change number).
time_t m_generation_time; ///< Time of last view change.
- bool m_use_security_opt; ///< Use group local security.
+ bool m_use_security_opt; ///< Use group local security.
SecurityComp::Option m_security_opt; ///< Type of security.
- bool m_use_security_key; ///< Use group local key.
- SecurityComp::Key m_security_key; ///< MD5 key.
+ bool m_use_security_key; ///< Use group local key.
+ SecurityComp::Key m_security_key; ///< MD5 key.
/** Group assignment data.
This is used as a place to generate an assignment or
@@ -2072,20 +1995,19 @@ namespace detail {
/// Default constructor.
GroupData();
/// Use @a key instead of global default.
- self& setKey(
- char const* key ///< Shared key.
- );
+ self &setKey(char const *key ///< Shared key.
+ );
/// Use security @a style instead of global default.
- self& setSecurity(
- SecurityOption style ///< Security style to use.
- );
+ self &setSecurity(SecurityOption style ///< Security style to use.
+ );
};
}
}
// ------------------------------------------------------
/** Base class for all messages.
*/
-class BaseMsg {
+class BaseMsg
+{
public:
/// Default constructor.
BaseMsg();
@@ -2093,11 +2015,10 @@ public:
virtual ~BaseMsg() {}
/// Set the message @a buffer.
- void setBuffer(
- MsgBuffer const& buffer ///< Storage for message.
- );
+ void setBuffer(MsgBuffer const &buffer ///< Storage for message.
+ );
/// Get the current buffer.
- MsgBuffer const& buffer() const;
+ MsgBuffer const &buffer() const;
/// Invoke once all components have been filled.
/// Sets the length and updates security data if needed.
virtual void finalize();
@@ -2111,17 +2032,17 @@ public:
bool validateSecurity() const;
// Common starting components for all messages.
- MsgHeaderComp m_header; ///< Message header.
+ MsgHeaderComp m_header; ///< Message header.
SecurityComp m_security; ///< Security component.
- ServiceComp m_service; ///< Service provided.
+ ServiceComp m_service; ///< Service provided.
protected:
MsgBuffer m_buffer; ///< Raw storage for message data.
};
/// Sect 5.1: Layout and control for @c WCCP2_HERE_I_AM
-class HereIAmMsg
- : public BaseMsg {
+class HereIAmMsg : public BaseMsg
+{
public:
typedef HereIAmMsg self; ///< Self reference type.
@@ -2132,67 +2053,62 @@ public:
after this call, which will allocate the appropriate spaces
in the message layou.
*/
- void fill(
- detail::cache::GroupData const& group, ///< Service group for message.
- CacheIdBox const& cache_id, ///< ID to use for this cache.
- SecurityOption sec_opt ///< Security option to use.
- );
+ void fill(detail::cache::GroupData const &group, ///< Service group for message.
+ CacheIdBox const &cache_id, ///< ID to use for this cache.
<TRUNCATED>