+/* vi: set sw=4 ts=4: */
/*
* Copyright (c) 1988, 1989, 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000
* The Regents of the University of California. All rights reserved.
//#define CONFIG_FEATURE_TRACEROUTE_USE_ICMP
#include <errno.h>
-#include <memory.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
-#include <malloc.h>
#include <netdb.h>
#include <endian.h>
#include <getopt.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
-#include <sys/time.h> /* concession to AIX */
#include <sys/select.h>
#include "inet_common.h"
struct ifreq ibuf[(32 * 1024) / sizeof(struct ifreq)], ifr;
struct IFADDRLIST *st_ifaddrlist;
- fd = socket(AF_INET, SOCK_DGRAM, 0);
- if (fd < 0)
- bb_perror_msg_and_die("socket");
+ fd = bb_xsocket(AF_INET, SOCK_DGRAM, 0);
ifc.ifc_len = sizeof(ibuf);
ifc.ifc_buf = (caddr_t)ibuf;
static void
freehostinfo(struct hostinfo *hi)
{
- if (hi->name != NULL) {
- free(hi->name);
- hi->name = NULL;
- }
+ free(hi->name);
+ hi->name = NULL;
free((char *)hi->addrs);
free((char *)hi);
}
if (n > 2)
close(n);
- if ((s = socket(AF_INET, SOCK_RAW, pe->p_proto)) < 0)
- bb_perror_msg_and_die(bb_msg_can_not_create_raw_socket);
+ s = bb_xsocket(AF_INET, SOCK_RAW, pe->p_proto);
#ifdef CONFIG_FEATURE_TRACEROUTE_SO_DEBUG
if (op & USAGE_OP_DEBUG)
(void)setsockopt(s, SOL_SOCKET, SO_DONTROUTE, (char *)&on,
sizeof(on));
- sndsock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
- if (sndsock < 0)
- bb_perror_msg_and_die(bb_msg_can_not_create_raw_socket);
+ sndsock = bb_xsocket(AF_INET, SOCK_RAW, IPPROTO_RAW);
#ifdef CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE
#if defined(IP_OPTIONS)
outip->ip_src = from->sin_addr;
#ifndef IP_HDRINCL
- if (bind(sndsock, (struct sockaddr *)from, sizeof(*from)) < 0) {
- bb_perror_msg_and_die("bind");
- }
+ bb_xbind(sndsock, (struct sockaddr *)from, sizeof(*from));
#endif
fprintf(stderr, "traceroute to %s (%s)", hostname, inet_ntoa(to->sin_addr));