]>
Commit | Line | Data |
---|---|---|
e2fb63d0 TP |
1 | Index: arpwatch/arp2ethers |
2 | diff -u arpwatch/arp2ethers:1.1.1.2 arpwatch/arp2ethers:1.1.1.1.14.4 | |
3 | --- arpwatch/arp2ethers:1.1.1.2 Tue Aug 10 10:53:34 2004 | |
4 | +++ arpwatch/arp2ethers Fri Aug 13 00:34:55 2004 | |
5 | @@ -12,12 +12,84 @@ | |
6 | # - append "-old", "-old1", etc. as necessary | |
7 | # - sort | |
8 | # | |
9 | +# 1999-04-12 KELEMEN Peter <fuji@debian.org> | |
10 | +# Use sh(1) instead of csh(1). | |
11 | +# | |
12 | +# 2000-03-21 Erik Warmelink <erik@selwerd.nl> | |
13 | +# Use next instead of continue in included p.awk. | |
14 | +# | |
15 | +# 2004-06-26 Javier Fernandez-Sanguino <jfs@debian.org> | |
16 | +# Use a default file or the one provided in the command line | |
17 | ||
18 | -sort +2rn arp.dat | \ | |
19 | +FILE=/var/lib/arpwatch/arp.dat | |
20 | +[ -n "$1" ] && FILE=$1 | |
21 | +[ -r "$FILE" ] || { | |
22 | + echo "Cannot read file $FILE" | |
23 | + exit 1 | |
24 | +} | |
25 | + | |
26 | +sort +2rn $FILE | \ | |
27 | awk 'NF == 4 { print }' | \ | |
28 | - awk -f p.awk | \ | |
29 | +# 1999-04-12 KELEMEN Peter <fuji@debian.org> | |
30 | +# awk -f p.awk | \ | |
31 | + awk ' | |
32 | +# Only print the first ethernet address seen | |
33 | + | |
34 | +{ | |
35 | + e = $1 | |
36 | + if (seen[e]) | |
37 | + next | |
38 | + seen[e] = 1 | |
39 | + print $0 | |
40 | +} | |
41 | + ' | \ | |
42 | egrep -v '\.[0-9][0-9]*$' | \ | |
43 | sed -e 's/ .* / /' | \ | |
44 | - awk -f d.awk | \ | |
45 | - awk -f e.awk | \ | |
46 | +# 1999-04-12 KELEMEN Peter <fuji@debian.org> | |
47 | +# awk -f d.awk | \ | |
48 | + awk ' | |
49 | +# DECnet hacking | |
50 | + | |
51 | +BEGIN { | |
52 | + n = 0 | |
53 | + sdecnet = "aa:0:4:" | |
54 | + ldecnet = length(sdecnet) | |
55 | +} | |
56 | + | |
57 | +{ | |
58 | + ++n | |
59 | + e[n] = $1 | |
60 | + h[n] = $2 | |
61 | + if (sdecnet == substr($1, 1, ldecnet)) | |
62 | + decnet[$2] = 1 | |
63 | +} | |
64 | + | |
65 | +END { | |
66 | + for (i = 1; i <= n; ++i) { | |
67 | + if (decnet[h[i]] && sdecnet != substr(e[i], 1, ldecnet)) | |
68 | + h[i] = h[i] "-ip" | |
69 | + print e[i] "\t" h[i] | |
70 | + } | |
71 | +} | |
72 | + ' | \ | |
73 | +# 1999-04-12 KELEMEN Peter <fuji@debian.org> | |
74 | +# awk -f e.awk | \ | |
75 | + awk ' | |
76 | +# Add -old suffix to ethers file, as required. Assumed sorted input | |
77 | + | |
78 | +{ | |
79 | + if (!seen[$2]) { | |
80 | + seen[$2] = 1 | |
81 | ||
82 | + next | |
83 | + } | |
84 | + h = $2 "-old" | |
85 | + s = h | |
86 | + for (n = 1; seen[h]; ++n) | |
87 | + h = s n | |
88 | + seen[h] = 1 | |
89 | + print $1 "\t" h | |
90 | + next | |
91 | +} | |
92 | + ' | \ | |
93 | sort |