diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-10-22 21:59:27 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-10-22 21:59:27 +0000 |
commit | f44c0036572d5557d2496748a4190a61e40e61ff (patch) | |
tree | bceb908e8542883ed246f96b4c619c0c49a06782 /src/core/core_api.c | |
parent | 9d87d51965287d83ee332b8c50baff95bd62649a (diff) | |
download | gnunet-f44c0036572d5557d2496748a4190a61e40e61ff.tar.gz gnunet-f44c0036572d5557d2496748a4190a61e40e61ff.zip |
replacing 0-terminated atsi-array with array+length in core API (and the core-connect IPC)
Diffstat (limited to 'src/core/core_api.c')
-rw-r--r-- | src/core/core_api.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/core/core_api.c b/src/core/core_api.c index b903d73bb..3349f79ab 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c | |||
@@ -781,6 +781,7 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
781 | const struct GNUNET_MessageHeader *em; | 781 | const struct GNUNET_MessageHeader *em; |
782 | const struct SendMessageReady *smr; | 782 | const struct SendMessageReady *smr; |
783 | const struct GNUNET_CORE_MessageHandler *mh; | 783 | const struct GNUNET_CORE_MessageHandler *mh; |
784 | const struct GNUNET_ATS_Information* ats; | ||
784 | GNUNET_CORE_StartupCallback init; | 785 | GNUNET_CORE_StartupCallback init; |
785 | struct PeerRecord *pr; | 786 | struct PeerRecord *pr; |
786 | struct GNUNET_CORE_TransmitHandle *th; | 787 | struct GNUNET_CORE_TransmitHandle *th; |
@@ -851,7 +852,7 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
851 | &h->me.hashPubKey, pr, | 852 | &h->me.hashPubKey, pr, |
852 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); | 853 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); |
853 | if (NULL != h->connects) | 854 | if (NULL != h->connects) |
854 | h->connects (h->cls, &h->me, NULL); | 855 | h->connects (h->cls, &h->me, NULL, 0); |
855 | break; | 856 | break; |
856 | case GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT: | 857 | case GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT: |
857 | if (msize < sizeof (struct ConnectNotifyMessage)) | 858 | if (msize < sizeof (struct ConnectNotifyMessage)) |
@@ -862,11 +863,9 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
862 | } | 863 | } |
863 | cnm = (const struct ConnectNotifyMessage *) msg; | 864 | cnm = (const struct ConnectNotifyMessage *) msg; |
864 | ats_count = ntohl (cnm->ats_count); | 865 | ats_count = ntohl (cnm->ats_count); |
865 | if ((msize != | 866 | if (msize != |
866 | sizeof (struct ConnectNotifyMessage) + | 867 | sizeof (struct ConnectNotifyMessage) + |
867 | ats_count * sizeof (struct GNUNET_ATS_Information)) || | 868 | ats_count * sizeof (struct GNUNET_ATS_Information)) |
868 | (GNUNET_ATS_ARRAY_TERMINATOR != | ||
869 | ntohl ((&cnm->ats)[ats_count].type))) | ||
870 | { | 869 | { |
871 | GNUNET_break (0); | 870 | GNUNET_break (0); |
872 | reconnect_later (h); | 871 | reconnect_later (h); |
@@ -897,8 +896,11 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
897 | GNUNET_CONTAINER_multihashmap_put (h->peers, | 896 | GNUNET_CONTAINER_multihashmap_put (h->peers, |
898 | &cnm->peer.hashPubKey, pr, | 897 | &cnm->peer.hashPubKey, pr, |
899 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); | 898 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); |
899 | ats = (const struct GNUNET_ATS_Information*) &cnm[1]; | ||
900 | if (NULL != h->connects) | 900 | if (NULL != h->connects) |
901 | h->connects (h->cls, &cnm->peer, &cnm->ats); | 901 | h->connects (h->cls, &cnm->peer, |
902 | ats, | ||
903 | ats_count); | ||
902 | break; | 904 | break; |
903 | case GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT: | 905 | case GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT: |
904 | if (msize != sizeof (struct DisconnectNotifyMessage)) | 906 | if (msize != sizeof (struct DisconnectNotifyMessage)) |
@@ -988,14 +990,16 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
988 | continue; | 990 | continue; |
989 | } | 991 | } |
990 | if (GNUNET_OK != | 992 | if (GNUNET_OK != |
991 | h->handlers[hpos].callback (h->cls, &ntm->peer, em, &ntm->ats)) | 993 | h->handlers[hpos].callback (h->cls, &ntm->peer, em, &ntm->ats, |
994 | ats_count)) | ||
992 | { | 995 | { |
993 | /* error in processing, do not process other messages! */ | 996 | /* error in processing, do not process other messages! */ |
994 | break; | 997 | break; |
995 | } | 998 | } |
996 | } | 999 | } |
997 | if (NULL != h->inbound_notify) | 1000 | if (NULL != h->inbound_notify) |
998 | h->inbound_notify (h->cls, &ntm->peer, em, &ntm->ats); | 1001 | h->inbound_notify (h->cls, &ntm->peer, em, &ntm->ats, |
1002 | ats_count); | ||
999 | break; | 1003 | break; |
1000 | case GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND: | 1004 | case GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND: |
1001 | if (msize < sizeof (struct NotifyTrafficMessage)) | 1005 | if (msize < sizeof (struct NotifyTrafficMessage)) |
@@ -1050,7 +1054,7 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
1050 | GNUNET_break (0); | 1054 | GNUNET_break (0); |
1051 | break; | 1055 | break; |
1052 | } | 1056 | } |
1053 | h->outbound_notify (h->cls, &ntm->peer, em, &ntm->ats); | 1057 | h->outbound_notify (h->cls, &ntm->peer, em, &ntm->ats, ats_count); |
1054 | break; | 1058 | break; |
1055 | case GNUNET_MESSAGE_TYPE_CORE_SEND_READY: | 1059 | case GNUNET_MESSAGE_TYPE_CORE_SEND_READY: |
1056 | if (msize != sizeof (struct SendMessageReady)) | 1060 | if (msize != sizeof (struct SendMessageReady)) |