OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef NET_BASE_IP_MAPPING_RULES_H_ | |
6 #define NET_BASE_IP_MAPPING_RULES_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "net/base/address_list.h" | |
wtc
2014/02/11 23:52:30
1. Nit: I think you can include "base/macros.h" in
jar (doing other things)
2014/02/15 21:14:56
Done.
| |
12 #include "net/base/net_export.h" | |
13 | |
14 namespace net { | |
15 | |
16 class NET_EXPORT_PRIVATE IPMappingRules { | |
wtc
2014/02/11 23:52:30
Nit: it would be nice to have a short comment desc
jar (doing other things)
2014/02/15 21:14:56
Done.
| |
17 public: | |
18 IPMappingRules(); | |
19 ~IPMappingRules(); | |
20 | |
21 // Modifies |*addresses| based on the current rules. Returns true if | |
22 // |addresses| was modified, false otherwise. | |
23 bool RewriteAddresses(AddressList* addresses) const; | |
24 | |
25 // Adds a rule to this mapper. | |
26 // Rules are evaluated against an address list until one is found that | |
wtc
2014/02/11 23:52:30
Nit: "one" is ambiguous because it could mean a ru
jar (doing other things)
2014/02/15 21:14:56
Done.
| |
27 // applies, causing a modification of the address resolution list. | |
wtc
2014/02/11 23:52:30
Nit: remove "resolution".
jar (doing other things)
2014/02/15 21:14:56
Done.
| |
28 // Each rule consists of one or more of the following pattern and action | |
29 // directives. | |
30 // | |
31 // RULE : CHANGE_DIRECTIVE | EMPTY | |
wtc
2014/02/11 23:52:30
Nit: remove the space before ":".
jar (doing other things)
2014/02/15 21:14:56
Done.
| |
32 // CHANGE_DIRECTIVE: "PREFACE" SPACE IP_PATTERN SPACE IP_LITERAL | |
wtc
2014/02/11 23:52:30
You should document the PREFACE directive somewher
jar (doing other things)
2014/02/15 21:14:56
Done.
| |
33 // SPACE: " " | |
34 // EMPTY: | |
35 // | |
36 // IP_LITERAL: IP_V6_LITERAL | IP_V4_LITERAL | |
37 // | |
38 // IP_V4_LITERAL: OCTET "." OCTET "." OCTET "." OCTET | |
39 // OCTET: decimal number in range 0 ... 255 | |
40 // | |
41 // IP_V6_LITERAL: HEX_COMPONENT | IP_V6_LITERAL ":" HEX_COMPONENT | |
wtc
2014/02/11 23:52:30
This may not be a complete specification of IPv6 l
jar (doing other things)
2014/02/15 21:14:56
I made this explicit in a new comment below.
| |
42 // HEX_COMPONENT: hexidecimal values with no more than 4 hex digits | |
wtc
2014/02/11 23:52:30
Typo: hexidecimal => hexadecimal
jar (doing other things)
2014/02/15 21:14:56
Done.
| |
43 // | |
44 // IP_PATTERN: IP_V6_PATTERN | IP_V4_PATTERN | |
45 // | |
46 // IP_V6_PATTERN: HEX_PATTERN | IP_V6_PATTERN ":" HEX_PATTERN | |
47 // HEX_PATTERN: HEX_COMPONENT | "[" HEX_GROUP_PATTERN "]" | "[*]" | |
wtc
2014/02/12 00:11:15
Please fix the grammar here and on line 53. '*' sh
jar (doing other things)
2014/02/15 21:14:56
Done.
| |
48 // HEX_GROUP_PATTERN: HEX_RANGE | HEX_GROUP_PATTERN "," HEX_RANGE | |
49 // HEX_RANGE: HEX_COMPONENT | HEX_COMPONENT "-" HEX_COMPONENT | |
50 // | |
51 // IP_V4_PATTERN: OCTET_PATTERN "." OCTET_PATTERN "." OCTET_PATTERN | |
52 // "." OCTET_PATTERN | |
53 // OCTET_PATTERN: OCTET | "[" OCTET_GROUP_PATTERN "]" | "[*]" | |
54 // OCTET_GROUP_PATTERN: OCTET_ITEM | OCTET_GROUP_PATTERN "," OCTET_ITEM | |
55 // OCTET_ITEM: OCTET | OCTET "-" OCTET | |
wtc
2014/02/11 23:52:30
I think OCTET_ITEM should be renamed OCTET_RANGE t
jar (doing other things)
2014/02/15 21:14:56
Done.
| |
56 // | |
57 // All literals are required to have all their components specified (4 | |
58 // components for IPv4, and 8 for IPv6). | |
wtc
2014/02/11 23:52:30
Nit: these two lines probably should have only one
jar (doing other things)
2014/02/15 21:14:56
Done.
| |
59 // Returns true if the rule was successfully parsed and added. | |
60 bool AddRuleFromString(const std::string& rule_string); | |
61 | |
62 // Sets the rules from a semicolon separated list of rules. | |
63 // Returns true if all the rules were successfully parsed and added. | |
64 bool SetRulesFromString(const std::string& rules_string); | |
65 | |
66 private: | |
67 // Delete all rules, starting with first_rule_. | |
68 void DeleteRules(); | |
69 | |
70 class MapRule; | |
wtc
2014/02/11 23:52:30
Nit: our Style Guide seems to recommend placing th
jar (doing other things)
2014/02/15 21:14:56
Done.
| |
71 // Singly linked list of rules. We own (and destroy) all rules by walking | |
72 // the list. | |
73 MapRule* first_rule_; | |
Ryan Hamilton
2014/02/12 00:44:03
nit: instead of implementing a linked-list manuall
jar (doing other things)
2014/02/15 21:14:56
Done.
| |
74 | |
75 DISALLOW_COPY_AND_ASSIGN(IPMappingRules); | |
76 }; | |
77 | |
78 } // namespace net | |
79 | |
80 #endif // NET_BASE_IP_MAPPING_RULES_H_ | |
OLD | NEW |