1 /*
2 */
3
4 #include "graph.h"
5
6 #define CONVABS(idx,base) \
7 (((intptr_t)(idx))==-1 ? NULL : ((intptr_t)(idx))+(base))
8 #define RELTOABS(ptr,base) ((ptr)= CONVABS ((ptr), (base)))
9 #define PROLOGABS(m,d,base) \
10 do { \
11 m = mobj_count (d) ; \
12 mobj_sethead ((d), CONVABS (mobj_head (d), (base))) ; \
13 } while (0)
14
15
rel_to_abs(MOBJ * graph[])16 void rel_to_abs (MOBJ *graph [])
17 {
18 int i, max ;
19
20 struct symtab **hashtab = mobj_data (graph [HASHMOBJIDX]) ;
21 struct symtab *symtab = mobj_data (graph [SYMMOBJIDX]) ;
22 char *strtab = mobj_data (graph [STRMOBJIDX]) ;
23 struct node *nodetab = mobj_data (graph [NODEMOBJIDX]) ;
24 struct link *linktab = mobj_data (graph [LINKMOBJIDX]) ;
25 struct linklist *llisttab = mobj_data (graph [LLISTMOBJIDX]) ;
26 struct eq *eqtab = mobj_data (graph [EQMOBJIDX]) ;
27 struct vlan *vlantab = mobj_data (graph [VLANMOBJIDX]) ;
28 struct network *nettab = mobj_data (graph [NETMOBJIDX]) ;
29 struct netlist *nlisttab = mobj_data (graph [NLISTMOBJIDX]) ;
30 struct lvlan *lvlantab = mobj_data (graph [LVLANMOBJIDX]) ;
31 struct rnet *rnettab = mobj_data (graph [RNETMOBJIDX]) ;
32 struct route *routetab = mobj_data (graph [ROUTEMOBJIDX]) ;
33 struct ssid *ssidtab = mobj_data (graph [SSIDMOBJIDX]) ;
34 struct ssidprobe *ssidprobetab = mobj_data (graph [SSIDPROBEMOBJIDX]) ;
35
36 PROLOGABS (max, graph [HASHMOBJIDX], hashtab) ;
37 for (i = 0 ; i < max ; i++)
38 {
39 RELTOABS (hashtab [i], symtab) ;
40 }
41
42 PROLOGABS (max, graph [SYMMOBJIDX], symtab) ;
43 for (i = 0 ; i < max ; i++)
44 {
45 RELTOABS (symtab [i].name, strtab) ;
46 RELTOABS (symtab [i].node, nodetab) ;
47 RELTOABS (symtab [i].link, linktab) ;
48 RELTOABS (symtab [i].next, symtab) ;
49 }
50
51 PROLOGABS (max, graph [STRMOBJIDX], strtab) ;
52 /* nothing for strmobj */
53
54 PROLOGABS (max, graph [SSIDMOBJIDX], ssidtab) ;
55 for (i = 0 ; i < max ; i++)
56 {
57 RELTOABS (ssidtab [i].name, strtab) ;
58 RELTOABS (ssidtab [i].next, ssidtab) ;
59 }
60
61 PROLOGABS (max, graph [EQMOBJIDX], eqtab) ;
62 for (i = 0 ; i < max ; i++)
63 {
64 RELTOABS (eqtab [i].name, strtab) ;
65 RELTOABS (eqtab [i].type, strtab) ;
66 RELTOABS (eqtab [i].model, strtab) ;
67 RELTOABS (eqtab [i].snmp, strtab) ;
68 RELTOABS (eqtab [i].location, strtab) ;
69 RELTOABS (eqtab [i].enhead, nodetab) ;
70 RELTOABS (eqtab [i].entail, nodetab) ;
71 RELTOABS (eqtab [i].next, eqtab) ;
72 }
73
74 PROLOGABS (max, graph [NODEMOBJIDX], nodetab) ;
75 for (i = 0 ; i < max ; i++)
76 {
77 RELTOABS (nodetab [i].name, strtab) ;
78 RELTOABS (nodetab [i].eq, eqtab) ;
79 RELTOABS (nodetab [i].next, nodetab) ;
80 RELTOABS (nodetab [i].enext, nodetab) ;
81 RELTOABS (nodetab [i].eprev, nodetab) ;
82 RELTOABS (nodetab [i].linklist, llisttab) ;
83
84 switch (nodetab [i].nodetype)
85 {
86 case NT_L1 :
87 RELTOABS (nodetab [i].u.l1.ifname, strtab) ;
88 RELTOABS (nodetab [i].u.l1.ifdesc, strtab) ;
89 RELTOABS (nodetab [i].u.l1.link, strtab) ;
90 RELTOABS (nodetab [i].u.l1.stat, strtab) ;
91 RELTOABS (nodetab [i].u.l1.radio.ssid, ssidtab) ;
92 break ;
93 case NT_L2 :
94 RELTOABS (nodetab [i].u.l2.stat, strtab) ;
95 RELTOABS (nodetab [i].u.l2.ifname, strtab) ;
96 break ;
97 case NT_ROUTER :
98 RELTOABS (nodetab [i].u.router.name, strtab) ;
99 break ;
100 default :
101 break ;
102 }
103 }
104
105 PROLOGABS (max, graph [LINKMOBJIDX], linktab) ;
106 for (i = 0 ; i < max ; i++)
107 {
108 RELTOABS (linktab [i].name, strtab) ;
109 RELTOABS (linktab [i].node [0], nodetab) ;
110 RELTOABS (linktab [i].node [1], nodetab) ;
111 }
112
113 PROLOGABS (max, graph [LLISTMOBJIDX], llisttab) ;
114 for (i = 0 ; i < max ; i++)
115 {
116 RELTOABS (llisttab [i].link, linktab) ;
117 RELTOABS (llisttab [i].next, llisttab) ;
118 }
119
120 PROLOGABS (max, graph [NETMOBJIDX], nettab) ;
121 for (i = 0 ; i < max ; i++)
122 {
123 RELTOABS (nettab [i].next, nettab) ;
124 }
125
126 PROLOGABS (max, graph [NLISTMOBJIDX], nlisttab) ;
127 for (i = 0 ; i < max ; i++)
128 {
129 RELTOABS (nlisttab [i].net, nettab) ;
130 RELTOABS (nlisttab [i].next, nlisttab) ;
131 }
132
133 PROLOGABS (max, graph [LVLANMOBJIDX], lvlantab) ;
134 for (i = 0 ; i < max ; i++)
135 {
136 RELTOABS (lvlantab [i].eq, eqtab) ;
137 RELTOABS (lvlantab [i].name, strtab) ;
138 RELTOABS (lvlantab [i].next, lvlantab) ;
139 }
140
141 PROLOGABS (max, graph [VLANMOBJIDX], vlantab) ;
142 for (i = 0 ; i < max ; i++)
143 {
144 RELTOABS (vlantab [i].name, strtab) ;
145 RELTOABS (vlantab [i].netlist, nlisttab) ;
146 RELTOABS (vlantab [i].lvlan, lvlantab) ;
147 }
148
149 PROLOGABS (max, graph [RNETMOBJIDX], rnettab) ;
150 for (i = 0 ; i < max ; i++)
151 {
152 RELTOABS (rnettab [i].net, nettab) ;
153 RELTOABS (rnettab [i].router, nodetab) ;
154 RELTOABS (rnettab [i].l3, nodetab) ;
155 RELTOABS (rnettab [i].l2, nodetab) ;
156 RELTOABS (rnettab [i].l1, nodetab) ;
157 RELTOABS (rnettab [i].routelist, routetab) ;
158 RELTOABS (rnettab [i].next, rnettab) ;
159 }
160
161 PROLOGABS (max, graph [ROUTEMOBJIDX], routetab) ;
162 for (i = 0 ; i < max ; i++)
163 {
164 RELTOABS (routetab [i].next, routetab) ;
165 }
166
167 PROLOGABS (max, graph [SSIDPROBEMOBJIDX], ssidprobetab) ;
168 for (i = 0 ; i < max ; i++)
169 {
170 RELTOABS (ssidprobetab [i].name, strtab) ;
171 RELTOABS (ssidprobetab [i].eq, eqtab) ;
172 RELTOABS (ssidprobetab [i].l1, nodetab) ;
173 RELTOABS (ssidprobetab [i].ssid, ssidtab) ;
174 RELTOABS (ssidprobetab [i].next, ssidprobetab) ;
175 }
176 }
177