friendlier error messages for vpn-users in get-gateway
This commit is contained in:
parent
5ff9684bf9
commit
fc6ef16b8f
@ -131,11 +131,23 @@ int get_hw_addr(struct in_addr *gw_ip, char *iface, unsigned char *hw_mac)
|
||||
while (RTA_OK(rt_attr, rt_len)) {
|
||||
switch (rt_attr->rta_type) {
|
||||
case NDA_LLADDR:
|
||||
assert(RTA_PAYLOAD(rt_attr) == IFHWADDRLEN);
|
||||
if (RTA_PAYLOAD(rt_attr) != IFHWADDRLEN) {
|
||||
// could be using a VPN
|
||||
log_fatal("get_gateway", "Unexpected hardware address length (%d).\n\n" \
|
||||
" If you are using a VPN, supply the --vpn flag (and provide an interface via -i)",
|
||||
RTA_PAYLOAD(rt_attr));
|
||||
exit(1);
|
||||
}
|
||||
memcpy(mac, RTA_DATA(rt_attr), IFHWADDRLEN);
|
||||
break;
|
||||
case NDA_DST:
|
||||
assert(RTA_PAYLOAD(rt_attr) == sizeof(dst_ip));
|
||||
if (RTA_PAYLOAD(rt_attr) != sizeof(dst_ip)) {
|
||||
// could be using a VPN
|
||||
log_fatal("get_gateway", "Unexpected IP address length (%d).\n" \
|
||||
" If you are using a VPN, supply the --vpn flag (and provide an interface via -i)",
|
||||
RTA_PAYLOAD(rt_attr));
|
||||
exit(1);
|
||||
}
|
||||
memcpy(&dst_ip, RTA_DATA(rt_attr), sizeof(dst_ip));
|
||||
if (memcmp(&dst_ip, gw_ip, sizeof(dst_ip)) == 0) {
|
||||
correct_ip = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user