summaryrefslogtreecommitdiff
path: root/other_scripts/birdroutes.awk
blob: 615917abd80521cead31e9ea1a0d1847a283eafc (plain)
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
# Intended purpose: Pipe birdc s p all into this script

# initialize variable
BEGIN {
  if (!pref) {
    pref="^p_";
  }
  if (print_info=="") {
    print_info=0;
  }

  proto="";
  print "<table><tr><th>Peer</th><th>type</th><th>state</th>";
  if (print_info == 1) {
    print "<th>Info</th>";
  }
  print "</tr>";
  #rowspan='2'
#  print "<tr><th>imported</th><th>exported</th><th>preferred</th></tr>";
}
END {
  print "</table>";
}


# default output for birdc, filter
$1=="BIRD" || $1=="Name" {
  next
}

# if line begins with dn and is a BGP line
$0 ~ pref && $2=="BGP" {
  proto=$1
  print "<tr><td>" $1 "</td><td>" $2 "</td><td>" $4 "</td>";
  if (print_info == 1) {
    print "<td>" $6 "</td>";
  }
  print "</tr>";
  #rowspan='2'
  next
}

# for every other line "starting" a protocol
/^[a-zA-Z]/ {
  # reset proto
  proto=""
  next
}