-/* $OpenBSD: ping.c,v 1.97 2013/11/22 04:12:48 deraadt Exp $ */
+/* $OpenBSD: ping.c,v 1.98 2014/01/10 06:18:40 brad Exp $ */
/* $NetBSD: ping.c,v 1.20 1995/08/11 22:37:58 cgd Exp $ */
/*
fd_set *fdmaskp;
size_t fdmasks;
uid_t uid;
- u_int rtableid;
+ int rtableid = -1;
if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0)
err(1, "socket");
-/* $OpenBSD: ping6.c,v 1.86 2013/11/22 04:12:48 deraadt Exp $ */
+/* $OpenBSD: ping6.c,v 1.87 2014/01/10 06:18:40 brad Exp $ */
/* $KAME: ping6.c,v 1.163 2002/10/25 02:19:06 itojun Exp $ */
/*
size_t rthlen;
int mflag = 0;
uid_t uid;
- u_int rtableid;
+ int rtableid = -1;
/* just to be sure */
memset(&smsghdr, 0, sizeof(smsghdr));
res->ai_protocol)) < 0)
err(1, "socket");
- if (setsockopt(s, SOL_SOCKET, SO_RTABLE, &rtableid,
- sizeof(rtableid)) == -1)
+ if (rtableid >= 0 && (setsockopt(s, SOL_SOCKET, SO_RTABLE, &rtableid,
+ sizeof(rtableid)) == -1))
err(1, "setsockopt SO_RTABLE");
/* set the source address if specified. */