aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-02-23 10:28:44 +0000
committerChristian Grothoff <christian@grothoff.org>2010-02-23 10:28:44 +0000
commit5f06d8083398fcc74314b7a7c238b902d9be68c4 (patch)
treeac8fecba964b16e265c6db1f342a38712f274b27
parentc30d9ea5af167ff86db1a9ddba435ebc333c46fb (diff)
downloadgnunet-5f06d8083398fcc74314b7a7c238b902d9be68c4.tar.gz
gnunet-5f06d8083398fcc74314b7a7c238b902d9be68c4.zip
fix endianess conversion
-rw-r--r--src/core/gnunet-service-core.c49
1 files changed, 36 insertions, 13 deletions
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c
index fbd1f46ed..2ba255394 100644
--- a/src/core/gnunet-service-core.c
+++ b/src/core/gnunet-service-core.c
@@ -584,7 +584,7 @@ struct Client
584 * about (with "tcnt" entries). Allocated as part 584 * about (with "tcnt" entries). Allocated as part
585 * of this client struct, do not free! 585 * of this client struct, do not free!
586 */ 586 */
587 uint16_t *types; 587 const uint16_t *types;
588 588
589 /** 589 /**
590 * Options for messages this client cares about, 590 * Options for messages this client cares about,
@@ -816,8 +816,10 @@ handle_client_init (void *cls,
816 struct Client *c; 816 struct Client *c;
817 uint16_t msize; 817 uint16_t msize;
818 const uint16_t *types; 818 const uint16_t *types;
819 uint16_t *wtypes;
819 struct Neighbour *n; 820 struct Neighbour *n;
820 struct ConnectNotifyMessage cnm; 821 struct ConnectNotifyMessage cnm;
822 unsigned int i;
821 823
822#if DEBUG_CORE_CLIENT 824#if DEBUG_CORE_CLIENT
823 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 825 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -851,10 +853,15 @@ handle_client_init (void *cls,
851 c->client_handle = client; 853 c->client_handle = client;
852 c->next = clients; 854 c->next = clients;
853 clients = c; 855 clients = c;
854 memcpy (&c[1], types, msize);
855 c->types = (uint16_t *) & c[1];
856 c->options = ntohl (im->options);
857 c->tcnt = msize / sizeof (uint16_t); 856 c->tcnt = msize / sizeof (uint16_t);
857 c->types = (const uint16_t *) &c[1];
858 wtypes = (uint16_t *) &c[1];
859 for (i=0;i<c->tcnt;i++)
860 wtypes[i] = ntohs (types[i]);
861 c->options = ntohl (im->options);
862 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
863 "Client %p is interested in %u message types\n",
864 c->tcnt);
858 /* send init reply message */ 865 /* send init reply message */
859 irm.header.size = htons (sizeof (struct InitReplyMessage)); 866 irm.header.size = htons (sizeof (struct InitReplyMessage));
860 irm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY); 867 irm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_INIT_REPLY);
@@ -906,7 +913,8 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
906 return; 913 return;
907#if DEBUG_CORE_CLIENT 914#if DEBUG_CORE_CLIENT
908 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 915 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
909 "Client has disconnected from core service.\n"); 916 "Client %p has disconnected from core service.\n",
917 client);
910#endif 918#endif
911 prev = NULL; 919 prev = NULL;
912 pos = clients; 920 pos = clients;
@@ -2777,14 +2785,16 @@ deliver_message (struct Neighbour *sender,
2777 uint16_t type; 2785 uint16_t type;
2778 unsigned int tpos; 2786 unsigned int tpos;
2779 int deliver_full; 2787 int deliver_full;
2788 int dropped;
2780 2789
2781 type = ntohs (m->type); 2790 type = ntohs (m->type);
2782#if DEBUG_HANDSHAKE 2791#if DEBUG_CORE
2783 fprintf (stderr, 2792 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2784 "Received encapsulated message of type %u from `%4s'\n", 2793 "Received encapsulated message of type %u from `%4s'\n",
2785 type, 2794 type,
2786 GNUNET_i2s (&sender->peer)); 2795 GNUNET_i2s (&sender->peer));
2787#endif 2796#endif
2797 dropped = GNUNET_YES;
2788 cpos = clients; 2798 cpos = clients;
2789 while (cpos != NULL) 2799 while (cpos != NULL)
2790 { 2800 {
@@ -2802,12 +2812,25 @@ deliver_message (struct Neighbour *sender,
2802 } 2812 }
2803 } 2813 }
2804 if (GNUNET_YES == deliver_full) 2814 if (GNUNET_YES == deliver_full)
2805 send_p2p_message_to_client (sender, cpos, m, msize); 2815 {
2816 send_p2p_message_to_client (sender, cpos, m, msize);
2817 dropped = GNUNET_NO;
2818 }
2806 else if (cpos->options & GNUNET_CORE_OPTION_SEND_HDR_INBOUND) 2819 else if (cpos->options & GNUNET_CORE_OPTION_SEND_HDR_INBOUND)
2807 send_p2p_message_to_client (sender, cpos, m, 2820 {
2808 sizeof (struct GNUNET_MessageHeader)); 2821 send_p2p_message_to_client (sender, cpos, m,
2822 sizeof (struct GNUNET_MessageHeader));
2823 }
2809 cpos = cpos->next; 2824 cpos = cpos->next;
2810 } 2825 }
2826 if (dropped == GNUNET_YES)
2827 {
2828 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2829 "Message of type %u from `%4s' not delivered to any client.\n",
2830 type,
2831 GNUNET_i2s (&sender->peer));
2832 /* FIXME: stats... */
2833 }
2811} 2834}
2812 2835
2813 2836