diff options
Diffstat (limited to 'src/ats/ats_api_scanner.c')
-rw-r--r-- | src/ats/ats_api_scanner.c | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/src/ats/ats_api_scanner.c b/src/ats/ats_api_scanner.c index 64c02acf6..f9c30770e 100644 --- a/src/ats/ats_api_scanner.c +++ b/src/ats/ats_api_scanner.c | |||
@@ -62,32 +62,38 @@ GNUNET_ATS_print_network_type (enum GNUNET_ATS_Network_Type net) | |||
62 | 62 | ||
63 | 63 | ||
64 | /** | 64 | /** |
65 | * Convert a ATS property to a string | 65 | * Convert ATS properties from host to network byte order. |
66 | * | 66 | * |
67 | * @param type the property type | 67 | * @param nbo[OUT] value written |
68 | * @return a string or NULL if invalid | 68 | * @param hbo value read |
69 | */ | 69 | */ |
70 | const char * | 70 | void |
71 | GNUNET_ATS_print_property_type (enum GNUNET_ATS_Property type) | 71 | GNUNET_ATS_properties_hton (struct GNUNET_ATS_PropertiesNBO *nbo, |
72 | const struct GNUNET_ATS_Properties *hbo) | ||
72 | { | 73 | { |
73 | switch (type) | 74 | nbo->utilization_out = htonl (hbo->utilization_out); |
74 | { | 75 | nbo->utilization_in = htonl (hbo->utilization_in); |
75 | case GNUNET_ATS_ARRAY_TERMINATOR: | 76 | nbo->scope = htonl ((uint32_t) hbo->scope); |
76 | return "TERMINATOR"; | 77 | nbo->distance = htonl (hbo->distance); |
77 | case GNUNET_ATS_UTILIZATION_OUT: | 78 | nbo->delay = GNUNET_TIME_relative_hton (hbo->delay); |
78 | return "UTILIZATION_UP"; | 79 | } |
79 | case GNUNET_ATS_UTILIZATION_IN: | 80 | |
80 | return "UTILIZATION_DOWN"; | 81 | |
81 | case GNUNET_ATS_NETWORK_TYPE: | 82 | /** |
82 | return "NETWORK_TYPE"; | 83 | * Convert ATS properties from network to host byte order. |
83 | case GNUNET_ATS_QUALITY_NET_DELAY: | 84 | * |
84 | return "DELAY"; | 85 | * @param hbo[OUT] value written |
85 | case GNUNET_ATS_QUALITY_NET_DISTANCE: | 86 | * @param nbo value read |
86 | return "DISTANCE"; | 87 | */ |
87 | default: | 88 | void |
88 | GNUNET_break (0); | 89 | GNUNET_ATS_properties_ntoh (struct GNUNET_ATS_Properties *hbo, |
89 | return NULL; | 90 | const struct GNUNET_ATS_PropertiesNBO *nbo) |
90 | } | 91 | { |
92 | hbo->utilization_out = ntohl (nbo->utilization_out); | ||
93 | hbo->utilization_in = ntohl (nbo->utilization_in); | ||
94 | hbo->scope = ntohl ((uint32_t) nbo->scope); | ||
95 | hbo->distance = ntohl (nbo->distance); | ||
96 | hbo->delay = GNUNET_TIME_relative_ntoh (nbo->delay); | ||
91 | } | 97 | } |
92 | 98 | ||
93 | 99 | ||