aboutsummaryrefslogtreecommitdiff
path: root/src/ats/ats_api_scheduling.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-01-17 21:31:48 +0000
committerChristian Grothoff <christian@grothoff.org>2015-01-17 21:31:48 +0000
commitc76f29f898f6b1a73f33ce6d2578e06ce8e0a24e (patch)
tree4d9fbf87fa9d65b8b966b51739af96205943be8f /src/ats/ats_api_scheduling.c
parentf6323d915af7494ecfeba39407d1c30dc06dc238 (diff)
downloadgnunet-c76f29f898f6b1a73f33ce6d2578e06ce8e0a24e.tar.gz
gnunet-c76f29f898f6b1a73f33ce6d2578e06ce8e0a24e.zip
use ATS functions to convert quality network type to string, instead of using string API
Diffstat (limited to 'src/ats/ats_api_scheduling.c')
-rw-r--r--src/ats/ats_api_scheduling.c80
1 files changed, 59 insertions, 21 deletions
diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c
index 6bb595391..4cf48d761 100644
--- a/src/ats/ats_api_scheduling.c
+++ b/src/ats/ats_api_scheduling.c
@@ -77,7 +77,7 @@ struct SessionRecord
77 struct Session *session; 77 struct Session *session;
78 78
79 /** 79 /**
80 * Set to GNUNET_YES if the slot is used. 80 * Set to #GNUNET_YES if the slot is used.
81 */ 81 */
82 int slot_used; 82 int slot_used;
83}; 83};
@@ -122,7 +122,7 @@ struct GNUNET_ATS_SchedulingHandle
122 GNUNET_ATS_AddressSuggestionCallback suggest_cb; 122 GNUNET_ATS_AddressSuggestionCallback suggest_cb;
123 123
124 /** 124 /**
125 * Closure for 'suggest_cb'. 125 * Closure for @e suggest_cb.
126 */ 126 */
127 void *suggest_cb_cls; 127 void *suggest_cb_cls;
128 128
@@ -833,34 +833,72 @@ get_addresses (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
833 sh); 833 sh);
834} 834}
835 835
836
836/** 837/**
837 * Convert a GNUNET_ATS_NetworkType to a string 838 * Convert a `enum GNUNET_ATS_Network_Type` to a string
838 * 839 *
839 * @param net the network type 840 * @param net the network type
840 * @return a string or NULL if invalid 841 * @return a string or NULL if invalid
841 */ 842 */
842const char * 843const char *
843GNUNET_ATS_print_network_type (uint32_t net) 844GNUNET_ATS_print_network_type (enum GNUNET_ATS_Network_Type net)
844{ 845{
845 char *networks[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkTypeString; 846 switch (net)
846 if (net < GNUNET_ATS_NetworkTypeCount) 847 {
847 return networks[net]; 848 case GNUNET_ATS_NET_UNSPECIFIED:
848 return NULL; 849 return "UNSPECIFIED";
850 case GNUNET_ATS_NET_LOOPBACK:
851 return "LOOPBACK";
852 case GNUNET_ATS_NET_LAN:
853 return "LAN";
854 case GNUNET_ATS_NET_WAN:
855 return "WAN";
856 case GNUNET_ATS_NET_WLAN:
857 return "WLAN";
858 case GNUNET_ATS_NET_BT:
859 return "BLUETOOTH";
860 default:
861 return NULL;
862 }
849} 863}
850 864
865
851/** 866/**
852 * Convert a ATS property to a string 867 * Convert a ATS property to a string
853 * 868 *
854 * @param type the atsi type 869 * @param type the property type
855 * @return a string or NULL if invalid 870 * @return a string or NULL if invalid
856 */ 871 */
857const char * 872const char *
858GNUNET_ATS_print_property_type (uint32_t type) 873GNUNET_ATS_print_property_type (enum GNUNET_ATS_Property type)
859{ 874{
860 char *props[GNUNET_ATS_PropertyCount] = GNUNET_ATS_PropertyStrings; 875 switch (type)
861 if ((type > 0) && (type < GNUNET_ATS_PropertyCount)) 876 {
862 return props[type]; 877 case GNUNET_ATS_ARRAY_TERMINATOR:
863 return NULL; 878 return "TERMINATOR";
879 case GNUNET_ATS_UTILIZATION_OUT:
880 return "UTILIZATION_UP";
881 case GNUNET_ATS_UTILIZATION_IN:
882 return "UTILIZATION_DOWN";
883 case GNUNET_ATS_UTILIZATION_PAYLOAD_OUT:
884 return "UTILIZATION_PAYLOAD_UP";
885 case GNUNET_ATS_UTILIZATION_PAYLOAD_IN:
886 return "UTILIZATION_PAYLOAD_DOWN";
887 case GNUNET_ATS_NETWORK_TYPE:
888 return "NETWORK_TYPE";
889 case GNUNET_ATS_QUALITY_NET_DELAY:
890 return "DELAY";
891 case GNUNET_ATS_QUALITY_NET_DISTANCE:
892 return "DISTANCE";
893 case GNUNET_ATS_COST_WAN:
894 return "COST_WAN";
895 case GNUNET_ATS_COST_LAN:
896 return "COST_LAN";
897 case GNUNET_ATS_COST_WLAN:
898 return "COST_WLAN";
899 default:
900 return NULL;
901 }
864} 902}
865 903
866 904
@@ -1057,17 +1095,17 @@ GNUNET_ATS_reset_backoff (struct GNUNET_ATS_SchedulingHandle *sh,
1057 do_transmit (sh); 1095 do_transmit (sh);
1058} 1096}
1059 1097
1098
1060/** 1099/**
1061 * We would like to receive address suggestions for a peer. ATS will 1100 * We would like to receive address suggestions for a peer. ATS will
1062 * respond with a call to the continuation immediately containing an address or 1101 * respond with a call to the continuation immediately containing an address or
1063 * no address if none is available. ATS can suggest more addresses until we call 1102 * no address if none is available. ATS can suggest more addresses until we call
1064 * #GNUNET_ATS_suggest_address_cancel. 1103 * #GNUNET_ATS_suggest_address_cancel().
1065 *
1066 * 1104 *
1067 * @param sh handle 1105 * @param sh handle
1068 * @param peer identity of the peer we need an address for 1106 * @param peer identity of the peer we need an address for
1069 * @param cont the continuation to call with the address 1107 * @param cont the continuation to call with the address
1070 * @param cont_cls the cls for the continuation 1108 * @param cont_cls the cls for the @a cont
1071 * @return suggest handle 1109 * @return suggest handle
1072 */ 1110 */
1073struct GNUNET_ATS_SuggestHandle * 1111struct GNUNET_ATS_SuggestHandle *
@@ -1269,9 +1307,9 @@ GNUNET_ATS_address_add (struct GNUNET_ATS_SchedulingHandle *sh,
1269 * @param address the address 1307 * @param address the address
1270 * @param session session handle, can be NULL 1308 * @param session session handle, can be NULL
1271 * @param ats performance data for the address 1309 * @param ats performance data for the address
1272 * @param ats_count number of performance records in 'ats' 1310 * @param ats_count number of performance records in @a ats
1273 * @return GNUNET_YES on success, GNUNET_NO if address or session are unknown, 1311 * @return #GNUNET_YES on success, #GNUNET_NO if address or session are unknown,
1274 * GNUNET_SYSERR on hard failure 1312 * #GNUNET_SYSERR on hard failure
1275 */ 1313 */
1276int 1314int
1277GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh, 1315GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh,
@@ -1357,7 +1395,7 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_SchedulingHandle *sh,
1357 * @param sh handle 1395 * @param sh handle
1358 * @param address the address 1396 * @param address the address
1359 * @param session session handle, can be NULL 1397 * @param session session handle, can be NULL
1360 * @param in_use GNUNET_YES if this address is now used, GNUNET_NO 1398 * @param in_use #GNUNET_YES if this address is now used, #GNUNET_NO
1361 * if address is not used any more 1399 * if address is not used any more
1362 */ 1400 */
1363void 1401void