summaryrefslogtreecommitdiffstats
path: root/pimd/pimd.h
blob: b42c54cfacb161b0ccade98b6ffdcc3c5f318745 (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
  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 PIMD_H
#define PIMD_H

#include <stdint.h>

#include "pim_mroute.h"
#include "pim_assert.h"

#define PIMD_PROGNAME       "pimd"
#define PIMD_DEFAULT_CONFIG "pimd.conf"
#define PIMD_VTY_PORT       2611
#define PIMD_BUG_ADDRESS    "http://savannah.nongnu.org/projects/qpimd"

#define PIM_IP_HEADER_MIN_LEN         (20)
#define PIM_IP_HEADER_MAX_LEN         (60)
#define PIM_IP_PROTO_IGMP             (2)
#define PIM_IP_PROTO_PIM              (103)
#define PIM_IGMP_MIN_LEN              (8)
#define PIM_MSG_HEADER_LEN            (4)
#define PIM_PIM_MIN_LEN               PIM_MSG_HEADER_LEN
#define PIM_PROTO_VERSION             (2)

#define MCAST_ALL_SYSTEMS      "224.0.0.1"
#define MCAST_ALL_ROUTERS      "224.0.0.2"
#define MCAST_ALL_PIM_ROUTERS  "224.0.0.13"
#define MCAST_ALL_IGMP_ROUTERS "224.0.0.22"

#define PIM_FORCE_BOOLEAN(expr) ((expr) != 0)

#define PIM_NET_INADDR_ANY (htonl(INADDR_ANY))
#define PIM_INADDR_IS_ANY(addr) ((addr).s_addr == PIM_NET_INADDR_ANY) /* struct in_addr addr */
#define PIM_INADDR_ISNOT_ANY(addr) ((addr).s_addr != PIM_NET_INADDR_ANY) /* struct in_addr addr */

#define PIM_MASK_PIM_EVENTS   (1 << 0)
#define PIM_MASK_PIM_PACKETS  (1 << 1)
#define PIM_MASK_PIM_TRACE    (1 << 2)
#define PIM_MASK_IGMP_EVENTS  (1 << 3)
#define PIM_MASK_IGMP_PACKETS (1 << 4)
#define PIM_MASK_IGMP_TRACE   (1 << 5)
#define PIM_MASK_ZEBRA        (1 << 6)
#define PIM_MASK_SSMPINGD     (1 << 7)

const char *const PIM_ALL_SYSTEMS;
const char *const PIM_ALL_ROUTERS;
const char *const PIM_ALL_PIM_ROUTERS;
const char *const PIM_ALL_IGMP_ROUTERS;

struct thread_master     *master;
uint32_t                  qpim_debugs;
int                       qpim_mroute_socket_fd;
int64_t                   qpim_mroute_socket_creation; /* timestamp of creation */
struct thread            *qpim_mroute_socket_reader;
int                       qpim_mroute_oif_highest_vif_index;
struct list              *qpim_channel_oil_list; /* list of struct channel_oil */
struct in_addr            qpim_all_pim_routers_addr;
int                       qpim_t_periodic; /* Period between Join/Prune Messages */
struct list              *qpim_upstream_list; /* list of struct pim_upstream */
struct zclient           *qpim_zclient_lookup;
struct pim_assert_metric  qpim_infinite_assert_metric;
long                      qpim_rpf_cache_refresh_delay_msec;
struct thread            *qpim_rpf_cache_refresher;
int64_t                   qpim_rpf_cache_refresh_requests;
int64_t                   qpim_rpf_cache_refresh_events;
int64_t                   qpim_rpf_cache_refresh_last;
struct in_addr            qpim_inaddr_any;
struct list              *qpim_ssmpingd_list; /* list of struct ssmpingd_sock */
struct in_addr            qpim_ssmpingd_group_addr;

#define PIM_JP_HOLDTIME (qpim_t_periodic * 7 / 2)

#define PIM_MROUTE_IS_ENABLED  (qpim_mroute_socket_fd >= 0)
#define PIM_MROUTE_IS_DISABLED (qpim_mroute_socket_fd < 0)

#define PIM_DEBUG_PIM_EVENTS   (qpim_debugs & PIM_MASK_PIM_EVENTS)
#define PIM_DEBUG_PIM_PACKETS  (qpim_debugs & PIM_MASK_PIM_PACKETS)
#define PIM_DEBUG_PIM_TRACE    (qpim_debugs & PIM_MASK_PIM_TRACE)
#define PIM_DEBUG_IGMP_EVENTS  (qpim_debugs & PIM_MASK_IGMP_EVENTS)
#define PIM_DEBUG_IGMP_PACKETS (qpim_debugs & PIM_MASK_IGMP_PACKETS)
#define PIM_DEBUG_IGMP_TRACE   (qpim_debugs & PIM_MASK_IGMP_TRACE)
#define PIM_DEBUG_ZEBRA        (qpim_debugs & PIM_MASK_ZEBRA)
#define PIM_DEBUG_SSMPINGD     (qpim_debugs & PIM_MASK_SSMPINGD)

#define PIM_DEBUG_EVENTS       (qpim_debugs & (PIM_MASK_PIM_EVENTS | PIM_MASK_IGMP_EVENTS))
#define PIM_DEBUG_PACKETS      (qpim_debugs & (PIM_MASK_PIM_PACKETS | PIM_MASK_IGMP_PACKETS))
#define PIM_DEBUG_TRACE        (qpim_debugs & (PIM_MASK_PIM_TRACE | PIM_MASK_IGMP_TRACE))

#define PIM_DO_DEBUG_PIM_EVENTS   (qpim_debugs |= PIM_MASK_PIM_EVENTS)
#define PIM_DO_DEBUG_PIM_PACKETS  (qpim_debugs |= PIM_MASK_PIM_PACKETS)
#define PIM_DO_DEBUG_PIM_TRACE    (qpim_debugs |= PIM_MASK_PIM_TRACE)
#define PIM_DO_DEBUG_IGMP_EVENTS  (qpim_debugs |= PIM_MASK_IGMP_EVENTS)
#define PIM_DO_DEBUG_IGMP_PACKETS (qpim_debugs |= PIM_MASK_IGMP_PACKETS)
#define PIM_DO_DEBUG_IGMP_TRACE   (qpim_debugs |= PIM_MASK_IGMP_TRACE)
#define PIM_DO_DEBUG_ZEBRA        (qpim_debugs |= PIM_MASK_ZEBRA)
#define PIM_DO_DEBUG_SSMPINGD     (qpim_debugs |= PIM_MASK_SSMPINGD)

#define PIM_DONT_DEBUG_PIM_EVENTS   (qpim_debugs &= ~PIM_MASK_PIM_EVENTS)
#define PIM_DONT_DEBUG_PIM_PACKETS  (qpim_debugs &= ~PIM_MASK_PIM_PACKETS)
#define PIM_DONT_DEBUG_PIM_TRACE    (qpim_debugs &= ~PIM_MASK_PIM_TRACE)
#define PIM_DONT_DEBUG_IGMP_EVENTS  (qpim_debugs &= ~PIM_MASK_IGMP_EVENTS)
#define PIM_DONT_DEBUG_IGMP_PACKETS (qpim_debugs &= ~PIM_MASK_IGMP_PACKETS)
#define PIM_DONT_DEBUG_IGMP_TRACE   (qpim_debugs &= ~PIM_MASK_IGMP_TRACE)
#define PIM_DONT_DEBUG_ZEBRA        (qpim_debugs &= ~PIM_MASK_ZEBRA)
#define PIM_DONT_DEBUG_SSMPINGD     (qpim_debugs &= ~PIM_MASK_SSMPINGD)

void pim_init(void);
void pim_terminate(void);

#endif /* PIMD_H */