/* This socket is used for TXing IGMP packets only, IGMP RX happens
* in pim_mroute_msg()
*/
-static int igmp_sock_open(struct in_addr ifaddr, ifindex_t ifindex, uint32_t pim_options)
+static int igmp_sock_open(struct in_addr ifaddr, struct interface *ifp, uint32_t pim_options)
{
int fd;
int join = 0;
struct in_addr group;
- fd = pim_socket_mcast(IPPROTO_IGMP, ifaddr, ifindex, 1);
+ fd = pim_socket_mcast(IPPROTO_IGMP, ifaddr, ifp, 1);
if (fd < 0)
return -1;
if (PIM_IF_TEST_IGMP_LISTEN_ALLROUTERS(pim_options)) {
if (inet_aton(PIM_ALL_ROUTERS, &group)) {
- if (!pim_socket_join(fd, group, ifaddr, ifindex))
+ if (!pim_socket_join(fd, group, ifaddr, ifp->ifindex))
++join;
}
else {
IGMP routers must receive general queries for querier election.
*/
if (inet_aton(PIM_ALL_SYSTEMS, &group)) {
- if (!pim_socket_join(fd, group, ifaddr, ifindex))
+ if (!pim_socket_join(fd, group, ifaddr, ifp->ifindex))
++join;
}
else {
}
if (inet_aton(PIM_ALL_IGMP_ROUTERS, &group)) {
- if (!pim_socket_join(fd, group, ifaddr, ifindex)) {
+ if (!pim_socket_join(fd, group, ifaddr, ifp->ifindex)) {
++join;
}
}
pim_ifp = ifp->info;
- fd = igmp_sock_open(ifaddr, ifp->ifindex, pim_ifp->options);
+ fd = igmp_sock_open(ifaddr, ifp, pim_ifp->options);
if (fd < 0) {
zlog_warn("Could not open IGMP socket for %s on %s",
inet_ntoa(ifaddr), ifp->name);
pim_ifp->pim_sock_fd);
}
-static int pim_sock_open(struct in_addr ifaddr, ifindex_t ifindex)
+static int pim_sock_open(struct in_addr ifaddr, struct interface *ifp)
{
int fd;
- fd = pim_socket_mcast(IPPROTO_PIM, ifaddr, ifindex, 0 /* loop=false */);
+ fd = pim_socket_mcast(IPPROTO_PIM, ifaddr, ifp, 0 /* loop=false */);
if (fd < 0)
return -1;
- if (pim_socket_join(fd, qpim_all_pim_routers_addr, ifaddr, ifindex)) {
+ if (pim_socket_join(fd, qpim_all_pim_routers_addr, ifaddr, ifp->ifindex)) {
close(fd);
return -2;
}
ifaddr = pim_ifp->primary_address;
- pim_ifp->pim_sock_fd = pim_sock_open(ifaddr, ifp->ifindex);
+ pim_ifp->pim_sock_fd = pim_sock_open(ifaddr, ifp);
if (pim_ifp->pim_sock_fd < 0) {
if (PIM_DEBUG_PIM_PACKETS)
zlog_debug("Could not open PIM socket on interface %s",
return ret;
}
-int pim_socket_mcast(int protocol, struct in_addr ifaddr, int ifindex, u_char loop)
+int pim_socket_mcast(int protocol, struct in_addr ifaddr, struct interface *ifp, u_char loop)
{
int rcvbuf = 1024 * 1024 * 8;
#ifdef HAVE_STRUCT_IP_MREQN_IMR_IFINDEX
if (protocol == IPPROTO_PIM)
{
int ret;
- struct interface *ifp = NULL;
-
- ifp = if_lookup_by_index_vrf (ifindex, VRF_DEFAULT);
ret = pim_socket_bind (fd, ifp);
if (ret)
memset (&mreq, 0, sizeof (mreq));
#ifdef HAVE_STRUCT_IP_MREQN_IMR_IFINDEX
- mreq.imr_ifindex = ifindex;
+ mreq.imr_ifindex = ifp->ifindex;
#else
/*
* I am not sure what to do here yet for *BSD
int pim_socket_bind (int fd, struct interface *ifp);
int pim_socket_ip_hdr (int fd);
int pim_socket_raw(int protocol);
-int pim_socket_mcast(int protocol, struct in_addr ifaddr, int ifindex, u_char loop);
+int pim_socket_mcast(int protocol, struct in_addr ifaddr, struct interface *ifp, u_char loop);
int pim_socket_join(int fd, struct in_addr group,
struct in_addr ifaddr, ifindex_t ifindex);
int pim_socket_join_source(int fd, ifindex_t ifindex,