Commit Graph

16041 Commits

Author SHA1 Message Date
Nick Mathewson
0cb921f3e9 Convert all include-guard macros to avoid reserved identifiers.
In C, we technically aren't supposed to define our own things that
start with an underscore.

This is a purely machine-generated commit.  First, I ran this script
on all the headers in src/{common,or,test,tools/*}/*.h :
==============================

use strict;

my %macros = ();
my %skipped = ();
FILE: for my $fn (@ARGV) {
    my $f = $fn;
    if ($fn !~ /^\.\//) {
	$f = "./$fn";
    }
    $skipped{$fn} = 0;
    open(F, $fn);
    while (<F>) {
	if (/^#ifndef ([A-Za-z0-9_]+)/) {
	    $macros{$fn} = $1;
	    next FILE;
	}
    }
}

print "#!/usr/bin/perl -w -i -p\n\n";
for my $fn (@ARGV) {
    if (! exists $macros{$fn}) {
	print "# No macro known for $fn!\n" if (!$skipped{$fn});
	next;
    }
    if ($macros{$fn} !~ /_H_?$/) {
	print "# Weird macro for $fn...\n";
    }
    my $goodmacro = uc $fn;
    $goodmacro =~ s#.*/##;
    $goodmacro =~ s#[\/\-\.]#_#g;
    print "s/(?<![A-Za-z0-9_])$macros{$fn}(?![A-Za-z0-9_])/TOR_${goodmacro}/g;\n"
}
==============================

It produced the following output, which I then re-ran on those same files:

==============================

s/(?<![A-Za-z0-9_])_TOR_ADDRESS_H(?![A-Za-z0-9_])/TOR_ADDRESS_H/g;
s/(?<![A-Za-z0-9_])_TOR_AES_H(?![A-Za-z0-9_])/TOR_AES_H/g;
s/(?<![A-Za-z0-9_])_TOR_COMPAT_H(?![A-Za-z0-9_])/TOR_COMPAT_H/g;
s/(?<![A-Za-z0-9_])_TOR_COMPAT_LIBEVENT_H(?![A-Za-z0-9_])/TOR_COMPAT_LIBEVENT_H/g;
s/(?<![A-Za-z0-9_])_TOR_CONTAINER_H(?![A-Za-z0-9_])/TOR_CONTAINER_H/g;
s/(?<![A-Za-z0-9_])_TOR_CRYPTO_H(?![A-Za-z0-9_])/TOR_CRYPTO_H/g;
s/(?<![A-Za-z0-9_])TOR_DI_OPS_H(?![A-Za-z0-9_])/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
s/(?<![A-Za-z0-9_])_TOR_COMMAND_H(?![A-Za-z0-9_])/TOR_COMMAND_H/g;
s/(?<![A-Za-z0-9_])_TOR_CONFIG_H(?![A-Za-z0-9_])/TOR_CONFIG_H/g;
s/(?<![A-Za-z0-9_])TOR_CONFPARSE_H(?![A-Za-z0-9_])/TOR_CONFPARSE_H/g;
s/(?<![A-Za-z0-9_])_TOR_CONNECTION_EDGE_H(?![A-Za-z0-9_])/TOR_CONNECTION_EDGE_H/g;
s/(?<![A-Za-z0-9_])_TOR_CONNECTION_H(?![A-Za-z0-9_])/TOR_CONNECTION_H/g;
s/(?<![A-Za-z0-9_])_TOR_CONNECTION_OR_H(?![A-Za-z0-9_])/TOR_CONNECTION_OR_H/g;
s/(?<![A-Za-z0-9_])_TOR_CONTROL_H(?![A-Za-z0-9_])/TOR_CONTROL_H/g;
s/(?<![A-Za-z0-9_])_TOR_CPUWORKER_H(?![A-Za-z0-9_])/TOR_CPUWORKER_H/g;
s/(?<![A-Za-z0-9_])_TOR_DIRECTORY_H(?![A-Za-z0-9_])/TOR_DIRECTORY_H/g;
s/(?<![A-Za-z0-9_])_TOR_DIRSERV_H(?![A-Za-z0-9_])/TOR_DIRSERV_H/g;
s/(?<![A-Za-z0-9_])_TOR_DIRVOTE_H(?![A-Za-z0-9_])/TOR_DIRVOTE_H/g;
s/(?<![A-Za-z0-9_])_TOR_DNS_H(?![A-Za-z0-9_])/TOR_DNS_H/g;
s/(?<![A-Za-z0-9_])_TOR_DNSSERV_H(?![A-Za-z0-9_])/TOR_DNSSERV_H/g;
s/(?<![A-Za-z0-9_])TOR_EVENTDNS_TOR_H(?![A-Za-z0-9_])/TOR_EVENTDNS_TOR_H/g;
s/(?<![A-Za-z0-9_])_TOR_GEOIP_H(?![A-Za-z0-9_])/TOR_GEOIP_H/g;
s/(?<![A-Za-z0-9_])_TOR_HIBERNATE_H(?![A-Za-z0-9_])/TOR_HIBERNATE_H/g;
s/(?<![A-Za-z0-9_])_TOR_MAIN_H(?![A-Za-z0-9_])/TOR_MAIN_H/g;
s/(?<![A-Za-z0-9_])_TOR_MICRODESC_H(?![A-Za-z0-9_])/TOR_MICRODESC_H/g;
s/(?<![A-Za-z0-9_])_TOR_NETWORKSTATUS_H(?![A-Za-z0-9_])/TOR_NETWORKSTATUS_H/g;
s/(?<![A-Za-z0-9_])_TOR_NODELIST_H(?![A-Za-z0-9_])/TOR_NODELIST_H/g;
s/(?<![A-Za-z0-9_])_TOR_NTMAIN_H(?![A-Za-z0-9_])/TOR_NTMAIN_H/g;
s/(?<![A-Za-z0-9_])_TOR_ONION_H(?![A-Za-z0-9_])/TOR_ONION_H/g;
s/(?<![A-Za-z0-9_])_TOR_OR_H(?![A-Za-z0-9_])/TOR_OR_H/g;
s/(?<![A-Za-z0-9_])_TOR_POLICIES_H(?![A-Za-z0-9_])/TOR_POLICIES_H/g;
s/(?<![A-Za-z0-9_])_TOR_REASONS_H(?![A-Za-z0-9_])/TOR_REASONS_H/g;
s/(?<![A-Za-z0-9_])_TOR_RELAY_H(?![A-Za-z0-9_])/TOR_RELAY_H/g;
s/(?<![A-Za-z0-9_])_TOR_RENDCLIENT_H(?![A-Za-z0-9_])/TOR_RENDCLIENT_H/g;
s/(?<![A-Za-z0-9_])_TOR_RENDCOMMON_H(?![A-Za-z0-9_])/TOR_RENDCOMMON_H/g;
s/(?<![A-Za-z0-9_])_TOR_RENDMID_H(?![A-Za-z0-9_])/TOR_RENDMID_H/g;
s/(?<![A-Za-z0-9_])_TOR_RENDSERVICE_H(?![A-Za-z0-9_])/TOR_RENDSERVICE_H/g;
s/(?<![A-Za-z0-9_])_TOR_REPHIST_H(?![A-Za-z0-9_])/TOR_REPHIST_H/g;
s/(?<![A-Za-z0-9_])_TOR_REPLAYCACHE_H(?![A-Za-z0-9_])/TOR_REPLAYCACHE_H/g;
s/(?<![A-Za-z0-9_])_TOR_ROUTER_H(?![A-Za-z0-9_])/TOR_ROUTER_H/g;
s/(?<![A-Za-z0-9_])_TOR_ROUTERLIST_H(?![A-Za-z0-9_])/TOR_ROUTERLIST_H/g;
s/(?<![A-Za-z0-9_])_TOR_ROUTERPARSE_H(?![A-Za-z0-9_])/TOR_ROUTERPARSE_H/g;
s/(?<![A-Za-z0-9_])TOR_ROUTERSET_H(?![A-Za-z0-9_])/TOR_ROUTERSET_H/g;
s/(?<![A-Za-z0-9_])TOR_STATEFILE_H(?![A-Za-z0-9_])/TOR_STATEFILE_H/g;
s/(?<![A-Za-z0-9_])_TOR_STATUS_H(?![A-Za-z0-9_])/TOR_STATUS_H/g;
s/(?<![A-Za-z0-9_])TOR_TRANSPORTS_H(?![A-Za-z0-9_])/TOR_TRANSPORTS_H/g;
s/(?<![A-Za-z0-9_])_TOR_TEST_H(?![A-Za-z0-9_])/TOR_TEST_H/g;
s/(?<![A-Za-z0-9_])_TOR_FW_HELPER_H(?![A-Za-z0-9_])/TOR_TOR_FW_HELPER_H/g;
s/(?<![A-Za-z0-9_])_TOR_FW_HELPER_NATPMP_H(?![A-Za-z0-9_])/TOR_TOR_FW_HELPER_NATPMP_H/g;
s/(?<![A-Za-z0-9_])_TOR_FW_HELPER_UPNP_H(?![A-Za-z0-9_])/TOR_TOR_FW_HELPER_UPNP_H/g;
==============================
2012-10-12 12:13:10 -04:00
Nick Mathewson
d7b79bf020 Clean up reserved identifier usage in src/ext include guards 2012-10-12 12:11:54 -04:00
Nick Mathewson
0d9c336a87 Add guard macro for eventdns_tor.h 2012-10-12 12:08:53 -04:00
Nick Mathewson
8586611718 Make tor_addr_is_internal log the calling function on error
This might make it a little easier to track down bug  7086.
2012-10-12 11:34:54 -04:00
Andrea Shepard
9c605ecb7e Install correct incoming cell handlers on reachability testing channels
Fix for bug 7086.
2012-10-12 10:02:13 -04:00
Andrea Shepard
3a33b1fe3b Merge branch 'move_contrib_source' of git://git.torproject.org/nickm/tor 2012-10-11 15:55:26 -07:00
Nick Mathewson
63f542a5c2 Move all externally maintained source files into src/ext
The rationale for treating these files differently is that we should
be checking upstream for changes as applicable, and merging changes
upstream as warranted.
2012-10-11 17:22:03 -04:00
Nick Mathewson
a45760b53b Make very sure to handle cells in-order on channels.
Fix on code for 6465, not yet in any release.
2012-10-11 00:35:58 -04:00
Nick Mathewson
7ea904cbc0 Merge branch 'bug7011'
Conflicts:
	src/or/circuitbuild.c

The conflict was trivial, since no line of code actually changed in
both branches: There was a fmt_addr() that turned into fmt_addrport()
in bug7011, and a "if (!n_conn)" that turned into "if (!n_chan)" in
master.
2012-10-10 22:31:06 -04:00
Nick Mathewson
e6d1ab3600 Fix changes/bug7011 slightly 2012-10-10 22:27:52 -04:00
David Fifield
6e31b9c503 Add changes file for bug7011. 2012-10-10 22:25:30 -04:00
David Fifield
8b3f3fb86e Use fmt_addrport in pt_get_extra_info_descriptor_string.
This patch is by asn.
https://trac.torproject.org/projects/tor/ticket/7011#comment:11
2012-10-10 22:25:30 -04:00
David Fifield
8419d18441 Use fmt_addrport where appropriate.
This is mostly a conversion from this pattern:
	log("... %s:%d ...", fmt_and_decorate_addr(&addr), port);
to this:
	log("... %s ...", fmt_addrport(&addr, port));

The output is the same in all cases.
2012-10-10 22:25:30 -04:00
David Fifield
78e2d8c7a8 Add fmt_addrport.
This function formats an addr:port pair, and always decorates IPv6
addresses.
2012-10-10 22:25:30 -04:00
David Fifield
4b0a039cb8 Use fmt_and_decorate_addr in extra-info "transport" lines.
Apparently BridgeDB is already expecting transport lines to be formatted
thus; see https://trac.torproject.org/projects/tor/ticket/7011#comment:12 ff.
It may be that there are no extant IPv6 pluggable transport bridges yet,
so this didn't cause a problem.
2012-10-10 22:25:29 -04:00
David Fifield
5cbf0f2106 Use fmt_and_decorate_addr in TransportProxy statefile entry.
state_transport_line_is_valid calls tor_addr_port_lookup, which expects
brackets around an IPv6 address. Without this, cached transport
addresses can't be parsed later:

[warn] state: Could not parse addrport.
[warn] state: State file seems to be broken.

See #7011.
2012-10-10 22:25:29 -04:00
David Fifield
41328c7009 Decorate addresses given to a HTTP CONNECT proxy.
This affects the Request-URI and the value of the Host header. RFC 2616
doesn't directly address the formatting of IPv6 addresses, but it
delegates some productions to RFC 2396 "Uniform Resource Identifiers
(URI): Generic Syntax," which is obsoleted by RFC 3986, which requires
square brackets for IPv6 addresses in both places.

I tested this with
	HTTPSProxy 127.0.0.1:8000
	Bridge <IPv6 bridge>
	UseBridges 1
and an Ncat HTTP proxy:
	ncat --proxy-type http -l 8000 -vvv

https://tools.ietf.org/html/rfc2616#section-3.2.1
https://tools.ietf.org/html/rfc2616#section-5.1.2
https://tools.ietf.org/html/rfc2616#section-14.23
https://tools.ietf.org/html/rfc3986#section-3.2.2
2012-10-10 22:25:29 -04:00
David Fifield
34c6ee7e9b Use fmt_and_decorate_addr in log messages. 2012-10-10 22:25:29 -04:00
Andrea Shepard
8b36d4cc2a Merge branch 'bug6816_squashed_nowarn' of git://git.torproject.org/nickm/tor 2012-10-10 18:53:38 -07:00
Nick Mathewson
bd28322d38 Remove variables; fix gcc 4.7 warnings
My GCC warns when variables are assigned to but never used.  There
were a few like that in the 6816/6465 branches.
2012-10-10 21:25:52 -04:00
Andrea Shepard
cf994f7ad7
Add changes file for bug6816 2012-10-10 00:51:55 -07:00
Andrea Shepard
5543c5b202
Fix formatting in various places after 6465/6816 work 2012-10-10 00:48:36 -07:00
Andrea Shepard
217352c362 Make channel_flush_some_cells() compile cleanly on machines with ssize_t larger than int per sjumrdoch comment 2012-10-10 00:44:47 -07:00
Andrea Shepard
bec776480d Don't remove circuitmux hash table entries in circuitmux_detach_circuit() until after circuitmux_make_circuit_inactive() 2012-10-10 00:44:47 -07:00
Andrea Shepard
1bc9a040f7 Fix 'warning: circuit was already inactive' and assert in circuitmux_make_circuit_inactive() during circuitmux_detach_all_circuits() 2012-10-10 00:44:47 -07:00
Andrea Shepard
c9e48ded5d Bring summary comment block in circuitmux.c up to date 2012-10-10 00:44:47 -07:00
Andrea Shepard
49d534e524 New and improved circuitmux_detach_all_circuits(), now without the stupid 2012-10-10 00:44:47 -07:00
Andrea Shepard
c9607694c9 Correctly set magic numbers on ewma policy data/circuit data when allocating 2012-10-10 00:44:47 -07:00
Andrea Shepard
9d615cc5c0 Set circuitmux policy on existing active channels when ewma_enabled changes 2012-10-10 00:44:47 -07:00
Andrea Shepard
bb62281ba4 Set circuitmux policy on new channels in channeltls.c 2012-10-10 00:44:47 -07:00
Andrea Shepard
0c4f717b3e Implement cell_ewma_enabled() 2012-10-10 00:44:47 -07:00
Andrea Shepard
8afe41b481 Implement channel_set_cmux_policy_everywhere() 2012-10-10 00:44:46 -07:00
Andrea Shepard
13972aee78 Fix broken circuitmux_move_active_circ_to_tail(); don't assume n_chan is not NULL in circuitmux_detach_circuit() 2012-10-10 00:44:46 -07:00
Andrea Shepard
903cc8acd1 Allow n_chan to be NULL in circuitmux_find_map_entry(); it can be but with non-NULL p_chan when extending a circuit 2012-10-10 00:44:46 -07:00
Andrea Shepard
a0200c1f6e Use circuit_get_by_circid_channel_even_if_marked() and fix some asserts in circuitmux.c 2012-10-10 00:44:46 -07:00
Andrea Shepard
1498a6e84a Fix some circuitmux-related asserts in relay.c 2012-10-10 00:44:46 -07:00
Andrea Shepard
b28119e6a8 Fix detach when setting circuit ID to 0 bug in circuit_set_circid_chan_helper() and add circuit_get_by_circid_channel_even_if_marked() 2012-10-10 00:44:46 -07:00
Andrea Shepard
c097fb33fc Detach circuits from circuitmux early when freeing channel so they can find the channel by ID 2012-10-10 00:44:46 -07:00
Andrea Shepard
3d092ffbdd Handle closing circuits correctly with circuitmux_t 2012-10-10 00:44:46 -07:00
Andrea Shepard
6830c9c232 Add a bunch of paranoid-mode expensive asserts incircuitmux.c 2012-10-10 00:44:46 -07:00
Andrea Shepard
7598e669e8 Adjust the circuitmux_t counter correctly in circuitmux_notify_xmit_cells() 2012-10-10 00:44:46 -07:00
Andrea Shepard
96a6eff8fe Fix circuitmux attach/detach logic in circuit_set_circid_chan_helper(); it's possible for id to be zero (not assigned yet) and shouldn't be attached then 2012-10-10 00:44:46 -07:00
Andrea Shepard
60ec46a2ec Update circuitmux-related TODOs in channeltls.c 2012-10-10 00:44:46 -07:00
Andrea Shepard
2565710fd7 Fix comment on circuit_t.n_hop and remove circuitmux TODO in or.h 2012-10-10 00:44:46 -07:00
Andrea Shepard
bbb2c31d26 Move all EWMA code into circuitmux.c and implement circuitmux_policy_t methods using it 2012-10-10 00:44:46 -07:00
Andrea Shepard
0af2eab9a2 Add circuitmux.h, circuitmux_ewma.h includes now necessary in networkstatus.c 2012-10-10 00:44:46 -07:00
Andrea Shepard
d194b8602a Remove cell_ewma_t from or.h and from circuit_t/or_circuit_t; all that goes to the new circuitmux_ewma.c now 2012-10-10 00:44:46 -07:00
Andrea Shepard
5f9d37e74e Add circuitmux.h, circuitmux_ewma.h includes now necessary in config.c 2012-10-10 00:44:46 -07:00
Andrea Shepard
14fe0d5859 Remove EWMA code from relay.{c,h}; it goes to a circuitmux policy now 2012-10-10 00:44:46 -07:00
Andrea Shepard
b7d5784c54 Remove ewma setup code in init_circuit_base()/or_circuit_new() of circuitlist.c; it gets allocated when the circuit is attached to a circuitmux_t with that policy now 2012-10-10 00:44:46 -07:00