Skip to content

Instantly share code, notes, and snippets.

@Voultapher
Last active November 7, 2016 17:02
Show Gist options
  • Save Voultapher/9114c3d90ed0c5d86914fd6bc5bc6817 to your computer and use it in GitHub Desktop.
Save Voultapher/9114c3d90ed0c5d86914fd6bc5bc6817 to your computer and use it in GitHub Desktop.
IncludeOS addr naming
template <int N = 0>
static auto&& ifconfig(
IP4::addr addr,
IP4::addr nmask,
IP4::addr router,
IP4::addr dns = IP4::INADDR_ANY
)
{ ... }
net::Inet4::ifconfig(
{ 10,0,0,42 }, // IP
{ 255,255,255,0 }, // Netmask
{ 10,0,0,1 }, // Gateway
{ 10,0,0,1 }); // DNS
// could be
namespace IP4
{
using mask = addr;
using router = addr;
using dns = addr;
}
template <int N = 0>
static auto&& ifconfig(
IP4::addr addr,
IP4::mask nmask,
IP4::router router,
IP4::dns dns = IP4::INADDR_ANY
)
{ ... }
net::Inet4::ifconfig(
net::IP4::addr{ 10,0,0,42 },
net::IP4::mask{ 255,255,255,0 },
net::IP4::router{ 10,0,0,1 },
net::IP4::dns{ 10,0,0,1 }
);
{ ... }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment