/*
  PIM for Quagga
  Copyright (C) 2008  Everton da Silva Marques

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  General Public License for more details.
  
  You should have received a copy of the GNU General Public License
  along with this program; see the file COPYING; if not, write to the
  Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
  MA 02110-1301 USA
  
  $QuaggaId: $Format:%an, %ai, %h$ $
*/

#ifndef PIM_IFACE_H
#define PIM_IFACE_H

#include <zebra.h>

#include "if.h"
#include "vty.h"

#include "pim_igmp.h"

#define PIM_IF_MASK_PIM                             (1 << 0)
#define PIM_IF_MASK_IGMP                            (1 << 1)
#define PIM_IF_MASK_IGMP_LISTEN_ALLROUTERS          (1 << 2)
#define PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPRESSION (1 << 3)

#define PIM_IF_IS_DELETED(ifp) ((ifp)->ifindex == IFINDEX_INTERNAL)

#define PIM_IF_TEST_PIM(options) (PIM_IF_MASK_PIM & (options))
#define PIM_IF_TEST_IGMP(options) (PIM_IF_MASK_IGMP & (options))
#define PIM_IF_TEST_IGMP_LISTEN_ALLROUTERS(options) (PIM_IF_MASK_IGMP_LISTEN_ALLROUTERS & (options))
#define PIM_IF_TEST_PIM_CAN_DISABLE_JOIN_SUPRESSION(options) (PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPRESSION & (options))

#define PIM_IF_DO_PIM(options) ((options) |= PIM_IF_MASK_PIM)
#define PIM_IF_DO_IGMP(options) ((options) |= PIM_IF_MASK_IGMP)
#define PIM_IF_DO_IGMP_LISTEN_ALLROUTERS(options) ((options) |= PIM_IF_MASK_IGMP_LISTEN_ALLROUTERS)
#define PIM_IF_DO_PIM_CAN_DISABLE_JOIN_SUPRESSION(options) ((options) |= PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPRESSION)

#define PIM_IF_DONT_PIM(options) ((options) &= ~PIM_IF_MASK_PIM)
#define PIM_IF_DONT_IGMP(options) ((options) &= ~PIM_IF_MASK_IGMP)
#define PIM_IF_DONT_IGMP_LISTEN_ALLROUTERS(options) ((options) &= ~PIM_IF_MASK_IGMP_LISTEN_ALLROUTERS)
#define PIM_IF_DONT_PIM_CAN_DISABLE_JOIN_SUPRESSION(options) ((options) &= ~PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPRESSION)

struct pim_interface {
  uint32_t       options;                            /* bit vector */
  int            mroute_vif_index;
  struct in_addr primary_address; /* remember addr to detect change */

  int          igmp_default_robustness_variable;   /* IGMPv3 QRV */
  int          igmp_default_query_interval;        /* IGMPv3 secs between general queries */
  int          igmp_query_max_response_time_dsec;  /* IGMPv3 Max Response Time in dsecs */
  struct list *igmp_socket_list;                   /* list of struct igmp_sock */
  struct list *igmp_join_list;                     /* list of struct igmp_join */

  int            pim_sock_fd;       /* PIM socket file descriptor */
  struct thread *t_pim_sock_read;   /* thread for reading PIM socket */
  int64_t        pim_sock_creation; /* timestamp of PIM socket creation */

  struct thread *t_pim_hello_timer;
  int            pim_hello_period;
  int            pim_default_holdtime;
  int            pim_triggered_hello_delay;
  uint32_t       pim_generation_id;
  uint16_t       pim_propagation_delay_msec; /* config */
  uint16_t       pim_override_interval_msec; /* config */
  struct list   *pim_neighbor_list; /* list of struct pim_neighbor */
  struct list   *pim_ifchannel_list; /* list of struct pim_ifchannel */

  /* neighbors without lan_delay */
  int            pim_number_of_nonlandelay_neighbors;
  uint16_t       pim_neighbors_highest_propagation_delay_msec;
  uint16_t       pim_neighbors_highest_override_interval_msec;

  /* DR Election */
  int64_t        pim_dr_election_last; /* timestamp */
  int            pim_dr_election_count;
  struct in_addr pim_dr_addr;
  uint32_t       pim_dr_priority;            /* config */
  int            pim_dr_num_nondrpri_neighbors; /* neighbors without dr_pri */

  int64_t        pim_ifstat_start; /* start timestamp for stats */
  uint32_t       pim_ifstat_hello_sent;
  uint32_t       pim_ifstat_hello_sendfail;
  uint32_t       pim_ifstat_hello_recv;
  uint32_t       pim_ifstat_hello_recvfail;
};

/*
  if default_holdtime is set (>= 0), use it;
  otherwise default_holdtime is 3.5 * hello_period
 */
#define PIM_IF_DEFAULT_HOLDTIME(pim_ifp) \
  (((pim_ifp)->pim_default_holdtime < 0) ? \
  ((pim_ifp)->pim_hello_period * 7 / 2) : \
  ((pim_ifp)->pim_default_holdtime))

void pim_if_init(void);

struct pim_interface *pim_if_new(struct interface *ifp, int igmp, int pim);
void                  pim_if_delete(struct interface *ifp);
int                   pim_if_igmp_listen(struct vty *vty,
					 struct interface *ifp);
void pim_if_addr_add(struct connected *ifc);
void pim_if_addr_del(struct connected *ifc);
void pim_if_addr_add_all(struct interface *ifp);
void pim_if_addr_del_all(struct interface *ifp);
void pim_if_addr_del_all_igmp(struct interface *ifp);
void pim_if_addr_del_all_pim(struct interface *ifp);

int pim_if_add_vif(struct interface *ifp);
int pim_if_del_vif(struct interface *ifp);
void pim_if_add_vif_all(void);
void pim_if_del_vif_all(void);

struct interface *pim_if_find_by_vif_index(int vif_index);
int pim_if_find_vifindex_by_ifindex(int ifindex);

int pim_if_lan_delay_enabled(struct interface *ifp);
uint16_t pim_if_effective_propagation_delay_msec(struct interface *ifp);
uint16_t pim_if_effective_override_interval_msec(struct interface *ifp);
uint16_t pim_if_jp_override_interval_msec(struct interface *ifp);
struct pim_neighbor *pim_if_find_neighbor(struct interface *ifp,
					  struct in_addr addr);

long pim_if_t_suppressed_msec(struct interface *ifp);
int pim_if_t_override_msec(struct interface *ifp);

struct in_addr pim_find_primary_addr(struct interface *ifp);

int pim_if_igmp_join_add(struct interface *ifp,
			 struct in_addr group_addr,
			 struct in_addr source_addr);
int pim_if_igmp_join_del(struct interface *ifp,
			 struct in_addr group_addr,
			 struct in_addr source_addr);

void pim_if_update_could_assert(struct interface *ifp);

void pim_if_assert_on_neighbor_down(struct interface *ifp,
				    struct in_addr neigh_addr);

void pim_if_rpf_interface_changed(struct interface *old_rpf_ifp,
				  struct pim_upstream *up);

void pim_if_update_join_desired(struct pim_interface *pim_ifp);

void pim_if_update_assert_tracking_desired(struct interface *ifp);

#endif /* PIM_IFACE_H */
