[hipl-commit] [tiny] Rev 3734: Removed opptcp relicts.

  • From: Tim Just <tim.just@xxxxxxxxxxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Sat, 27 Mar 2010 16:10:03 +0200

Committer: Tim Just <tim.just@xxxxxxxxxxxxxx>
Date: 27/03/2010 at 16:10:03
Revision: 3734
Revision-id: tim.just@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: tiny

Log:
  Removed opptcp relicts.

Modified:
  M  hipd/accessor.c
  M  hipd/hipd.c
  M  hipd/oppdb.c
  M  hipd/oppdb.h
  M  hipd/output.c
  M  lib/conf/hipconf.c

=== modified file 'hipd/accessor.c'
--- hipd/accessor.c     2010-03-19 14:29:54 +0000
+++ hipd/accessor.c     2010-03-27 14:09:51 +0000
@@ -19,8 +19,7 @@
 unsigned int hipd_state         = HIPD_STATE_CLOSED;
 #ifdef CONFIG_HIP_OPPORTUNISTIC
 unsigned int opportunistic_mode = 1;
-extern int hip_use_opptcp;
-#endif // CONFIG_HIP_OPPORTUNISTIC
+#endif /* CONFIG_HIP_OPPORTUNISTIC */
 
 /**
  * Set global daemon state.
@@ -61,67 +60,6 @@
 
 #ifdef CONFIG_HIP_OPPORTUNISTIC
 /**
- * Set opportunistic TCP status on or off
- *
- * @param msg a message with message type as HIP_MSG_SET_OPPTCP_ON
- *            or HIP_MSG_SET_OPPTCP_OFF
- */
-void hip_set_opportunistic_tcp_status(struct hip_common *msg)
-{
-    struct sockaddr_in6 sock_addr;
-    int retry, type, n;
-
-    type = hip_get_msg_type(msg);
-
-    _HIP_DEBUG("type=%d\n", type);
-
-    memset(&sock_addr, 0, sizeof(sock_addr));
-    sock_addr.sin6_family = AF_INET6;
-    sock_addr.sin6_port   = htons(HIP_FIREWALL_PORT);
-    sock_addr.sin6_addr   = in6addr_loopback;
-
-    for (retry = 0; retry < 3; retry++) {
-        /* Switched from hip_sendto() to hip_sendto_user() due to
-         * namespace collision. Both message.h and user.c had functions
-         * hip_sendto(). Introducing a prototype hip_sendto() to user.h
-         * led to compiler errors --> user.c hip_sendto() renamed to
-         * hip_sendto_user().
-         *
-         * Lesson learned: use function prototypes unless functions are
-         * ment only for local (inside the same file where defined) use.
-         * -Lauri 11.07.2008 */
-        n = hip_sendto_user(msg, (struct sockaddr *) &sock_addr);
-        if (n <= 0) {
-            HIP_ERROR("hipconf opptcp failed (round %d)\n", retry);
-            HIP_DEBUG("Sleeping few seconds to wait for fw\n");
-            sleep(2);
-        } else {
-            HIP_DEBUG("hipconf opptcp ok (sent %d bytes)\n", n);
-            break;
-        }
-    }
-
-    if (type == HIP_MSG_SET_OPPTCP_ON) {
-        hip_use_opptcp = 1;
-    } else {
-        hip_use_opptcp = 0;
-    }
-
-    HIP_DEBUG("Opportunistic tcp set %s\n",
-              (hip_use_opptcp ? "on" : "off"));
-}
-
-/**
- * query status for the opportunistic TCP extensions
- *
- * @return 1 if it is enabled or 0 otherwise
- */
-int hip_get_opportunistic_tcp_status(void)
-{
-    return hip_use_opptcp;
-}
-
-/**
  * Set opportunistic mode
  *
  * @param msg A message containing a HIP_PARAM_UINT parameter.
@@ -131,7 +69,7 @@
  */
 int hip_set_opportunistic_mode(struct hip_common *msg)
 {
-    int err            =  0;
+    int err =  0;
     unsigned int *mode = NULL;
 
     mode = hip_get_param_contents(msg, HIP_PARAM_UINT);
@@ -150,14 +88,6 @@
         goto out_err;
     }
 
-    hip_msg_init(msg);
-    HIP_IFE(hip_build_user_hdr(msg,
-                               (opportunistic_mode == 2 ?
-                                HIP_MSG_SET_OPPTCP_ON :
-                                HIP_MSG_SET_OPPTCP_OFF),
-                               0), -1);
-    hip_set_opportunistic_tcp_status(msg);
-
 out_err:
     return err;
 }

=== modified file 'hipd/hipd.c'
--- hipd/hipd.c 2010-03-27 13:54:20 +0000
+++ hipd/hipd.c 2010-03-27 14:09:51 +0000
@@ -116,8 +116,6 @@
 int hip_trigger_update_on_heart_beat_failure = 1;
 int hip_wait_addr_changes_to_stabilize       = 0;
 
-int hip_use_opptcp                           = 0; // false
-
 static void usage(void)
 {
     fprintf(stderr, "Usage: hipd [options]\n\n");

=== modified file 'hipd/oppdb.c'
--- hipd/oppdb.c        2010-03-19 14:29:54 +0000
+++ hipd/oppdb.c        2010-03-27 14:09:51 +0000
@@ -30,9 +30,6 @@
  * process which means that it should proceed without HIP. Consequtive
  * rejects are faster because they are cached.
  *
- * See firewall/opptcp.c extension on how the initial timeout can be
- * reduced to a single round-trip time.
- *
  * Authors:
  * - Bing Zhou <bingzhou@xxxxxxxxx>
  */
@@ -635,8 +632,7 @@
 
     /* Create an opportunistic HIT from the peer's IP  */
 
-    if (hip_get_opportunistic_tcp_status() &&
-        (ptr = hip_get_param_contents(msg, HIP_PARAM_SRC_TCP_PORT))) {
+    if ((ptr = hip_get_param_contents(msg, HIP_PARAM_SRC_TCP_PORT))) {
         /*get the src tcp port from the message for the TCP SYN
          * i1 packet*/
         HIP_IFEL(!ptr, -1, "No peer port in msg\n");

=== modified file 'hipd/oppdb.h'
--- hipd/oppdb.h        2010-03-19 08:47:02 +0000
+++ hipd/oppdb.h        2010-03-27 14:09:51 +0000
@@ -43,9 +43,6 @@
 typedef struct hip_opp_blocking_request_entry hip_opp_block_t;
 
 void hip_init_opp_db(void);
-//void hip_uninit_opp_db();
-int hip_opptcp_send_tcp_packet(struct hip_common *msg, const struct 
sockaddr_in6 *src);
-int hip_opptcp_unblock_and_blacklist(struct hip_common *msg, const struct 
sockaddr_in6 *src);
 int hip_handle_opp_fallback(hip_opp_block_t *entry,
                             void *current_time);
 hip_opp_block_t *hip_oppdb_find_byhits(const hip_hit_t *phit, struct 
sockaddr_in6 *src);

=== modified file 'hipd/output.c'
--- hipd/output.c       2010-03-25 15:24:20 +0000
+++ hipd/output.c       2010-03-27 14:09:51 +0000
@@ -227,89 +227,6 @@
 }
 
 /**
- * Builds the TCP SYN packet that will be send with the i1 option.
- *
- * Send an I1 packet to the responder if an IPv6 address for the peer
- * is known.
- *
- * @param entry     a pointer to a host association database state reserved for
- *                  the peer. The src and dst ports are included in this 
parameter
- * @return          nothing
- */
-#ifdef CONFIG_HIP_OPPORTUNISTIC
-static void hip_send_opp_tcp_i1(hip_ha_t *entry)
-{
-    int ipType = !IN6_IS_ADDR_V4MAPPED(&entry->peer_addr);
-    struct ip *iphdr = NULL;
-    struct ip6_hdr *ip6_hdr = NULL;
-    struct tcphdr *tcphdr = NULL;
-    int hdr_size = 0;
-    char bytes[sizeof(struct ip) * (1 - ipType) + sizeof(struct ip6_hdr) * 
ipType + 5 * 4];
-
-    HIP_DEBUG("\n");
-
-    if (ipType == 0) {
-        hdr_size = sizeof(struct ip);
-    } else if (ipType == 1) {
-        hdr_size = sizeof(struct ip6_hdr);
-    }
-
-    //set all bytes of both headers to 0
-    memset(&bytes[0], 0, 40);
-
-    //fill in the ip header fields
-    if (ipType == 0) {  //ipv4
-        //get the ip header
-        iphdr         = (struct ip *) (void *) &bytes[0];
-        //get the tcp header
-        tcphdr        = ((struct tcphdr *) (void *) (((char *) iphdr) + 
hdr_size));
-
-        iphdr->ip_v   = 4;
-        iphdr->ip_hl  = 5;
-        iphdr->ip_tos = 0;
-        iphdr->ip_len = 44;        //20+20+4 ?????
-        iphdr->ip_id  = 100;       //random
-        //iphdr->FLAGS
-        iphdr->ip_off = 0;
-        iphdr->ip_ttl = 64;
-        iphdr->ip_p   = 6;
-        iphdr->ip_sum = in_cksum((unsigned short *) iphdr, sizeof(struct ip));
-        IPV6_TO_IPV4_MAP(&entry->our_addr, &iphdr->ip_src);
-        IPV6_TO_IPV4_MAP(&entry->peer_addr, &iphdr->ip_dst);
-    } else if (ipType == 1)    { //ipv6
-        //get the ip header
-        ip6_hdr = (struct ip6_hdr *) (void *) &bytes[0];
-        //get the tcp header
-        tcphdr  = ((struct tcphdr *) (void *) (((char *) ip6_hdr) + hdr_size));
-
-        ip6_hdr->ip6_ctlun.ip6_un1.ip6_un1_flow = 1610612736; 
//01100000000000000000000000000000;
-        ip6_hdr->ip6_ctlun.ip6_un1.ip6_un1_plen = 20;
-        ip6_hdr->ip6_ctlun.ip6_un1.ip6_un1_nxt  = 6;
-        ip6_hdr->ip6_ctlun.ip6_un1.ip6_un1_hlim = 64;
-        memcpy(&ip6_hdr->ip6_src, &entry->our_addr, sizeof(struct in6_addr));
-        memcpy(&ip6_hdr->ip6_dst, &entry->peer_addr, sizeof(struct in6_addr));
-    }
-
-    //randomize the source port to one of 1024-65535
-    //but different from entry->tcp_opptcp_src_port
-    tcphdr->source  = rand() % (65536 - 1024) + 1024; 
//entry->tcp_opptcp_src_port;
-    tcphdr->seq     = 0;
-    tcphdr->ack_seq = 0;    //is not important in the SYN packet
-    tcphdr->doff    = 5;
-    tcphdr->syn     = 1;
-    //tcphdr->rst = 1;
-    tcphdr->window  = 34;   //random
-    tcphdr->check   = 0;  //will be set right when sent, no need to calculate 
it here
-    //tcphdr->urg_ptr = ???????? TO BE FIXED
-    if (ipType == 0) {
-        send_tcp_packet(&bytes[0], hdr_size + 4 * tcphdr->doff, 4, 
hip_raw_sock_output_v4, 1, 0);
-    } else if (ipType == 1) {
-        send_tcp_packet(&bytes[0], hdr_size + 4 * tcphdr->doff, 6, 
hip_raw_sock_output_v6, 1, 0);
-    }
-}
-#endif /* CONFIG_HIP_OPPORTUNISTIC */
-
-/**
  * Send an I1 packet to the Responder. Used internally by hip_send_i1().
  *
  * @param i1         a pointer to a i1 packet common header with source and
@@ -365,16 +282,6 @@
         err = 0;
     }
 
-#ifdef CONFIG_HIP_OPPORTUNISTIC
-    /*send the TCP SYN_i1 packet*/
-    if (hip_get_opportunistic_tcp_status() &&
-        hit_is_opportunistic_hit(dst_hit)) {
-        /* Ensure that I1 gets first to destination */
-        usleep(50);
-        hip_send_opp_tcp_i1(entry);
-    }
-#endif /* CONFIG_HIP_OPPORTUNISTIC */
-
     return err;
 }
 

=== modified file 'lib/conf/hipconf.c'
--- lib/conf/hipconf.c  2010-03-19 14:29:54 +0000
+++ lib/conf/hipconf.c  2010-03-27 14:09:51 +0000
@@ -2291,41 +2291,6 @@
     return err;
 }
 
-/**
- * turn on or off opportunistic TCP extension
- *
- * @param msg input/output message for the query/response for hipd
- * @param action unused
- * @param opt "on" or "off"
- * @param optc 1
- * @param send_only 1 if no response from hipd should be requrested, or 0 if
- *                  should block for a response from hipd
- * @return zero for success and negative on error
- */
-static int hip_conf_handle_opptcp(hip_common_t *msg,
-                                  int action,
-                                  const char *opt[],
-                                  int optc,
-                                  int send_only)
-{
-    int err = 0, status = 0;
-
-    if (!strcmp("on", opt[0])) {
-        status = HIP_MSG_SET_OPPTCP_ON;
-    } else if (!strcmp("off", opt[0])) {
-        status = HIP_MSG_SET_OPPTCP_OFF;
-    } else {
-        HIP_IFEL(1, -1, "bad args\n");
-    }
-    HIP_IFEL(hip_build_user_hdr(msg, status, 0),
-             -1,
-             "Failed to build user message header.: %s\n",
-             strerror(err));
-
-out_err:
-    return err;
-}
-
 static int hip_conf_handle_nsupdate(hip_common_t *msg,
                                     int action,
                                     const char *opt[],
@@ -2670,7 +2635,7 @@
     hip_conf_handle_locator,            /* 20: TYPE_LOCATOR */
     NULL,                               /* 21: unused, was TYPE_SET */
     NULL,                               /* 22: unused, was TYPE_DHT */
-    hip_conf_handle_opptcp,             /* 23: TYPE_OPPTCP */
+    NULL,                               /* 23: unused, was TYPE_OPPTCP */
     hip_conf_handle_trans_order,        /* 24: TYPE_ORDER */
     NULL,                               /* 25: unused, was TYPE_TCPTIMEOUT */
     NULL,                               /* 26: unused, was TYPE_HIPPROXY */

Other related posts:

  • » [hipl-commit] [tiny] Rev 3734: Removed opptcp relicts. - Tim Just