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

Function bridge_addresses

tools/ifconfig/ifbridge.c:204–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202}
203
204static void
205bridge_addresses(int s, const char *prefix)
206{
207 struct ifbaconf ifbac;
208 struct ifbareq *ifba;
209 char *inbuf = NULL, *ninbuf;
210 int i, len = 8192;
211 struct ether_addr ea;
212
213 for (;;) {
214 ninbuf = realloc(inbuf, len);
215 if (ninbuf == NULL)
216 err(1, "unable to allocate address buffer");
217 ifbac.ifbac_len = len;
218 ifbac.ifbac_buf = inbuf = ninbuf;
219 if (do_cmd(s, BRDGRTS, &ifbac, sizeof(ifbac), 0) < 0)
220 err(1, "unable to get address cache");
221 if ((ifbac.ifbac_len + sizeof(*ifba)) < len)
222 break;
223 len *= 2;
224 }
225
226 for (i = 0; i < ifbac.ifbac_len / sizeof(*ifba); i++) {
227 ifba = ifbac.ifbac_req + i;
228 memcpy(ea.octet, ifba->ifba_dst,
229 sizeof(ea.octet));
230 printf("%s%s Vlan%d %s %lu ", prefix, ether_ntoa(&ea),
231 ifba->ifba_vlan, ifba->ifba_ifsname, ifba->ifba_expire);
232 printb("flags", ifba->ifba_flags, IFBAFBITS);
233 printf("\n");
234 }
235
236 free(inbuf);
237}
238
239static void
240bridge_status(int s)

Callers 1

setbridge_addrFunction · 0.85

Calls 6

do_cmdFunction · 0.70
printbFunction · 0.70
reallocFunction · 0.50
memcpyFunction · 0.50
printfFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected