|
reSIProcate/stack
9694
|
00001 #include "rutil/Logger.hxx" 00002 00003 #include "resip/stack/Uri.hxx" 00004 00005 #include "Register.hxx" 00006 #include "Registrar.hxx" 00007 #include "InviteServer.hxx" 00008 #include "InviteClient.hxx" 00009 #include "Transceiver.hxx" 00010 00011 00012 using namespace resip; 00013 using namespace std; 00014 using namespace Loadgen; 00015 00016 00017 #define RESIPROCATE_SUBSYSTEM Subsystem::SIP 00018 00019 void usage() 00020 { 00021 cout << "Usage: lg port {REG_RECEIVE, INV_RECEIVE}" << endl 00022 << " lg port {REG_SEND, INV_SEND} targetHost:port startingExt endingExt [registers]" << endl; 00023 exit(-1); 00024 } 00025 00026 int 00027 main(int argc, char* argv[]) 00028 { 00029 Log::initialize(Log::Cout, Log::Info, argv[0]); 00030 00031 if (!(argc == 3 || argc == 6 || argc == 7)) 00032 { 00033 usage(); 00034 } 00035 00036 int port = atoi(argv[1]); 00037 if (port == 0) 00038 { 00039 usage(); 00040 } 00041 00042 if (Data(argv[2]) == "REG_SEND" || Data(argv[2]) == "INV_SEND") 00043 { 00044 Uri target; 00045 00046 ParseBuffer host(argv[3], strlen(argv[3])); 00047 const char* start = host.position(); 00048 host.skipToChar(Symbols::COLON[0]); 00049 if (host.position() == host.end()) 00050 { 00051 usage(); 00052 } 00053 00054 target.host() = host.data(start); 00055 host.skipChar(); 00056 target.port() = host.integer(); 00057 target.param(p_transport) = "udp"; 00058 00059 InfoLog(<< target); 00060 00061 Transceiver stack(port); 00062 00063 int startExt = atoi(argv[4]); 00064 int endExt = atoi(argv[5]); 00065 if (startExt == 0 || endExt == 0 || startExt > endExt) 00066 { 00067 usage(); 00068 } 00069 int numTimes = 0; 00070 if (argc == 7) 00071 { 00072 numTimes = atoi(argv[6]); 00073 if (numTimes == 0) 00074 { 00075 usage(); 00076 } 00077 } 00078 if (Data(argv[2]) == "REG_SEND") 00079 { 00080 Register reg(stack, target, 00081 startExt, endExt, numTimes); 00082 reg.go(); 00083 } 00084 else 00085 { 00086 InviteClient inv(stack, target, 00087 startExt, endExt, numTimes); 00088 inv.go(); 00089 } 00090 } 00091 else if (Data(argv[2]) == "REG_RECEIVE") 00092 { 00093 Transceiver stack(port); 00094 Registrar reg(stack); 00095 reg.go(); 00096 } 00097 else if (Data(argv[2]) == "INV_RECEIVE") 00098 { 00099 Transceiver stack(port); 00100 InviteServer inv(stack); 00101 inv.go(); 00102 } 00103 else 00104 { 00105 usage(); 00106 } 00107 return 0; 00108 } 00109 /* ==================================================================== 00110 * The Vovida Software License, Version 1.0 00111 * 00112 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00113 * 00114 * Redistribution and use in source and binary forms, with or without 00115 * modification, are permitted provided that the following conditions 00116 * are met: 00117 * 00118 * 1. Redistributions of source code must retain the above copyright 00119 * notice, this list of conditions and the following disclaimer. 00120 * 00121 * 2. Redistributions in binary form must reproduce the above copyright 00122 * notice, this list of conditions and the following disclaimer in 00123 * the documentation and/or other materials provided with the 00124 * distribution. 00125 * 00126 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00127 * and "Vovida Open Communication Application Library (VOCAL)" must 00128 * not be used to endorse or promote products derived from this 00129 * software without prior written permission. For written 00130 * permission, please contact vocal@vovida.org. 00131 * 00132 * 4. Products derived from this software may not be called "VOCAL", nor 00133 * may "VOCAL" appear in their name, without prior written 00134 * permission of Vovida Networks, Inc. 00135 * 00136 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00137 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00138 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00139 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00140 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00141 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00142 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00143 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00144 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00145 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00146 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00147 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00148 * DAMAGE. 00149 * 00150 * ==================================================================== 00151 * 00152 * This software consists of voluntary contributions made by Vovida 00153 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00154 * Inc. For more information on Vovida Networks, Inc., please see 00155 * <http://www.vovida.org/>. 00156 * 00157 */
1.7.5.1