Beispiel #1
0
NMRDisc *
nm_lndp_rdisc_new (int ifindex, const char *ifname)
{
	NMRDisc *rdisc;
	NMLNDPRDiscPrivate *priv;
	int error;

	rdisc = g_object_new (NM_TYPE_LNDP_RDISC, NULL);

	rdisc->ifindex = ifindex;
	rdisc->ifname = g_strdup (ifname);

	rdisc->max_addresses = ipv6_sysctl_get (ifname, "max_addresses",
	                                        NM_RDISC_MAX_ADDRESSES_DEFAULT);
	rdisc->rtr_solicitations = ipv6_sysctl_get (ifname, "router_solicitations",
	                                            NM_RDISC_RTR_SOLICITATIONS_DEFAULT);
	rdisc->rtr_solicitation_interval = ipv6_sysctl_get (ifname, "router_solicitation_interval",
	                                                    NM_RDISC_RTR_SOLICITATION_INTERVAL_DEFAULT);

	priv = NM_LNDP_RDISC_GET_PRIVATE (rdisc);
	error = ndp_open (&priv->ndp);
	if (error != 0) {
		g_object_unref (rdisc);
		debug ("(%s): error creating socket for NDP; errno=%d", ifname, -error);
		return NULL;
	}
	return rdisc;
}
Beispiel #2
0
static gboolean
send_rs (NMRDisc *rdisc)
{
	NMLNDPRDiscPrivate *priv = NM_LNDP_RDISC_GET_PRIVATE (rdisc);
	struct ndp_msg *msg;
	int error;

	error = ndp_msg_new (&msg, NDP_MSG_RS);
	g_assert (!error);
	ndp_msg_ifindex_set (msg, rdisc->ifindex);

	error = ndp_msg_send (priv->ndp, msg);
	ndp_msg_destroy (msg);
	if (error) {
		_LOGE ("cannot send router solicitation: %d.", error);
		return FALSE;
	}

	return TRUE;
}