* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <errno.h>
+#include <string.h>
#include <unistd.h>
#include "gnetworkmonitornetlink.h"
static void
g_network_monitor_netlink_init (GNetworkMonitorNetlink *nl)
{
- nl->priv = g_network_monitor_netlink_get_private (nl);
+ nl->priv = g_network_monitor_netlink_get_instance_private (nl);
}
add_network (GNetworkMonitorNetlink *nl,
GSocketFamily family,
gint dest_len,
- guint8 *dest,
- guint8 *gateway)
+ guint8 *dest)
{
GInetAddress *dest_addr;
GInetAddressMask *network;
remove_network (GNetworkMonitorNetlink *nl,
GSocketFamily family,
gint dest_len,
- guint8 *dest,
- guint8 *gateway)
+ guint8 *dest)
{
GInetAddress *dest_addr;
GInetAddressMask *network;
struct rtmsg *rtmsg;
struct rtattr *attr;
gsize attrlen;
- guint8 *dest, *gateway;
+ guint8 *dest, *gateway, *oif;
gboolean retval = TRUE;
iv.buffer = NULL;
attrlen = NLMSG_PAYLOAD (msg, sizeof (struct rtmsg));
attr = RTM_RTA (rtmsg);
- dest = gateway = NULL;
+ dest = gateway = oif = NULL;
while (RTA_OK (attr, attrlen))
{
if (attr->rta_type == RTA_DST)
dest = RTA_DATA (attr);
else if (attr->rta_type == RTA_GATEWAY)
gateway = RTA_DATA (attr);
+ else if (attr->rta_type == RTA_OIF)
+ oif = RTA_DATA (attr);
attr = RTA_NEXT (attr, attrlen);
}
- if (dest || gateway)
+ if (dest || gateway || oif)
{
+ /* Unless we're processing the results of a dump, ignore
+ * IPv6 link-local multicast routes, which are added and
+ * removed all the time for some reason.
+ */
+#define UNALIGNED_IN6_IS_ADDR_MC_LINKLOCAL(a) \
+ ((a[0] == 0xff) && ((a[1] & 0xf) == 0x2))
+
+ if (!nl->priv->dump_networks &&
+ rtmsg->rtm_family == AF_INET6 &&
+ rtmsg->rtm_dst_len != 0 &&
+ UNALIGNED_IN6_IS_ADDR_MC_LINKLOCAL (dest))
+ continue;
+
if (msg->nlmsg_type == RTM_NEWROUTE)
- add_network (nl, rtmsg->rtm_family, rtmsg->rtm_dst_len, dest, gateway);
+ add_network (nl, rtmsg->rtm_family, rtmsg->rtm_dst_len, dest);
else
- remove_network (nl, rtmsg->rtm_family, rtmsg->rtm_dst_len, dest, gateway);
+ remove_network (nl, rtmsg->rtm_family, rtmsg->rtm_dst_len, dest);
queue_request_dump (nl);
}
break;