diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-02-10 23:24:01 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-02-10 23:24:01 +0000 |
commit | 1c323bd4cbb388a9e7515a1f733a3062bf093aee (patch) | |
tree | 7cc525d79149d44840b9f7a0040aaf3e69ecd665 /src/ats/gnunet-service-ats_performance.c | |
parent | aedaaed687db1ff20b447378f01ad7306921450c (diff) | |
download | gnunet-1c323bd4cbb388a9e7515a1f733a3062bf093aee.tar.gz gnunet-1c323bd4cbb388a9e7515a1f733a3062bf093aee.zip |
fixing #3657 (replace ATS_Information with struct), but WIHTOUT fixing ATS testcases yet
Diffstat (limited to 'src/ats/gnunet-service-ats_performance.c')
-rw-r--r-- | src/ats/gnunet-service-ats_performance.c | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/src/ats/gnunet-service-ats_performance.c b/src/ats/gnunet-service-ats_performance.c index 0f17f0bec..c3d9e78eb 100644 --- a/src/ats/gnunet-service-ats_performance.c +++ b/src/ats/gnunet-service-ats_performance.c | |||
@@ -54,8 +54,7 @@ static struct GNUNET_SERVER_NotificationContext *nc_pic; | |||
54 | * to maintain a connection to a peer; | 54 | * to maintain a connection to a peer; |
55 | * #GNUNET_NO if the address is not actively used; | 55 | * #GNUNET_NO if the address is not actively used; |
56 | * #GNUNET_SYSERR if this address is no longer available for ATS | 56 | * #GNUNET_SYSERR if this address is no longer available for ATS |
57 | * @param atsi performance data for the address | 57 | * @param prop performance data for the address |
58 | * @param atsi_count number of performance records in @a atsi | ||
59 | * @param bandwidth_out assigned outbound bandwidth | 58 | * @param bandwidth_out assigned outbound bandwidth |
60 | * @param bandwidth_in assigned inbound bandwidth | 59 | * @param bandwidth_in assigned inbound bandwidth |
61 | */ | 60 | */ |
@@ -66,40 +65,34 @@ notify_client (struct GNUNET_SERVER_Client *client, | |||
66 | const void *plugin_addr, | 65 | const void *plugin_addr, |
67 | size_t plugin_addr_len, | 66 | size_t plugin_addr_len, |
68 | int active, | 67 | int active, |
69 | const struct GNUNET_ATS_Information *atsi, | 68 | const struct GNUNET_ATS_Properties *prop, |
70 | uint32_t atsi_count, | ||
71 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 69 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
72 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) | 70 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) |
73 | { | 71 | { |
74 | struct PeerInformationMessage *msg; | 72 | struct PeerInformationMessage *msg; |
75 | size_t plugin_name_length = strlen (plugin_name) + 1; | 73 | size_t plugin_name_length = strlen (plugin_name) + 1; |
76 | size_t msize = | 74 | size_t msize = |
77 | sizeof (struct PeerInformationMessage) + | 75 | sizeof (struct PeerInformationMessage) + |
78 | atsi_count * sizeof (struct GNUNET_ATS_Information) + plugin_addr_len + | 76 | plugin_addr_len + |
79 | plugin_name_length; | 77 | plugin_name_length; |
80 | char buf[msize] GNUNET_ALIGN; | 78 | char buf[msize] GNUNET_ALIGN; |
81 | struct GNUNET_ATS_Information *atsp; | ||
82 | struct GNUNET_SERVER_NotificationContext *nc; | 79 | struct GNUNET_SERVER_NotificationContext *nc; |
83 | char *addrp; | 80 | char *addrp; |
84 | 81 | ||
85 | GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE); | 82 | GNUNET_assert (msize < GNUNET_SERVER_MAX_MESSAGE_SIZE); |
86 | GNUNET_assert (atsi_count < | ||
87 | GNUNET_SERVER_MAX_MESSAGE_SIZE / | ||
88 | sizeof (struct GNUNET_ATS_Information)); | ||
89 | msg = (struct PeerInformationMessage *) buf; | 83 | msg = (struct PeerInformationMessage *) buf; |
90 | msg->header.size = htons (msize); | 84 | msg->header.size = htons (msize); |
91 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION); | 85 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_ATS_PEER_INFORMATION); |
92 | msg->id = htonl (0); | 86 | msg->id = htonl (0); |
93 | msg->ats_count = htonl (atsi_count); | ||
94 | msg->peer = *peer; | 87 | msg->peer = *peer; |
95 | msg->address_length = htons (plugin_addr_len); | 88 | msg->address_length = htons (plugin_addr_len); |
96 | msg->address_active = ntohl ((uint32_t) active); | 89 | msg->address_active = ntohl ((uint32_t) active); |
97 | msg->plugin_name_length = htons (plugin_name_length); | 90 | msg->plugin_name_length = htons (plugin_name_length); |
98 | msg->bandwidth_out = bandwidth_out; | 91 | msg->bandwidth_out = bandwidth_out; |
99 | msg->bandwidth_in = bandwidth_in; | 92 | msg->bandwidth_in = bandwidth_in; |
100 | atsp = (struct GNUNET_ATS_Information *) &msg[1]; | 93 | GNUNET_ATS_properties_hton (&msg->properties, |
101 | memcpy (atsp, atsi, sizeof (struct GNUNET_ATS_Information) * atsi_count); | 94 | prop); |
102 | addrp = (char *) &atsp[atsi_count]; | 95 | addrp = (char *) &msg[1]; |
103 | memcpy (addrp, plugin_addr, plugin_addr_len); | 96 | memcpy (addrp, plugin_addr, plugin_addr_len); |
104 | strcpy (&addrp[plugin_addr_len], plugin_name); | 97 | strcpy (&addrp[plugin_addr_len], plugin_name); |
105 | if (NULL == client) | 98 | if (NULL == client) |
@@ -137,8 +130,7 @@ notify_client (struct GNUNET_SERVER_Client *client, | |||
137 | * to maintain a connection to a peer; | 130 | * to maintain a connection to a peer; |
138 | * #GNUNET_NO if the address is not actively used; | 131 | * #GNUNET_NO if the address is not actively used; |
139 | * #GNUNET_SYSERR if this address is no longer available for ATS | 132 | * #GNUNET_SYSERR if this address is no longer available for ATS |
140 | * @param atsi performance data for the address | 133 | * @param prop performance data for the address |
141 | * @param atsi_count number of performance records in @a atsi | ||
142 | * @param bandwidth_out assigned outbound bandwidth | 134 | * @param bandwidth_out assigned outbound bandwidth |
143 | * @param bandwidth_in assigned inbound bandwidth | 135 | * @param bandwidth_in assigned inbound bandwidth |
144 | */ | 136 | */ |
@@ -148,8 +140,7 @@ GAS_performance_notify_all_clients (const struct GNUNET_PeerIdentity *peer, | |||
148 | const void *plugin_addr, | 140 | const void *plugin_addr, |
149 | size_t plugin_addr_len, | 141 | size_t plugin_addr_len, |
150 | int active, | 142 | int active, |
151 | const struct GNUNET_ATS_Information *atsi, | 143 | const struct GNUNET_ATS_Properties *prop, |
152 | uint32_t atsi_count, | ||
153 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 144 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
154 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) | 145 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) |
155 | { | 146 | { |
@@ -159,7 +150,7 @@ GAS_performance_notify_all_clients (const struct GNUNET_PeerIdentity *peer, | |||
159 | plugin_addr, | 150 | plugin_addr, |
160 | plugin_addr_len, | 151 | plugin_addr_len, |
161 | active, | 152 | active, |
162 | atsi, atsi_count, | 153 | prop, |
163 | bandwidth_out, | 154 | bandwidth_out, |
164 | bandwidth_in); | 155 | bandwidth_in); |
165 | GNUNET_STATISTICS_update (GSA_stats, | 156 | GNUNET_STATISTICS_update (GSA_stats, |
@@ -178,8 +169,7 @@ GAS_performance_notify_all_clients (const struct GNUNET_PeerIdentity *peer, | |||
178 | * @param plugin_addr address | 169 | * @param plugin_addr address |
179 | * @param plugin_addr_len length of @a plugin_addr | 170 | * @param plugin_addr_len length of @a plugin_addr |
180 | * @param active is address actively used | 171 | * @param active is address actively used |
181 | * @param atsi ats performance information | 172 | * @param prop performance information |
182 | * @param atsi_count number of ats performance elements in @a atsi | ||
183 | * @param bandwidth_out current outbound bandwidth assigned to address | 173 | * @param bandwidth_out current outbound bandwidth assigned to address |
184 | * @param bandwidth_in current inbound bandwidth assigned to address | 174 | * @param bandwidth_in current inbound bandwidth assigned to address |
185 | */ | 175 | */ |
@@ -190,8 +180,7 @@ peerinfo_it (void *cls, | |||
190 | const void *plugin_addr, | 180 | const void *plugin_addr, |
191 | size_t plugin_addr_len, | 181 | size_t plugin_addr_len, |
192 | int active, | 182 | int active, |
193 | const struct GNUNET_ATS_Information *atsi, | 183 | const struct GNUNET_ATS_Properties *prop, |
194 | uint32_t atsi_count, | ||
195 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, | 184 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, |
196 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) | 185 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) |
197 | { | 186 | { |
@@ -211,7 +200,7 @@ peerinfo_it (void *cls, | |||
211 | plugin_addr, | 200 | plugin_addr, |
212 | plugin_addr_len, | 201 | plugin_addr_len, |
213 | active, | 202 | active, |
214 | atsi, atsi_count, | 203 | prop, |
215 | bandwidth_out, | 204 | bandwidth_out, |
216 | bandwidth_in); | 205 | bandwidth_in); |
217 | } | 206 | } |