Back to index

tor  0.2.3.18-rc
directory.h
Go to the documentation of this file.
00001 /* Copyright (c) 2001 Matej Pfajfar.
00002  * Copyright (c) 2001-2004, Roger Dingledine.
00003  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
00004  * Copyright (c) 2007-2012, The Tor Project, Inc. */
00005 /* See LICENSE for licensing information */
00006 
00012 #ifndef _TOR_DIRECTORY_H
00013 #define _TOR_DIRECTORY_H
00014 
00015 int directories_have_accepted_server_descriptor(void);
00016 void directory_post_to_dirservers(uint8_t dir_purpose, uint8_t router_purpose,
00017                                   dirinfo_type_t type, const char *payload,
00018                                   size_t payload_len, size_t extrainfo_len);
00019 void directory_get_from_dirserver(uint8_t dir_purpose, uint8_t router_purpose,
00020                                   const char *resource,
00021                                   int pds_flags);
00022 void directory_get_from_all_authorities(uint8_t dir_purpose,
00023                                         uint8_t router_purpose,
00024                                         const char *resource);
00025 void directory_initiate_command_routerstatus(const routerstatus_t *status,
00026                                              uint8_t dir_purpose,
00027                                              uint8_t router_purpose,
00028                                              int anonymized_connection,
00029                                              const char *resource,
00030                                              const char *payload,
00031                                              size_t payload_len,
00032                                              time_t if_modified_since);
00033 void directory_initiate_command_routerstatus_rend(const routerstatus_t *status,
00034                                                   uint8_t dir_purpose,
00035                                                   uint8_t router_purpose,
00036                                                   int anonymized_connection,
00037                                                   const char *resource,
00038                                                   const char *payload,
00039                                                   size_t payload_len,
00040                                                   time_t if_modified_since,
00041                                                 const rend_data_t *rend_query);
00042 
00043 int parse_http_response(const char *headers, int *code, time_t *date,
00044                         compress_method_t *compression, char **response);
00045 
00046 int connection_dir_is_encrypted(dir_connection_t *conn);
00047 int connection_dir_reached_eof(dir_connection_t *conn);
00048 int connection_dir_process_inbuf(dir_connection_t *conn);
00049 int connection_dir_finished_flushing(dir_connection_t *conn);
00050 int connection_dir_finished_connecting(dir_connection_t *conn);
00051 void connection_dir_about_to_close(dir_connection_t *dir_conn);
00052 void directory_initiate_command(const char *address, const tor_addr_t *addr,
00053                                 uint16_t or_port, uint16_t dir_port,
00054                                 int supports_conditional_consensus,
00055                                 int supports_begindir, const char *digest,
00056                                 uint8_t dir_purpose, uint8_t router_purpose,
00057                                 int anonymized_connection,
00058                                 const char *resource,
00059                                 const char *payload, size_t payload_len,
00060                                 time_t if_modified_since);
00061 
00062 #define DSR_HEX       (1<<0)
00063 #define DSR_BASE64    (1<<1)
00064 #define DSR_DIGEST256 (1<<2)
00065 #define DSR_SORT_UNIQ (1<<3)
00066 int dir_split_resource_into_fingerprints(const char *resource,
00067                                      smartlist_t *fp_out, int *compressed_out,
00068                                      int flags);
00069 
00070 int dir_split_resource_into_fingerprint_pairs(const char *res,
00071                                               smartlist_t *pairs_out);
00072 char *directory_dump_request_log(void);
00073 void note_request(const char *key, size_t bytes);
00074 int router_supports_extrainfo(const char *identity_digest, int is_authority);
00075 
00076 time_t download_status_increment_failure(download_status_t *dls,
00077                                          int status_code, const char *item,
00078                                          int server, time_t now);
00081 #define download_status_failed(dls, sc)                                 \
00082   download_status_increment_failure((dls), (sc), NULL,                  \
00083                                     get_options()->DirPort!=NULL, time(NULL))
00084 
00085 void download_status_reset(download_status_t *dls);
00086 static int download_status_is_ready(download_status_t *dls, time_t now,
00087                                     int max_failures);
00090 static INLINE int
00091 download_status_is_ready(download_status_t *dls, time_t now,
00092                          int max_failures)
00093 {
00094   return (dls->n_download_failures <= max_failures
00095           && dls->next_attempt_at <= now);
00096 }
00097 
00098 static void download_status_mark_impossible(download_status_t *dl);
00100 static INLINE void
00101 download_status_mark_impossible(download_status_t *dl)
00102 {
00103   dl->n_download_failures = IMPOSSIBLE_TO_DOWNLOAD;
00104 }
00105 
00106 int download_status_get_n_failures(const download_status_t *dls);
00107 
00108 #endif
00109