Lines 42-47
static const char rcsid[] =
Link Here
|
42 |
#include <stdlib.h> |
42 |
#include <stdlib.h> |
43 |
#include <string.h> |
43 |
#include <string.h> |
44 |
#include <unistd.h> |
44 |
#include <unistd.h> |
|
|
45 |
#include <time.h> |
45 |
#include <ifaddrs.h> |
46 |
#include <ifaddrs.h> |
46 |
|
47 |
|
47 |
#include <arpa/inet.h> |
48 |
#include <arpa/inet.h> |
Lines 98-107
static void
Link Here
|
98 |
setip6lifetime(const char *cmd, const char *val, int s, |
99 |
setip6lifetime(const char *cmd, const char *val, int s, |
99 |
const struct afswtch *afp) |
100 |
const struct afswtch *afp) |
100 |
{ |
101 |
{ |
101 |
time_t newval, t; |
102 |
struct timespec now; |
|
|
103 |
time_t newval; |
102 |
char *ep; |
104 |
char *ep; |
103 |
|
105 |
|
104 |
t = time(NULL); |
106 |
clock_gettime(CLOCK_MONOTONIC_FAST, &now); |
105 |
newval = (time_t)strtoul(val, &ep, 0); |
107 |
newval = (time_t)strtoul(val, &ep, 0); |
106 |
if (val == ep) |
108 |
if (val == ep) |
107 |
errx(1, "invalid %s", cmd); |
109 |
errx(1, "invalid %s", cmd); |
Lines 108-117
setip6lifetime(const char *cmd, const char *val, i
Link Here
|
108 |
if (afp->af_af != AF_INET6) |
110 |
if (afp->af_af != AF_INET6) |
109 |
errx(1, "%s not allowed for the AF", cmd); |
111 |
errx(1, "%s not allowed for the AF", cmd); |
110 |
if (strcmp(cmd, "vltime") == 0) { |
112 |
if (strcmp(cmd, "vltime") == 0) { |
111 |
in6_addreq.ifra_lifetime.ia6t_expire = t + newval; |
113 |
in6_addreq.ifra_lifetime.ia6t_expire = now.tv_sec + newval; |
112 |
in6_addreq.ifra_lifetime.ia6t_vltime = newval; |
114 |
in6_addreq.ifra_lifetime.ia6t_vltime = newval; |
113 |
} else if (strcmp(cmd, "pltime") == 0) { |
115 |
} else if (strcmp(cmd, "pltime") == 0) { |
114 |
in6_addreq.ifra_lifetime.ia6t_preferred = t + newval; |
116 |
in6_addreq.ifra_lifetime.ia6t_preferred = now.tv_sec + newval; |
115 |
in6_addreq.ifra_lifetime.ia6t_pltime = newval; |
117 |
in6_addreq.ifra_lifetime.ia6t_pltime = newval; |
116 |
} |
118 |
} |
117 |
} |
119 |
} |
Lines 172-180
in6_status(int s __unused, const struct ifaddrs *i
Link Here
|
172 |
int s6; |
174 |
int s6; |
173 |
u_int32_t flags6; |
175 |
u_int32_t flags6; |
174 |
struct in6_addrlifetime lifetime; |
176 |
struct in6_addrlifetime lifetime; |
175 |
time_t t = time(NULL); |
177 |
struct timespec now; |
176 |
int error; |
178 |
int error; |
177 |
|
179 |
|
|
|
180 |
clock_gettime(CLOCK_MONOTONIC_FAST, &now); |
181 |
|
178 |
memset(&null_sin, 0, sizeof(null_sin)); |
182 |
memset(&null_sin, 0, sizeof(null_sin)); |
179 |
|
183 |
|
180 |
sin = (struct sockaddr_in6 *)ifa->ifa_addr; |
184 |
sin = (struct sockaddr_in6 *)ifa->ifa_addr; |
Lines 258-272
in6_status(int s __unused, const struct ifaddrs *i
Link Here
|
258 |
if (ip6lifetime && (lifetime.ia6t_preferred || lifetime.ia6t_expire)) { |
262 |
if (ip6lifetime && (lifetime.ia6t_preferred || lifetime.ia6t_expire)) { |
259 |
printf("pltime "); |
263 |
printf("pltime "); |
260 |
if (lifetime.ia6t_preferred) { |
264 |
if (lifetime.ia6t_preferred) { |
261 |
printf("%s ", lifetime.ia6t_preferred < t |
265 |
printf("%s ", lifetime.ia6t_preferred < now.tv_sec |
262 |
? "0" : sec2str(lifetime.ia6t_preferred - t)); |
266 |
? "0" : sec2str(lifetime.ia6t_preferred - now.tv_sec)); |
263 |
} else |
267 |
} else |
264 |
printf("infty "); |
268 |
printf("infty "); |
265 |
|
269 |
|
266 |
printf("vltime "); |
270 |
printf("vltime "); |
267 |
if (lifetime.ia6t_expire) { |
271 |
if (lifetime.ia6t_expire) { |
268 |
printf("%s ", lifetime.ia6t_expire < t |
272 |
printf("%s ", lifetime.ia6t_expire < now.tv_sec |
269 |
? "0" : sec2str(lifetime.ia6t_expire - t)); |
273 |
? "0" : sec2str(lifetime.ia6t_expire - now.tv_sec)); |
270 |
} else |
274 |
} else |
271 |
printf("infty "); |
275 |
printf("infty "); |
272 |
} |
276 |
} |