config-pot
上传用户:sy_wanhua
上传日期:2013-07-25
资源大小:3048k
文件大小:6k
- #!/usr/bin/perl
- # ====================================================================
- # The Vovida Software License, Version 1.0
- #
- # Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
- #
- # Redistribution and use in source and binary forms, with or without
- # modification, are permitted provided that the following conditions
- # are met:
- #
- # 1. Redistributions of source code must retain the above copyright
- # notice, this list of conditions and the following disclaimer.
- #
- # 2. Redistributions in binary form must reproduce the above copyright
- # notice, this list of conditions and the following disclaimer in
- # the documentation and/or other materials provided with the
- # distribution.
- #
- # 3. The names "VOCAL", "Vovida Open Communication Application Library",
- # and "Vovida Open Communication Application Library (VOCAL)" must
- # not be used to endorse or promote products derived from this
- # software without prior written permission. For written
- # permission, please contact vocal@vovida.org.
- #
- # 4. Products derived from this software may not be called "VOCAL", nor
- # may "VOCAL" appear in their name, without prior written
- # permission of Vovida Networks, Inc.
- #
- # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
- # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
- # NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
- # NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
- # IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
- # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
- # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
- # DAMAGE.
- #
- # ====================================================================
- #
- # This software consists of voluntary contributions made by Vovida
- # Networks, Inc. and many individuals on behalf of Vovida Networks,
- # Inc. For more information on Vovida Networks, Inc., please see
- # <http://www.vovida.org/>.
- $number_eps = 50;
- $agent_host = "localhost";
- chomp($billing_server = `hostname`);
- require "getopts.pl";
- &Getopts("a:n:b:");
- if($opt_b) {
- $billing_server = $opt_b;
- }
- if($opt_n) {
- $number_eps = $opt_n;
- }
- if($opt_a) {
- $agent_host = $opt_a;
- }
- $start_gw_number = 0;
- $start_port = 5050;
- $original_start_dn = 5000;
- $original_start_ep = 0;
- #$number_eps = 50;
- $gw_count = 0;
- $start_dn = $original_start_dn;
- $start_ep = $original_start_ep;
- foreach(@ARGV) {
- open(POT, ">pot$gw_count.cfg");
- print POT "# this file automatically generatednn";
- print POT "domainName string $_n";
- print POT "gatewayName string Residential-gatewayn";
- print POT "remotePort int ", ($start_port + $gw_count), "n";
- print POT "proxyAddress string $_n";
- print POT "proxyPort int ", ($start_port + $gw_count), "n";
- print POT "endpoint string 1@pot$gw_count.cfgn";
- if(($gw_count % 4) > 1) {
- print POT "inputQueue int 1n";
- } else {
- print POT "inputQueue int 0n";
- }
- close(POT);
- open(AT_POT, ">1@pot$gw_count.cfg");
- print AT_POT "# this file automatically generatednn";
- for($i = 0; $i < $number_eps; $i++) {
- print AT_POT "directoryNumber string ep", ($i + $start_ep), "@$_ ", ($i + $start_dn), "n";
- }
- close(AT_POT);
- $start_ep = $start_ep + $number_eps;
- $start_dn = $start_dn + $number_eps;
- $gw_count++;
- }
- open(CA, ">ca.cfg");
- print CA "# this file automatically generatednn";
- print CA "localPort int 2427n";
- print CA "maxNumberOfEndpoints int ", ($gw_count * $number_eps), "n";
- print CA "maxNumberOfCalls int ", ($gw_count * $number_eps), "n";
- print CA "billingServer string $billing_servern";
- print CA "billingServerPort int 1812n";
- print CA "numberOfThreads int 2n";
- for($i = 0; $i < $gw_count; $i++) {
- print CA "residentialGateway string pot$i.cfgn";
- }
- close(CA);
- # now, do the gateways
- $j = 0;
- $start_dn = $original_start_dn;
- $start_ep = $original_start_ep;
- foreach(@ARGV) {
- mkdir("gw$j", 0755);
- open(GW, ">gw$j/gw.cfg");
- print GW "# this file automatically generated for gw$jnn";
- print GW "GatewayHardware string nulln";
- print GW "GatewayPort int ", ($start_port + $j), "n";
- print GW "GatewayAgentHostname string $agent_hostn";
- print GW "GatewayAgentPort int 2427n";
- print GW "GatewayNumEndpoints int ", $number_eps, "n";
- print GW "GatewayCntsPerEndpt int 1n";
- print GW "GatewayFirstRtpPort int 6050n";
- print GW "GatewayEndpoint int ", ($start_ep), "n";
- print GW "n";
- if($j % 2) {
- print GW "GatewayRunMode string CallingGWn";
- } else {
- print GW "GatewayRunMode string ReceiveGWn";
- }
- print GW "GatewayCallDuration int 2000n";
- print GW "GatewayCallDelay int 10n";
- print GW "GatewayAnswerDelay int 50n";
- print GW "DebugMsgInterval int 14n";
- # if($j % 2) {
- # print GW "ReceiveGWHU int 0n";
- # } else {
- print GW "ReceiveGWHU int 1n";
- # }
-
- print GW "DialNumber string ", ($start_dn - $number_eps), "n";
- close(GW);
- $start_ep += $number_eps;
- $start_dn += $number_eps;
- $j++;
- }