[pisa-src] r1786 - trunk/pisacd/cdtun.c

  • From: Thomas Jansen <mithi@xxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Thu, 26 Nov 2009 12:08:43 +0100

Author: tjansen
Date: Thu Nov 26 12:08:43 2009
New Revision: 1786

Log:
Save one level of indentation.

Modified:
   trunk/pisacd/cdtun.c

Modified: trunk/pisacd/cdtun.c
==============================================================================
--- trunk/pisacd/cdtun.c        Wed Nov 25 16:27:16 2009        (r1785)
+++ trunk/pisacd/cdtun.c        Thu Nov 26 12:08:43 2009        (r1786)
@@ -51,45 +51,46 @@
 
        /* Check if we have an active connection with the origin */
        entry = pisa_conmgr_findby_hit(cd_ctx.conlist, &from.sin6_addr);
-       if (entry != NULL) {
-               if (entry->status != PISA_CON_CONNECTED) {
-                       PISA_DEBUG(PL_DATA, "Discarding data from a server that 
is not in CONNECTED state!\n");
-                       return;
-               }
-
-               if (entry->data_port != (int)ntohs(from.sin6_port)) {
-                       PISA_DEBUG(PL_DATA, "Discarding data from the wrong 
port!\n");
-                       return;
-               }
+       if (!entry) {
+               inet_ntop(AF_INET6, &(from.sin6_addr), buffer, sizeof(buffer));
+               PISA_DEBUG(PL_DATA, "remote -> local: from unknown server 
%s\n", buffer);
+               return;
+       }
 
-               /* Check for IPv4 in the payload, otherwise drop it */
-               if ((hdr = pisa_nat_get_iphdr(buffer)) == NULL)
-                       return;
+       if (entry->status != PISA_CON_CONNECTED) {
+               PISA_DEBUG(PL_DATA, "Discarding data from a server that is not 
in CONNECTED state!\n");
+               return;
+       }
 
-               /* Apply NAT if needed */
-               srcaddr = (struct in_addr *)&hdr->ip_src;
-               map = pisa_nat_mapping_find_by_remote(cd_ctx.natlist, 
&from.sin6_addr, srcaddr);
-               if (map != NULL)
-                       pisa_nat_apply(hdr, srcaddr, &map->local_private);
-
-               /* Send the packet out to the tunnel device */
-               if (write(cd_ctx.fd_tunnel, buffer + 6, len - 6) == -1) {
-                       PISA_ERROR("remote -> local: write failed: %s\n", 
strerror(errno));
-               } else {
-                       /* Sending a heartbeat at the next scheduled time is
-                        * unnecessary, we already sent some payload. */
-                       entry->heartbeat_flag = 1;
+       if (entry->data_port != (int)ntohs(from.sin6_port)) {
+               PISA_DEBUG(PL_DATA, "Discarding data from the wrong port!\n");
+               return;
+       }
 
-                       /* Keep track of the last time this connection was
-                        * used. Disconnect after a timeout to save
-                        * resources. */
-                       entry->timeout_flag = 1;
+       /* Check for IPv4 in the payload, otherwise drop it */
+       if ((hdr = pisa_nat_get_iphdr(buffer)) == NULL)
+               return;
 
-                       PISA_DEBUG(PL_DATA, "remote -> local: %i bytes\n", len 
- 6);
-               }
+       /* Apply NAT if needed */
+       srcaddr = (struct in_addr *)&hdr->ip_src;
+       map = pisa_nat_mapping_find_by_remote(cd_ctx.natlist, &from.sin6_addr, 
srcaddr);
+       if (map != NULL)
+               pisa_nat_apply(hdr, srcaddr, &map->local_private);
+
+       /* Send the packet out to the tunnel device */
+       if (write(cd_ctx.fd_tunnel, buffer + 6, len - 6) == -1) {
+               PISA_ERROR("remote -> local: write failed: %s\n", 
strerror(errno));
        } else {
-               inet_ntop(AF_INET6, &(from.sin6_addr), buffer, sizeof(buffer));
-               PISA_DEBUG(PL_DATA, "remote -> local: from unknown server 
%s\n", buffer);
+               /* Sending a heartbeat at the next scheduled time is
+                * unnecessary, we already sent some payload. */
+               entry->heartbeat_flag = 1;
+
+               /* Keep track of the last time this connection was
+                * used. Disconnect after a timeout to save
+                * resources. */
+               entry->timeout_flag = 1;
+
+               PISA_DEBUG(PL_DATA, "remote -> local: %i bytes\n", len - 6);
        }
 }
 

Other related posts:

  • » [pisa-src] r1786 - trunk/pisacd/cdtun.c - Thomas Jansen