/** * Get the Link-local address for a specific network interface * * @param ifname Name of the interface * @param af Address family * @param ip Returned link-local address * * @return 0 if success, otherwise errorcode */ int net_if_getlinklocal(const char *ifname, int af, struct sa *ip) { struct sa addr; void *argv[3]; int err; if (!ip) return EINVAL; sa_init(&addr, sa_af(ip)); argv[0] = (void *)ifname; argv[1] = ⁡ argv[2] = &addr; err = net_if_apply(linklocal_handler, argv); if (err) return err; if (!sa_isset(&addr, SA_ADDR)) return ENOENT; *ip = addr; return 0; }
void agent_gather(struct agent *ag) { int err; if (!ag) return; net_if_apply(interface_handler, ag); re_printf("HOST gathering complete (interfaces = %u)\n", ag->interfacec); if (is_gathering_complete(ag)) { re_printf("local candidate gathering completed" " -- sending EOC\n"); ag->local_eoc = true; err = control_send_message(ag->cli, "a=end-of-candidates\r\n"); if (err) { re_fprintf(stderr, "failed to send EOC\n"); } } }