static void SetNetworkConfiguration
(
)
{
char ipAddr[100] = {0};
char gatewayAddr[100] = {0};
char dns1Addr[100] = {0};
char dns2Addr[100] = {0};
char systemCmd[200] = {0};
FILE* resolvFilePtr;
mode_t oldMask;
{
== LE_OK);
dns1Addr, sizeof(dns1Addr),
dns2Addr, sizeof(dns2Addr)) == LE_OK );
snprintf(systemCmd, sizeof(systemCmd), "/sbin/route add default gw %s", gatewayAddr);
}
{
== LE_OK);
dns1Addr, sizeof(dns1Addr),
dns2Addr, sizeof(dns2Addr)) == LE_OK );
snprintf(systemCmd, sizeof(systemCmd), "/sbin/route -A inet6 add default gw %s",
gatewayAddr);
}
sleep(5);
oldMask = umask(022);
resolvFilePtr = fopen("/etc/resolv.conf", "w+");
if (resolvFilePtr == NULL)
{
LE_ERROR(
"Unable to open resolv.conf: %m");
}
LE_ASSERT( fprintf(resolvFilePtr,
"nameserver %s\n", dns1Addr) > 0 );
if (dns2Addr[0] != '\0')
{
LE_ASSERT( fprintf(resolvFilePtr,
"nameserver %s\n", dns2Addr) > 0 );
}
umask(oldMask);
}