[hipl-commit] [trunk] Rev 4191: Remove all OpenWrt-related #ifdeffery.

  • From: Diego Biurrun <diego@xxxxxxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Thu, 8 Apr 2010 19:21:28 +0300

Committer: Diego Biurrun <diego@xxxxxxxxxx>
Date: 08/04/2010 at 19:21:28
Revision: 4191
Revision-id: diego@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: trunk

Log:
  Remove all OpenWrt-related #ifdeffery.
  
  The code compiles fine without all these workarounds in place.

Modified:
  M  firewall/esp_prot_api.c
  M  firewall/esp_prot_conntrack.c
  M  firewall/firewall.c
  M  hipd/init.c
  M  lib/core/filemanip.h
  M  lib/core/hip_capability.c

=== modified file 'firewall/esp_prot_api.c'
--- firewall/esp_prot_api.c     2010-03-30 11:51:33 +0000
+++ firewall/esp_prot_api.c     2010-04-08 16:20:56 +0000
@@ -839,11 +839,7 @@
 
     HIP_DEBUG("checking active_root...\n");
 
-#ifdef CONFIG_HIP_OPENWRT
-    data_index = *((uint32_t *) hash_value);
-#else
     data_index = ntohl(*((uint32_t *) hash_value));
-#endif
 
     if ((err = htree_verify_branch(active_root, hash_length,
                                    hash_value + (sizeof(uint32_t) + 
hash_length),

=== modified file 'firewall/esp_prot_conntrack.c'
--- firewall/esp_prot_conntrack.c       2010-03-18 21:15:21 +0000
+++ firewall/esp_prot_conntrack.c       2010-04-08 16:20:56 +0000
@@ -420,13 +420,8 @@
             -1, "failed to look up matching esp_tuple\n");
 
     for (i = 0; i < esp_tuple->num_hchains; i++) {
-#ifdef CONFIG_HIP_OPENWRT
-        branch_length = esp_branches[i]->branch_length;
-        anchor_offset = esp_branches[i]->anchor_offset;
-#else
         branch_length = ntohl(esp_branches[i]->branch_length);
         anchor_offset = ntohl(esp_branches[i]->anchor_offset);
-#endif
 
         // verify the branch
         if (!htree_verify_branch(esp_tuple->active_roots[i],
@@ -638,12 +633,7 @@
                 conntrack_tfm               = 
esp_prot_conntrack_resolve_transform(
                     esp_tuple->esp_prot_tfm);
                 hash_length                 = conntrack_tfm->hash_length;
-
-#ifdef CONFIG_HIP_OPENWRT
-                esp_tuple->hash_item_length = prot_anchor->hash_item_length;
-#else
                 esp_tuple->hash_item_length = 
ntohl(prot_anchor->hash_item_length);
-#endif
 
                 if (esp_tuple->esp_prot_tfm == ESP_PROT_TFM_TREE) {
                     esp_tuple->hash_tree_depth = ceil(
@@ -794,11 +784,7 @@
                     esp_tuple->esp_prot_tfm);
                 hash_length                 = conntrack_tfm->hash_length;
 
-#ifdef CONFIG_HIP_OPENWRT
-                esp_tuple->hash_item_length = prot_anchor->hash_item_length;
-#else
                 esp_tuple->hash_item_length = 
ntohl(prot_anchor->hash_item_length);
-#endif
 
                 if (esp_tuple->esp_prot_tfm == ESP_PROT_TFM_TREE) {
                     esp_tuple->hash_tree_depth = ceil(

=== modified file 'firewall/firewall.c'
--- firewall/firewall.c 2010-04-08 11:21:53 +0000
+++ firewall/firewall.c 2010-04-08 16:20:56 +0000
@@ -852,7 +852,6 @@
     system_print("echo 1048576 > /proc/sys/net/core/wmem_max");
 }
 
-#ifndef CONFIG_HIP_OPENWRT
 /**
  * Loads several modules that are needed by the firewall.
  */
@@ -889,7 +888,6 @@
     HIP_DEBUG("Probing completed\n");
 }
 
-#endif /* !CONFIG_HIP_OPENWRT */
 
 /*-------------PACKET FILTERING FUNCTIONS------------------*/
 
@@ -2343,9 +2341,7 @@
     print_rule_tables();
 
     firewall_increase_netlink_buffers();
-#ifndef CONFIG_HIP_OPENWRT
     firewall_probe_kernel_modules();
-#endif
 
     // create firewall queue handles for IPv4 traffic
     // FIXME died handle will still be used below

=== modified file 'hipd/init.c'
--- hipd/init.c 2010-04-08 16:02:42 +0000
+++ hipd/init.c 2010-04-08 16:20:56 +0000
@@ -124,7 +124,6 @@
     return fcntl(desc, F_SETFD, oldflags);
 }
 
-#ifndef CONFIG_HIP_OPENWRT
 #ifdef CONFIG_HIP_DEBUG
 /**
  * print information about underlying the system for bug reports
@@ -234,7 +233,6 @@
 }
 
 #endif
-#endif
 
 /**
  * Create a file with the given contents unless it already exists
@@ -405,7 +403,6 @@
     return err;
 }
 
-#ifndef CONFIG_HIP_OPENWRT
 /**
  * probe for kernel modules (linux specific)
  */
@@ -448,7 +445,6 @@
 
     HIP_DEBUG("Probing completed\n");
 }
-#endif /* CONFIG_HIP_OPENWRT */
 
 /**
  * Main initialization function for HIP daemon.
@@ -486,12 +482,10 @@
     hip_bex_timestamp_db_init();
         #endif
 
-#ifndef CONFIG_HIP_OPENWRT
 #ifdef CONFIG_HIP_DEBUG
     hip_print_sysinfo();
 #endif
     hip_probe_kernel_modules();
-#endif
 
     /* Register signal handlers */
     signal(SIGINT, hip_close);
@@ -980,13 +974,11 @@
     /* see bug id 212 why RECV_ERR is off */
     err = setsockopt(*hip_nat_sock_udp, IPPROTO_IP, IP_RECVERR, &off, 
sizeof(on));
     HIP_IFEL(err, -1, "setsockopt udp recverr failed\n");
-        #ifndef CONFIG_HIP_OPENWRT
     if (!is_output) {
         int encap_on = HIP_UDP_ENCAP_ESPINUDP;
         err = setsockopt(*hip_nat_sock_udp, SOL_UDP, HIP_UDP_ENCAP, &encap_on, 
sizeof(encap_on));
     }
     HIP_IFEL(err, -1, "setsockopt udp encap failed\n");
-        #endif
     err = setsockopt(*hip_nat_sock_udp, SOL_SOCKET, SO_REUSEADDR, &on, 
sizeof(on));
     HIP_IFEL(err, -1, "setsockopt udp reuseaddr failed\n");
     err = setsockopt(*hip_nat_sock_udp, SOL_SOCKET, SO_BROADCAST, &on, 
sizeof(on));

=== modified file 'lib/core/filemanip.h'
--- lib/core/filemanip.h        2010-03-30 12:41:08 +0000
+++ lib/core/filemanip.h        2010-04-08 16:20:56 +0000
@@ -10,11 +10,7 @@
 
 #include "config.h"
 
-#ifdef CONFIG_HIP_OPENWRT
-# define HIP_CREATE_FILE(x)     check_and_create_file(x, 0644)
-#else
-# define HIP_CREATE_FILE(x)     open((x), O_RDWR | O_CREAT, 0644)
-#endif
+#define HIP_CREATE_FILE(x)     open((x), O_RDWR | O_CREAT, 0644)
 
 #define HIP_DEFAULT_EXEC_PATH 
"/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin"
 

=== modified file 'lib/core/hip_capability.c'
--- lib/core/hip_capability.c   2010-04-08 16:11:04 +0000
+++ lib/core/hip_capability.c   2010-04-08 16:20:56 +0000
@@ -22,7 +22,6 @@
 #include "config.h"
 #ifdef CONFIG_HIP_PRIVSEP
 #ifdef CONFIG_HIP_ALTSEP
-/* Note: OpenWRT has to use <linux/capability.h> */
 #include <linux/capability.h>
 int capget(cap_user_header_t header, cap_user_data_t data);
 int capset(cap_user_header_t header, const cap_user_data_t data);
@@ -51,7 +50,6 @@
 int hip_user_to_uid(char *name)
 {
     int uid            = -1;
-#ifndef CONFIG_HIP_OPENWRT
     int i;
     struct passwd *pwp = NULL, pw;
     char buf[4096];
@@ -70,7 +68,6 @@
         }
     }
     endpwent();
-#endif
     return uid;
 }
 
@@ -103,12 +100,8 @@
 
     HIP_DEBUG("Now PR_SET_KEEPCAPS=%d\n", prctl(PR_GET_KEEPCAPS));
 
-#ifndef CONFIG_HIP_OPENWRT
     uid = hip_user_to_uid(USER_NOBODY);
-#else
-    /* todo: hardcode the uid for a suitable user for openwrt */
-    uid = -1;
-#endif
+
     HIP_IFEL((uid < 0), -1,
              "Error while retrieving USER 'nobody' uid\n");
     HIP_IFEL(capget(&header, &data), -1,

Other related posts:

  • » [hipl-commit] [trunk] Rev 4191: Remove all OpenWrt-related #ifdeffery. - Diego Biurrun