[hipl-commit] [trunk] Rev 3695: replaced icmpv6 kernel includes with userspace counterparts

  • From: Rene Hummen <rene.hummen@xxxxxxxxxxxxxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Tue, 23 Feb 2010 16:12:16 +0200

Committer: Rene Hummen <rene.hummen@xxxxxxxxxxxxxxxxx>
Date: Tue Feb 23 15:10:06 2010 +0100
Revision: 3695
Revision-id: rene.hummen@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: trunk

Log:
  replaced icmpv6 kernel includes with userspace counterparts
  
  this should fix bug #1244. i also removed unrequired headers.

Modified:
  M  firewall/firewalldb.c
  M  firewall/proxy.c
  M  firewall/proxyconndb.c
  M  hipd/heartbeat.c
  M  hipd/init.c
  M  hipd/init.h
  M  hipd/output.c

=== modified file 'firewall/firewalldb.c'
--- firewall/firewalldb.c       2010-02-17 13:55:23 +0000
+++ firewall/firewalldb.c       2010-02-23 14:10:06 +0000
@@ -16,6 +16,8 @@
 #define _BSD_SOURCE
 
 #include <netinet/ip_icmp.h>
+#include <netinet/icmp6.h>
+
 #include "firewalldb.h"
 #include "cache.h"
 #include "firewall_defines.h"
@@ -858,8 +860,8 @@
         break;
     case IPPROTO_ICMPV6:
         firewall_raw_sock = firewall_raw_sock_icmp_v6;
-        ((struct icmp6hdr *) msg)->icmp6_cksum = htons(0);
-        ((struct icmp6hdr *) msg)->icmp6_cksum
+        ((struct icmp6_hdr *) msg)->icmp6_cksum = htons(0);
+        ((struct icmp6_hdr *) msg)->icmp6_cksum
                 = ipv6_checksum(IPPROTO_ICMPV6, &sock_src6->sin6_addr,
                                    &sock_dst6->sin6_addr, msg, len);
         break;

=== modified file 'firewall/proxy.c'
--- firewall/proxy.c    2010-02-18 16:45:11 +0000
+++ firewall/proxy.c    2010-02-23 14:10:06 +0000
@@ -5,6 +5,8 @@
 /* required for s6_addr32 */
 #define _BSD_SOURCE
 
+#include <netinet/icmp6.h>
+
 #include "firewall/proxy.h"
 #include "firewall/proxyconndb.h"
 #include "firewall/firewall_defines.h"
@@ -568,8 +570,8 @@
     if (protocol == IPPROTO_ICMPV6) {
         //TODO
         HIP_DEBUG("ICMPV6 packet\n");
-        ((struct icmp6hdr *) msg)->icmp6_cksum = htons(0);
-        ((struct icmp6hdr *) msg)->icmp6_cksum = ipv6_checksum(
+        ((struct icmp6_hdr *) msg)->icmp6_cksum = htons(0);
+        ((struct icmp6_hdr *) msg)->icmp6_cksum = ipv6_checksum(
                 IPPROTO_ICMPV6, &src6->sin6_addr, &dst6->sin6_addr, msg, len);
     }
 
@@ -636,7 +638,7 @@
     struct tcphdr *tcp          = NULL;
     struct udphdr *udp          = NULL;
     struct icmphdr *icmp        = NULL;
-    struct icmp6hdr *icmpv6     = NULL;
+    struct icmp6_hdr *icmpv6     = NULL;
     u8 *msg                     = NULL;
     /* Points either to v4 or v6 raw sock */
     int hip_raw_sock            = 0;
@@ -664,7 +666,7 @@
     tcp         = (struct tcphdr *) (buff + 40); //sizeof ip6_hdr is 40
     udp         = (struct udphdr *) (buff + 40); //sizeof ip6_hdr is 40
     icmp        = (struct icmphdr *) (buff + 40); //sizeof ip6_hdr is 40
-    icmpv6      = (struct icmp6hdr *) (buff + 40); //sizeof ip6_hdr is 40
+    icmpv6      = (struct icmp6_hdr *) (buff + 40); //sizeof ip6_hdr is 40
 
     memset(&src, 0, sizeof(src));
     memset(&dst, 0, sizeof(dst));

=== modified file 'firewall/proxyconndb.c'
--- firewall/proxyconndb.c      2010-02-18 11:40:11 +0000
+++ firewall/proxyconndb.c      2010-02-23 14:10:06 +0000
@@ -16,26 +16,10 @@
 /* required for s6_addr32 */
 #define _BSD_SOURCE
 
-#include <sys/types.h>
-#include <unistd.h>
-#include <errno.h>
-#include <stddef.h>
-#include <sys/socket.h>
-#include <netinet/tcp.h>
-#include <netinet/udp.h>
-#include <netinet/ip_icmp.h>
-
 #include "hipd/hidb.h"
 #include "lib/core/hashtable.h"
 #include "proxyconndb.h"
 
-#ifndef ANDROID_CHANGES
- #include <linux/icmpv6.h>
-#else
- #include <linux/icmp.h>
- #include <linux/coda.h>
- #include "libhipandroid/icmp6.h"
-#endif
 
 static HIP_HASHTABLE *hip_proxy_conn_db = NULL;
 

=== modified file 'hipd/heartbeat.c'
--- hipd/heartbeat.c    2010-02-11 09:57:04 +0000
+++ hipd/heartbeat.c    2010-02-23 14:10:06 +0000
@@ -1,6 +1,8 @@
 /* required for s6_addr32 */
 #define _BSD_SOURCE
 
+#include <netinet/icmp6.h>
+
 #include "heartbeat.h"
 #include "maintenance.h"
 
@@ -97,7 +99,7 @@
     struct iovec iov[1];
     u_char cmsgbuf[CMSG_SPACE(sizeof(struct inet6_pktinfo))];
     u_char iovbuf[HIP_MAX_ICMP_PACKET];
-    struct icmp6hdr *icmph = NULL;
+    struct icmp6_hdr *icmph = NULL;
     struct inet6_pktinfo *pktinfo;
     struct sockaddr_in6 src_sin6;
     struct in6_addr *src   = NULL, *dst = NULL;
@@ -161,13 +163,13 @@
     gettimeofday(rtval, (struct timezone *) NULL);
 
     /* Check if the process identifier is ours and that this really is echo 
response */
-    icmph = (struct icmp6hdr *) (void *) iovbuf;
-    if (icmph->icmp6_type != ICMPV6_ECHO_REPLY) {
+    icmph = (struct icmp6_hdr *) (void *) iovbuf;
+    if (icmph->icmp6_type != ICMP6_ECHO_REPLY) {
         err = 0;
         goto out_err;
     }
     identifier = getpid() & 0xFFFF;
-    if (identifier != icmph->icmp6_identifier) {
+    if (identifier != icmph->icmp6_id) {
         err = 0;
         goto out_err;
     }

=== modified file 'hipd/init.c'
--- hipd/init.c 2010-02-16 08:35:10 +0000
+++ hipd/init.c 2010-02-23 14:10:06 +0000
@@ -10,6 +10,7 @@
 
 #include <sys/prctl.h>
 #include <sys/types.h>
+#include <netinet/icmp6.h>
 
 #ifdef HAVE_CONFIG_H
   #include "config.h"
@@ -365,15 +366,9 @@
     HIP_IFEL(*icmpsockfd <= 0, 1, "ICMPv6 socket creation failed\n");
 
     ICMP6_FILTER_SETBLOCKALL(&filter);
-#ifdef ANDROID_CHANGES
     ICMP6_FILTER_SETPASS(ICMP6_ECHO_REPLY, &filter);
     err = setsockopt(*icmpsockfd, IPPROTO_ICMPV6, ICMP6_FILTER, &filter,
                      sizeof(struct icmp6_filter));
-#else
-    ICMP6_FILTER_SETPASS(ICMPV6_ECHO_REPLY, &filter);
-    err = setsockopt(*icmpsockfd, IPPROTO_ICMPV6, ICMPV6_FILTER, &filter,
-                     sizeof(struct icmp6_filter));
-#endif
     HIP_IFEL(err, -1, "setsockopt icmp ICMP6_FILTER failed\n");
 
 

=== modified file 'hipd/init.h'
--- hipd/init.h 2010-02-17 13:08:39 +0000
+++ hipd/init.h 2010-02-23 14:10:06 +0000
@@ -1,5 +1,6 @@
 #ifndef HIP_HIPD_INIT_H
 #define HIP_HIPD_INIT_H
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/socket.h>
@@ -7,12 +8,7 @@
 #include <sys/resource.h>
 #include <sys/wait.h>
 #include <sys/utsname.h>
-#ifndef ANDROID_CHANGES
-#ifdef CONFIG_HIP_MAEMO
-#define asm(arg) __asm(arg)
-#endif
-#include <linux/icmpv6.h>
-#endif
+
 #include "lib/tool/xfrmapi.h"
 #include "lib/conf/hipconf.h"
 #include "oppipdb.h"

=== modified file 'hipd/output.c'
--- hipd/output.c       2010-02-17 14:11:29 +0000
+++ hipd/output.c       2010-02-23 14:10:06 +0000
@@ -14,6 +14,8 @@
 /* required for s6_addr32 */
 #define _BSD_SOURCE
 
+#include <netinet/icmp6.h>
+
 #ifdef HAVE_CONFIG_H
   #include "config.h"
 #endif /* HAVE_CONFIG_H */
@@ -1430,7 +1432,7 @@
 int hip_send_icmp(int sockfd, hip_ha_t *entry)
 {
     int err                = 0, i = 0, identifier = 0;
-    struct icmp6hdr *icmph = NULL;
+    struct icmp6_hdr *icmph = NULL;
     struct sockaddr_in6 dst6;
     u_char cmsgbuf[CMSG_SPACE(sizeof(struct inet6_pktinfo))];
     u_char *icmp_pkt       = NULL;
@@ -1475,13 +1477,13 @@
     dst6.sin6_flowinfo      = 0;
 
     /* build icmp header */
-    icmph                   = (struct icmp6hdr *) (void *) icmp_pkt;
-    icmph->icmp6_type       = ICMPV6_ECHO_REQUEST;
+    icmph                   = (struct icmp6_hdr *) (void *) icmp_pkt;
+    icmph->icmp6_type       = ICMP6_ECHO_REQUEST;
     icmph->icmp6_code       = 0;
     entry->heartbeats_sent++;
 
-    icmph->icmp6_sequence   = htons(entry->heartbeats_sent);
-    icmph->icmp6_identifier = identifier;
+    icmph->icmp6_seq        = htons(entry->heartbeats_sent);
+    icmph->icmp6_id         = identifier;
 
     gettimeofday(&tval, NULL);
 
@@ -1491,7 +1493,7 @@
 
     /* put the icmp packet to the io vector struct for the msghdr */
     iov[0].iov_base     = icmp_pkt;
-    iov[0].iov_len      = sizeof(struct icmp6hdr) + sizeof(struct timeval);
+    iov[0].iov_len      = sizeof(struct icmp6_hdr) + sizeof(struct timeval);
 
     /* build the msghdr for the sendmsg, put ancillary data also*/
     mhdr.msg_name       = &dst6;

Other related posts:

  • » [hipl-commit] [trunk] Rev 3695: replaced icmpv6 kernel includes with userspace counterparts - Rene Hummen