struct FinderParser

Parser of finder messages. More...

Definition#include <finder-msg.hh>
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Types

Public Methods

Public Static Methods

Protected Methods

Protected Static Methods

Protected Members


Detailed Description

Parser of finder messages. Parses common header and passes payload data to registered ParsingElements that invoke user callbacks when packets of given type arrive.

Sub-parsers are added with the add method. add takes a ParsingElement as an argument. These are created by helper functions like hello_notifier, eg:



void hello_handler(const FinderHello& msg) {
	... do something with hello message
}

FinderParser fp;

fp.add(hello_notifier(callback(hello_handler)));


typedef ref_ptr<const FinderParselet> ParsingElement

ParsingElement

typedef list<ParsingElement> PEList

PEList

ssize_t  peek_header_bytes (const string& header)
throw (BadFinderMessage)

peek_header_bytes

[static]

Attempts to determine if the supplied string looks like a FinderMessage header.

Parameters:
headercandidate finder message header.

Returns: header size if valid, 0 if there is no enough data to determine if it is a valid header. Throws an exception is data does not look like a FinderMessage header.

size_t  max_header_bytes ()

max_header_bytes

[static]

Returns: maximum header size (actually size can be certain not a valid header).

size_t  peek_payload_bytes (const string& header)
throw (BadFinderMessage)

peek_payload_bytes

[static]

Returns: the size of the payload data.

inline size_t  parse (const string& buf, string::const_iterator& buf_pos)
throw (BadFinderMessage)

parse

[const]

Parses message and calls callbacks if message type has a registered notifier.

Parameters:
bufbuffer to be parsed.
buf_posstarting position of parsing. Updated to point to end of parsing upon return.

inline size_t  parse_signed (const HMAC& h, const string& buf, string::const_iterator& buf_pos)
throw (BadFinderMessage)

parse_signed

[const]

Parses a message using HMAC and calls callbacks if message type has a registered notifier.

Parameters:
hHMAC instance to be used to check header authentication.
bufbuffer to be parsed.
buf_posstarting position of parsing. Updated to point to end of parsing upon return.

size_t  parse (const HMAC* h, const string& b, string::const_iterator& bp)
throw (BadFinderMessage)

parse

[const]

Parses a message using HMAC and calls callbacks if message type has a registered notifier.

Parameters:
hpointer to HMAC to be used to check header authentication.
bufbuffer to be parsed.
buf_posstarting position of parsing. Updated to point to end of parsing upon return.

bool  add (const ParsingElement& pe)

add

Add user callback for a particular message type. Used in conjunction with ParsingElement generating functions (ie notifier and it similarly named brethren).

bool  parse_header (string::const_iterator& buffer_pos, uint32_t& major, uint32_t& minor, uint32_t& src, uint32_t& seq, uint32_t& payload_bytes, string& msgname)

parse_header

[protected static]

bool  parse_payload (uint32_t src, uint32_t seq, const string& msgname, const string& buf, string::const_iterator& buf_pos)

parse_payload

[protected const]

inline bool  parse_signature (const HMAC* h, const string& header, const string& b, string::const_iterator& bp)

parse_signature

[protected const]

PEList _parsers

_parsers

[protected]


Generated by: pavlin on possum.icir.org on Wed Dec 11 16:50:42 2002, using kdoc 2.0a54+XORP.