-/* sonar, Copyright (c) 1998-2012 Jamie Zawinski and Stephen Martin
+/* sonar, Copyright (c) 1998-2018 Jamie Zawinski and Stephen Martin
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
*/
#endif
-#ifndef USE_IPHONE
+#ifndef HAVE_MOBILE
# define READ_FILES
#endif
# include <sys/types.h>
# include <sys/time.h>
# include <sys/ipc.h>
-# include <sys/shm.h>
+# ifndef HAVE_ANDROID
+# include <sys/shm.h>
+# endif
# include <sys/socket.h>
# include <netinet/in_systm.h>
# include <netinet/in.h>
# undef HAVE_PING
#endif
-#ifndef USE_IPHONE
+#ifndef HAVE_MOBILE
# define LOAD_FILES
#endif
/* Packs an IP address quad into bigendian network order. */
-static unsigned long
+static in_addr_t
pack_addr (unsigned int a, unsigned int b, unsigned int c, unsigned int d)
{
unsigned long i = (((a & 255) << 24) |
if (!strcmp (sb->name, "ssh-rsa") ||
!strcmp (sb->name, "ssh-dsa") ||
!strcmp (sb->name, "ssh-dss") ||
+ !strncmp (sb->name, "ecdsa-", 6) ||
strlen (sb->name) >= 80)
return 0;
fp = fopen(filename, "r");
if (!fp)
{
- char buf[1024];
- sprintf(buf, "%s: %s", progname, filename);
-#ifdef HAVE_COCOA
+ char buf2[1024];
+ sprintf(buf2, "%s: %s", progname, filename);
+#ifdef HAVE_JWXYZ
if (pd->debug_p) /* on OSX don't syslog this */
#endif
- perror (buf);
+ perror (buf2);
return 0;
}
}
-static unsigned int
-width_mask (int width)
+static unsigned long
+width_mask (unsigned long width)
{
- unsigned int m = 0;
+ unsigned long m = 0;
int i;
for (i = 0; i < width; i++)
m |= (1L << (31-i));
#ifdef HAVE_GETIFADDRS
-static int
-mask_width (unsigned int mask)
+static unsigned int
+mask_width (unsigned long mask)
{
int i;
for (i = 0; i < 32; i++)
{
struct in_addr in2;
unsigned long mask;
- if (ifa->ifa_addr->sa_family != AF_INET)
+ if (! ifa->ifa_addr)
+ continue;
+ else if (ifa->ifa_addr->sa_family != AF_INET)
{
if (pd->debug_p)
fprintf (stderr, "%s: if: %4s: %s\n", progname,
h_base = ntohl (n_base);
if (desc_ret && !*desc_ret) {
- char buf[255];
+ char buf2[255];
unsigned int a, b, c, d;
unsigned long bb = n_base & htonl(h_mask);
unpack_addr (bb, &a, &b, &c, &d);
if (subnet_width > 24)
- sprintf (buf, "%u.%u.%u.%u/%d", a, b, c, d, subnet_width);
+ sprintf (buf2, "%u.%u.%u.%u/%d", a, b, c, d, subnet_width);
else
- sprintf (buf, "%u.%u.%u/%d", a, b, c, subnet_width);
- *desc_ret = strdup (buf);
+ sprintf (buf2, "%u.%u.%u/%d", a, b, c, subnet_width);
+ *desc_ret = strdup (buf2);
}
for (i = 255; i >= 0; i--) {
const char *token = "org.jwz.xscreensaver.sonar";
char *host_id;
- int pcktsiz = (sizeof(struct ICMP) + sizeof(struct timeval) +
+ unsigned long pcktsiz = (sizeof(struct ICMP) + sizeof(struct timeval) +
sizeof(socklen_t) + pb->addrlen +
- strlen(token) + 1 +
+ strlen(token) + 1 +
strlen(pd->version) + 1);
/* Create the ICMP packet */
{
ping_data *pd = (ping_data *) ssd->closure;
struct sockaddr from;
- unsigned int fromlen; /* Posix says socklen_t, but that's not portable */
+ socklen_t fromlen;
int result;
u_char packet[1024];
struct timeval now;
From Valentijn Sessink <valentyn@openoffice.nl> */
if (select(pd->icmpsock + 1, &rfds, 0, 0, &tv) >0)
{
- result = recvfrom (pd->icmpsock, packet, sizeof(packet),
+ result = (int)recvfrom (pd->icmpsock, packet, sizeof(packet),
0, &from, &fromlen);
/* Check the packet */
{
sonar_bogie *new_bogie = bogie_for_host (ssd, fallback,
NULL);
- new_bogie->next = *sbp;
-
- if (! ((ping_bogie *)new_bogie->closure)->lookup_addr &&
- ! find_duplicate_host(pd, &pd->targets, new_bogie))
- *sbp = new_bogie;
- else
- sonar_free_bogie (ssd, new_bogie);
+ if (new_bogie) {
+ new_bogie->next = *sbp;
+
+ if (! ((ping_bogie *)new_bogie->closure)->lookup_addr &&
+ ! find_duplicate_host(pd, &pd->targets, new_bogie))
+ *sbp = new_bogie;
+ else
+ sonar_free_bogie (ssd, new_bogie);
+ }
free (fallback);
}
if (sb && !pb->lookup_addr)
{
- assert (pb->addrlen);
+ if (!pb->addrlen) abort();
send_ping (pd, sb);
pd->last_pinged = sb;
}