GNUnet  0.10.x
Macros | Functions
common_endian.c File Reference

endian conversion helpers More...

#include "platform.h"
#include "gnunet_crypto_lib.h"
Include dependency graph for common_endian.c:

Go to the source code of this file.

Macros

#define LOG(kind, ...)   GNUNET_log_from (kind, "util-common-endian",__VA_ARGS__)
 

Functions

uint64_t GNUNET_htonll (uint64_t n)
 Convert unsigned 64-bit integer to network byte order. More...
 
uint64_t GNUNET_ntohll (uint64_t n)
 Convert unsigned 64-bit integer to host byte order. More...
 
double GNUNET_hton_double (double d)
 Convert double to network-byte-order. More...
 
double GNUNET_ntoh_double (double d)
 Convert double to host-byte-order. More...
 

Detailed Description

endian conversion helpers

Author
Christian Grothoff
Gabor X Toth

Definition in file common_endian.c.

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log_from (kind, "util-common-endian",__VA_ARGS__)

Definition at line 31 of file common_endian.c.

Function Documentation

◆ GNUNET_htonll()

uint64_t GNUNET_htonll ( uint64_t  n)

Convert unsigned 64-bit integer to network byte order.

Parameters
nThe value in host byte order.
Returns
The same value in network byte order.

Definition at line 35 of file common_endian.c.

Referenced by block_proc(), change_service(), commit_set(), consider_sending_fc(), create_loc_uri(), credential_string_to_value(), determine_id(), GCCH_handle_channel_plaintext_data_ack(), GNUNET_ARM_request_service_list(), GNUNET_BIO_write_int64(), GNUNET_CREDENTIAL_credential_issue(), GNUNET_CREDENTIAL_credential_serialize(), GNUNET_CREDENTIAL_credentials_serialize(), GNUNET_DATASTORE_get_key(), GNUNET_DATASTORE_get_zero_anonymity(), GNUNET_DATASTORE_reserve(), GNUNET_FS_tree_encoder_next(), GNUNET_GNSRECORD_records_serialize(), GNUNET_hton_double(), GNUNET_NAMESTORE_zone_iterator_next(), GNUNET_NAMESTORE_zone_monitor_next(), GNUNET_RECLAIM_ATTRIBUTE_serialize(), GNUNET_RECLAIM_attribute_store(), GNUNET_TESTBED_controller_connect(), GNUNET_TESTBED_controller_link(), GNUNET_TESTBED_generate_peergetconfig_msg_(), GNUNET_TESTBED_generate_slavegetconfig_msg_(), GNUNET_TIME_absolute_hton(), GNUNET_TIME_relative_hton(), GST_send_operation_fail_msg(), GST_send_operation_success_msg(), hash_for_index_cb(), notify_change(), opstart_manage_service(), opstart_overlay_connect(), opstart_peer_create(), opstart_peer_destroy(), opstart_peer_reconfigure(), opstart_peer_start(), opstart_peer_stop(), opstart_shutdown_peers(), p2_controller_connect_cb(), qconv_abs_time(), qconv_uint64(), run(), save(), send_ack(), send_channel_data_ack(), send_client_done(), send_client_element(), send_controller_link_response(), send_hello_thru_rocc(), send_overlay_connect_success_msg(), signal_result(), transmit(), transmit_item(), transmit_set(), unindex_process(), union_accept(), uri_chk_parse(), and uri_loc_parse().

36 {
37 #if __BYTE_ORDER == __BIG_ENDIAN
38  return n;
39 #elif __BYTE_ORDER == __LITTLE_ENDIAN
40  return (((uint64_t) htonl (n)) << 32) + htonl (n >> 32);
41 #else
42  #error byteorder undefined
43 #endif
44 }

◆ GNUNET_ntohll()

uint64_t GNUNET_ntohll ( uint64_t  n)

Convert unsigned 64-bit integer to host byte order.

Parameters
nThe value in network byte order.
Returns
The same value in host byte order.

Definition at line 48 of file common_endian.c.

Referenced by backward_resolution(), cb_intersection_element_removed(), copy_element_cb(), credential_value_to_string(), extract_abs_time(), extract_uint64(), find_proof(), forward_overlay_connect(), GNUNET_BIO_read_int64__(), GNUNET_CREDENTIAL_credential_deserialize(), GNUNET_CREDENTIAL_credentials_deserialize(), GNUNET_FRAGMENT_print_ack(), GNUNET_FRAGMENT_process_ack(), GNUNET_FS_handle_on_demand_block(), GNUNET_FS_publish_stop(), GNUNET_FS_uri_chk_get_file_size(), GNUNET_GNSRECORD_records_deserialize(), GNUNET_ntoh_double(), GNUNET_RECLAIM_ATTRIBUTE_deserialize(), GNUNET_TIME_absolute_ntoh(), GNUNET_TIME_relative_ntoh(), GNUNET_xfree_(), handle_alice_client_message(), handle_arm_list_result(), handle_arm_result(), handle_attribute_store_message(), handle_bob_client_message(), handle_client_index_start(), handle_client_loc_sign(), handle_data(), handle_flow_control(), handle_get(), handle_get_key(), handle_get_zero_anonymity(), handle_iteration_next(), handle_link_controllers(), handle_link_controllers_result(), handle_manage_peer_service(), handle_monitor_next(), handle_op_fail_event(), handle_opsuccess(), handle_overlay_connect(), handle_peer_conevent(), handle_peer_config(), handle_peer_create(), handle_peer_create_success(), handle_peer_destroy(), handle_peer_event(), handle_peer_get_config(), handle_peer_reconfigure(), handle_peer_start(), handle_peer_stop(), handle_remote_overlay_connect(), handle_reserve(), handle_result(), handle_set(), handle_shutdown_peers(), handle_slave_config(), handle_slave_get_config(), handle_start(), handle_statistics_value(), handle_statistics_watch_value(), handle_stop(), handle_union_p2p_strata_estimator(), process_result_with_request(), reconstruct_cb(), set_result_cb(), try_match_block(), uri_chk_to_string(), uri_loc_to_string(), and verify_message_crypto().

49 {
50 #if __BYTE_ORDER == __BIG_ENDIAN
51  return n;
52 #elif __BYTE_ORDER == __LITTLE_ENDIAN
53  return (((uint64_t) ntohl (n)) << 32) + ntohl (n >> 32);
54 #else
55  #error byteorder undefined
56 #endif
57 }

◆ GNUNET_hton_double()

double GNUNET_hton_double ( double  d)

Convert double to network-byte-order.

Convert double to network byte order.

Parameters
dthe value in network byte order
Returns
the same value in host byte order

Definition at line 66 of file common_endian.c.

References GNUNET_htonll(), and res.

Referenced by setup_estimate_message().

67 {
68  double res;
69  uint64_t *in = (uint64_t *) &d;
70  uint64_t *out = (uint64_t *) &res;
71 
72  out[0] = GNUNET_htonll(in[0]);
73 
74  return res;
75 }
static int res
uint64_t GNUNET_htonll(uint64_t n)
Convert unsigned 64-bit integer to network byte order.
Definition: common_endian.c:35
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ntoh_double()

double GNUNET_ntoh_double ( double  d)

Convert double to host-byte-order.

Convert double to host byte order.

Parameters
dthe value in network byte order
Returns
the same value in host byte order

Definition at line 84 of file common_endian.c.

References GNUNET_ntohll(), and res.

Referenced by handle_estimate().

85 {
86  double res;
87  uint64_t *in = (uint64_t *) &d;
88  uint64_t *out = (uint64_t *) &res;
89 
90  out[0] = GNUNET_ntohll(in[0]);
91 
92  return res;
93 }
static int res
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
Definition: common_endian.c:48
Here is the call graph for this function:
Here is the caller graph for this function: