17 struct sockaddr_in localAddr, servAddr;
23 if (argc >= 2 && argv[1][0] ==
'/')
29 else if (argc >= 4 && argv[3][0] ==
'/')
32 port = (short)atoi(argv[2]);
37 cerr <<
"usage: " << argv[0] <<
" [<server> <port>] /<command> [<parm>=<value>]" << endl;
38 cerr <<
" Valid Commands are:" << endl;
39 cerr <<
" /GetStackInfo - retrieves low level information about the stack state" << endl;
40 cerr <<
" /GetStackStats - retrieves a dump of the stack statistics" << endl;
41 cerr <<
" /ResetStackStats - resets all cumulative stack statistics to zero" << endl;
42 cerr <<
" /LogDnsCache - causes the DNS cache contents to be written to the resip logs" << endl;
43 cerr <<
" /ClearDnsCache - empties the stacks DNS cache" << endl;
44 cerr <<
" /GetDnsCache - retrieves the DNS cache contents" << endl;
45 cerr <<
" /GetCongestionStats - retrieves the stacks congestion manager stats and state" << endl;
46 cerr <<
" /SetCongestionTolerance metric=<SIZE|WAIT_TIME|TIME_DEPTH> maxTolerance=<value>" << endl;
47 cerr <<
" [fifoDescription=<desc>] - sets congestion tolerances" << endl;
48 cerr <<
" /Shutdown - signal the proxy to shut down." << endl;
49 cerr <<
" /Restart - signal the proxy to restart - leaving active registrations in place." << endl;
50 cerr <<
" /GetProxyConfig - retrieves the all of configuration file settings currently" << endl;
51 cerr <<
" being used by the proxy" << endl;
52 cerr <<
" /AddTransport type=<UDP|TCP|etc.> port=<value> [ipVersion=<V4|V6>]" << endl;
53 cerr <<
" [interface=<ipaddress>] [rruri=<AUTO|sip:host:port>]" << endl;
54 cerr <<
" [udprcvbuflen=<value>] [stun=<YES|NO>] [flags=<uint>]" << endl;
55 cerr <<
" [domain=<tlsdomainname>] [ssltype=<DynamicTLS|TLSv1>]" << endl;
56 cerr <<
" [certfile=<filename>] [keyfile=<filename>]" << endl;
57 cerr <<
" [tlscvm=<NONE|OPT|MAN>] [tlsuseemail=<YES|NO>]" << endl;
58 cerr <<
" - adds a new transport to the stack." << endl;
59 cerr <<
" /RemoveTransport key=<transportKey> - removes the requested transport" << endl;
64 struct addrinfo hints = {};
65 struct addrinfo* res =
nullptr;
66 hints.ai_family = AF_INET;
67 hints.ai_socktype = SOCK_STREAM;
69 if (getaddrinfo(host,
nullptr, &hints, &res) != 0 || res ==
nullptr)
71 cerr <<
"unknown host " << host << endl;
75 memcpy(&servAddr, res->ai_addr, res->ai_addrlen);
76 servAddr.sin_port = htons(port);
80 sd = (int)socket(AF_INET, SOCK_STREAM, 0);
83 cerr <<
"cannot open socket" << endl;
89 localAddr.sin_family = AF_INET;
90 localAddr.sin_addr.s_addr = htonl(INADDR_ANY);
91 localAddr.sin_port = 0;
92 rc = ::bind(sd, (
struct sockaddr*)&localAddr,
sizeof(localAddr));
95 cerr <<
"error binding locally" << endl;
100 rc = ::connect(sd, (
struct sockaddr*)&servAddr,
sizeof(servAddr));
103 cerr <<
"error connecting" << endl;
107 Data command(&argv[cmdIndex][1]);
109 bool dumpRawResult =
false;
112 request +=
"<InitialSync>\r\n";
113 request +=
" <Request>\r\n";
115 request +=
" </Request>\r\n";
116 request +=
"</InitialSync>\r\n";
118 dumpRawResult =
true;
124 request +=
">\r\n <Request>\r\n";
125 for (
int i = cmdIndex + 1; i < argc; i++)
135 pb.
data(parm, anchor);
139 pb.
data(value, anchor);
149 request +=
" </Request>\r\n";
157 rc = send(sd, request.
c_str(), (
int)request.
size(), 0);
160 cerr <<
"error sending request on socket." << endl;
165 char readBuffer[8000];
168 rc = recv(sd, (
char*)&readBuffer,
sizeof(readBuffer), 0);
171 cerr <<
"error receiving response from socket." << endl;
183 cout <<
"Received response: \r\n" << response << endl;
189 bool responseOK =
false;
196 unsigned int code = 0;
201 code = it->second.convertUnsignedLong();
208 if (code >= 200 && code < 300)
211 cout << text << endl;
215 cout <<
"Error " << code <<
" processing request: " << text << endl;
236 cout <<
"Unable to parse response:" << endl << response << endl;
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Data xmlCharDataDecode() const
Performs in-place XML Character Data un-escaping of a Data.
const char * c_str() const
Returns a null-terminated string representing.
@ Borrow
The Data instance is borrowing the memory from the passed in buffer.
static const PreallocateType Preallocate
used only to disambiguate constructors
size_type size() const noexcept
Returns the number of bytes in this Data.
iterator find(const Key &key)
List::const_iterator const_iterator
Provides string-parsing functionality with protection from buffer overflow.
CurrentPosition skipToEnd()
CurrentPosition skipToChar(char c)
CurrentPosition position() const
CurrentPosition skipChar()
void data(Data &data, const char *start) const
make the passed in data share memory with the buffer (uses Data::Share)
const Data & getValue() const
const Data & getTag() const
const AttributeMap & getAttributes() const
dcm! – add UnusedChecking(_enum) below;
bool isEqualNoCase(const Data &left, const Data &right)
void initNetwork()
set up network - does nothing in unix but needed for windows
int closeSocket(Socket fd)
int main(int argc, char **argv)