tor  0.4.1.1-alpha-dev
Functions
bytes.h File Reference
#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

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

Definition at line 37 of file bytes.h.

Referenced by cell_unpack(), packed_cell_get_circid(), and parse_create2_payload().

◆ get_uint32()

static uint32_t get_uint32 ( const void *  cp)
inlinestatic

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

Definition at line 49 of file bytes.h.

Referenced by cell_unpack(), connected_cell_parse(), get_random_virtual_addr(), and packed_cell_get_circid().

◆ 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 61 of file bytes.h.

◆ 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 73 of file bytes.h.

Referenced by cell_pack(), connection_write_ext_or_command(), 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 82 of file bytes.h.

Referenced by cell_pack(), connected_cell_format_payload(), get_random_virtual_addr(), 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 91 of file bytes.h.

◆ tor_htonll()

static uint64_t tor_htonll ( uint64_t  a)
inlinestatic

Return a uint64_t value from a in network byte order.

Definition at line 167 of file bytes.h.

Referenced by crypto_mac_sha3_256(), and tor_ntohll().

◆ 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 176 of file bytes.h.

References tor_htonll().