|
|
All packet decode routines must inherit from this interface. Also provides some utility routines to perform common packet processing.
static const size_t STANDARD_HEADER_V2 | STANDARD_HEADER_V2 |
static const size_t STANDARD_HEADER_V3 | STANDARD_HEADER_V3 |
static const size_t VERSION_OFFSET | VERSION_OFFSET |
static const size_t TYPE_OFFSET | TYPE_OFFSET |
static const size_t LEN_OFFSET | LEN_OFFSET |
static const size_t ROUTER_ID_OFFSET | ROUTER_ID_OFFSET |
static const size_t AREA_ID_OFFSET | AREA_ID_OFFSET |
static const size_t CHECKSUM_OFFSET | CHECKSUM_OFFSET |
static const size_t AUTH_TYPE_OFFSET | AUTH_TYPE_OFFSET |
static const size_t AUTH_PAYLOAD_OFFSET | AUTH_PAYLOAD_OFFSET |
static const size_t AUTH_PAYLOAD_SIZE | AUTH_PAYLOAD_SIZE |
static const size_t INSTANCE_ID_OFFSET | INSTANCE_ID_OFFSET |
Packet (OspfTypes::Version version)
| Packet |
~Packet ()
| ~Packet |
[virtual]
size_t decode_standard_header (uint8_t *ptr, size_t& len)
throw(InvalidPacket) | decode_standard_header |
Decode standard header.
Used by the derived classes to extract the standard header and options field.
Parameters:
len | if the frame is larger than what is specified by the header length field drop the length down to the header length. |
Returns: the offset where the specific header starts.
Packet * decode (uint8_t *ptr, size_t len)
throw(InvalidPacket) | decode |
[const pure virtual]
Decode the packet. The returned packet must be free'd.
size_t encode_standard_header (uint8_t *ptr, size_t len)
| encode_standard_header |
Encode standard header.
Used by the derived classes to put the standard header in the packet. Which includes the checksum so all other fields should already be in the packet.
Parameters:
ptr | location to start writing header. |
len | size of the buffer. |
Returns: The offset that the header has been written to. Returns 0 on failure, such as the buffer is too small.
bool encode (vector<uint8_t>& pkt)
| encode |
[pure virtual]
Encode the packet.
Parameters:
pkt | vector into which the packet should be placed. |
Returns: true if the encoding suceeded.
void store (uint8_t *ptr, size_t len)
| store |
Store the original packet, required for authentication.
vector<uint8_t>& get ()
| get |
Get a reference to the original packet data, required for authentication.
OspfTypes::Version get_version ()
| get_version |
[const]
Returns: The version this packet represents.
OspfTypes::Type get_type ()
| get_type |
[const pure virtual]
It is the responsibilty of the derived type to return this information.
Returns: The type this packet represents.
OspfTypes::RouterID get_router_id ()
| get_router_id |
[const]
void set_router_id (OspfTypes::RouterID id)
| set_router_id |
OspfTypes::AreaID get_area_id ()
| get_area_id |
[const]
void set_area_id (OspfTypes::AreaID id)
| set_area_id |
uint16_t get_auth_type ()
| get_auth_type |
[const]
void set_auth_type (uint16_t auth_type)
| set_auth_type |
uint8_t get_instance_id ()
| get_instance_id |
[const]
void set_instance_id (uint8_t instance_id)
| set_instance_id |
size_t get_standard_header_length ()
| get_standard_header_length |
Returns: the standard header length for this version of OSPF.
size_t decode_point ()
| decode_point |
[const]
Decode Point.
If a packet is being decoded the standard header has already been processed. This method returns the offset at which the specific data starts.
Returns: The offset at which a derived class should start decoding.
string standard ()
| standard |
[const]
Generate a printable representation of the standard header. Used by the derived classes implementing str().
string str ()
| str |
[const pure virtual]
Generate a printable representation of the packet.