Tor 0.4.9.2-alpha-dev
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Functions
bytes.h File Reference

Inline functions for reading and writing multibyte values from the middle of strings, and for manipulating byte order. More...

#include <string.h>
#include "lib/cc/torint.h"

Go to the source code of this file.

Functions

static uint8_t get_uint8 (const void *cp)
 
static void set_uint8 (void *cp, uint8_t v)
 
static uint16_t get_uint16 (const void *cp)
 
static uint32_t get_uint32 (const void *cp)
 
static uint64_t get_uint64 (const void *cp)
 
static void set_uint16 (void *cp, uint16_t v)
 
static void set_uint32 (void *cp, uint32_t v)
 
static void set_uint64 (void *cp, uint64_t v)
 
static uint16_t tor_htons (uint16_t a)
 
static uint16_t tor_ntohs (uint16_t a)
 
static uint32_t tor_htonl (uint32_t a)
 
static uint32_t tor_ntohl (uint32_t a)
 
static uint64_t tor_htonll (uint64_t a)
 
static uint64_t tor_ntohll (uint64_t a)
 

Detailed Description

Inline functions for reading and writing multibyte values from the middle of strings, and for manipulating byte order.

Definition in file bytes.h.

Function Documentation

◆ get_uint16()

static uint16_t get_uint16 ( const void *  cp)
inlinestatic

◆ get_uint32()

static uint32_t get_uint32 ( const void *  cp)
inlinestatic

◆ get_uint64()

static uint64_t get_uint64 ( const void *  cp)
inlinestatic

Read a 64-bit value beginning at cp. Equivalent to *(uint64_t*)(cp), but will not cause segfaults on platforms that forbid unaligned memory access.

Definition at line 66 of file bytes.h.

Referenced by commit_decode(), and reveal_decode().

◆ get_uint8()

static uint8_t get_uint8 ( const void *  cp)
inlinestatic

◆ set_uint16()

static void set_uint16 ( void *  cp,
uint16_t  v 
)
inlinestatic

Set a 16-bit value beginning at cp to v. Equivalent to *(uint16_t*)(cp) = v, but will not cause segfaults on platforms that forbid unaligned memory access.

Definition at line 78 of file bytes.h.

Referenced by cell_pack(), connection_ap_handshake_socks_resolved(), connection_or_compute_authenticate_cell_body(), connection_or_send_versions(), connection_write_ext_or_command(), control_send_v0_reject(), create_cell_format_impl(), created_cell_format(), encode_v0_cell(), encode_v1_cell(), extended_cell_format(), and var_cell_pack_header().

◆ set_uint32()

static void set_uint32 ( void *  cp,
uint32_t  v 
)
inlinestatic

Set a 32-bit value beginning at cp to v. Equivalent to *(uint32_t*)(cp) = v, but will not cause segfaults on platforms that forbid unaligned memory access.

Definition at line 87 of file bytes.h.

Referenced by cell_pack(), chanid_circid_entry_hash(), connected_cell_format_payload(), connection_ap_handshake_send_begin(), connection_edge_end(), crypto_pwbox(), generate_srv(), get_random_virtual_addr(), send_resolved_cell(), send_resolved_hostname_cell(), and var_cell_pack_header().

◆ set_uint64()

static void set_uint64 ( void *  cp,
uint64_t  v 
)
inlinestatic

Set a 64-bit value beginning at cp to v. Equivalent to *(uint64_t*)(cp) = v, but will not cause segfaults on platforms that forbid unaligned memory access.

Definition at line 96 of file bytes.h.

Referenced by build_blinded_key_param(), build_secret_input(), chanid_circid_entry_hash(), commit_encode(), compute_disaster_srv(), generate_srv(), hs_build_hs_index(), hs_build_hsdir_index(), and reveal_encode().

◆ set_uint8()

static void set_uint8 ( void *  cp,
uint8_t  v 
)
inlinestatic

Store an 8-bit value from v to cp.

Definition at line 31 of file bytes.h.

Referenced by build_hs_address(), build_hs_checksum(), cell_pack(), connected_cell_format_payload(), and var_cell_pack_header().

◆ tor_htonl()

static uint32_t tor_htonl ( uint32_t  a)
inlinestatic

Convert a 32-bit value from host order to network order (big-endian).

Definition at line 163 of file bytes.h.

Referenced by crypto_pwbox(), ope_get_cipher(), tor_htonll(), tor_ntohl(), and validate_equix_challenge().

◆ tor_htonll()

static uint64_t tor_htonll ( uint64_t  a)
inlinestatic

◆ tor_htons()

static uint16_t tor_htons ( uint16_t  a)
inlinestatic

Convert a 16-bit value from host order to network order (big-endian).

Definition at line 142 of file bytes.h.

Referenced by tor_ntohs().

◆ tor_ntohl()

static uint32_t tor_ntohl ( uint32_t  a)
inlinestatic

Convert a 32-bit value from network order (big-endian) to host order.

Definition at line 177 of file bytes.h.

Referenced by crypto_unpwbox().

◆ tor_ntohll()

static uint64_t tor_ntohll ( uint64_t  a)
inlinestatic

Return a uint64_t value from a in host byte order.

Definition at line 193 of file bytes.h.

Referenced by commit_decode(), and reveal_decode().

◆ tor_ntohs()

static uint16_t tor_ntohs ( uint16_t  a)
inlinestatic

Convert a 16-bit value from network order (big-endian) to host order.

Definition at line 154 of file bytes.h.

Referenced by detect_compression_method().