Tor  0.4.7.0-alpha-dev
describe.h
Go to the documentation of this file.
1 /* Copyright (c) 2001 Matej Pfajfar.
2  * Copyright (c) 2001-2004, Roger Dingledine.
3  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4  * Copyright (c) 2007-2021, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
7 /**
8  * \file describe.h
9  * \brief Header file for describe.c.
10  **/
11 
12 #ifndef TOR_DESCRIBE_H
13 #define TOR_DESCRIBE_H
14 
15 struct extend_info_t;
16 struct node_t;
17 struct routerinfo_t;
18 struct routerstatus_t;
19 
20 const char *extend_info_describe(const struct extend_info_t *ei);
21 const char *node_describe(const struct node_t *node);
22 const char *router_describe(const struct routerinfo_t *ri);
23 const char *routerstatus_describe(const struct routerstatus_t *ri);
24 
25 void router_get_verbose_nickname(char *buf, const routerinfo_t *router);
26 
27 #if defined(DESCRIBE_PRIVATE) || defined(TOR_UNIT_TESTS)
28 
29 /**
30  * Longest allowed output for an IPv4 address "255.255.255.255", with NO
31  * terminating NUL.
32  */
33 #define IPV4_BUF_LEN_NO_NUL 15
34 
35 /**
36  * Longest allowed output of format_node_description, plus 1 character for
37  * NUL. This allows space for:
38  * "$FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF~xxxxxxxxxxxxxxxxxxx "
39  * "[+++++++++++++++++++++++++++++++++++++++++++] at"
40  * " 255.255.255.255 and [ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255]"
41  * plus a terminating NUL.
42  */
43 #define NODE_DESC_BUF_LEN \
44  (MAX_VERBOSE_NICKNAME_LEN+4 \
45  + ED25519_BASE64_LEN+3 \
46  + IPV4_BUF_LEN_NO_NUL+5 \
47  + TOR_ADDR_BUF_LEN)
48 
49 #endif /* defined(DESCRIBE_PRIVATE) || defined(TOR_UNIT_TESTS) */
50 
51 #ifdef TOR_UNIT_TESTS
53 
54 STATIC const char *format_node_description(char *buf,
55  const char *rsa_id_digest,
56  const struct ed25519_public_key_t *ed25519_id,
57  const char *nickname,
58  const tor_addr_t *ipv4_addr,
59  const tor_addr_t *ipv6_addr);
60 
61 #endif /* defined(TOR_UNIT_TESTS) */
62 
63 #endif /* !defined(TOR_DESCRIBE_H) */
const char * router_describe(const routerinfo_t *ri)
Definition: describe.c:137
const char * extend_info_describe(const extend_info_t *ei)
Definition: describe.c:224
const char * routerstatus_describe(const routerstatus_t *rs)
Definition: describe.c:203
const char * node_describe(const node_t *node)
Definition: describe.c:160
STATIC const char * format_node_description(char *buf, const char *rsa_id_digest, const ed25519_public_key_t *ed25519_id, const char *nickname, const tor_addr_t *ipv4_addr, const tor_addr_t *ipv6_addr)
Definition: describe.c:40
void router_get_verbose_nickname(char *buf, const routerinfo_t *router)
Definition: describe.c:256
Definition: node_st.h:34
#define STATIC
Definition: testsupport.h:32