summaryrefslogtreecommitdiffstats
path: root/pimd/pim_oil.h
blob: 0c99afb62533a8359b43cf876118dbf855ec4cdf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
  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
  
*/

#ifndef PIM_OIL_H
#define PIM_OIL_H

#include "pim_mroute.h"

/*
 * Where did we get this (S,G) from?
 *
 * IGMP - Learned from IGMP
 * PIM - Learned from PIM
 * SOURCE - Learned from Source multicast packet received
 */
#define PIM_OIF_FLAG_PROTO_IGMP   (1 << 0)
#define PIM_OIF_FLAG_PROTO_PIM    (1 << 1)
#define PIM_OIF_FLAG_PROTO_SOURCE (2 << 1)
#define PIM_OIF_FLAG_PROTO_ANY    (PIM_OIF_FLAG_PROTO_IGMP | \
                                   PIM_OIF_FLAG_PROTO_PIM | \
                                   PIM_OIF_FLAG_PROTO_SOURCE)

/*
 * We need a pimreg vif id from the kernel.
 * Since ifindex == vif id for most cases and the number
 * of expected interfaces is at most 100, using MAXVIFS -1
 * is probably ok.
 * Don't come running to me if this assumption is bad,
 * fix it.
 */
#define PIM_OIF_PIM_REGISTER_VIF   (MAXVIFS - 1)
#define PIM_MAX_USABLE_VIFS        (MAXVIFS - 2)


struct channel_counts
{
  unsigned long long lastused;
  unsigned long pktcnt;
  unsigned long oldpktcnt;
  unsigned long bytecnt;
  unsigned long oldbytecnt;
  unsigned long wrong_if;
  unsigned long oldwrong_if;
};

/*
  qpim_channel_oil_list holds a list of struct channel_oil.

  Each channel_oil.oil is used to control an (S,G) entry in the Kernel
  Multicast Forwarding Cache.
*/

struct channel_oil {
  struct mfcctl oil;
  int           installed;
  int           oil_size;
  int           oil_ref_count;
  time_t        oif_creation[MAXVIFS];
  uint32_t      oif_flags[MAXVIFS];
  struct channel_counts cc;
};

extern struct list *pim_channel_oil_list;

void pim_oil_init (void);
void pim_oil_terminate (void);

void pim_channel_oil_free(struct channel_oil *c_oil);
struct channel_oil *pim_channel_oil_add(struct prefix_sg *sg,
					int input_vif_index);
void pim_channel_oil_del(struct channel_oil *c_oil);

int pim_channel_add_oif(struct channel_oil *c_oil,
			struct interface *oif,
			uint32_t proto_mask);
int pim_channel_del_oif (struct channel_oil *c_oil,
			 struct interface *oif,
			 uint32_t proto_mask);

#endif /* PIM_OIL_H */