if (cmdedit_x >= num) {
cmdedit_x -= num;
if (num <= 4) {
- do putchar('\b'); while (--num);
+ printf("\b\b\b\b" + (4-num));
return;
}
printf("\033[%uD", num);
count_y = 1 + (num / cmdedit_termw);
cmdedit_y -= count_y;
cmdedit_x = cmdedit_termw * count_y - num;
- /* go to 1st col; go up; go to correct column */
+ /* go to 1st column; go up; go to correct column */
printf("\r" "\033[%dA" "\033[%dC", count_y, cmdedit_x);
}
* some seventy years Bell Labs was asleep.
*/
-static u_int machtime(void)
+static unsigned machtime(void)
{
struct timeval tv;
fprintf(stderr, "Unable to get time of day\n");
return 0L;
}
- return htonl((u_int) tv.tv_sec + 2208988800UL);
+ return htonl((unsigned) tv.tv_sec + 2208988800UL);
}
/* ARGSUSED */
static void
machtime_stream(int s, servtab_t *sep ATTRIBUTE_UNUSED)
{
- u_int result;
+ unsigned result;
result = machtime();
(void) write(s, (char *) &result, sizeof(result));
static void
machtime_dg(int s, servtab_t *sep ATTRIBUTE_UNUSED)
{
- u_int result;
+ unsigned result;
/* struct sockaddr_storage ss; */
struct sockaddr sa;
struct sockaddr_in *dg_sin;
/* vi: set sw=4 ts=4: */
/*
- * $Id: ping.c,v 1.56 2004/03/15 08:28:48 andersen Exp $
* Mini ping implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
*
* Adapted from the ping in netkit-base 0.10:
* Copyright (c) 1989 The Regents of the University of California.
- * Derived from software contributed to Berkeley by Mike Muuss.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Mike Muuss.
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
pingsock = create_icmp_socket();
- memset(&pingaddr, 0, sizeof(struct sockaddr_in));
+ memset(&pingaddr, 0, sizeof(pingaddr));
pingaddr.sin_family = AF_INET;
h = xgethostbyname(host);
pkt->icmp_cksum = 0;
pkt->icmp_seq = htons(ntransmitted); /* don't ++ here, it can be a macro */
pkt->icmp_id = myid;
- CLR(ntohs(pkt->icmp_seq) % MAX_DUP_CHK);
+ CLR((uint16_t)ntransmitted % MAX_DUP_CHK);
ntransmitted++;
gettimeofday((struct timeval *) &pkt->icmp_dun, NULL);
static char *icmp_type_name(int id)
{
switch (id) {
- case ICMP_ECHOREPLY: return "Echo Reply";
- case ICMP_DEST_UNREACH: return "Destination Unreachable";
- case ICMP_SOURCE_QUENCH: return "Source Quench";
- case ICMP_REDIRECT: return "Redirect (change route)";
- case ICMP_ECHO: return "Echo Request";
- case ICMP_TIME_EXCEEDED: return "Time Exceeded";
- case ICMP_PARAMETERPROB: return "Parameter Problem";
- case ICMP_TIMESTAMP: return "Timestamp Request";
- case ICMP_TIMESTAMPREPLY: return "Timestamp Reply";
- case ICMP_INFO_REQUEST: return "Information Request";
- case ICMP_INFO_REPLY: return "Information Reply";
- case ICMP_ADDRESS: return "Address Mask Request";
- case ICMP_ADDRESSREPLY: return "Address Mask Reply";
- default: return "unknown ICMP type";
+ case ICMP_ECHOREPLY: return "Echo Reply";
+ case ICMP_DEST_UNREACH: return "Destination Unreachable";
+ case ICMP_SOURCE_QUENCH: return "Source Quench";
+ case ICMP_REDIRECT: return "Redirect (change route)";
+ case ICMP_ECHO: return "Echo Request";
+ case ICMP_TIME_EXCEEDED: return "Time Exceeded";
+ case ICMP_PARAMETERPROB: return "Parameter Problem";
+ case ICMP_TIMESTAMP: return "Timestamp Request";
+ case ICMP_TIMESTAMPREPLY: return "Timestamp Reply";
+ case ICMP_INFO_REQUEST: return "Information Request";
+ case ICMP_INFO_REPLY: return "Information Reply";
+ case ICMP_ADDRESS: return "Address Mask Request";
+ case ICMP_ADDRESSREPLY: return "Address Mask Reply";
+ default: return "unknown ICMP type";
}
}
return; /* not our ping */
if (icmppkt->icmp_type == ICMP_ECHOREPLY) {
- u_int16_t recv_seq = ntohs(icmppkt->icmp_seq);
+ uint16_t recv_seq = ntohs(icmppkt->icmp_seq);
++nreceived;
tp = (struct timeval *) icmppkt->icmp_data;
if (dupflag)
printf(" (DUP!)");
puts("");
- } else
+ } else {
if (icmppkt->icmp_type != ICMP_ECHO)
bb_error_msg("warning: got ICMP %d (%s)",
icmppkt->icmp_type,
icmp_type_name(icmppkt->icmp_type));
+ }
fflush(stdout);
}
xbind(pingsock, (struct sockaddr*)&sourceaddr, sizeof(sourceaddr));
}
- memset(&pingaddr, 0, sizeof(struct sockaddr_in));
+ memset(&pingaddr, 0, sizeof(pingaddr));
pingaddr.sin_family = AF_INET;
hostent = xgethostbyname(host);
setsockopt_broadcast(pingsock);
/* set recv buf for broadcast pings */
- sockopt = 48 * 1024;
+ sockopt = 48 * 1024; /* explain why 48k? */
setsockopt(pingsock, SOL_SOCKET, SO_RCVBUF, (char *) &sockopt,
sizeof(sockopt));
/* vi: set sw=4 ts=4: */
/*
- * $Id: ping6.c,v 1.6 2004/03/15 08:28:48 andersen Exp $
* Mini ping implementation for busybox
*
* Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
pingsock = create_icmp6_socket();
- memset(&pingaddr, 0, sizeof(struct sockaddr_in));
+ memset(&pingaddr, 0, sizeof(pingaddr));
pingaddr.sin6_family = AF_INET6;
h = xgethostbyname2(host, AF_INET6);
pkt->icmp6_cksum = 0;
pkt->icmp6_seq = htons(ntransmitted); /* don't ++ here, it can be a macro */
pkt->icmp6_id = myid;
- CLR(pkt->icmp6_seq % MAX_DUP_CHK);
+ CLR((uint16_t)ntransmitted % MAX_DUP_CHK);
ntransmitted++;
gettimeofday((struct timeval *) &pkt->icmp6_data8[4], NULL);
}
}
-/* RFC3542 changed some definitions from RFC2292 for no good reason, whee !
+/* RFC3542 changed some definitions from RFC2292 for no good reason, whee!
* the newer 3542 uses a MLD_ prefix where as 2292 uses ICMP6_ prefix */
#ifndef MLD_LISTENER_QUERY
# define MLD_LISTENER_QUERY ICMP6_MEMBERSHIP_QUERY
static char *icmp6_type_name(int id)
{
switch (id) {
- case ICMP6_DST_UNREACH: return "Destination Unreachable";
- case ICMP6_PACKET_TOO_BIG: return "Packet too big";
- case ICMP6_TIME_EXCEEDED: return "Time Exceeded";
- case ICMP6_PARAM_PROB: return "Parameter Problem";
- case ICMP6_ECHO_REPLY: return "Echo Reply";
- case ICMP6_ECHO_REQUEST: return "Echo Request";
- case MLD_LISTENER_QUERY: return "Listener Query";
- case MLD_LISTENER_REPORT: return "Listener Report";
- case MLD_LISTENER_REDUCTION: return "Listener Reduction";
- default: return "unknown ICMP type";
+ case ICMP6_DST_UNREACH: return "Destination Unreachable";
+ case ICMP6_PACKET_TOO_BIG: return "Packet too big";
+ case ICMP6_TIME_EXCEEDED: return "Time Exceeded";
+ case ICMP6_PARAM_PROB: return "Parameter Problem";
+ case ICMP6_ECHO_REPLY: return "Echo Reply";
+ case ICMP6_ECHO_REQUEST: return "Echo Request";
+ case MLD_LISTENER_QUERY: return "Listener Query";
+ case MLD_LISTENER_REPORT: return "Listener Report";
+ case MLD_LISTENER_REDUCTION: return "Listener Reduction";
+ default: return "unknown ICMP type";
}
}
return; /* not our ping */
if (icmppkt->icmp6_type == ICMP6_ECHO_REPLY) {
+ uint16_t recv_seq = ntohs(icmppkt->icmp6_seq);
++nreceived;
tp = (struct timeval *) &icmppkt->icmp6_data8[4];
if (triptime > tmax)
tmax = triptime;
- if (TST(icmppkt->icmp6_seq % MAX_DUP_CHK)) {
+ if (TST(recv_seq % MAX_DUP_CHK)) {
++nrepeats;
--nreceived;
dupflag = 1;
} else {
- SET(icmppkt->icmp6_seq % MAX_DUP_CHK);
+ SET(recv_seq % MAX_DUP_CHK);
dupflag = 0;
}
printf("%d bytes from %s: icmp6_seq=%u", sz,
inet_ntop(AF_INET6, &pingaddr.sin6_addr,
buf, sizeof(buf)),
- ntohs(icmppkt->icmp6_seq));
+ recv_seq);
printf(" ttl=%d time=%lu.%lu ms", hoplimit,
triptime / 10, triptime % 10);
if (dupflag)
printf(" (DUP!)");
puts("");
- } else
+ } else {
if (icmppkt->icmp6_type != ICMP6_ECHO_REQUEST)
bb_error_msg("warning: got ICMP %d (%s)",
- icmppkt->icmp6_type, icmp6_type_name(icmppkt->icmp6_type));
+ icmppkt->icmp6_type,
+ icmp6_type_name(icmppkt->icmp6_type));
+ }
+ fflush(stdout);
}
static void ping(const char *host)
pingsock = create_icmp6_socket();
- memset(&pingaddr, 0, sizeof(struct sockaddr_in));
+ memset(&pingaddr, 0, sizeof(pingaddr));
pingaddr.sin6_family = AF_INET6;
hostent = xgethostbyname2(host, AF_INET6);
"%s: invalid interface name", opt_I);
}
- myid = (int16_t)getpid();
+ myid = (int16_t) getpid();
ping(argv[optind]);
return EXIT_SUCCESS;
}
struct hostinfo {
char *name;
int n;
- u_int32_t *addrs;
+ uint32_t *addrs;
};
/* Data section of the probe packet */
};
struct IFADDRLIST {
- u_int32_t addr;
+ uint32_t addr;
char device[sizeof(struct ifreq)];
};
#if ENABLE_FEATURE_TRACEROUTE_SOURCE_ROUTE
/* Maximum number of gateways (include room for one noop) */
-#define NGATEWAYS ((int)((MAX_IPOPTLEN - IPOPT_MINOFF - 1) / sizeof(u_int32_t)))
+#define NGATEWAYS ((int)((MAX_IPOPTLEN - IPOPT_MINOFF - 1) / sizeof(uint32_t)))
/* loose source route gateway list (including room for final destination) */
-static u_int32_t gwlist[NGATEWAYS + 1];
+static uint32_t gwlist[NGATEWAYS + 1];
#endif
static int s; /* receive (icmp) socket file descriptor */
static void
-setsin(struct sockaddr_in *addr_sin, u_int32_t addr)
+setsin(struct sockaddr_in *addr_sin, uint32_t addr)
{
memset(addr_sin, 0, sizeof(*addr_sin));
#ifdef HAVE_SOCKADDR_SA_LEN
{
int i, n;
FILE *f;
- u_int32_t mask;
- u_int32_t dest, tmask;
+ uint32_t mask;
+ uint32_t dest, tmask;
struct IFADDRLIST *al;
char buf[256], tdevice[256], device[256];
int nshorts, i;
sp = (uint16_t *)outip;
- nshorts = (u_int)packlen / sizeof(uint16_t);
+ nshorts = (unsigned)packlen / sizeof(uint16_t);
i = 0;
printf("[ %d bytes", packlen);
while (--nshorts >= 0) {
#if ENABLE_FEATURE_TRACEROUTE_VERBOSE
if (verbose) {
int i;
- u_int32_t *lp = (u_int32_t *)&icp->icmp_ip;
+ uint32_t *lp = (uint32_t *)&icp->icmp_ip;
printf("\n%d bytes from %s to "
"%s: icmp type %d (%s) code %d\n",
struct hostent *hp;
struct hostinfo *hi;
char **p;
- u_int32_t addr, *ap;
+ uint32_t addr, *ap;
hi = xzalloc(sizeof(*hi));
addr = inet_addr(host);
#if ENABLE_FEATURE_TRACEROUTE_SOURCE_ROUTE
static void
-getaddr(u_int32_t *ap, const char *host)
+getaddr(uint32_t *ap, const char *host)
{
struct hostinfo *hi;
int code, n;
unsigned char *outp;
- u_int32_t *ap;
+ uint32_t *ap;
struct sockaddr_in *from = (struct sockaddr_in *)&wherefrom;
struct sockaddr_in *to = (struct sockaddr_in *)&whereto;
struct hostinfo *hi;
int nprobes = 3;
char *nprobes_str = NULL;
char *waittime_str = NULL;
- u_int pausemsecs = 0;
+ unsigned pausemsecs = 0;
char *pausemsecs_str = NULL;
int first_ttl = 1;
char *first_ttl_str = NULL;
(void)fflush(stderr);
for (ttl = first_ttl; ttl <= max_ttl; ++ttl) {
- u_int32_t lastaddr = 0;
+ uint32_t lastaddr = 0;
int gotlastaddr = 0;
int got_there = 0;
int unreachable = 0;
/* This list holds information about clients. The xid_* functions manipulate this list. */
static struct xid_item {
- u_int32_t xid;
+ uint32_t xid;
struct sockaddr_in ip;
int client;
time_t timestamp;
} dhcprelay_xid_list = {0, {0}, 0, 0, NULL};
-static struct xid_item * xid_add(u_int32_t xid, struct sockaddr_in *ip, int client)
+static struct xid_item * xid_add(uint32_t xid, struct sockaddr_in *ip, int client)
{
struct xid_item *item;
}
}
-static struct xid_item * xid_find(u_int32_t xid)
+static struct xid_item * xid_find(uint32_t xid)
{
struct xid_item *item = dhcprelay_xid_list.next;
while (item != NULL) {
return NULL;
}
-static void xid_del(u_int32_t xid)
+static void xid_del(uint32_t xid)
{
struct xid_item *item = dhcprelay_xid_list.next;
struct xid_item *last = &dhcprelay_xid_list;