[hipl-commit] [trunk] Rev 3906: Splitting misc.c continued (bug id 1139).

  • From: Miika Komu <miika@xxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Wed, 10 Mar 2010 15:03:38 +0200

Committer: Miika Komu <miika@xxxxxx>
Date: Wed Mar 10 15:03:35 2010 +0200
Revision: 3906
Revision-id: miika@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: trunk

Log:
  Splitting misc.c continued (bug id 1139).
  Added hit.c. Moved a couple of functions elsewhere because they were 
references only from one place.

Modified:
  M  Makefile.am
  M  firewall/cache_port.c
  M  firewall/datapkt.c
  M  firewall/lsi.c
  M  hipd/dht.c
  M  hipd/hidb.c
  M  hipd/input.c
  M  hipd/keymat.c
  M  hipd/netdev.c
  M  hipd/nsupdate.c
  M  lib/core/hostid.c
  M  lib/core/hostid.h
  M  lib/core/misc.c
  M  lib/core/misc.h
  M  lib/core/prefix.c
  M  lib/core/prefix.h

=== modified file 'Makefile.am'
--- Makefile.am 2010-03-10 11:34:35 +0000
+++ Makefile.am 2010-03-10 13:03:35 +0000
@@ -258,6 +258,7 @@
                                  lib/core/solve.c \
                                  lib/core/transform.c \
                                  lib/core/keylen.c \
+                                 lib/core/hit.c \
                                  lib/core/sqlitedbapi.c \
                                  lib/core/hashchain_store.c \
                                  lib/core/hip_statistics.c \

=== modified file 'firewall/cache_port.c'
--- firewall/cache_port.c       2010-02-18 12:26:08 +0000
+++ firewall/cache_port.c       2010-03-10 13:03:35 +0000
@@ -30,6 +30,90 @@
 static HIP_HASHTABLE *firewall_port_cache_db = NULL;
 
 /**
+ * Check from the proc file system whether a local port is attached
+ * to an IPv4 or IPv6 address. This is required to determine whether
+ * incoming packets should be diverted to an LSI.
+ *
+ * @param port_dest     the port number of the socket
+ * @param *proto        protocol type
+ * @return              1 if it finds the required socket, 0 otherwise
+ *
+ * @note this is used only from the firewall, so move this there
+ */
+int hip_get_proto_info(in_port_t port_dest, char *proto)
+{
+    FILE *fd       = NULL;
+    char line[500], sub_string_addr_hex[8], path[11 + sizeof(proto)];
+    char *fqdn_str = NULL, *separator = NULL, *sub_string_port_hex = NULL;
+    int lineno     = 0, index_addr_port = 0, exists = 0, result;
+    uint32_t result_addr;
+    struct in_addr addr;
+    List list;
+
+    if (!proto) {
+        return 0;
+    }
+
+    if (!strcmp(proto, "tcp6") || !strcmp(proto, "tcp")) {
+        index_addr_port = 15;
+    } else if (!strcmp(proto, "udp6") || !strcmp(proto, "udp")) {
+        index_addr_port = 10;
+    } else {
+        return 0;
+    }
+
+    strcpy(path, "/proc/net/");
+    strcat(path, proto);
+    fd = fopen(path, "r");
+
+    initlist(&list);
+    while (fd && getwithoutnewline(line, 500, fd) != NULL && !exists) {
+        lineno++;
+
+        destroy(&list);
+        initlist(&list);
+
+        if (lineno == 1 || strlen(line) <= 1) {
+            continue;
+        }
+
+        extractsubstrings(line, &list);
+
+        fqdn_str = getitem(&list, index_addr_port);
+        if (fqdn_str) {
+            separator = strrchr(fqdn_str, ':');
+        }
+
+        if (!separator) {
+            continue;
+        }
+
+        sub_string_port_hex = strtok(separator, ":");
+        sscanf(sub_string_port_hex, "%X", &result);
+        HIP_DEBUG("Result %i\n", result);
+        HIP_DEBUG("port dest %i\n", port_dest);
+        if (result == port_dest) {
+            strncpy(sub_string_addr_hex, fqdn_str, 8);
+            sscanf(sub_string_addr_hex, "%X", &result_addr);
+            addr.s_addr = result_addr;
+            if (IS_LSI32(addr.s_addr)) {
+                exists = 2;
+                break;
+            } else {
+                exists = 1;
+                break;
+            }
+        }
+    }     /* end of while */
+    if (fd) {
+        fclose(fd);
+    }
+    destroy(&list);
+
+    return exists;
+}
+
+/**
  * add a default entry in the firewall port cache.
  *
  * @param key       the hash key (a string consisting of concatenation of the 
port, an underscore and the protocol)

=== modified file 'firewall/datapkt.c'
--- firewall/datapkt.c  2010-03-09 18:26:22 +0000
+++ firewall/datapkt.c  2010-03-10 13:03:35 +0000
@@ -82,6 +82,49 @@
 }
 
 /**
+ * ask hipd to sign a hiccups data packet
+ *
+ * @param src_hit the source HIT of the data packet
+ * @param dst_hit the destination HIT of the data packet
+ * @param payload the payload protocol value
+ * @param msg     An input/output parameter. For input, contains the
+ *                data packet with payload. For output, contains the
+ *                same but including a signature from hipd.
+ * @return        zero on success or negative on error
+ */
+int hip_get_data_packet_header(const struct in6_addr *src_hit,
+                               const struct in6_addr *dst_hit,
+                               int payload,
+                               struct hip_common *msg)
+{
+    int err = 0;
+
+    hip_build_network_hdr(msg, HIP_DATA, 0, src_hit, dst_hit);
+    msg->payload_proto = payload;
+
+    HIP_DEBUG("PAYLOAD_PROTO in HIP DATA HEADER = %d  ", payload );
+
+    /* @todo: this will assert  */
+    HIP_IFEL(hip_build_user_hdr(msg, 
SO_HIP_BUILD_HOST_ID_SIGNATURE_DATAPACKET, 0),
+             -1, "build hdr failed\n");
+    _HIP_DUMP_MSG(msg);
+
+    /* send msg to hipd and receive corresponding reply */
+    HIP_IFEL(hip_send_recv_daemon_info(msg, 0, 0), -1, "send_recv msg 
failed\n");
+
+    /* check error value */
+    HIP_IFEL(hip_get_msg_err(msg), -1, "hipd returned error message!\n");
+    HIP_DEBUG("Send_recv msg succeed \n");
+
+out_err:
+    msg->type_hdr      = HIP_DATA;
+    /* this was overwritten by some mischief.. So reseting it */
+    msg->payload_proto = payload;
+
+    return err;
+}
+
+/**
  * Process an inbound HICCUPS data packet and remove the HIP header. Caller
  * is responsible to reinjecting the decapsulated message back to the 
networking
  * stack.

=== modified file 'firewall/lsi.c'
--- firewall/lsi.c      2010-03-05 08:47:53 +0000
+++ firewall/lsi.c      2010-03-10 13:03:35 +0000
@@ -59,6 +59,67 @@
 }
 
 /**
+ * get the state of the bex for a pair of ip addresses.
+ *
+ * @param src_ip       input for finding the correct entries
+ * @param dst_ip       input for finding the correct entries
+ * @param src_hit      output data of the correct entry
+ * @param dst_hit      output data of the correct entry
+ * @param src_lsi      output data of the correct entry
+ * @param dst_lsi      output data of the correct entry
+ * @return             the state of the bex if the entry is found
+ *                     otherwise returns -1
+ */
+int hip_get_bex_state_from_LSIs(hip_lsi_t       *src_lsi,
+                                hip_lsi_t       *dst_lsi,
+                                struct in6_addr *src_ip,
+                                struct in6_addr *dst_ip,
+                                struct in6_addr *src_hit,
+                                struct in6_addr *dst_hit)
+{
+    int err = 0, res = -1;
+    struct hip_tlv_common *current_param = NULL;
+    struct hip_common *msg               = NULL;
+    struct hip_hadb_user_info_state *ha;
+
+    HIP_ASSERT(src_ip != NULL && dst_ip != NULL);
+
+    HIP_IFEL(!(msg = hip_msg_alloc()), -1, "malloc failed\n");
+    hip_msg_init(msg);
+    HIP_IFEL(hip_build_user_hdr(msg, SO_HIP_GET_HA_INFO, 0),
+             -1, "Building of daemon header failed\n");
+    HIP_IFEL(hip_send_recv_daemon_info(msg, 0, 0), -1, "send recv daemon 
info\n");
+
+    while ((current_param = hip_get_next_param(msg, current_param)) != NULL) {
+        ha = hip_get_param_contents_direct(current_param);
+
+        if ((ipv4_addr_cmp(dst_lsi, &ha->lsi_our) == 0)  &&
+            (ipv4_addr_cmp(src_lsi, &ha->lsi_peer) == 0)) {
+            *src_hit = ha->hit_peer;
+            *dst_hit = ha->hit_our;
+            *src_ip  = ha->ip_peer;
+            *dst_ip  = ha->ip_our;
+            res      = ha->state;
+            break;
+        } else if ((ipv4_addr_cmp(src_lsi, &ha->lsi_our) == 0)  &&
+                   (ipv4_addr_cmp(dst_lsi, &ha->lsi_peer) == 0)) {
+            *src_hit = ha->hit_our;
+            *dst_hit = ha->hit_peer;
+            *src_ip  = ha->ip_our;
+            *dst_ip  = ha->ip_peer;
+            res      = ha->state;
+            break;
+        }
+    }
+
+out_err:
+    if (msg) {
+        HIP_FREE(msg);
+    }
+    return res;
+}
+
+/**
  * Analyzes first whether the ipv6 packet belongs to an ipv6 socket.
  * If not, it then analyzes whether the packet belongs to an
  * ipv4 socket with an LSI as IP address.

=== modified file 'hipd/dht.c'
--- hipd/dht.c  2010-03-08 22:07:59 +0000
+++ hipd/dht.c  2010-03-10 13:03:35 +0000
@@ -16,6 +16,7 @@
 #include "dht.h"
 #include "hipd.h"
 #include "lib/core/hostid.h"
+#include "lib/core/hit.h"
 
 static void hip_publish_hit(char *, char *);
 static int hip_publish_addr(char *);

=== modified file 'hipd/hidb.c'
--- hipd/hidb.c 2010-03-09 18:26:22 +0000
+++ hipd/hidb.c 2010-03-10 13:03:35 +0000
@@ -15,6 +15,7 @@
 #include "config.h"
 #include "hidb.h"
 #include "lib/core/hostid.h"
+#include "lib/core/hit.h"
 
 HIP_HASHTABLE *hip_local_hostid_db = NULL;
 #define HIP_MAX_HOST_ID_LEN 1600

=== modified file 'hipd/input.c'
--- hipd/input.c        2010-03-10 11:34:35 +0000
+++ hipd/input.c        2010-03-10 13:03:35 +0000
@@ -38,6 +38,7 @@
 #include "netdev.h"
 #include "lib/tool/lutil.h"
 #include "lib/core/state.h"
+#include "lib/core/hit.h"
 #include "oppdb.h"
 #include "registration.h"
 #include "esp_prot_hipd_msg.h"

=== modified file 'hipd/keymat.c'
--- hipd/keymat.c       2010-03-05 09:10:50 +0000
+++ hipd/keymat.c       2010-03-10 13:03:35 +0000
@@ -14,6 +14,7 @@
 #define _BSD_SOURCE
 
 #include "keymat.h"
+#include "lib/core/hit.h"
 
 static uint8_t *hip_create_keymat_buffer(char *kij, size_t kij_len, size_t 
hash_len,
                                     struct in6_addr *smaller_hit,

=== modified file 'hipd/netdev.c'
--- hipd/netdev.c       2010-03-09 18:26:22 +0000
+++ hipd/netdev.c       2010-03-10 13:03:35 +0000
@@ -35,6 +35,7 @@
 #include "lib/conf/hipconf.h"
 #include "lib/core/hostsfiles.h"
 #include "lib/core/hip_udp.h"
+#include "lib/core/hit.h"
 #include "hipd.h"
 
 /**

=== modified file 'hipd/nsupdate.c'
--- hipd/nsupdate.c     2010-03-09 18:26:22 +0000
+++ hipd/nsupdate.c     2010-03-10 13:03:35 +0000
@@ -27,6 +27,7 @@
 #include "config.h"
 #include "hidb.h"
 #include "nsupdate.h"
+#include "lib/core/hit.h"
 
 // parameters for nsupdate.pl
 #define VAR_IPS "HIPD_IPS"

=== modified file 'lib/core/hostid.c'
--- lib/core/hostid.c   2010-03-10 11:14:55 +0000
+++ lib/core/hostid.c   2010-03-10 13:03:35 +0000
@@ -26,6 +26,42 @@
 
 #define HOST_ID_FILENAME_MAX_LEN 256
 
+
+/**
+ * calculate a HIT from a HI without the prefix
+ *
+ * @param orig a pointer to a host identity
+ * @param orig_len the length of the host identity in bits
+ * @param encoded an output argument where the HIT will be stored
+ * @param encoded_len the length of the encoded HIT in bits
+ * @return zero on success or negative on error
+ */
+int khi_encode(unsigned char *orig, int orig_len,
+               unsigned char *encoded,
+               int encoded_len)
+{
+    BIGNUM *bn = NULL;
+    int err    = 0, shift = (orig_len - encoded_len) / 2,
+        len    = encoded_len / 8 + ((encoded_len % 8) ? 1 : 0);
+
+    HIP_IFEL((encoded_len > orig_len), -1, "len mismatch\n");
+    HIP_IFEL((!(bn = BN_bin2bn(orig, orig_len / 8, NULL))), -1,
+             "BN_bin2bn\n");
+    HIP_IFEL(!BN_rshift(bn, bn, shift), -1, "BN_lshift\n");
+    HIP_IFEL(!BN_mask_bits(bn, encoded_len), -1,
+             "BN_mask_bits\n");
+    HIP_IFEL((bn2bin_safe(bn, encoded, len) != len), -1,
+             "BN_bn2bin_safe\n");
+
+    _HIP_HEXDUMP("encoded: ", encoded, len);
+
+out_err:
+    if (bn) {
+        BN_free(bn);
+    }
+    return err;
+}
+
 /**
  * Calculates a Host Identity Tag (HIT) from a Host Identifier (HI) using DSA
  * encryption.

=== modified file 'lib/core/hostid.h'
--- lib/core/hostid.h   2010-03-09 19:45:13 +0000
+++ lib/core/hostid.h   2010-03-10 13:03:35 +0000
@@ -45,5 +45,8 @@
                                  const char *hi_file,
                                  int rsa_key_bits,
                                  int dsa_key_bits);
+int khi_encode(unsigned char *orig, int orig_len,
+               unsigned char *encoded,
+               int encoded_len);
 
 #endif /* HIP_LIB_CORE_HOSTID_H */

=== modified file 'lib/core/misc.c'
--- lib/core/misc.c     2010-03-10 11:34:35 +0000
+++ lib/core/misc.c     2010-03-10 13:03:35 +0000
@@ -17,31 +17,6 @@
 #include "misc.h"
 #include "prefix.h"
 
-/**
- * convert a binary HIT into a string
- *
- * @param hit a binary HIT
- * @param prefix an optional HIT prefix as a string
- * @param hit_str the HIT as a string with the given prefix
- * @return zero on success and negative on error
- */
-int hip_convert_hit_to_str(const hip_hit_t *hit,
-                           const char *prefix,
-                           char *hit_str)
-{
-    int err = 0;
-
-    HIP_ASSERT(hit);
-
-    memset(hit_str, 0, INET6_ADDRSTRLEN);
-    err = !hip_in6_ntop(hit, hit_str);
-
-    if (prefix) {
-        memcpy(hit_str + strlen(hit_str), prefix, strlen(prefix));
-    }
-
-    return err;
-}
 
 /**
  * find the maximum value from a variable list of integers
@@ -80,33 +55,6 @@
     return ipv4_addr_cmp(lsi1, lsi2) == 0;
 }
 
-/**
- * compare two HITs to check which HIT is "bigger"
- *
- * @param hit1 the first HIT to be compared
- * @param hit2 the second HIT to be compared
- *
- * @return 1 if hit1 was bigger than hit2, or else 0
- */
-int hip_hit_is_bigger(const struct in6_addr *hit1,
-                      const struct in6_addr *hit2)
-{
-    return ipv6_addr_cmp(hit1, hit2) > 0;
-}
-
-/**
- * compare two HITs to check which if they are equal
- *
- * @param hit1 the first HIT to be compared
- * @param hit2 the second HIT to be compared
- *
- * @return 1 if the HITs were equal and zero otherwise
- */
-int hip_hit_are_equal(const struct in6_addr *hit1,
-                      const struct in6_addr *hit2)
-{
-    return ipv6_addr_cmp(hit1, hit2) == 0;
-}
 
 /**
  * convert a binary IPv6 address to a string
@@ -254,102 +202,6 @@
 }
 
 /**
- * calculate a HIT from a HI without the prefix
- *
- * @param orig a pointer to a host identity
- * @param orig_len the length of the host identity in bits
- * @param encoded an output argument where the HIT will be stored
- * @param encoded_len the length of the encoded HIT in bits
- * @return zero on success or negative on error
- */
-int khi_encode(unsigned char *orig, int orig_len,
-               unsigned char *encoded,
-               int encoded_len)
-{
-    BIGNUM *bn = NULL;
-    int err    = 0, shift = (orig_len - encoded_len) / 2,
-        len    = encoded_len / 8 + ((encoded_len % 8) ? 1 : 0);
-
-    HIP_IFEL((encoded_len > orig_len), -1, "len mismatch\n");
-    HIP_IFEL((!(bn = BN_bin2bn(orig, orig_len / 8, NULL))), -1,
-             "BN_bin2bn\n");
-    HIP_IFEL(!BN_rshift(bn, bn, shift), -1, "BN_lshift\n");
-    HIP_IFEL(!BN_mask_bits(bn, encoded_len), -1,
-             "BN_mask_bits\n");
-    HIP_IFEL((bn2bin_safe(bn, encoded, len) != len), -1,
-             "BN_bn2bin_safe\n");
-
-    _HIP_HEXDUMP("encoded: ", encoded, len);
-
-out_err:
-    if (bn) {
-        BN_free(bn);
-    }
-    return err;
-}
-
-/**
- * get the state of the bex for a pair of ip addresses.
- *
- * @param src_ip       input for finding the correct entries
- * @param dst_ip       input for finding the correct entries
- * @param src_hit      output data of the correct entry
- * @param dst_hit      output data of the correct entry
- * @param src_lsi      output data of the correct entry
- * @param dst_lsi      output data of the correct entry
- * @return             the state of the bex if the entry is found
- *                     otherwise returns -1
- */
-int hip_get_bex_state_from_LSIs(hip_lsi_t       *src_lsi,
-                                hip_lsi_t       *dst_lsi,
-                                struct in6_addr *src_ip,
-                                struct in6_addr *dst_ip,
-                                struct in6_addr *src_hit,
-                                struct in6_addr *dst_hit)
-{
-    int err = 0, res = -1;
-    struct hip_tlv_common *current_param = NULL;
-    struct hip_common *msg               = NULL;
-    struct hip_hadb_user_info_state *ha;
-
-    HIP_ASSERT(src_ip != NULL && dst_ip != NULL);
-
-    HIP_IFEL(!(msg = hip_msg_alloc()), -1, "malloc failed\n");
-    hip_msg_init(msg);
-    HIP_IFEL(hip_build_user_hdr(msg, SO_HIP_GET_HA_INFO, 0),
-             -1, "Building of daemon header failed\n");
-    HIP_IFEL(hip_send_recv_daemon_info(msg, 0, 0), -1, "send recv daemon 
info\n");
-
-    while ((current_param = hip_get_next_param(msg, current_param)) != NULL) {
-        ha = hip_get_param_contents_direct(current_param);
-
-        if ((ipv4_addr_cmp(dst_lsi, &ha->lsi_our) == 0)  &&
-            (ipv4_addr_cmp(src_lsi, &ha->lsi_peer) == 0)) {
-            *src_hit = ha->hit_peer;
-            *dst_hit = ha->hit_our;
-            *src_ip  = ha->ip_peer;
-            *dst_ip  = ha->ip_our;
-            res      = ha->state;
-            break;
-        } else if ((ipv4_addr_cmp(src_lsi, &ha->lsi_our) == 0)  &&
-                   (ipv4_addr_cmp(dst_lsi, &ha->lsi_peer) == 0)) {
-            *src_hit = ha->hit_our;
-            *dst_hit = ha->hit_peer;
-            *src_ip  = ha->ip_our;
-            *dst_ip  = ha->ip_peer;
-            res      = ha->state;
-            break;
-        }
-    }
-
-out_err:
-    if (msg) {
-        HIP_FREE(msg);
-    }
-    return res;
-}
-
-/**
  * build a message for hipd to trigger a base exchange
  *
  * @param src_hit an optional source HIT for the I1
@@ -456,134 +308,6 @@
 }
 
 /**
- * ask hipd to sign a hiccups data packet
- *
- * @param src_hit the source HIT of the data packet
- * @param dst_hit the destination HIT of the data packet
- * @param payload the payload protocol value
- * @param msg     An input/output parameter. For input, contains the
- *                data packet with payload. For output, contains the
- *                same but including a signature from hipd.
- * @return        zero on success or negative on error
- */
-int hip_get_data_packet_header(const struct in6_addr *src_hit,
-                               const struct in6_addr *dst_hit,
-                               int payload,
-                               struct hip_common *msg)
-{
-    int err = 0;
-
-    hip_build_network_hdr(msg, HIP_DATA, 0, src_hit, dst_hit);
-    msg->payload_proto = payload;
-
-    HIP_DEBUG("PAYLOAD_PROTO in HIP DATA HEADER = %d  ", payload );
-
-    /* @todo: this will assert  */
-    HIP_IFEL(hip_build_user_hdr(msg, 
SO_HIP_BUILD_HOST_ID_SIGNATURE_DATAPACKET, 0),
-             -1, "build hdr failed\n");
-    _HIP_DUMP_MSG(msg);
-
-    /* send msg to hipd and receive corresponding reply */
-    HIP_IFEL(hip_send_recv_daemon_info(msg, 0, 0), -1, "send_recv msg 
failed\n");
-
-    /* check error value */
-    HIP_IFEL(hip_get_msg_err(msg), -1, "hipd returned error message!\n");
-    HIP_DEBUG("Send_recv msg succeed \n");
-
-out_err:
-    msg->type_hdr      = HIP_DATA;
-    /* this was overwritten by some mischief.. So reseting it */
-    msg->payload_proto = payload;
-
-    return err;
-}
-
-/**
- * Check from the proc file system whether a local port is attached
- * to an IPv4 or IPv6 address. This is required to determine whether
- * incoming packets should be diverted to an LSI.
- *
- * @param port_dest     the port number of the socket
- * @param *proto        protocol type
- * @return              1 if it finds the required socket, 0 otherwise
- *
- * @note this is used only from the firewall, so move this there
- */
-int hip_get_proto_info(in_port_t port_dest, char *proto)
-{
-    FILE *fd       = NULL;
-    char line[500], sub_string_addr_hex[8], path[11 + sizeof(proto)];
-    char *fqdn_str = NULL, *separator = NULL, *sub_string_port_hex = NULL;
-    int lineno     = 0, index_addr_port = 0, exists = 0, result;
-    uint32_t result_addr;
-    struct in_addr addr;
-    List list;
-
-    if (!proto) {
-        return 0;
-    }
-
-    if (!strcmp(proto, "tcp6") || !strcmp(proto, "tcp")) {
-        index_addr_port = 15;
-    } else if (!strcmp(proto, "udp6") || !strcmp(proto, "udp")) {
-        index_addr_port = 10;
-    } else {
-        return 0;
-    }
-
-    strcpy(path, "/proc/net/");
-    strcat(path, proto);
-    fd = fopen(path, "r");
-
-    initlist(&list);
-    while (fd && getwithoutnewline(line, 500, fd) != NULL && !exists) {
-        lineno++;
-
-        destroy(&list);
-        initlist(&list);
-
-        if (lineno == 1 || strlen(line) <= 1) {
-            continue;
-        }
-
-        extractsubstrings(line, &list);
-
-        fqdn_str = getitem(&list, index_addr_port);
-        if (fqdn_str) {
-            separator = strrchr(fqdn_str, ':');
-        }
-
-        if (!separator) {
-            continue;
-        }
-
-        sub_string_port_hex = strtok(separator, ":");
-        sscanf(sub_string_port_hex, "%X", &result);
-        HIP_DEBUG("Result %i\n", result);
-        HIP_DEBUG("port dest %i\n", port_dest);
-        if (result == port_dest) {
-            strncpy(sub_string_addr_hex, fqdn_str, 8);
-            sscanf(sub_string_addr_hex, "%X", &result_addr);
-            addr.s_addr = result_addr;
-            if (IS_LSI32(addr.s_addr)) {
-                exists = 2;
-                break;
-            } else {
-                exists = 1;
-                break;
-            }
-        }
-    }     /* end of while */
-    if (fd) {
-        fclose(fd);
-    }
-    destroy(&list);
-
-    return exists;
-}
-
-
-/**
  * convert a string containing upper case characters to lower case
  *
  * @param to the result of the conversion (minimum length @c count)
@@ -632,25 +356,6 @@
 }
 
 
-
-/**
- * verify if a given IPv6 address or IPv6 mapped IPv4 address
- * is a loopback
- *
- * @param addr the address to verify
- * @return one if the address if loopback or zero otherwise
- */
-int hip_addr_is_loopback(struct in6_addr *addr)
-{
-    struct in_addr addr_in;
-
-    if (!IN6_IS_ADDR_V4MAPPED(addr)) {
-        return IN6_IS_ADDR_LOOPBACK(addr);
-    }
-    IPV6_TO_IPV4_MAP(addr, &addr_in);
-    return IS_IPV4_LOOPBACK(addr_in.s_addr);
-}
-
 /**
  * encode the given content to Base64
  *

=== modified file 'lib/core/misc.h'
--- lib/core/misc.h     2010-03-10 11:34:35 +0000
+++ lib/core/misc.h     2010-03-10 13:03:35 +0000
@@ -103,20 +103,12 @@
     }
 }
 
-int khi_encode(unsigned char *orig, int orig_len,
-               unsigned char *encoded,
-               int encoded_len);
-
 char *hip_in6_ntop(const struct in6_addr *in6, char *buf);
 char *hip_hit_ntop(const hip_hit_t *hit, char *buf);
 uint8_t *hip_host_id_extract_public_key(uint8_t *buffer, struct hip_host_id 
*data);
 
 int hip_lsi_are_equal(const hip_lsi_t *lsi1,
                       const hip_lsi_t *lsi2);
-int hip_hit_is_bigger(const struct in6_addr *hit1,
-                      const struct in6_addr *hit2);
-int hip_hit_are_equal(const struct in6_addr *hit1,
-                      const struct in6_addr *hit2);
 
 unsigned long hip_hash_hit(const void *hit);
 int hip_match_hit(const void *, const void *);
@@ -124,7 +116,6 @@
 int convert_string_to_address(const char *str, struct in6_addr *ip6);
 
 uint64_t hip_get_current_birthday(void);
-int hip_convert_hit_to_str(const hip_hit_t *hit, const char *prefix, char 
*str);
 
 int maxof(int num_args, ...);
 
@@ -170,11 +161,6 @@
                                int payload,
                                struct hip_common *msg);
 
-/**
- * Check if the given address is loopback.
- */
-int hip_addr_is_loopback(struct in6_addr *addr);
-
 HIP_HASHTABLE *hip_linked_list_init(void);
 
 int hip_get_proto_info(in_port_t port_dest, char *proto);

=== modified file 'lib/core/prefix.c'
--- lib/core/prefix.c   2010-03-08 21:21:01 +0000
+++ lib/core/prefix.c   2010-03-10 13:03:35 +0000
@@ -320,3 +320,21 @@
         ipv6_addr_copy(&in6->sin6_addr, addr);
     }
 }
+
+/**
+ * verify if a given IPv6 address or IPv6 mapped IPv4 address
+ * is a loopback
+ *
+ * @param addr the address to verify
+ * @return one if the address if loopback or zero otherwise
+ */
+int hip_addr_is_loopback(struct in6_addr *addr)
+{
+    struct in_addr addr_in;
+
+    if (!IN6_IS_ADDR_V4MAPPED(addr)) {
+        return IN6_IS_ADDR_LOOPBACK(addr);
+    }
+    IPV6_TO_IPV4_MAP(addr, &addr_in);
+    return IS_IPV4_LOOPBACK(addr_in.s_addr);
+}

=== modified file 'lib/core/prefix.h'
--- lib/core/prefix.h   2010-03-09 19:45:13 +0000
+++ lib/core/prefix.h   2010-03-10 13:03:35 +0000
@@ -34,7 +34,7 @@
 int hip_sa_addr_len(void *sockaddr);
 void hip_addr_to_sockaddr(struct in6_addr *addr, struct sockaddr_storage *sa);
 int hip_sockaddr_is_v6_mapped(struct sockaddr *sa);
-
+int hip_addr_is_loopback(struct in6_addr *addr);
 
 /* IN6_IS_ADDR_V4MAPPED(a) is defined in /usr/include/netinet/in.h */

Other related posts:

  • » [hipl-commit] [trunk] Rev 3906: Splitting misc.c continued (bug id 1139). - Miika Komu