#include "config.h"
#endif
-struct icmphdr {
- u_int8_t type;
- u_int8_t code;
- u_int16_t checksum;
-};
-
-struct reqhdr {
- u_int8_t type;
- u_int8_t code;
- u_int16_t checksum;
- u_int16_t id;
- u_int16_t seq;
-};
-
-struct rephdr {
- u_int8_t type;
- u_int8_t code;
- u_int16_t checksum;
- u_int16_t id;
- u_int16_t seq;
- int32_t ttl;
-
-};
-
-#define ICMP_NAMEREQ 37
-#define ICMP_NAMEREP 38
+#include "icmpdefs.h"
unsigned char buf[65536];
memset(&aihint, 0, sizeof(aihint));
aihint.ai_socktype = SOCK_RAW;
aihint.ai_protocol = IPPROTO_ICMP;
- ret = getaddrinfo(argv[optind], NULL, &aihint, &ai);
+ if((ret = getaddrinfo(argv[optind], NULL, &aihint, &ai)) != 0) {
+ fprintf(stderr, "%s: %s\n", argv[optind], gai_strerror(ret));
+ exit(1);
+ }
for(cai = ai; cai != NULL; cai = cai->ai_next) {
if((s = socket(cai->ai_family, SOCK_RAW, IPPROTO_ICMP)) < 0) {