-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathietf-tech-report
executable file
·253 lines (210 loc) · 6.51 KB
/
ietf-tech-report
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
#!/usr/bin/env perl
#
# Copyright (c) 2012 IETF Trust and the persons identified as
# authors of the code. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# Neither the name of Internet Society, IETF or IETF Trust, nor the
# names of specific contributors, may be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# Author: Alan DeKok <[email protected]>
#
use Getopt::Std;
%drafts = (); # information about the draft
%rfc = (); # information about the RFC
%search = (); # option: search for drafts using these RFCs
%opts = (); # command-line options
%wgs = (); # working groups to ignore
%tech = (); # named technologies
$keyword = "";
getopts('hik:Nr:W:', \%opts);
if ($opts{'h'}) {
print "ietf-tech-report [-h] [-i] [-N] [-r LIST] [-W EXCLUDE] tech...\n";
print " -h print this message\n";
print " -i include informative references for the technologies\n";
print " -k keyword(s) to look for\n";
print " -N exclude normative references (default is to include them)\n";
print " -r LIST comma-separated list of key RFCs\n";
print " -W EXCLUDE comma-separated list of working groups to exclude\n";
print "\n";
print " The 'tech' is a list of RFCs or technologies to look for.\n";
print " See the file 'tech.txt' for more configuration\n";
exit(1);
}
# The arguments are just a list of RFCs to look for.
#
# -r 2865,2866,3179
foreach (split(/,/, $opts{'r'})) {
if (! /^\d+$/) {
die "FATAL: Command line option is not a number: -r $_\n";
}
$search{$_}++;
}
# A list of Working groups to exclude. It's a good idea to exclude the
# working groups generating the drafts. We presume that people in the WG
# already know that the drafts exist.
#
# -W radext,dime
foreach (split(/,/,$opts{'W'})) {
$wgs{$_} = 0;
}
# The rest of the command-line arguments are the technologies to look for.
foreach $name (@ARGV) {
$tech{$name}++;
}
if (! $opts{'k'}) {
undef $keyword;
} else {
$keyword = $opts{'k'};
$keyword =~ tr/[A-Z]/[a-z]/;
}
# Get the list of named technologies
if (scalar keys %tech > 0) {
open FILE, "<tech.txt";
$lineno = 0;
while (<FILE>) {
$lineno++;
s/#.*$//;
next if (/^\s*$/);
@words = split /\s/;
# ignore technologies that weren't named
next if (! defined $tech{$words[0]});
shift @words;
# -WG #### -WG #### #### -WG
foreach $doc (@words) {
# -foo means "ignore WG foo"
if ($doc =~ /^-/) {
$doc =~ s/^-//;
$wgs{$doc} = 0;
} elsif ($doc eq '') {
next;
} elsif ($doc !~ /^\d+/) {
die "FATAL: tech.txt line $lineno unrecognized text '$doc'\n";
} else {
$search{$doc}++;
}
}
}
close FILE;
}
if (scalar keys %search == 0) {
if (scalar keys %tech > 0) {
if (!$keyword) {
die "FATAL: Failed to find ", join ' ', @ARGV, "\n";
}
}
# die "FATAL: Nothing to search for.\n";
}
# Open the list of active internet drafts.
open FILE, "<internet-drafts/all_id.txt" or die "Can't open all_id.txt\n";
while (<FILE>) {
$_ =~ /^(draft-ietf-.*)\s+\d{4}-\d{2}-\d{2}\s+(.*)$/;
$doc = $1;
$state = $2;
$doc =~ /draft-ietf-([^-]+)-/;
$wg = $1;
# Ignore drafts which have been published as RFCs
next if ($state =~ /^RFC/);
# Ignore certain WGs. i.e. ignore RADEXT references to RADIUS rfcs.
if (defined $wgs{$wg}) {
next if ($wgs{$wg} == 0);
}
# cache the state of the draft.
$drafts{$doc}{'state'} = $state;
}
close FILE;
sub check {
my $line = shift;
my $ref = shift;
# Look for [RFC2865]
if ($line =~ /\[RFC(\d+)\]/) {
$drafts{$doc}{$ref}{$1}++;
$rfc{$1}{$doc}++;
return;
}
# Or maybe "RFC 2865,"
if ($line =~ /RFC (\d+),/) {
$drafts{$doc}{$ref}{$1}++;
$rfc{$1}{$doc}++;
return;
}
# TO DO: have a smarter parser.
}
#
# Root through all of the drafts, finding the documents they reference.
#
foreach $doc (keys %drafts) {
# Ignore ones which no longer exist.
open FILE, "<internet-drafts/$doc.txt" or next;
$normative = 0;
$informative = 0;
# print "? $doc\n";
while (<FILE>) {
if ($keyword && !$rfc{$keyword}{$doc} && ($_ =~ /$keyword/i)) {
$drafts{$doc}{"normative"}{$keyword}++;
$rfc{$keyword}{$doc}++;
}
# Ignore everything until we find the "Normative References" section.
if (/^\d/) {
if (/\s*normative references\s*$/i && !$opts{'N'}) {
$normative = 1;
$informative = 0;
}
if (/\s*informative references\s*$/i) {
$informative = $opts{'i'};
$normative = 0;
}
next;
}
# In the "normative references" section.
if ($normative) {
check($_, 'normative');
}
if ($informative) {
check($_, 'informative');
}
}
close FILE;
}
# For each RFC we're interested in, grab the list of drafts
# which reference that RFC. Cache the draft.
%output = ();
foreach $doc (keys %search,$keyword) {
# find each draft that has a normative reference to the RFC
foreach $ref (keys %{$rfc{$doc}}) {
$output{$ref} = $drafts{$ref}{'state'};
}
}
# and print out the drafts by name, in sorted order
foreach $ref (sort {$a cmp $b} keys %output) {
$padding = 50 - length($ref);
print $ref, ' ' x $padding, $drafts{$ref}{'state'}, "\n";
}
exit 0;