static void sighandler(int signal);
-static int sysctl_interface(const char *ifname, const char *option,
- const char *data);
static int usage(void);
uint16_t opttype;
enum odhcp6c_ia_mode ia_na_mode = IA_MODE_TRY;
- bool help = false, daemonize = false, reset = false;
+ bool help = false, daemonize = false;
int c, request_pd = 0, timeout = 0;
- while ((c = getopt(argc, argv, "RN:P:c:r:s:t:hdp:")) != -1) {
+ while ((c = getopt(argc, argv, "N:P:c:r:s:t:hdp:")) != -1) {
switch (c) {
- case 'R':
- reset = true;
- break;
-
case 'N':
if (!strcmp(optarg, "force"))
ia_na_mode = IA_MODE_FORCE;
signal(SIGUSR1, sighandler);
signal(SIGUSR2, sighandler);
- // Configure interface to accept RA
- if (reset) {
- sysctl_interface(ifname, "accept_ra", "2");
- sysctl_interface(ifname, "disable_ipv6", "1");
- struct timespec ts = {1, 0};
- nanosleep(&ts, NULL);
- sysctl_interface(ifname, "disable_ipv6", "0");
- }
-
if (daemonize) {
openlog("odhcp6c", LOG_PID, LOG_DAEMON); // Disable LOG_PERROR
if (daemon(0, 0)) {
}
-static int sysctl_interface(const char *ifname, const char *option,
- const char *data)
-{
- char pathbuf[64];
- const char *sysctl_pattern = "/proc/sys/net/ipv6/conf/%s/%s";
- snprintf(pathbuf, sizeof(pathbuf), sysctl_pattern, ifname, option);
-
- int fd = open(pathbuf, O_WRONLY);
- int written = write(fd, data, strlen(data));
- close(fd);
-
- return (written > 0) ? 0 : -1;
-}
-
-
static void sighandler(int signal)
{
if (signal == SIGCHLD)