summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bc066c7)
raw | patch | inline | side by side (parent: bc066c7)
author | octo <octo> | |
Thu, 9 Mar 2006 21:41:43 +0000 (21:41 +0000) | ||
committer | octo <octo> | |
Thu, 9 Mar 2006 21:41:43 +0000 (21:41 +0000) |
src/battery.c | patch | blob | history | |
src/liboping/liboping.c | patch | blob | history |
diff --git a/src/battery.c b/src/battery.c
index d467ecc8614148181cd945941f45d616915a6f26..21b19bb7c74620aec584d9bd85c503ac877c762d 100644 (file)
--- a/src/battery.c
+++ b/src/battery.c
};
static int ds_num_charge = 1;
+#if BATTERY_HAVE_READ
static int battery_pmu_num = 0;
static char *battery_pmu_file = "/proc/pmu/battery_%i";
+#endif
static void battery_init (void)
{
index 915de7bdcde357d2608caa55a46f3d5532ac0654..6f7d079f4378d4bd00ee8491b695dff3444d6fba 100644 (file)
--- a/src/liboping/liboping.c
+++ b/src/liboping/liboping.c
#include <sys/socket.h>
#include <netdb.h>
+
+#include <netinet/in_systm.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
+#ifdef HAVE_NETINET_IP_VAR_H
+# include <netinet/ip_var.h>
+#endif
+
+#include <netinet/ip6.h>
#include <netinet/icmp6.h>
#include <sys/time.h>
static pinghost_t *ping_receive_ipv4 (pinghost_t *ph, char *buffer, size_t buffer_len)
{
struct ip *ip_hdr;
- struct icmphdr *icmp_hdr;
+ struct icmp *icmp_hdr;
size_t ip_hdr_len;
@@ -125,23 +134,23 @@ static pinghost_t *ping_receive_ipv4 (pinghost_t *ph, char *buffer, size_t buffe
buffer += ip_hdr_len;
buffer_len -= ip_hdr_len;
- if (buffer_len < sizeof (struct icmphdr))
+ if (buffer_len < sizeof (struct icmp))
return (NULL);
- icmp_hdr = (struct icmphdr *) buffer;
- buffer += sizeof (struct icmphdr);
- buffer_len -= sizeof (struct icmphdr);
+ icmp_hdr = (struct icmp *) buffer;
+ buffer += sizeof (struct icmp);
+ buffer_len -= sizeof (struct icmp);
- if (icmp_hdr->type != ICMP_ECHOREPLY)
+ if (icmp_hdr->icmp_type != ICMP_ECHOREPLY)
{
- dprintf ("Unexpected ICMP type: %i\n", icmp_hdr->type);
+ dprintf ("Unexpected ICMP type: %i\n", icmp_hdr->icmp_type);
return (NULL);
}
- recv_checksum = icmp_hdr->checksum;
- icmp_hdr->checksum = 0;
+ recv_checksum = icmp_hdr->icmp_cksum;
+ icmp_hdr->icmp_cksum = 0;
calc_checksum = ping_icmp4_checksum ((char *) icmp_hdr,
- sizeof (struct icmphdr) + buffer_len);
+ sizeof (struct icmp) + buffer_len);
if (recv_checksum != calc_checksum)
{
@@ -150,8 +159,8 @@ static pinghost_t *ping_receive_ipv4 (pinghost_t *ph, char *buffer, size_t buffe
return (NULL);
}
- ident = ntohs (icmp_hdr->un.echo.id);
- seq = ntohs (icmp_hdr->un.echo.sequence);
+ ident = ntohs (icmp_hdr->icmp_id);
+ seq = ntohs (icmp_hdr->icmp_seq);
for (ptr = ph; ptr != NULL; ptr = ptr->next)
{
@@ -198,8 +207,8 @@ static pinghost_t *ping_receive_ipv6 (pinghost_t *ph, char *buffer, size_t buffe
return (NULL);
icmp_hdr = (struct icmp6_hdr *) buffer;
- buffer += sizeof (struct icmphdr);
- buffer_len -= sizeof (struct icmphdr);
+ buffer += sizeof (struct icmp);
+ buffer_len -= sizeof (struct icmp);
if (icmp_hdr->icmp6_type != ICMP6_ECHO_REPLY)
{
static int ping_send_one_ipv4 (pinghost_t *ph)
{
- struct icmphdr *icmp4;
+ struct icmp *icmp4;
int status;
char buf[4096];
dprintf ("ph->hostname = %s\n", ph->hostname);
memset (buf, '\0', sizeof (buf));
- icmp4 = (struct icmphdr *) buf;
+ icmp4 = (struct icmp *) buf;
data = (char *) (icmp4 + 1);
- icmp4->type = ICMP_ECHO;
- icmp4->code = 0;
- /* The checksum will be calculated by the TCP/IP stack. */
- icmp4->checksum = 0;
- icmp4->un.echo.id = htons (ph->ident);
- icmp4->un.echo.sequence = htons (ph->sequence);
+ icmp4->icmp_type = ICMP_ECHO;
+ icmp4->icmp_code = 0;
+ icmp4->icmp_cksum = 0;
+ icmp4->icmp_id = htons (ph->ident);
+ icmp4->icmp_seq = htons (ph->sequence);
strcpy (data, PING_DATA);
datalen = strlen (data);
- buflen = datalen + sizeof (struct icmphdr);
+ buflen = datalen + sizeof (struct icmp);
- icmp4->checksum = ping_icmp4_checksum (buf, buflen);
+ icmp4->icmp_cksum = ping_icmp4_checksum (buf, buflen);
dprintf ("Sending ICMPv4 package with ID 0x%04x\n", ph->ident);