Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch-contrib
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch-contrib
Commits
12b22d2a
提交
12b22d2a
authored
3月 16, 2011
作者:
Eliot Gable
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Initial check-in of mod_ha_cluster code; currently a work in progress.
上级
8d5a6ce7
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
2765 行增加
和
0 行删除
+2765
-0
Makefile.am
mod/applications/mod_ha_cluster/Makefile.am
+10
-0
ha_cluster.conf.xml
mod/applications/mod_ha_cluster/ha_cluster.conf.xml
+131
-0
ha_cluster_config.c
mod/applications/mod_ha_cluster/ha_cluster_config.c
+756
-0
ha_cluster_interfaces.c
mod/applications/mod_ha_cluster/ha_cluster_interfaces.c
+642
-0
ha_cluster_util.c
mod/applications/mod_ha_cluster/ha_cluster_util.c
+96
-0
mod_ha_cluster.2008.vcproj
mod/applications/mod_ha_cluster/mod_ha_cluster.2008.vcproj
+287
-0
mod_ha_cluster.c
mod/applications/mod_ha_cluster/mod_ha_cluster.c
+551
-0
mod_ha_cluster.h
mod/applications/mod_ha_cluster/mod_ha_cluster.h
+292
-0
没有找到文件。
mod/applications/mod_ha_cluster/Makefile.am
0 → 100644
浏览文件 @
12b22d2a
include
$(top_srcdir)/build/modmake.rulesam
MODNAME
=
mod_ha_cluster
mod_LTLIBRARIES
=
mod_ha_cluster.la
mod_ha_cluster_la_SOURCES
=
mod_ha_cluster.c ha_cluster_config.c ha_cluster_util.c
\
ha_cluster_interfaces.c
mod_ha_cluster_la_CFLAGS
=
$(AM_CFLAGS)
-I
.
mod_ha_cluster_la_LIBADD
=
$(switch_builddir)
/libfreeswitch.la
mod_ha_cluster_la_LDFLAGS
=
-avoid-version
-module
-no-undefined
-shared
mod/applications/mod_ha_cluster/ha_cluster.conf.xml
0 → 100644
浏览文件 @
12b22d2a
<configuration
name=
"ha_cluster.conf"
description=
"High Availability Cluster"
>
<network>
<!-- Define some anti-DoS rules for the IP addresses we manage.
To make use of this functionality, you must run:
iptables -N ha-cluster-rules
iptables -I INPUT -j ha-cluster-rules
/etc/init.d/iptables save
To disable this functionality, you can run:
iptables -D INPUT -j ha-cluster-rules
/etc/init.d/iptables save
-->
<dos-rules>
<!-- By default, udp ports 1024 - 65535 and tcp ports
5060 and 5061 are allowed. These rules limit the
number of requests per second which can be sent
to FreeSWITCH, as well as dropping scans from
SIP Vicious. -->
<rule-group
name=
"public"
>
<!-- Rules applied in the order listed. When
you hit the end of the list, the default
rules are applied, then everything that
does not match a rule is dropped. -->
<rule
name=
"sipvicios"
type=
"drop"
string=
"friendly-scanner"
/>
<rule
name=
"register"
type=
"limit"
string=
"REGISTER"
rate=
"14/minute"
burst=
"8"
mode=
"srcip"
/>
<rule
name=
"options"
type=
"limit"
string=
"OPTIONS"
rate=
"5/minute"
burst=
"5"
mode=
"srcip"
/>
<rule
name=
"notify"
type=
"limit"
string=
"NOTIFY"
rate=
"5/minute"
burst=
"5"
mode=
"srcip"
/>
<rule
name=
"invite"
type=
"limit"
string=
"INVITE"
rate=
"5/sec"
burst=
"10"
mode=
"srcip"
/>
<rule
name=
"bye"
type=
"limit"
string=
"BYE"
rate=
"5/sec"
burst=
"10"
mode=
"srcip"
/>
<rule
name=
"ack"
type=
"limit"
string=
"ACK"
rate=
"20/sec"
burst=
"40"
mode=
"srcip"
/>
<rule
name=
"cancel"
type=
"limit"
string=
"CANCEL"
rate=
"5/sec"
burst=
"10"
mode=
"srcip"
/>
<rule
name=
"update"
type=
"limit"
string=
"UPDATE"
rate=
"5/sec"
burst=
"10"
mode=
"srcip"
/>
<rule
name=
"info"
type=
"limit"
string=
"INFO"
rate=
"20/sec"
burst=
"40"
mode=
"srcip"
/>
<rule
name=
"prack"
type=
"limit"
string=
"PRACK"
rate=
"20/sec"
burst=
"40"
mode=
"srcip"
/>
<rule
name=
"refer"
type=
"limit"
string=
"REFER"
rate=
"5/sec"
burst=
"10"
mode=
"srcip"
/>
<rule
name=
"subscribe"
type=
"limit"
string=
"SUBSCRIBE"
rate=
"5/sec"
burst=
"10"
mode=
"srcip"
/>
<rule
name=
"publish"
type=
"limit"
string=
"PUBLISH"
rate=
"5/sec"
burst=
"10"
mode=
"srcip"
/>
<rule
name=
"message"
type=
"limit"
string=
"MESSAGE"
rate=
"5/sec"
burst=
"10"
mode=
"srcip"
/>
</rule-group>
</dos-rules>
<!-- Define interfaces to be controlled by FreeSWITCH. These
interfaces should be entirely under the control of
FreeSWITCH or bad things might happen. -->
<interfaces>
<interface
name=
"eth1"
description=
"Public Interface"
>
<!-- Define a set of master/slave failover IP addresses
on this interface and assign a variable to them
for use in other configs. -->
<failover-ips
name=
"eth1_ms_ips_group1"
>
<ip
name=
"external5-ip"
cidr=
"10.0.1.8/24"
var=
"external5-ip"
rule-group=
"public"
/>
<ip
name=
"external4-ip"
cidr=
"10.0.1.7/24"
var=
"external4-ip"
rule-group=
"public"
/>
<ip
name=
"external3-ip"
cidr=
"10.0.1.6/24"
var=
"external3-ip"
rule-group=
"public"
/>
<ip
name=
"external2-ip"
cidr=
"10.0.1.5/24"
var=
"external2-ip"
rule-group=
"public"
/>
<ip
name=
"external1-ip"
cidr=
"10.0.1.4/24"
var=
"external1-ip"
rule-group=
"public"
/>
</failover-ips>
<!-- Set the default route to this interface when it comes up. -->
<route
name=
"default"
destination=
"0.0.0.0/0"
gateway=
"10.0.1.1"
metric=
"0"
/>
<!-- Make sure we know where the gateway is when the
interface comes up since we use NOARP flag -->
<arp
ip=
"10.0.1.1"
mac=
"00:00:0D:03:DB:13"
/>
</interface>
<interface
name=
"eth2"
description=
"Internal Interface"
>
<failover-ips
name=
"eth2_ms_ips_group1"
>
<ip
name=
"internal-ip"
cidr=
"10.0.0.4/24"
var=
"internal-ip"
/>
</failover-ips>
<arp
ip=
"10.0.0.1"
mac=
"00:00:0D:03:DB:14"
/>
</interface>
</interfaces>
<!-- Define failover groups. Each group requires one master
node. If you have two groups and two nodes, you end up
with two masters - one for each group. If you have two
groups and three nodes, you get two masters and one
slave. One group and two nodes gets you one master and
one slave. Two groups and four nodes gets you two masters
and two slaves. Two groups and five nodes gets you two
masters and three slaves.
type - can be failover-ips
-->
<failover-groups>
<group
name=
"group1"
type=
"failover-ips"
>
<include
name=
"eth1_ms_ips_group1"
/>
<include
name=
"eth2_ms_ips_group1"
/>
</group>
</failover-groups>
</network>
<general>
<!-- This node-id must be unique in the cluster -->
<nodeid
value=
"0"
/>
<!-- How many nodes are in the cluster -->
<total-nodes
value=
"2"
/>
<!-- How long to listen and learn of other nodes before
choosing a state and starting -->
<timer-a
value=
"60"
/>
<!-- Maximum time to spend listening in the starting state if
no other nodes can be heard. If set to -1, timer-a is also
the max it can be in starting. -->
<timer-b
value=
"-1"
/>
<!-- Maximum link latency in ms across all multicast groups.
This is used for de-duplicating events. If set too low,
you may process duplicate events if you have more than one
multicast group. -->
<max-latency
value=
"50"
/>
<!-- Define multicast groups and the source IP and port for
each group. To avoid split-brain, you need at least two.
Then, if one fails, the nodes can still talk to each
other, which prevents the nodes from trying to take over
another node's traffic while the other node is still
actually running. Split-brain is VERY BAD. -->
<heartbeat
interval=
"100"
bind-network=
"192.168.0.4"
multicast-address=
"224.0.0.51"
port=
"4096"
ttl=
"1"
/>
<heartbeat
interval=
"100"
bind-network=
"192.168.1.4"
multicast-address=
"224.0.0.51"
port=
"4096"
ttl=
"1"
/>
<!-- How long in ms to wait for a heartbeat before declaring
a node dead and commencing failover. -->
<failure-threshold
value=
"3000"
/>
<!-- Define a set of events on which to consider this node
dead and force a restart of FreeSWITCH. -->
<failover>
<condition
event=
"SWITCH_EVENT_FAILURE"
>
<match
name=
"module"
value=
"mod_sofia"
/>
<match
name=
"class"
value=
"PROFILE_START_FAILURE"
/>
</condition>
<condition
event=
"SWITCH_EVENT_FAILURE"
>
<match
name=
"module"
value=
"mod_sofia"
/>
<match
name=
"class"
value=
"CONFIGURATION_LOAD_FAILURE"
/>
</condition>
</failover>
</general>
</configuration>
mod/applications/mod_ha_cluster/ha_cluster_config.c
0 → 100644
浏览文件 @
12b22d2a
差异被折叠。
点击展开。
mod/applications/mod_ha_cluster/ha_cluster_interfaces.c
0 → 100644
浏览文件 @
12b22d2a
差异被折叠。
点击展开。
mod/applications/mod_ha_cluster/ha_cluster_util.c
0 → 100644
浏览文件 @
12b22d2a
/*
* High Availability Cluster Module for FreeSWITCH Modular Media Switching
* Software Library / Soft-Switch Application
*
* High Availability Cluster Module is
* Copyright (C) 2010, Eliot Gable <egable@gmail.com>
*
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application is
* Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is High Availability Module for FreeSWITCH Modular Media
* Switching Software Library / Soft-Switch Application
*
* The Initial Developer of the Original Code is
* Eliot Gable <egable@gmail.com>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
*
*/
#include <mod_ha_cluster.h>
/* Don't forget to free "out" when done with it */
switch_status_t
execute_command
(
const
char
*
cmd
,
char
**
out
)
{
FILE
*
fh
=
NULL
;
char
buf
[
HAC_BUFFSIZE
];
int
ret_code
=
0
;
ssize_t
len
;
memset
(
buf
,
0
,
HAC_BUFFSIZE
);
#ifdef MACOSX
#elif defined(DARWIN)
#elif defined(WIN32)
#else
setenv
(
"PATH"
,
"/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/freeswitch/bin:/opt/bin:/opt/sbin"
,
1
);
errno
=
0
;
fh
=
popen
(
cmd
,
"r"
);
if
(
!
fh
||
errno
)
{
char
errbuf
[
256
];
memset
(
errbuf
,
0
,
256
);
strerror_r
(
errno
,
errbuf
,
sizeof
(
errbuf
));
if
(
strlen
(
errbuf
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CRIT
,
"HAC: unable to execute command '%s': %s
\n
"
,
cmd
,
errbuf
);
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CRIT
,
"HAC: unable to execute command '%s': process failed to open (errno %d)
\n
"
,
cmd
,
errno
);
}
return
SWITCH_STATUS_FALSE
;
}
len
=
fread
(
buf
,
1
,
sizeof
(
buf
),
fh
);
if
(
errno
)
{
char
errbuf
[
256
];
memset
(
errbuf
,
0
,
256
);
strerror_r
(
errno
,
errbuf
,
sizeof
(
errbuf
));
if
(
strlen
(
errbuf
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CRIT
,
"HAC: unable to read file handle: %s
\n
"
,
errbuf
);
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CRIT
,
"HAC: unable to read file handle: an unknown error occurred
\n
"
);
}
return
SWITCH_STATUS_FALSE
;
}
errno
=
0
;
ret_code
=
pclose
(
fh
);
*
out
=
malloc
(
len
+
1
);
switch_assert
(
*
out
);
memset
(
*
out
,
0
,
len
+
1
);
memcpy
(
*
out
,
buf
,
len
);
#endif
if
(
errno
==
ECHILD
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CRIT
,
"HAC: unable to determine exit status of child command '%s'
\n
"
,
cmd
);
return
SWITCH_STATUS_FALSE
;
}
if
(
ret_code
!=
0
)
{
return
SWITCH_STATUS_FALSE
;
}
return
SWITCH_STATUS_SUCCESS
;
}
mod/applications/mod_ha_cluster/mod_ha_cluster.2008.vcproj
0 → 100644
浏览文件 @
12b22d2a
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType=
"Visual C++"
Version=
"9.00"
Name=
"mod_skel"
ProjectGUID=
"{11C9BC3D-45E9-46E3-BE84-B8CEE4685E39}"
RootNamespace=
"mod_skel"
Keyword=
"Win32Proj"
TargetFrameworkVersion=
"131072"
>
<Platforms>
<Platform
Name=
"Win32"
/>
<Platform
Name=
"x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name=
"Debug|Win32"
ConfigurationType=
"2"
InheritedPropertySheets=
"..\..\..\..\w32\module_debug.vsprops"
CharacterSet=
"2"
>
<Tool
Name=
"VCPreBuildEventTool"
/>
<Tool
Name=
"VCCustomBuildTool"
/>
<Tool
Name=
"VCXMLDataGeneratorTool"
/>
<Tool
Name=
"VCWebServiceProxyGeneratorTool"
/>
<Tool
Name=
"VCMIDLTool"
/>
<Tool
Name=
"VCCLCompilerTool"
UsePrecompiledHeader=
"0"
/>
<Tool
Name=
"VCManagedResourceCompilerTool"
/>
<Tool
Name=
"VCResourceCompilerTool"
/>
<Tool
Name=
"VCPreLinkEventTool"
/>
<Tool
Name=
"VCLinkerTool"
RandomizedBaseAddress=
"1"
DataExecutionPrevention=
"0"
/>
<Tool
Name=
"VCALinkTool"
/>
<Tool
Name=
"VCManifestTool"
/>
<Tool
Name=
"VCXDCMakeTool"
/>
<Tool
Name=
"VCBscMakeTool"
/>
<Tool
Name=
"VCFxCopTool"
/>
<Tool
Name=
"VCAppVerifierTool"
/>
<Tool
Name=
"VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name=
"Debug|x64"
OutputDirectory=
"$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory=
"$(PlatformName)\$(ConfigurationName)"
ConfigurationType=
"2"
InheritedPropertySheets=
"..\..\..\..\w32\module_debug.vsprops"
CharacterSet=
"2"
>
<Tool
Name=
"VCPreBuildEventTool"
/>
<Tool
Name=
"VCCustomBuildTool"
/>
<Tool
Name=
"VCXMLDataGeneratorTool"
/>
<Tool
Name=
"VCWebServiceProxyGeneratorTool"
/>
<Tool
Name=
"VCMIDLTool"
TargetEnvironment=
"3"
/>
<Tool
Name=
"VCCLCompilerTool"
UsePrecompiledHeader=
"0"
/>
<Tool
Name=
"VCManagedResourceCompilerTool"
/>
<Tool
Name=
"VCResourceCompilerTool"
/>
<Tool
Name=
"VCPreLinkEventTool"
/>
<Tool
Name=
"VCLinkerTool"
OutputFile=
"$(SolutionDir)$(PlatformName)\$(ConfigurationName)/mod/$(ProjectName).dll"
RandomizedBaseAddress=
"1"
DataExecutionPrevention=
"0"
TargetMachine=
"17"
/>
<Tool
Name=
"VCALinkTool"
/>
<Tool
Name=
"VCManifestTool"
/>
<Tool
Name=
"VCXDCMakeTool"
/>
<Tool
Name=
"VCBscMakeTool"
/>
<Tool
Name=
"VCFxCopTool"
/>
<Tool
Name=
"VCAppVerifierTool"
/>
<Tool
Name=
"VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name=
"Release|Win32"
ConfigurationType=
"2"
InheritedPropertySheets=
"..\..\..\..\w32\module_release.vsprops"
CharacterSet=
"2"
>
<Tool
Name=
"VCPreBuildEventTool"
/>
<Tool
Name=
"VCCustomBuildTool"
/>
<Tool
Name=
"VCXMLDataGeneratorTool"
/>
<Tool
Name=
"VCWebServiceProxyGeneratorTool"
/>
<Tool
Name=
"VCMIDLTool"
/>
<Tool
Name=
"VCCLCompilerTool"
UsePrecompiledHeader=
"0"
/>
<Tool
Name=
"VCManagedResourceCompilerTool"
/>
<Tool
Name=
"VCResourceCompilerTool"
/>
<Tool
Name=
"VCPreLinkEventTool"
/>
<Tool
Name=
"VCLinkerTool"
RandomizedBaseAddress=
"1"
DataExecutionPrevention=
"0"
/>
<Tool
Name=
"VCALinkTool"
/>
<Tool
Name=
"VCManifestTool"
/>
<Tool
Name=
"VCXDCMakeTool"
/>
<Tool
Name=
"VCBscMakeTool"
/>
<Tool
Name=
"VCFxCopTool"
/>
<Tool
Name=
"VCAppVerifierTool"
/>
<Tool
Name=
"VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name=
"Release|x64"
OutputDirectory=
"$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory=
"$(PlatformName)\$(ConfigurationName)"
ConfigurationType=
"2"
InheritedPropertySheets=
"..\..\..\..\w32\module_release.vsprops"
CharacterSet=
"2"
>
<Tool
Name=
"VCPreBuildEventTool"
/>
<Tool
Name=
"VCCustomBuildTool"
/>
<Tool
Name=
"VCXMLDataGeneratorTool"
/>
<Tool
Name=
"VCWebServiceProxyGeneratorTool"
/>
<Tool
Name=
"VCMIDLTool"
TargetEnvironment=
"3"
/>
<Tool
Name=
"VCCLCompilerTool"
UsePrecompiledHeader=
"0"
/>
<Tool
Name=
"VCManagedResourceCompilerTool"
/>
<Tool
Name=
"VCResourceCompilerTool"
/>
<Tool
Name=
"VCPreLinkEventTool"
/>
<Tool
Name=
"VCLinkerTool"
OutputFile=
"$(SolutionDir)$(PlatformName)\$(ConfigurationName)/mod/$(ProjectName).dll"
RandomizedBaseAddress=
"1"
DataExecutionPrevention=
"0"
TargetMachine=
"17"
/>
<Tool
Name=
"VCALinkTool"
/>
<Tool
Name=
"VCManifestTool"
/>
<Tool
Name=
"VCXDCMakeTool"
/>
<Tool
Name=
"VCBscMakeTool"
/>
<Tool
Name=
"VCFxCopTool"
/>
<Tool
Name=
"VCAppVerifierTool"
/>
<Tool
Name=
"VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=
".\mod_skel.c"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
mod/applications/mod_ha_cluster/mod_ha_cluster.c
0 → 100644
浏览文件 @
12b22d2a
差异被折叠。
点击展开。
mod/applications/mod_ha_cluster/mod_ha_cluster.h
0 → 100644
浏览文件 @
12b22d2a
#ifndef _HA_CLUSTER_H_
#define _HA_CLUSTER_H_
#include <switch.h>
#include <sys/time.h>
#include <errno.h>
#define HAC_BUFFSIZE 65536
#define HAC_HEARTBEAT "ha_cluster::heartbeat"
/* Call limit was just set up */
#define HAC_LIMIT_UP "ha_cluster::limit_up"
/* Call limit was just set up */
#define HAC_LIMIT_DOWN "ha_cluster::limit_down"
/* Call limit was just removed */
#define HAC_REGISTER "ha_cluster::register"
/* Register event occured here */
#define HAC_UNREGISTER "ha_cluster::unregister"
/* De-register event occured here */
#define HAC_STARTUP "ha_cluster::startup"
/* This node just started */
#define HAC_SHUTDOWN "ha_cluster::shutdown"
/* This node is shutting down */
#define HAC_FAILURE "ha_cluster::failure"
/* This node just failed in some way */
#define HAC_CHOSE_RANDOM "ha_cluster::random"
/* This node just picked a random number */
#define HAC_TAKEOVER "ha_cluster::takeover"
/* This node is taking over another node */
#define HAC_RELINQUISH "ha_cluster::relinquish"
/* This node is relinquishing master state to ensure we have a slave */
extern
unsigned
char
MAGIC
[];
/*static char *MARKER = "1"; */
typedef
enum
{
HAC_PEER_UNKNOWN
=
0
,
HAC_PEER_STARTING
=
1
,
HAC_PEER_MASTER
=
2
,
HAC_PEER_SLAVE
=
3
,
HAC_PEER_FAILED_MASTER
=
4
,
HAC_PEER_FAILED_SLAVE
=
5
,
HAC_PEER_STOPPING_MASTER
=
6
,
HAC_PEER_STOPPING_SLAVE
=
7
}
hac_peer_state_t
;
struct
s_hac_rule
{
const
char
*
name
;
const
char
*
type
;
const
char
*
string
;
const
char
*
rate
;
const
char
*
burst
;
const
char
*
mode
;
const
char
*
proto
;
const
char
*
sport
;
const
char
*
dport
;
const
char
*
src
;
const
char
*
srcrange
;
const
char
*
length
;
const
char
*
mports
;
const
char
*
srcmports
;
const
char
*
dstmports
;
const
char
*
state
;
const
char
*
rejectwith
;
const
char
*
mark
;
struct
s_hac_rule
*
next
;
};
typedef
struct
s_hac_rule
hac_rule_t
;
struct
s_hac_rule_group
{
const
char
*
name
;
hac_rule_t
*
rules
;
struct
s_hac_rule_group
*
next
;
};
typedef
struct
s_hac_rule_group
hac_rule_group_t
;
struct
s_hac_route
{
const
char
*
name
;
const
char
*
destination
;
const
char
*
gateway
;
const
char
*
metric
;
const
char
*
dev
;
struct
s_hac_route
*
next
;
};
typedef
struct
s_hac_route
hac_route_t
;
struct
s_hac_arp
{
const
char
*
ip
;
const
char
*
mac
;
const
char
*
dev
;
struct
s_hac_arp
*
next
;
};
typedef
struct
s_hac_arp
hac_arp_t
;
struct
s_hac_ip
{
const
char
*
name
;
const
char
*
cidr
;
const
char
*
var
;
const
char
*
dev
;
const
char
*
rgroup
;
hac_route_t
*
routes
;
struct
s_hac_ip
*
next
;
};
typedef
struct
s_hac_ip
hac_ip_t
;
struct
s_hac_cluster_ips
{
const
char
*
name
;
const
char
*
vmac
;
const
char
*
dev
;
hac_ip_t
*
ips
;
hac_route_t
*
routes
;
struct
s_hac_cluster_ips
*
next
;
};
typedef
struct
s_hac_cluster_ips
hac_cluster_ips_t
;
struct
s_hac_failover_ips
{
const
char
*
name
;
const
char
*
nodes
;
const
char
*
dev
;
hac_ip_t
*
ips
;
hac_route_t
*
routes
;
struct
s_hac_failover_ips
*
next
;
};
typedef
struct
s_hac_failover_ips
hac_failover_ips_t
;
struct
s_hac_interface
{
const
char
*
name
;
const
char
*
description
;
const
char
*
duplex
;
const
char
*
speed
;
hac_cluster_ips_t
*
cips
;
hac_failover_ips_t
*
fips
;
hac_ip_t
*
ips
;
hac_route_t
*
routes
;
hac_arp_t
*
arps
;
struct
s_hac_interface
*
next
;
};
typedef
struct
s_hac_interface
hac_interface_t
;
struct
s_hac_failover_group
{
const
char
*
name
;
const
char
*
include_type
;
const
char
**
include_names
;
int
num_includes
;
struct
s_hac_failover_group
*
next
;
};
typedef
struct
s_hac_failover_group
hac_failover_group_t
;
struct
s_hac_network
{
hac_rule_group_t
*
rgroups
;
hac_interface_t
*
interfaces
;
hac_failover_group_t
*
fgroups
;
int
num_interfaces
;
int
num_groups
;
};
typedef
struct
s_hac_network
hac_network_t
;
struct
s_hac_hb
{
const
char
*
interval
;
const
char
*
network
;
const
char
*
address
;
const
char
*
port
;
const
char
*
ttl
;
switch_port_t
lport
;
switch_sockaddr_t
*
addr
;
switch_sockaddr_t
*
iface
;
switch_socket_t
*
udp_sock
;
struct
timeval
last_hb
;
struct
s_hac_hb
*
next
;
};
typedef
struct
s_hac_hb
hac_hb_t
;
struct
s_hac_event_match
{
const
char
*
name
;
const
char
*
value
;
struct
s_hac_event_match
*
next
;
};
typedef
struct
s_hac_event_match
hac_event_match_t
;
struct
s_hac_failover
{
const
char
*
event
;
hac_event_match_t
*
match_rules
;
struct
s_hac_failover
*
next
;
};
typedef
struct
s_hac_failover
hac_failover_t
;
struct
s_hac_general
{
const
char
*
nodeid
;
const
char
*
msr
;
const
char
*
timer_a
;
const
char
*
timer_b
;
const
char
*
failure_threshold
;
hac_hb_t
*
heartbeat
;
hac_failover_t
*
failover
;
size_t
num_failover_conditions
;
};
typedef
struct
s_hac_general
hac_general_t
;
struct
s_hac_config
{
hac_network_t
network
;
hac_general_t
general
;
switch_memory_pool_t
*
pool
;
};
typedef
struct
s_hac_config
hac_config_t
;
typedef
enum
{
HAC_LOOPING
=
0
,
HAC_SHUTDOWN_RUNTIME
=
1
,
HAC_UNLOAD
=
2
}
hac_state_t
;
extern
hac_config_t
config
;
struct
s_hac_event
{
switch_event_t
*
event
;
switch_bool_t
processed
;
struct
timeval
arrived
;
};
typedef
struct
s_hac_event
hac_event_t
;
struct
s_hac_chain_list
{
char
*
chain_name
;
int
chain_len
;
char
chain_flush
[
64
];
char
chain_delete
[
64
];
struct
s_hac_chain_list
*
next
;
};
typedef
struct
s_hac_chain_list
hac_chain_list_t
;
struct
s_hac_peer
{
char
hostname
[
256
];
char
*
ip
;
int
nodeid
;
uint64_t
rand_val
;
struct
timeval
first_seen
;
struct
timeval
last_seen
;
hac_peer_state_t
state
;
uint64_t
missed_beats
;
};
typedef
struct
s_hac_peer
hac_peer_t
;
struct
s_global
{
switch_memory_pool_t
*
pool
;
char
hostname
[
256
];
uint64_t
host_hash
;
switch_memory_pool_t
*
event_pool
;
switch_hash_t
*
event_hash
;
switch_hash_t
*
peer_hash
;
hac_peer_state_t
state
;
hac_state_t
mod_state
;
hac_hb_t
*
hb
;
int
nodeid
;
uint64_t
rand_val
;
const
char
*
msr
;
int
req_masters
;
int
masters
;
int
slaves
;
int
timer_a_dur
;
int
timer_b_dur
;
struct
timeval
timer_a
;
struct
timeval
timer_b
;
int
failure_threshold
;
switch_thread_rwlock_t
*
lock
;
};
extern
struct
s_global
hac_globals
;
/* ha_cluster_util.c */
switch_status_t
execute_command
(
const
char
*
cmd
,
char
**
out
);
/* ha_cluster_config.c */
switch_status_t
config_routes
(
hac_route_t
**
routes
,
switch_xml_t
root
,
const
char
*
dev
);
switch_status_t
config_arp
(
hac_arp_t
**
arps
,
switch_xml_t
root
,
const
char
*
dev
);
switch_status_t
config_ips
(
hac_ip_t
**
ips
,
switch_xml_t
root
,
const
char
*
dev
);
switch_status_t
config_cluster_ips
(
hac_cluster_ips_t
**
cips
,
switch_xml_t
root
,
const
char
*
dev
);
switch_status_t
config_failover_ips
(
hac_failover_ips_t
**
fips
,
switch_xml_t
root
,
const
char
*
dev
);
switch_status_t
config_interfaces
(
hac_interface_t
**
ints
,
switch_xml_t
root
);
switch_status_t
config_rules
(
hac_rule_t
**
rules
,
switch_xml_t
root
);
switch_status_t
config_rule_groups
(
hac_rule_group_t
**
rgroups
,
switch_xml_t
root
);
switch_status_t
config_failover_groups
(
hac_failover_group_t
**
fover
,
switch_xml_t
root
);
switch_status_t
config_network
(
switch_xml_t
root
);
switch_status_t
config_hb
(
hac_hb_t
**
hb
,
switch_xml_t
root
);
switch_status_t
config_events
(
hac_event_match_t
**
events
,
switch_xml_t
root
);
switch_status_t
config_failover
(
hac_failover_t
**
fover
,
switch_xml_t
root
);
switch_status_t
config_general
(
switch_xml_t
root
);
switch_status_t
do_config
(
switch_bool_t
reload
);
/* ha_cluster_interfaces.c */
switch_status_t
initialize_interfaces
();
switch_status_t
initialize_firewall
();
switch_status_t
verify_interfaces
();
switch_status_t
routes_up
(
const
hac_route_t
*
routes
);
switch_status_t
routes_down
(
const
hac_route_t
*
routes
);
switch_status_t
ips_up
(
const
hac_ip_t
*
ips
);
switch_status_t
ips_down
(
const
hac_ip_t
*
ips
);
char
*
generate_rule_cmd
(
const
hac_rule_t
*
rule
,
const
hac_ip_t
*
ip
,
const
int
rule_num
);
switch_status_t
rules_up
(
const
hac_rule_t
*
rules
,
const
hac_ip_t
*
ip
);
#endif
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论