odhcp6c: add -K option to set packet kernel priority
[project/odhcp6c.git] / src / odhcp6c.c
index 0f58945246abf423ab444cb323bca1850f4a14f0..4a6d7bd62579a0570e720b2619722af14000468e 100644 (file)
@@ -175,8 +175,10 @@ int main(_unused int argc, char* const argv[])
        uint16_t opttype;
        enum odhcp6c_ia_mode ia_na_mode = IA_MODE_TRY;
        enum odhcp6c_ia_mode ia_pd_mode = IA_MODE_NONE;
+       bool stateful_only_mode = 0;
        struct odhcp6c_opt *opt;
        int ia_pd_iaid_index = 0;
+       int sk_prio = 0;
        int sol_timeout = DHCPV6_SOL_MAX_RT;
        int verbosity = 0;
        bool help = false, daemonize = false;
@@ -186,12 +188,16 @@ int main(_unused int argc, char* const argv[])
        unsigned int ra_options = RA_RDNSS_DEFAULT_LIFETIME;
        unsigned int ra_holdoff_interval = RA_MIN_ADV_INTERVAL;
 
-       while ((c = getopt(argc, argv, "S::N:V:P:FB:c:i:r:Ru:Ux:s:kt:m:Lhedp:fav")) != -1) {
+       while ((c = getopt(argc, argv, "S::DN:V:P:FB:c:i:r:Ru:Ux:s:kK:t:m:Lhedp:fav")) != -1) {
                switch (c) {
                case 'S':
                        allow_slaac_only = (optarg) ? atoi(optarg) : -1;
                        break;
 
+               case 'D':
+                       stateful_only_mode = 1;
+                       break;
+
                case 'N':
                        if (!strcmp(optarg, "force")) {
                                ia_na_mode = IA_MODE_FORCE;
@@ -340,6 +346,10 @@ int main(_unused int argc, char* const argv[])
                        release = false;
                        break;
 
+               case 'K':
+                       sk_prio = atoi(optarg);
+                       break;
+
                case 't':
                        sol_timeout = atoi(optarg);
                        break;
@@ -412,7 +422,7 @@ int main(_unused int argc, char* const argv[])
        signal(SIGUSR2, sighandler);
 
        if ((urandom_fd = open("/dev/urandom", O_CLOEXEC | O_RDONLY)) < 0 ||
-                       init_dhcpv6(ifname, client_options, sol_timeout) ||
+                       init_dhcpv6(ifname, client_options, sk_prio, sol_timeout) ||
                        ra_init(ifname, &ifid, ra_options, ra_holdoff_interval) ||
                        script_init(script, ifname)) {
                syslog(LOG_ERR, "failed to initialize: %s", strerror(errno));
@@ -456,7 +466,7 @@ int main(_unused int argc, char* const argv[])
                syslog(LOG_NOTICE, "(re)starting transaction on %s", ifname);
 
                signal_usr1 = signal_usr2 = false;
-               int mode = dhcpv6_set_ia_mode(ia_na_mode, ia_pd_mode);
+               int mode = dhcpv6_set_ia_mode(ia_na_mode, ia_pd_mode, stateful_only_mode);
                if (mode != DHCPV6_STATELESS)
                        mode = dhcpv6_request(DHCPV6_MSG_SOLICIT);
 
@@ -602,6 +612,7 @@ static int usage(void)
        "Usage: odhcp6c [options] <interface>\n"
        "\nFeature options:\n"
        "       -S <time>       Wait at least <time> sec for a DHCP-server (0)\n"
+       "       -D              Discard advertisements without any address or prefix proposed\n"
        "       -N <mode>       Mode for requesting addresses [try|force|none]\n"
        "       -P <length>     Request IPv6-Prefix (0 = auto)\n"
        "       -F              Force IPv6-Prefix\n"
@@ -621,6 +632,7 @@ static int usage(void)
        "       -a              Don't send Accept Reconfigure option\n"
        "       -f              Don't send Client FQDN option\n"
        "       -k              Don't send a RELEASE when stopping\n"
+       "       -K <sk-prio>    Set packet kernel priority (0)\n"
        "       -t <seconds>    Maximum timeout for DHCPv6-SOLICIT (120)\n"
        "       -m <seconds>    Minimum time between accepting RA updates (3)\n"
        "       -L              Ignore default lifetime for RDNSS records\n"