Sample code for network interface settings
//--------------------------------------------------------------------------------------------------/*** Set the network configuration.**///--------------------------------------------------------------------------------------------------static void SetNetworkConfiguration(le_mdc_ProfileRef_t profileRef){char ipAddr[100] = {0};char gatewayAddr[100] = {0};char dns1Addr[100] = {0};char dns2Addr[100] = {0};char systemCmd[200] = {0};FILE* resolvFilePtr;le_mdc_ConState_t state = LE_MDC_DISCONNECTED;mode_t oldMask;// Check the stateLE_ASSERT( le_mdc_GetSessionState(profileRef, &state) == LE_OK );LE_ASSERT( state == LE_MDC_CONNECTED );// Get IP, gateway and DNS addresses for IPv4 or IPv6 connectivityif ( le_mdc_IsIPv4(profileRef) ){LE_PRINT_VALUE("%s", ipAddr);== LE_OK);LE_PRINT_VALUE("%s", gatewayAddr);LE_ASSERT(le_mdc_GetIPv4DNSAddresses( profileRef,dns1Addr, sizeof(dns1Addr),dns2Addr, sizeof(dns2Addr)) == LE_OK );LE_PRINT_VALUE("%s", dns1Addr);LE_PRINT_VALUE("%s", dns2Addr);snprintf(systemCmd, sizeof(systemCmd), "/sbin/route add default gw %s", gatewayAddr);}{LE_PRINT_VALUE("%s", ipAddr);== LE_OK);LE_PRINT_VALUE("%s", gatewayAddr);LE_ASSERT(le_mdc_GetIPv6DNSAddresses( profileRef,dns1Addr, sizeof(dns1Addr),dns2Addr, sizeof(dns2Addr)) == LE_OK );LE_PRINT_VALUE("%s", dns1Addr);LE_PRINT_VALUE("%s", dns2Addr);snprintf(systemCmd, sizeof(systemCmd), "/sbin/route -A inet6 add default gw %s",gatewayAddr);}sleep(5);LE_DEBUG("%s", systemCmd);LE_ASSERT( system(systemCmd) == 0 );// allow fopen to create file with mode=644oldMask = umask(022);// open the resolver configurationresolvFilePtr = fopen("/etc/resolv.conf", "w+");if (resolvFilePtr == NULL){LE_ERROR("Unable to open resolv.conf: %m");}LE_ASSERT( resolvFilePtr != NULL );LE_ASSERT( fprintf(resolvFilePtr, "nameserver %s\n", dns1Addr) > 0 );if (dns2Addr[0] != '\0'){LE_ASSERT( fprintf(resolvFilePtr, "nameserver %s\n", dns2Addr) > 0 );}LE_ASSERT( fclose(resolvFilePtr) == 0 );// restore old maskumask(oldMask);}