示例#1
0
static bool if_getaddr_handler(const char *ifname,
			       const struct sa *sa, void *arg)
{
	struct ifentry *ife = arg;

	/* Match name of interface? */
	if (str_isset(ife->ifname) && 0 != str_casecmp(ife->ifname, ifname))
		return false;

	if (!sa_isset(sa, SA_ADDR))
		return false;

#if 1
	/* skip loopback and link-local IP */
	if (sa_is_loopback(sa) || sa_is_linklocal(sa))
		return false;
#endif

	/* Match address family */
	if (ife->af != sa_af(sa))
		return false;

	/* Match - copy address */
	sa_cpy(ife->ip, sa);
	ife->found = true;

	return ife->found;
}
示例#2
0
文件: agent.c 项目: alfredh/reicec
static bool interface_handler(const char *ifname, const struct sa *addr,
			      void *arg)
{
	struct agent *ag = arg;
	int err = 0;

	/* Skip loopback and link-local addresses */
	if (ag->cli->param.skip_local) {

		if (sa_is_loopback(addr) || sa_is_linklocal(addr))
			return false;
	}

	if (str_isset(ag->cli->param.ifname) &&
	    str_casecmp(ag->cli->param.ifname, ifname)) {
		return false;
	}

	switch (sa_af(addr)) {

	case AF_INET:
		if (!ag->cli->param.use_ipv4)
			return false;
		break;

	case AF_INET6:
		if (!ag->cli->param.use_ipv6)
			return false;
		break;
	}

	/* NOTE: on some machines an interface is listed twice. */
	if (interface_find(ag, addr)) {
		re_printf("ignoring duplicated interface (%s %j)\n",
			  ifname, addr);
		return false;
	}
	ag->interfacev[ag->interfacec++] = *addr;

	re_printf("interface: %s %j\n", ifname, addr);

	if (ag->cli->param.use_udp)
		err |= add_candidate(ag, addr, IPPROTO_UDP, 0, ifname);
	if (ag->cli->param.use_tcp) {
		err |= add_candidate(ag, addr, IPPROTO_TCP, ICE_TCP_SO,
				     ifname);
		err |= add_candidate(ag, addr, IPPROTO_TCP,
			     ag->client ? ICE_TCP_ACTIVE : ICE_TCP_PASSIVE,
			     ifname);
	}

	return err != 0;
}
示例#3
0
static bool linklocal_handler(const char *ifname, const struct sa *sa,
			      void *arg)
{
	void **argv = arg;
	int af = *(int *)argv[1];

	if (argv[0] && 0 != str_casecmp(argv[0], ifname))
		return false;

	if (af != AF_UNSPEC && af != sa_af(sa))
		return false;

	if (sa_is_linklocal(sa)) {
		*((struct sa *)argv[2]) = *sa;
		return true;
	}

	return false;
}