tftp_common  1.3.0
Public Member Functions | Friends | List of all members
tftp_common::packets::Request Class Referencefinal

Read/Write Request (RRQ/WRQ) Trivial File Transfer Protocol packet. More...

#include <packets.hpp>

Public Member Functions

 Request ()=default
 Use with parsing functions only. More...
 
 Request (types::Type Type, std::string_view Filename, std::string_view Mode)
 
 Request (types::Type Type, std::string &&Filename, std::string &&Mode) noexcept
 
 Request (types::Type Type, std::string_view Filename, std::string_view Mode, const std::vector< std::string > &OptionsNames, const std::vector< std::string > &OptionsValues)
 
 Request (types::Type Type, std::string &&Filename, std::string &&Mode, std::vector< std::string > &&OptionsNames, std::vector< std::string > &&OptionsValues) noexcept
 
template<class OutputIterator >
std::size_t serialize (OutputIterator It) const noexcept
 
std::uint16_t getType () const noexcept
 
std::string_view getFilename () const noexcept
 
std::string_view getMode () const noexcept
 
std::string_view getOptionName (std::size_t Idx) const noexcept
 
std::string_view getOptionValue (std::size_t Idx) const noexcept
 

Friends

ParseResult parse (const std::uint8_t *Buffer, std::size_t Len, Request &Packet)
 

Detailed Description

Read/Write Request (RRQ/WRQ) Trivial File Transfer Protocol packet.

Constructor & Destructor Documentation

◆ Request() [1/5]

tftp_common::packets::Request::Request ( )
default

Use with parsing functions only.

◆ Request() [2/5]

tftp_common::packets::Request::Request ( types::Type  Type,
std::string_view  Filename,
std::string_view  Mode 
)
inline
Parameters
[Type]Assumptions: The type is either ::ReadRequest or ::WriteRequest

◆ Request() [3/5]

tftp_common::packets::Request::Request ( types::Type  Type,
std::string &&  Filename,
std::string &&  Mode 
)
inlinenoexcept
Parameters
[Type]Assumptions: The type is either ::ReadRequest or ::WriteRequest

◆ Request() [4/5]

tftp_common::packets::Request::Request ( types::Type  Type,
std::string_view  Filename,
std::string_view  Mode,
const std::vector< std::string > &  OptionsNames,
const std::vector< std::string > &  OptionsValues 
)
inline
Parameters
[Type]Assumptions: The type is either ::ReadRequest or ::WriteRequest

◆ Request() [5/5]

tftp_common::packets::Request::Request ( types::Type  Type,
std::string &&  Filename,
std::string &&  Mode,
std::vector< std::string > &&  OptionsNames,
std::vector< std::string > &&  OptionsValues 
)
inlinenoexcept
Parameters
[Type]Assumptions: The type is either ::ReadRequest or ::WriteRequest

Member Function Documentation

◆ getFilename()

std::string_view tftp_common::packets::Request::getFilename ( ) const
inlinenoexcept
Here is the caller graph for this function:

◆ getMode()

std::string_view tftp_common::packets::Request::getMode ( ) const
inlinenoexcept
Here is the caller graph for this function:

◆ getOptionName()

std::string_view tftp_common::packets::Request::getOptionName ( std::size_t  Idx) const
inlinenoexcept
Here is the caller graph for this function:

◆ getOptionValue()

std::string_view tftp_common::packets::Request::getOptionValue ( std::size_t  Idx) const
inlinenoexcept
Here is the caller graph for this function:

◆ getType()

std::uint16_t tftp_common::packets::Request::getType ( ) const
inlinenoexcept
Here is the caller graph for this function:

◆ serialize()

template<class OutputIterator >
std::size_t tftp_common::packets::Request::serialize ( OutputIterator  It) const
inlinenoexcept

Convert packet to network byte order and serialize it into the given buffer by the iterator

Parameters
[It]Requirements: *(It) must be assignable from std::uint8_t
Returns
Size of the packet (in bytes)

Friends And Related Function Documentation

◆ parse

ParseResult parse ( const std::uint8_t *  Buffer,
std::size_t  Len,
Request Packet 
)
friend

Parse read/write request packet from buffer converting all fields to host byte order

Parameters
[Buffer]Assumptions: Buffer is not a nullptr, it's size is greater or equal than Len
[Len]Assumptions: Len is greater than zero
If parsing wasn't successful, Packet remains in valid but unspecified state

The documentation for this class was generated from the following file: