summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ospf6d/ospf6_interface.c8
-rw-r--r--ospf6d/ospf6_network.c82
-rw-r--r--ospf6d/ospf6_network.h6
3 files changed, 14 insertions, 82 deletions
diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c
index 13d69808..f6420513 100644
--- a/ospf6d/ospf6_interface.c
+++ b/ospf6d/ospf6_interface.c
@@ -399,12 +399,12 @@ ospf6_interface_state_change (u_char next_state, struct ospf6_interface *oi)
prev_state == OSPF6_INTERFACE_BDR) &&
(next_state != OSPF6_INTERFACE_DR &&
next_state != OSPF6_INTERFACE_BDR))
- ospf6_leave_alldrouters (oi->interface->ifindex);
+ ospf6_sso (oi->interface->ifindex, &alldrouters6, IPV6_LEAVE_GROUP);
if ((prev_state != OSPF6_INTERFACE_DR &&
prev_state != OSPF6_INTERFACE_BDR) &&
(next_state == OSPF6_INTERFACE_DR ||
next_state == OSPF6_INTERFACE_BDR))
- ospf6_join_alldrouters (oi->interface->ifindex);
+ ospf6_sso (oi->interface->ifindex, &alldrouters6, IPV6_JOIN_GROUP);
OSPF6_ROUTER_LSA_SCHEDULE (oi->area);
if (next_state == OSPF6_INTERFACE_DOWN)
@@ -612,7 +612,7 @@ interface_up (struct thread *thread)
}
/* Join AllSPFRouters */
- ospf6_join_allspfrouters (oi->interface->ifindex);
+ ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_JOIN_GROUP);
/* Update interface route */
ospf6_interface_connected_route_update (oi->interface);
@@ -707,7 +707,7 @@ interface_down (struct thread *thread)
/* Leave AllSPFRouters */
if (oi->state > OSPF6_INTERFACE_DOWN)
- ospf6_leave_allspfrouters (oi->interface->ifindex);
+ ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_LEAVE_GROUP);
ospf6_interface_state_change (OSPF6_INTERFACE_DOWN, oi);
diff --git a/ospf6d/ospf6_network.c b/ospf6d/ospf6_network.c
index 3372238b..e5a1436c 100644
--- a/ospf6d/ospf6_network.c
+++ b/ospf6d/ospf6_network.c
@@ -120,86 +120,22 @@ ospf6_serv_sock (void)
return 0;
}
+/* ospf6 set socket option */
void
-ospf6_join_allspfrouters (u_int ifindex)
-{
- struct ipv6_mreq mreq6;
- int retval;
-
- assert (ifindex);
- mreq6.ipv6mr_interface = ifindex;
- memcpy (&mreq6.ipv6mr_multiaddr, &allspfrouters6,
- sizeof (struct in6_addr));
-
- retval = setsockopt (ospf6_sock, IPPROTO_IPV6, IPV6_JOIN_GROUP,
- &mreq6, sizeof (mreq6));
-
- if (retval < 0)
- zlog_err ("Network: Join AllSPFRouters on ifindex %d failed: %s",
- ifindex, safe_strerror (errno));
-#if 0
- else
- zlog_debug ("Network: Join AllSPFRouters on ifindex %d", ifindex);
-#endif
-}
-
-void
-ospf6_leave_allspfrouters (u_int ifindex)
-{
- struct ipv6_mreq mreq6;
-
- assert (ifindex);
- mreq6.ipv6mr_interface = ifindex;
- memcpy (&mreq6.ipv6mr_multiaddr, &allspfrouters6,
- sizeof (struct in6_addr));
-
- if (setsockopt (ospf6_sock, IPPROTO_IPV6, IPV6_LEAVE_GROUP,
- &mreq6, sizeof (mreq6)) < 0)
- zlog_warn ("Network: Leave AllSPFRouters on ifindex %d Failed: %s",
- ifindex, safe_strerror (errno));
-#if 0
- else
- zlog_debug ("Network: Leave AllSPFRouters on ifindex %d", ifindex);
-#endif
-}
-
-void
-ospf6_join_alldrouters (u_int ifindex)
-{
- struct ipv6_mreq mreq6;
-
- assert (ifindex);
- mreq6.ipv6mr_interface = ifindex;
- memcpy (&mreq6.ipv6mr_multiaddr, &alldrouters6,
- sizeof (struct in6_addr));
-
- if (setsockopt (ospf6_sock, IPPROTO_IPV6, IPV6_JOIN_GROUP,
- &mreq6, sizeof (mreq6)) < 0)
- zlog_warn ("Network: Join AllDRouters on ifindex %d Failed: %s",
- ifindex, safe_strerror (errno));
-#if 0
- else
- zlog_debug ("Network: Join AllDRouters on ifindex %d", ifindex);
-#endif
-}
-
-void
-ospf6_leave_alldrouters (u_int ifindex)
+ospf6_sso (u_int ifindex, struct in6_addr *group, int option)
{
struct ipv6_mreq mreq6;
+ int ret;
assert (ifindex);
mreq6.ipv6mr_interface = ifindex;
- memcpy (&mreq6.ipv6mr_multiaddr, &alldrouters6,
- sizeof (struct in6_addr));
+ memcpy (&mreq6.ipv6mr_multiaddr, group, sizeof (struct in6_addr));
- if (setsockopt (ospf6_sock, IPPROTO_IPV6, IPV6_LEAVE_GROUP,
- &mreq6, sizeof (mreq6)) < 0)
- zlog_warn ("Network: Leave AllDRouters on ifindex %d Failed", ifindex);
-#if 0
- else
- zlog_debug ("Network: Leave AllDRouters on ifindex %d", ifindex);
-#endif
+ ret = setsockopt (ospf6_sock, IPPROTO_IPV6, option,
+ &mreq6, sizeof (mreq6));
+ if (ret < 0)
+ zlog_err ("Network: setsockopt (%d) on ifindex %d failed: %s",
+ option, ifindex, safe_strerror (errno));
}
static int
diff --git a/ospf6d/ospf6_network.h b/ospf6d/ospf6_network.h
index fd8758e8..0526b3e1 100644
--- a/ospf6d/ospf6_network.h
+++ b/ospf6d/ospf6_network.h
@@ -35,11 +35,7 @@ extern void ospf6_set_pktinfo (void);
extern void ospf6_set_checksum (void);
extern int ospf6_serv_sock (void);
-
-extern void ospf6_join_allspfrouters (u_int);
-extern void ospf6_leave_allspfrouters (u_int);
-extern void ospf6_join_alldrouters (u_int);
-extern void ospf6_leave_alldrouters (u_int);
+extern void ospf6_sso (u_int ifindex, struct in6_addr *group, int option);
extern int ospf6_sendmsg (struct in6_addr *, struct in6_addr *,
unsigned int *, struct iovec *);