Killian De Smedt
2013-10-31 10:58:55 UTC
Hi,
For a tunneling application I currently use a basic_raw_socket and an
ip::basic_endpoint with a protocol class similar to
www.boost.org/boost/asio/ip/icmp.hpp.
However, now I have to extend this application to support multiple
tunneling protocols (e.g. GRE, raw IP-in-IP) and the most obvious would be
to manage these in the same context. For this I'd actually need to pass the
ip protocol number (e.g. 47 for GRE) to the protocol class instance and
keep it as a dynamic (may be const), not static entry.
The basic_raw_socket poses no problem, but the ip::basic_endpoint does as
it requires a protocol that implements the InternetProtocol interface (
www.boost.org/doc/html/boost_asio/reference/InternetProtocol.html). This
requires a static v4 and v6 method that more or less acts as a factory for
the protocol, however this includes that I cannot have any dynamic content
in the protocol, so I can't use this approach for the protocol number.
So I need to create a protocol class (new type) per actual protocol id,
which introduces some overhead as this also lead to a new different socket
and endpoint type per protocol id. In the end I think I currently have the
choice between creating an endpoint per possible tunnel type and install
the right one based on the used tunnel type and between using boost::any.
The first introduces a lot of memory overhead, the second a lot of casting,
so I'm not a big fan of this. I'm wondering if there is some other way to
get around this limitation and have a dynamic protocol number instead of a
static one?
Thank you very much,
Killian
For a tunneling application I currently use a basic_raw_socket and an
ip::basic_endpoint with a protocol class similar to
www.boost.org/boost/asio/ip/icmp.hpp.
However, now I have to extend this application to support multiple
tunneling protocols (e.g. GRE, raw IP-in-IP) and the most obvious would be
to manage these in the same context. For this I'd actually need to pass the
ip protocol number (e.g. 47 for GRE) to the protocol class instance and
keep it as a dynamic (may be const), not static entry.
The basic_raw_socket poses no problem, but the ip::basic_endpoint does as
it requires a protocol that implements the InternetProtocol interface (
www.boost.org/doc/html/boost_asio/reference/InternetProtocol.html). This
requires a static v4 and v6 method that more or less acts as a factory for
the protocol, however this includes that I cannot have any dynamic content
in the protocol, so I can't use this approach for the protocol number.
So I need to create a protocol class (new type) per actual protocol id,
which introduces some overhead as this also lead to a new different socket
and endpoint type per protocol id. In the end I think I currently have the
choice between creating an endpoint per possible tunnel type and install
the right one based on the used tunnel type and between using boost::any.
The first introduces a lot of memory overhead, the second a lot of casting,
so I'm not a big fan of this. I'm wondering if there is some other way to
get around this limitation and have a dynamic protocol number instead of a
static one?
Thank you very much,
Killian