Macros | Enumerations | Functions
fmt_routerstatus.h File Reference

Go to the source code of this file.


#define MAX_V_LINE_LEN   128


enum  routerstatus_format_type_t {


char * routerstatus_format_entry (const routerstatus_t *rs, const char *version, const char *protocols, routerstatus_format_type_t format, int consensus_method, const vote_routerstatus_t *vrs)

Detailed Description

Format routerstatus entries for controller, vote, or consensus.

Header file for fmt_routerstatus.c.

(Because controllers consume this format, we can't make this code dirauth-only.)

Definition in file fmt_routerstatus.h.

Macro Definition Documentation


#define MAX_V_LINE_LEN   128

Maximum allowable length of a version line in a networkstatus.

Definition at line 31 of file fmt_routerstatus.h.

Enumeration Type Documentation

◆ routerstatus_format_type_t

An enum to describe what format we're generating a routerstatus line in.


For use in a v2 opinion


For use in a consensus networkstatus document (ns flavor)


For use in a vote networkstatus document


For passing to the controlport in response to a GETINFO request


For use in a consensus networkstatus document (microdesc flavor)

Definition at line 17 of file fmt_routerstatus.h.

Function Documentation

◆ routerstatus_format_entry()

char* routerstatus_format_entry ( const routerstatus_t rs,
const char *  version,
const char *  protocols,
routerstatus_format_type_t  format,
int  consensus_method,
const vote_routerstatus_t vrs 

Helper: write the router-status information in rs into a newly allocated character buffer. Use the same format as in network-status documents. If version is non-NULL, add a "v" line for the platform.

consensus_method is the current consensus method when format is NS_V3_CONSENSUS or NS_V3_CONSENSUS_MICRODESC. It is ignored for other formats: pass ROUTERSTATUS_FORMAT_NO_CONSENSUS_METHOD.

Return 0 on success, -1 on failure.

The format argument has one of the following values: NS_V2 - Output an entry suitable for a V2 NS opinion document NS_V3_CONSENSUS - Output the first portion of a V3 NS consensus entry for consensus_method. NS_V3_CONSENSUS_MICRODESC - Output the first portion of a V3 microdesc consensus entry for consensus_method. NS_V3_VOTE - Output a complete V3 NS vote. If vrs is present, it contains additional information for the vote. NS_CONTROL_PORT - Output a NS document for the control port.

Definition at line 47 of file fmt_routerstatus.c.

Referenced by networkstatus_getinfo_helper_single().