[pisa-src] r1815 - in trunk/pairing: packet_handler_send.c packet_handler_send.h

  • From: Diego Biurrun <diego@xxxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Thu, 26 Nov 2009 15:23:57 +0100

Author: biurrun
Date: Thu Nov 26 15:23:57 2009
New Revision: 1815

Log:
Reorder functions to avoid forward declarations.

Modified:
   trunk/pairing/packet_handler_send.c
   trunk/pairing/packet_handler_send.h

Modified: trunk/pairing/packet_handler_send.c
==============================================================================
--- trunk/pairing/packet_handler_send.c Thu Nov 26 15:18:51 2009        (r1814)
+++ trunk/pairing/packet_handler_send.c Thu Nov 26 15:23:57 2009        (r1815)
@@ -12,60 +12,6 @@
 
 #include "packet_handler_send.h"
 
-/** Handles an ack_1 packet
- *
- *  @param socket_addr Pointer to sockaddr_in6 structure connected to peer.
- *  @param hdr_ack_1 Pointer to the header_ack_1 structure
- * 
- *  @return -1 on failure; 0 if no IP addresses sent; 1 if only IPv4 address 
sent; 2 if only IPv6 address sent; 3 if both addresses sent
- */
-int handle_packet_ack_1(struct sockaddr_in6 *socket_addr, header_ack_1 
*hdr_ack_1)
-{
-        int has_ipv4 = 0;
-        int has_ipv6 = 0;
-        char hit[INET6_ADDRSTRLEN];
-
-        assert(socket_addr != NULL);
-        assert(hdr_ack_1 != NULL);
-
-        // Show the addresses
-        DEBUG_HIGH("IPv4 address: %s", hdr_ack_1->ipv4_addr);
-        DEBUG_HIGH("IPv6 address: %s", hdr_ack_1->ipv6_addr);
-
-        // Test to see if the addresses were included
-        has_ipv4 = hdr_ack_1->ipv4_addr[0] ? 1 : 0;
-        has_ipv6 = hdr_ack_1->ipv6_addr[0] ? 1 : 0;
-
-        inet_ntop(AF_INET6, &(socket_addr->sin6_addr), hit, sizeof(hit));
-
-        // Write out addresses (somewhere) if we don't already know this relay
-        if (!global_send.nickname_given)
-                store_relay_info((char*)hdr_ack_1->nickname, hit, 
(char*)hdr_ack_1->ipv4_addr, (char*)hdr_ack_1->ipv6_addr);
-        // Return a value indicating which addrs were received
-        // 0 = none; 1 = ipv4; 2 = ipv6; 3 = both
-        return has_ipv4*1 + has_ipv6*2;
-}
-
-
-
-/** Handles an ACK 2 packet.
- *
- *  @param socket_addr Pointer to sockaddr_in6 structure connected to peer.
- *  @param hdr_ack_2 Pointer to the header_pwd_request structure.
- *
- *  @return 1 if password is of nonzero length; 0 otherwise
- */
-int handle_packet_ack_2(struct sockaddr_in6 *socket_addr, header_ack_2 
*hdr_ack_2)
-{
-        assert(socket_addr != NULL);
-        assert(hdr_ack_2 != NULL);
-
-        USER_MSG("Password for your friend: %s", hdr_ack_2->password);
-
-        return (strlen((char*)hdr_ack_2->password) > 0);
-}
-
-
 
 /** Stores the contact information of a relay in FILE_KNOWN_RELAYS.
  *
@@ -199,3 +145,55 @@
         return 1;
 }
 
+/** Handles an ack_1 packet
+ *
+ *  @param socket_addr Pointer to sockaddr_in6 structure connected to peer.
+ *  @param hdr_ack_1 Pointer to the header_ack_1 structure
+ * 
+ *  @return -1 on failure; 0 if no IP addresses sent; 1 if only IPv4 address 
sent; 2 if only IPv6 address sent; 3 if both addresses sent
+ */
+int handle_packet_ack_1(struct sockaddr_in6 *socket_addr, header_ack_1 
*hdr_ack_1)
+{
+        int has_ipv4 = 0;
+        int has_ipv6 = 0;
+        char hit[INET6_ADDRSTRLEN];
+
+        assert(socket_addr != NULL);
+        assert(hdr_ack_1 != NULL);
+
+        // Show the addresses
+        DEBUG_HIGH("IPv4 address: %s", hdr_ack_1->ipv4_addr);
+        DEBUG_HIGH("IPv6 address: %s", hdr_ack_1->ipv6_addr);
+
+        // Test to see if the addresses were included
+        has_ipv4 = hdr_ack_1->ipv4_addr[0] ? 1 : 0;
+        has_ipv6 = hdr_ack_1->ipv6_addr[0] ? 1 : 0;
+
+        inet_ntop(AF_INET6, &(socket_addr->sin6_addr), hit, sizeof(hit));
+
+        // Write out addresses (somewhere) if we don't already know this relay
+        if (!global_send.nickname_given)
+                store_relay_info((char*)hdr_ack_1->nickname, hit, 
(char*)hdr_ack_1->ipv4_addr, (char*)hdr_ack_1->ipv6_addr);
+        // Return a value indicating which addrs were received
+        // 0 = none; 1 = ipv4; 2 = ipv6; 3 = both
+        return has_ipv4*1 + has_ipv6*2;
+}
+
+
+
+/** Handles an ACK 2 packet.
+ *
+ *  @param socket_addr Pointer to sockaddr_in6 structure connected to peer.
+ *  @param hdr_ack_2 Pointer to the header_pwd_request structure.
+ *
+ *  @return 1 if password is of nonzero length; 0 otherwise
+ */
+int handle_packet_ack_2(struct sockaddr_in6 *socket_addr, header_ack_2 
*hdr_ack_2)
+{
+        assert(socket_addr != NULL);
+        assert(hdr_ack_2 != NULL);
+
+        USER_MSG("Password for your friend: %s", hdr_ack_2->password);
+
+        return (strlen((char*)hdr_ack_2->password) > 0);
+}

Modified: trunk/pairing/packet_handler_send.h
==============================================================================
--- trunk/pairing/packet_handler_send.h Thu Nov 26 15:18:51 2009        (r1814)
+++ trunk/pairing/packet_handler_send.h Thu Nov 26 15:23:57 2009        (r1815)
@@ -22,6 +22,5 @@
 // Function prototypes
 int handle_packet_ack_1(struct sockaddr_in6 *socket_addr, header_ack_1 
*hdr_ack_1);
 int handle_packet_ack_2(struct sockaddr_in6 *socket_addr, header_ack_2 
*hdr_ack_2);
-int store_relay_info(char *nickname, char *hit, char *ipv4_addr, char 
*ipv6_addr);
 
 #endif /* PISA_PACKET_HANDLER_SEND_H */

Other related posts:

  • » [pisa-src] r1815 - in trunk/pairing: packet_handler_send.c packet_handler_send.h - Diego Biurrun