Commit a43ec842 authored by Stewart Brodie's avatar Stewart Brodie
Browse files

Modified to that if getprotobyname fails (ie. inetdbase:protocols is...

Modified to that if getprotobyname fails (ie. inetdbase:protocols is unavailable) then it defaults to IPPROTO_ICMP.  This means that this utility can function in the absense of the above named file.
parent 269b02d5
......@@ -175,6 +175,9 @@ main(argc, argv)
struct hostent *hp;
struct sockaddr_in *to;
struct protoent *proto;
#ifdef __riscos
int icmp_proto_id = IPPROTO_ICMP;
#endif
#ifdef __unix
struct termios ts;
#endif
......@@ -318,10 +321,12 @@ main(argc, argv)
ident = getpid() & 0xFFFF;
if (!(proto = getprotobyname("icmp"))) {
#ifndef __riscos
(void)fprintf(stderr, "ping: unknown protocol icmp.\n");
exit(1);
#endif
}
if ((s = socket(AF_INET, SOCK_RAW, proto->p_proto)) < 0) {
if ((s = socket(AF_INET, SOCK_RAW, proto?proto->p_proto:IPPROTO_ICMP)) < 0) {
perror("ping: socket");
exit(1);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment