diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2017-07-13 22:50:15 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2017-07-14 19:10:22 +0300 |
commit | c8ace1ee0a6cab5fd4ea2f084ea436cfa513637d (patch) | |
tree | a8db884a665fbf14797393a3b2ff95438c338bb9 /bbot/agent/tftp.hxx | |
parent | 8e8d599b129d35f638f2c1957c869b054a38b021 (diff) |
Make use of wildcards in buildfiles
Diffstat (limited to 'bbot/agent/tftp.hxx')
-rw-r--r-- | bbot/agent/tftp.hxx | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/bbot/agent/tftp.hxx b/bbot/agent/tftp.hxx new file mode 100644 index 0000000..76b4d1c --- /dev/null +++ b/bbot/agent/tftp.hxx @@ -0,0 +1,47 @@ +// file : bbot/agent/tftp.hxx -*- C++ -*- +// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd +// license : TBC; see accompanying LICENSE file + +#ifndef BBOT_AGENT_TFTP_HXX +#define BBOT_AGENT_TFTP_HXX + +#include <bbot/types.hxx> +#include <bbot/utility.hxx> + +namespace bbot +{ + // A TFTP server "wrapper" over tftpd-hpa. + // + // In a nutshell, we are pretending to be inetd and when a request arrives, + // spawn tftpd-hpa to handle it. + // + class tftp_server + { + public: + // The map argument specifies the path mapping rules, one per line (see + // the tftpd-hpa --map-file|-m option for details). If port is 0, then + // it is automatically assigned. + // + tftp_server (const string& map, uint16_t port); + + // Return the assigned port. + // + uint16_t + port () const; + + // Wait for a TFTP request for up to the specified number of seconds. If + // increment is not 0, then wait in the specified incremenets (i.e., wait + // for up to that number of seconds; useful when one needs to also + // periodically check for something else). Update the timeout value as + // well as return true if a request was served and false otherwise. + // + bool + serve (size_t& seconds, size_t increment = 0); + + private: + auto_fd fd_; + auto_rmfile map_; + }; +} + +#endif // BBOT_AGENT_TFTP_HXX |