ping.c (23295) | ping.c (23327) |
---|---|
1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Mike Muuss. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 31 unchanged lines hidden (view full) --- 40 The Regents of the University of California. All rights reserved.\n"; 41#endif /* not lint */ 42 43#ifndef lint 44/* 45static char sccsid[] = "@(#)ping.c 8.1 (Berkeley) 6/5/93"; 46*/ 47static const char rcsid[] = | 1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Mike Muuss. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 31 unchanged lines hidden (view full) --- 40 The Regents of the University of California. All rights reserved.\n"; 41#endif /* not lint */ 42 43#ifndef lint 44/* 45static char sccsid[] = "@(#)ping.c 8.1 (Berkeley) 6/5/93"; 46*/ 47static const char rcsid[] = |
48 "$Id: ping.c,v 1.18 1997/03/02 06:32:40 imp Exp $"; | 48 "$Id: ping.c,v 1.19 1997/03/02 20:01:13 imp Exp $"; |
49#endif /* not lint */ 50 51/* 52 * P I N G . C 53 * 54 * Using the InterNet Control Message Protocol (ICMP) "ECHO" facility, 55 * measure round-trip-delays and packet loss across network paths. 56 * --- 262 unchanged lines hidden (view full) --- 319 hostname = target; 320 } else { 321 hp = gethostbyname2(target, AF_INET); 322 if (!hp) 323 errx(EX_NOHOST, "cannot resolve %s: %s", 324 target, hstrerror(h_errno)); 325 326 to->sin_len = sizeof *to; | 49#endif /* not lint */ 50 51/* 52 * P I N G . C 53 * 54 * Using the InterNet Control Message Protocol (ICMP) "ECHO" facility, 55 * measure round-trip-delays and packet loss across network paths. 56 * --- 262 unchanged lines hidden (view full) --- 319 hostname = target; 320 } else { 321 hp = gethostbyname2(target, AF_INET); 322 if (!hp) 323 errx(EX_NOHOST, "cannot resolve %s: %s", 324 target, hstrerror(h_errno)); 325 326 to->sin_len = sizeof *to; |
327 if (hp->h_length > sizeof(to->sin_addr)) 328 errx(1,"gethostbyname2 returned an illegal address"); |
|
327 memcpy(&to->sin_addr, hp->h_addr_list[0], sizeof to->sin_addr); 328 (void)strncpy(hnamebuf, hp->h_name, sizeof(hnamebuf) - 1); 329 hnamebuf[(sizeof hnamebuf) - 1] = '\0'; 330 hostname = hnamebuf; 331 } 332 333 if (options & F_FLOOD && options & F_INTERVAL) 334 errx(EX_USAGE, "-f and -i: incompatible options"); --- 846 unchanged lines hidden --- | 329 memcpy(&to->sin_addr, hp->h_addr_list[0], sizeof to->sin_addr); 330 (void)strncpy(hnamebuf, hp->h_name, sizeof(hnamebuf) - 1); 331 hnamebuf[(sizeof hnamebuf) - 1] = '\0'; 332 hostname = hnamebuf; 333 } 334 335 if (options & F_FLOOD && options & F_INTERVAL) 336 errx(EX_USAGE, "-f and -i: incompatible options"); --- 846 unchanged lines hidden --- |