aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-04-03 07:25:02 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-04-03 07:25:02 +0000
commit5b082ff11acb8334d669af3e2d0dbdacb1e9f5aa (patch)
treec104635101079bfca897ab327abb929b0fafcdf4 /src
parent8eb1702f2a5944ebdccae9d9e37b58e6fec290cc (diff)
downloadgnunet-5b082ff11acb8334d669af3e2d0dbdacb1e9f5aa.tar.gz
gnunet-5b082ff11acb8334d669af3e2d0dbdacb1e9f5aa.zip
changes
Diffstat (limited to 'src')
-rw-r--r--src/ats/gnunet-service-ats_addresses.c2
-rw-r--r--src/ats/gnunet-service-ats_addresses_simplistic.c75
2 files changed, 58 insertions, 19 deletions
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c
index 2e662a661..921e93515 100644
--- a/src/ats/gnunet-service-ats_addresses.c
+++ b/src/ats/gnunet-service-ats_addresses.c
@@ -763,7 +763,7 @@ GAS_addresses_add (struct GAS_Addresses_Handle *handle,
763 763
764 /* Do the update */ 764 /* Do the update */
765 ea->session_id = session_id; 765 ea->session_id = session_id;
766 if (GNUNET_YES == disassemble_ats_information(atsi, atsi_count, ea)) 766 if (GNUNET_YES == disassemble_ats_information (atsi, atsi_count, ea))
767 { 767 {
768 GAS_performance_notify_all_clients (&aa->peer, 768 GAS_performance_notify_all_clients (&aa->peer,
769 aa->plugin, 769 aa->plugin,
diff --git a/src/ats/gnunet-service-ats_addresses_simplistic.c b/src/ats/gnunet-service-ats_addresses_simplistic.c
index 039eac7cd..aadd20f2e 100644
--- a/src/ats/gnunet-service-ats_addresses_simplistic.c
+++ b/src/ats/gnunet-service-ats_addresses_simplistic.c
@@ -765,6 +765,31 @@ addresse_decrement (struct GAS_SIMPLISTIC_Handle *s,
765 return res; 765 return res;
766} 766}
767 767
768/**
769 * Extract an ATS performance info from an address
770 *
771 * @param address the address
772 * @param type the type to extract in HBO
773 * @return the value in HBO or UINT32_MAX in HBO if value does not exist
774 */
775
776static int
777get_performance_info (struct ATS_Address *address, uint32_t type)
778{
779 int c1;
780 GNUNET_assert (NULL != address);
781
782 if ((NULL == address->atsi) || (0 == address->atsi_count))
783 return UINT32_MAX;
784
785 for (c1 = 0; c1 < address->atsi_count; c1++)
786 {
787 if (ntohl(address->atsi[c1].type) == type)
788 return ntohl(address->atsi[c1].value);
789 }
790 return UINT32_MAX;
791}
792
768 793
769/** 794/**
770 * Add a single address to the solve 795 * Add a single address to the solve
@@ -779,16 +804,20 @@ GAS_simplistic_address_add (void *solver, struct GNUNET_CONTAINER_MultiHashMap *
779 struct GAS_SIMPLISTIC_Handle *s = solver; 804 struct GAS_SIMPLISTIC_Handle *s = solver;
780 struct Network *net = NULL; 805 struct Network *net = NULL;
781 struct AddressWrapper *aw = NULL; 806 struct AddressWrapper *aw = NULL;
807 uint32_t addr_net;
782 808
783 GNUNET_assert (NULL != s); 809 GNUNET_assert (NULL != s);
784 int c; 810 int c;
811
812 addr_net = get_performance_info (address, GNUNET_ATS_NETWORK_TYPE);
813 if (UINT32_MAX == addr_net)
814 addr_net = GNUNET_ATS_NET_UNSPECIFIED;
815
785 for (c = 0; c < s->networks; c++) 816 for (c = 0; c < s->networks; c++)
786 { 817 {
787 net = &s->network_entries[c]; 818 net = &s->network_entries[c];
788#if 0 819 if (addr_net == net->type)
789 if (address->atsp_network_type == net->type)
790 break; 820 break;
791#endif
792 } 821 }
793 if (NULL == net) 822 if (NULL == net)
794 { 823 {
@@ -919,6 +948,7 @@ GAS_simplistic_address_update (void *solver,
919 int i; 948 int i;
920 uint32_t value; 949 uint32_t value;
921 uint32_t type; 950 uint32_t type;
951 uint32_t addr_net;
922 int save_active = GNUNET_NO; 952 int save_active = GNUNET_NO;
923 struct Network *new_net = NULL; 953 struct Network *new_net = NULL;
924 for (i = 0; i < atsi_count; i++) 954 for (i = 0; i < atsi_count; i++)
@@ -956,13 +986,18 @@ GAS_simplistic_address_update (void *solver,
956 986
957 break; 987 break;
958 case GNUNET_ATS_NETWORK_TYPE: 988 case GNUNET_ATS_NETWORK_TYPE:
959#if 0 989 addr_net = get_performance_info (address, GNUNET_ATS_NETWORK_TYPE);
960 if (address->atsp_network_type != value) 990 if (UINT32_MAX == addr_net)
991 {
992 GNUNET_break (0);
993 addr_net = GNUNET_ATS_NET_UNSPECIFIED;
994 }
995 if (addr_net != value)
961 { 996 {
962 997
963 LOG (GNUNET_ERROR_TYPE_DEBUG, "Network type changed, moving %s address from `%s' to `%s'\n", 998 LOG (GNUNET_ERROR_TYPE_DEBUG, "Network type changed, moving %s address from `%s' to `%s'\n",
964 (GNUNET_YES == address->active) ? "active" : "inactive", 999 (GNUNET_YES == address->active) ? "active" : "inactive",
965 GNUNET_ATS_print_network_type(address->atsp_network_type), 1000 GNUNET_ATS_print_network_type(addr_net),
966 GNUNET_ATS_print_network_type(value)); 1001 GNUNET_ATS_print_network_type(value));
967 1002
968 save_active = address->active; 1003 save_active = address->active;
@@ -970,15 +1005,8 @@ GAS_simplistic_address_update (void *solver,
970 GAS_simplistic_address_delete (solver, addresses, address, GNUNET_NO); 1005 GAS_simplistic_address_delete (solver, addresses, address, GNUNET_NO);
971 1006
972 /* set new network type */ 1007 /* set new network type */
973 address->atsp_network_type = value;
974 new_net = find_network (solver, value); 1008 new_net = find_network (solver, value);
975 address->solver_information = new_net; 1009 address->solver_information = new_net;
976 if (address->solver_information == NULL)
977 {
978 GNUNET_break (0);
979 address->atsp_network_type = GNUNET_ATS_NET_UNSPECIFIED;
980 return;
981 }
982 1010
983 /* Add to new network and update*/ 1011 /* Add to new network and update*/
984 GAS_simplistic_address_add (solver, addresses, address); 1012 GAS_simplistic_address_add (solver, addresses, address);
@@ -1012,7 +1040,7 @@ GAS_simplistic_address_update (void *solver,
1012 } 1040 }
1013 } 1041 }
1014 } 1042 }
1015#endif 1043
1016 break; 1044 break;
1017 case GNUNET_ATS_ARRAY_TERMINATOR: 1045 case GNUNET_ATS_ARRAY_TERMINATOR:
1018 break; 1046 break;
@@ -1060,6 +1088,10 @@ find_address_it (void *cls, const struct GNUNET_HashCode * key, void *value)
1060 struct ATS_Address *previous = *previous_p; 1088 struct ATS_Address *previous = *previous_p;
1061 struct GNUNET_TIME_Absolute now; 1089 struct GNUNET_TIME_Absolute now;
1062 struct Network *net = (struct Network *) current->solver_information; 1090 struct Network *net = (struct Network *) current->solver_information;
1091 uint32_t p_distance_cur;
1092 uint32_t p_distance_prev;
1093 uint32_t p_delay_cur;
1094 uint32_t p_delay_prev;
1063 1095
1064 now = GNUNET_TIME_absolute_get(); 1096 now = GNUNET_TIME_absolute_get();
1065 1097
@@ -1108,20 +1140,27 @@ find_address_it (void *cls, const struct GNUNET_HashCode * key, void *value)
1108 *previous_p = current; 1140 *previous_p = current;
1109 return GNUNET_OK; 1141 return GNUNET_OK;
1110 } 1142 }
1111#if 0 1143
1112 if (previous->atsp_distance > current->atsp_distance) 1144 p_distance_prev = get_performance_info (previous, GNUNET_ATS_QUALITY_NET_DISTANCE);
1145 p_distance_cur = get_performance_info (current, GNUNET_ATS_QUALITY_NET_DISTANCE);
1146 if ((p_distance_prev != UINT32_MAX) && (p_distance_cur != UINT32_MAX) &&
1147 (p_distance_prev > p_distance_cur))
1113 { 1148 {
1114 /* user shorter distance */ 1149 /* user shorter distance */
1115 *previous_p = current; 1150 *previous_p = current;
1116 return GNUNET_OK; 1151 return GNUNET_OK;
1117 } 1152 }
1118 if (previous->atsp_latency.rel_value > current->atsp_latency.rel_value) 1153
1154 p_delay_prev = get_performance_info (previous, GNUNET_ATS_QUALITY_NET_DELAY);
1155 p_delay_cur = get_performance_info (current, GNUNET_ATS_QUALITY_NET_DELAY);
1156 if ((p_delay_prev != UINT32_MAX) && (p_delay_cur != UINT32_MAX) &&
1157 (p_delay_prev > p_delay_cur))
1119 { 1158 {
1120 /* user lower latency */ 1159 /* user lower latency */
1121 *previous_p = current; 1160 *previous_p = current;
1122 return GNUNET_OK; 1161 return GNUNET_OK;
1123 } 1162 }
1124#endif 1163
1125 /* don't care */ 1164 /* don't care */
1126 return GNUNET_OK; 1165 return GNUNET_OK;
1127} 1166}