summaryrefslogtreecommitdiffstats
path: root/gdb/ospf.txt
blob: 984104b8514432b0ce5f8fe7e394857bd8119eae (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
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
# GDB macros for use with Quagga.
#
# Macros in this file are specific to ospfd/. Definitions here depend on the
# lib.txt macros file, which must also be loaed.
#
# The macro file can be loaded with 'source <filename>'. They can then be   
# called by the user. Macros that explore more complicated structs generally
# take pointer arguments. 

define dump_ospf_lsa_flags
  set $flags = $arg0
  
  printf "%u: ", $flags
  
  if $flags & 0x1
    echo Self,
  end
  if $flags & 0x2
    echo Self-checked,
  end
  if $flags & 0x4
    echo Recvd,
  end
  if $flags & 0x8
    echo Apprvd,
  end
  if $flags & 0x10
    echo Discard,
  end
  if $flags & 0x20
    echo Local-Xlt,
  end
  if $flags & 0x40
    echo Premature-Aged,
  end
  if $flags & 0x40
    echo In-Maxage,
  end
  echo \n
end

define dump_ospf_lsa_data
  set $lsad = (struct lsa_header *)$arg0
  
  echo ID / AdvRtr:  \t\t
  dump_s_addr &$lsad->id.s_addr
  echo \ : \ 
  dump_s_addr &$lsad->adv_router.s_addr
  echo \n
  
  def_ntohs &$lsad->ls_age
  printf "Type: %2u Age: %4u,", $lsad->type, $_
  
  def_ntohs &$lsad->length
  printf " length: %2u", $_
  
  def_ntohl &$lsad->ls_seqnum
  printf " Seqnum: 0x%08x", $_
  
  def_ntohs &$lsad->checksum
  printf " csum: 0x%04x\n", $_
  
  # return the age
  def_ntohs &$lsad->ls_age
end

define dump_ospf_lsa
  set $lsa = (struct ospf_lsa *)$arg0
  
  #print/x *$lsa
  
  dump_ospf_lsa_data $lsa->data
  
  set $relage = $_ + (relative_time.tv_sec - $lsa->tv_recv.tv_sec)
  printf "Relative age: %4u\n", $relage
  
  dump_ospf_lsa_flags $lsa->flags
  
  echo tv_recv: \ 
  dump_timeval &$lsa->tv_recv
  echo \ tv_orig: \ 
  dump_timeval &$lsa->tv_orig
  echo \n
  
  printf "lock %2u", $lsa->lock
  printf " stat %2d", $lsa->stat
  printf " rtx count: %u", $lsa->retransmit_counter
  printf " rfsh list: %d", $lsa->refresh_list
  printf "\n\n"
end

define walk_ospf_lsdb
  set $node = (struct route_node *)$arg0
  set $top = (struct route_node *)$arg0
  set $visited = 0
  
  while ($node != 0)
    set $prevl = $node
    
    if ($node->info != 0)
      dump_ospf_lsa $node->info
      set $visited = $visited + 1
    end
    
    walk_route_table_next $top $node
    set $node = $_
    
    # we've gotten back to the top, finish
    if ($node == $top)
      set $node = 0
    end
  end
  printf "Visited: %u\n", $visited
end

document walk_ospf_lsdb
Walk through an OSPF LSDB (or subset thereof) and dump all the LSAs
contained there-in.

Argument: A (struct route_node *) pointing to the top of the
LSDB route-table which should be dumped.
end

define ospf_backbone_lsdb_top
  set $type = $arg0
  
  set $ospf = ospf_master->ospf->head->data
  
  output/x ((struct ospf *)$ospf)->backbone->lsdb->type[$type]->db->top
  echo \n
end
document ospf_backbone_lsdb_top
Dump location of the LSDB in the backbone area for the given LSA type

Argument: Integer LSA type
end