MCPcopy Create free account
hub / github.com/F-Stack/f-stack / routepr

Function routepr

tools/netstat/route.c:120–156  ·  view source on GitHub ↗

* Print routing tables. */

Source from the content-addressed store, hash-verified

118 * Print routing tables.
119 */
120void
121routepr(int fibnum, int af)
122{
123 size_t intsize;
124 int numfibs;
125
126 if (live == 0)
127 return;
128
129 intsize = sizeof(int);
130 if (fibnum == -1 &&
131 sysctlbyname("net.my_fibnum", &fibnum, &intsize, NULL, 0) == -1)
132 fibnum = 0;
133 if (sysctlbyname("net.fibs", &numfibs, &intsize, NULL, 0) == -1)
134 numfibs = 1;
135 if (fibnum < 0 || fibnum > numfibs - 1)
136 errx(EX_USAGE, "%d: invalid fib", fibnum);
137 /*
138 * Since kernel & userland use different timebase
139 * (time_uptime vs time_second) and we are reading kernel memory
140 * directly we should do rt_expire --> expire_time conversion.
141 */
142#ifndef FSTACK
143 if (clock_gettime(CLOCK_UPTIME, &uptime) < 0)
144#else
145 if (clock_gettime(CLOCK_BOOTTIME, &uptime) < 0)
146#endif
147 err(EX_OSERR, "clock_gettime() failed");
148
149 xo_open_container("route-information");
150 xo_emit("{T:Routing tables}");
151 if (fibnum)
152 xo_emit(" ({L:fib}: {:fib/%d})", fibnum);
153 xo_emit("\n");
154 p_rtable_sysctl(fibnum, af);
155 xo_close_container("route-information");
156}
157
158
159/*

Callers 1

main.cFile · 0.85

Calls 5

sysctlbynameFunction · 0.85
xo_open_containerFunction · 0.85
xo_emitFunction · 0.85
p_rtable_sysctlFunction · 0.85
xo_close_containerFunction · 0.85

Tested by

no test coverage detected