3#if defined(HAVE_CONFIG_H)
10#include "cajun/json/elements.h"
11#include "cajun/json/writer.h"
45#define RESIPROCATE_SUBSYSTEM Subsystem::REPRO
50Data writeJson(
const json::UnknownElement& elem)
52 std::ostringstream oss;
53 json::Writer::Write(elem, oss);
54 std::string s = oss.str();
55 return Data(s.c_str(), s.size());
59Data successEnvelope(
const json::UnknownElement& payload)
62 obj[
"data"] = payload;
63 return writeJson(obj);
70 obj[
"status"] = json::String(
"ok");
71 return writeJson(obj);
75Data errorEnvelope(
int code,
const Data& message)
78 err[
"code"] = json::Number(code);
79 err[
"message"] = json::String(message.
c_str());
82 return writeJson(obj);
87std::string codeToKey(
unsigned int code)
89 std::ostringstream oss;
103const MethodNameEntry kTrackedMethods[] =
105 { resip::INVITE,
"INVITE" },
106 { resip::ACK,
"ACK" },
107 { resip::BYE,
"BYE" },
108 { resip::CANCEL,
"CANCEL" },
109 { resip::MESSAGE,
"MESSAGE" },
110 { resip::OPTIONS,
"OPTIONS" },
111 { resip::REGISTER,
"REGISTER" },
112 { resip::PUBLISH,
"PUBLISH" },
113 { resip::SUBSCRIBE,
"SUBSCRIBE" },
114 { resip::NOTIFY,
"NOTIFY" },
115 { resip::REFER,
"REFER" },
116 { resip::INFO,
"INFO" },
117 { resip::PRACK,
"PRACK" },
118 { resip::SERVICE,
"SERVICE" },
119 { resip::UPDATE,
"UPDATE" },
121const size_t kNumTrackedMethods =
sizeof(kTrackedMethods) /
sizeof(kTrackedMethods[0]);
125json::Object responseCodeMap(
const unsigned int* codeArr,
126 unsigned int maxCode)
129 for (
unsigned int c = 0; c < maxCode; ++c)
133 obj[codeToKey(c)] = json::Number(codeArr[c]);
141json::Object methodMap(
const unsigned int* methodArr)
144 for (
size_t i = 0; i < kNumTrackedMethods; ++i)
146 unsigned int v = methodArr[kTrackedMethods[i].type];
149 obj[kTrackedMethods[i].name] = json::Number(v);
161 for (
size_t i = 0; i < kNumTrackedMethods; ++i)
164 json::Object inner = responseCodeMap(
169 obj[kTrackedMethods[i].name] = inner;
183 obj[
"tuFifoSize"] = json::Number(p.
tuFifoSize);
200 obj[
"responsesByCode"] =
223 : mWebAdmin(webAdmin)
232RestAdmin::parseRequest(
const Data& uri,
233 std::vector<Data>& pathSegments,
234 ParamMap& queryParams)
const
236 pathSegments.clear();
249 pathPart = uri.
substr(0, q);
250 queryPart = uri.
substr(q + 1);
254 const Data prefix(
"/api/v1");
255 if (pathPart.
prefix(prefix))
257 pathPart = pathPart.
substr(prefix.size());
260 if (!pathPart.
empty() && pathPart.
data()[0] ==
'/')
262 pathPart = pathPart.
substr(1);
266 if (!pathPart.
empty())
271 const char* anchor = pb.position();
274 pb.
data(seg, anchor);
285 if (!queryPart.
empty())
290 const char* anchor1 = pb.position();
293 pb.
data(key, anchor1);
298 const char* anchor2 = pb.skipChar(
'=');
300 pb.
data(value, anchor2);
317RestAdmin::sendJson(
int pageNumber,
int statusCode,
const Data&
json)
323RestAdmin::sendOk(
int pageNumber)
325 sendJson(pageNumber, 200, okEnvelope());
329RestAdmin::sendError(
int pageNumber,
int statusCode,
const Data& message)
331 sendJson(pageNumber, statusCode, errorEnvelope(statusCode, message));
335RestAdmin::sendMethodNotAllowed(
int pageNumber,
const Data& method)
337 sendError(pageNumber, 405,
Data(
"Method not allowed: ") + method);
341RestAdmin::sendNotFound(
int pageNumber)
343 sendJson(pageNumber, 404, errorEnvelope(404,
"Not found"));
347RestAdmin::param(
const ParamMap& q,
const Data& key,
const Data& defaultValue)
349 ParamMap::const_iterator it = q.
find(key);
358RestAdmin::hasParam(
const ParamMap& q,
const Data& key)
360 return q.
find(key) != q.end();
369 std::vector<Data> path;
371 parseRequest(uri, path,
query);
373 DebugLog(<<
"RestAdmin dispatch: method=" << method <<
" uri=" << uri
374 <<
" segments=" << path.
size());
378 sendNotFound(pageNumber);
382 const Data& resource = path[0];
384 if (resource ==
"registrations")
386 handleRegistrations(method, path,
query, pageNumber);
388 else if (resource ==
"publications")
390 handlePublications(method, path,
query, pageNumber);
392 else if (resource ==
"domains")
394 handleDomains(method, path,
query, pageNumber);
396 else if (resource ==
"users")
398 handleUsers(method, path,
query, pageNumber);
400 else if (resource ==
"acls")
402 handleAcls(method, path,
query, pageNumber);
404 else if (resource ==
"routes")
406 handleRoutes(method, path,
query, pageNumber);
408 else if (resource ==
"filters")
410 handleFilters(method, path,
query, pageNumber);
412 else if (resource ==
"settings")
414 handleSettings(method, pageNumber);
416 else if (resource ==
"stackinfo")
418 handleStackInfo(method, pageNumber);
420 else if (resource ==
"stats")
422 handleStats(method, path, pageNumber);
424 else if (resource ==
"congestion")
426 handleCongestion(method, pageNumber);
428 else if (resource ==
"loglevel")
430 handleLogLevel(method,
query, pageNumber);
432 else if (resource ==
"dnscache")
434 handleDnsCache(method, path, pageNumber);
436 else if (resource ==
"restart")
438 handleRestart(method, pageNumber);
440 else if (resource ==
"certs")
442 handleCertsReload(method, pageNumber);
446 sendNotFound(pageNumber);
454RestAdmin::handleRegistrations(
const Data& method,
455 const std::vector<Data>& path,
461 if (method ==
"GET" && path.size() == 1)
468 for (RegistrationPersistenceManager::UriList::const_iterator aorIt = aors.begin();
469 aorIt != aors.end(); ++aorIt)
475 json::Array contactArr;
476 for (ContactList::iterator i = contacts.begin();
477 i != contacts.end(); ++i)
479 if (i->mRegExpires > now)
486 c[
"regId"] = json::Number(r.
mRegId);
489#ifdef RESIP_FIXED_POINT
492 c[
"qValue"] = json::Number(r.
mContact.
param(p_q).floatVal());
504 c[
"static"] = json::Boolean(staticRegContact);
505 if (staticRegContact)
507 c[
"expiresIn"] = json::Null();
511 c[
"expiresIn"] = json::Number((
double)(r.
mRegExpires - now));
513 contactArr.Insert(c);
523 aorObj[
"aor"] = json::String(
Data::from(aor).c_str());
524 aorObj[
"contacts"] = contactArr;
525 aorArr.Insert(aorObj);
528 sendJson(pageNumber, 200, successEnvelope(aorArr));
532 if (method ==
"DELETE" && path.size() == 2)
535 const Data& aorStr = path[1];
542 for (ContactList::iterator i = contacts.begin(); i != contacts.end(); ++i)
552 json::Object payload;
553 payload[
"removed"] = json::Number(removed);
554 payload[
"aor"] = json::String(aorStr.
c_str());
555 sendJson(pageNumber, 200, successEnvelope(payload));
559 WarningLog(<<
"REST delete registration: bad AOR " << aorStr <<
": " << e);
560 sendError(pageNumber, 400,
Data(
"Invalid AOR: ") + aorStr);
565 sendMethodNotAllowed(pageNumber, method);
572RestAdmin::handlePublications(
const Data& method,
573 const std::vector<Data>& path,
579 if (method ==
"GET" && path.size() == 1)
586 for (PublicationPersistenceManager::KeyToETagMap::iterator keyIt = publications.begin();
587 keyIt != publications.end(); ++keyIt)
589 for (PublicationPersistenceManager::ETagToDocumentMap::iterator eTagIt = keyIt->second.begin();
590 eTagIt != keyIt->second.end(); ++eTagIt)
592 if (eTagIt->second.mExpirationTime > now)
595 pubObj[
"aor"] = json::String(eTagIt->second.mDocumentKey.c_str());
596 pubObj[
"eventType"] = json::String(eTagIt->second.mEventType.c_str());
597 pubObj[
"eTag"] = json::String(eTagIt->second.mETag.c_str());
609 pubObj[
"data"] = json::String(summary.
c_str());
613 pubObj[
"data"] = json::Null();
616 pubObj[
"synced"] = json::Boolean(eTagIt->second.mSyncPublication);
617 pubObj[
"expiresIn"] = json::Number((
double)(eTagIt->second.mExpirationTime - now));
624 sendJson(pageNumber, 200, successEnvelope(arr));
628 sendMethodNotAllowed(pageNumber, method);
635RestAdmin::handleDomains(
const Data& method,
636 const std::vector<Data>& path,
637 const ParamMap&
query,
642 if (method ==
"GET" && path.size() == 1)
646 for (ConfigStore::ConfigData::const_iterator i = configs.begin();
647 i != configs.end(); ++i)
650 obj[
"domain"] = json::String(i->second.mDomain.c_str());
651 obj[
"tlsPort"] = json::Number(i->second.mTlsPort);
654 sendJson(pageNumber, 200, successEnvelope(arr));
658 if (method ==
"POST" && path.size() == 1)
660 if (!hasParam(
query,
"uri"))
662 sendError(pageNumber, 400,
"Missing required parameter: uri");
670 obj[
"domain"] = json::String(uri.
c_str());
671 obj[
"tlsPort"] = json::Number(tlsPort);
672 sendJson(pageNumber, 200, successEnvelope(obj));
676 sendError(pageNumber, 500,
"Failed to add domain (database error)");
681 if (method ==
"DELETE" && path.size() == 2)
683 const Data& domain = path[1];
689 sendMethodNotAllowed(pageNumber, method);
696RestAdmin::handleUsers(
const Data& method,
697 const std::vector<Data>& path,
698 const ParamMap&
query,
706 obj[
"user"] = json::String(rec.user.c_str());
707 obj[
"domain"] = json::String(rec.domain.c_str());
708 obj[
"realm"] = json::String(rec.realm.c_str());
709 obj[
"name"] = json::String(rec.name.c_str());
710 obj[
"email"] = json::String(rec.email.c_str());
715 if (method ==
"GET" && path.size() == 1)
723 json::Object obj = userToJson(rec);
725 obj[
"id"] = json::String((rec.
user +
Data(
"@") + rec.
domain).c_str());
734 sendJson(pageNumber, 200, successEnvelope(arr));
739 if (method ==
"POST" && path.size() == 1)
741 if (!hasParam(
query,
"user") || !hasParam(
query,
"domain"))
743 sendError(pageNumber, 400,
"Missing required parameter: user and/or domain");
748 Data password = param(
query,
"password");
753 if (userStore.
addUser(user, domain, domain, password,
true, name, email))
756 obj[
"user"] = json::String(user.
c_str());
757 obj[
"domain"] = json::String(domain.
c_str());
758 obj[
"id"] = json::String((user +
Data(
"@") + domain).c_str());
759 sendJson(pageNumber, 200, successEnvelope(obj));
763 sendError(pageNumber, 500,
"Failed to add user (database error; possible duplicate)");
771 sendMethodNotAllowed(pageNumber, method);
776 const Data&
id = path[1];
783 sendError(pageNumber, 400,
"User identifier must be user@domain");
786 userPart =
id.
substr(0, at);
787 domainPart =
id.
substr(at + 1);
798 sendNotFound(pageNumber);
801 json::Object obj = userToJson(rec);
802 obj[
"id"] = json::String((rec.
user +
Data(
"@") + rec.
domain).c_str());
803 sendJson(pageNumber, 200, successEnvelope(obj));
812 sendNotFound(pageNumber);
820 Data newUser = hasParam(
query,
"user") ? param(
query,
"user") : rec.user;
821 Data newDomain = hasParam(
query,
"domain") ? param(
query,
"domain") : rec.domain;
822 Data newName = hasParam(
query,
"name") ? param(
query,
"name") : rec.name;
823 Data newEmail = hasParam(
query,
"email") ? param(
query,
"email") : rec.email;
826 Data newRealm = newDomain;
828 bool identityChanged = (newUser != rec.
user) || (newDomain != rec.
domain);
829 bool passwordProvided = hasParam(
query,
"password") && !param(
query,
"password").
empty();
831 if (identityChanged && !passwordProvided)
833 sendError(pageNumber, 400,
834 "Changing user or domain requires a new password "
835 "(the stored password hash is bound to user+realm)");
840 Data passwordHashAlt;
841 bool applyA1HashToPassword;
842 if (passwordProvided)
844 password = param(
query,
"password");
845 applyA1HashToPassword =
true;
852 applyA1HashToPassword =
false;
856 if (userStore.
updateUser(key, newUser, newDomain, newRealm, password,
857 applyA1HashToPassword, newName, newEmail,
862 ? userStore.
buildKey(newUser, newRealm)
865 json::Object obj = userToJson(updated);
866 obj[
"id"] = json::String((updated.
user +
Data(
"@") + updated.
domain).c_str());
867 sendJson(pageNumber, 200, successEnvelope(obj));
871 sendError(pageNumber, 500,
"Failed to update user (database error)");
876 if (method ==
"DELETE")
881 sendNotFound(pageNumber);
889 sendMethodNotAllowed(pageNumber, method);
896RestAdmin::handleAcls(
const Data& method,
897 const std::vector<Data>& path,
898 const ParamMap&
query,
903 if (method ==
"GET" && path.size() == 1)
912 obj[
"key"] = json::String(key.
c_str());
913 obj[
"type"] = json::String(
"tlsPeerName");
924 obj[
"key"] = json::String(key.
c_str());
925 obj[
"type"] = json::String(
"address");
934 sendJson(pageNumber, 200, successEnvelope(arr));
938 if (method ==
"POST" && path.size() == 1)
940 if (!hasParam(
query,
"hostOrIp"))
942 sendError(pageNumber, 400,
"Missing required parameter: hostOrIp");
945 Data hostOrIp = param(
query,
"hostOrIp");
949 if (aclStore.
addAcl(hostOrIp, port, transport))
952 obj[
"hostOrIp"] = json::String(hostOrIp.
c_str());
953 obj[
"port"] = json::Number(port);
954 obj[
"transport"] = json::String(param(
query,
"transport",
"UDP").c_str());
955 sendJson(pageNumber, 200, successEnvelope(obj));
959 sendError(pageNumber, 400,
Data(
"Failed to add ACL (parse error or database error): ") + hostOrIp);
964 if (method ==
"DELETE" && path.size() == 2)
966 const Data& key = path[1];
972 sendMethodNotAllowed(pageNumber, method);
979RestAdmin::handleRoutes(
const Data& method,
980 const std::vector<Data>& path,
981 const ParamMap&
query,
988 obj[
"key"] = json::String(key.
c_str());
993 obj[
"order"] = json::Number(rec.
mOrder);
997 if (method ==
"GET" && path.size() == 1)
1005 arr.Insert(routeToJson(rec, key));
1007 sendJson(pageNumber, 200, successEnvelope(arr));
1011 if (method ==
"POST" && path.size() == 1)
1013 if (!hasParam(
query,
"uri") || !hasParam(
query,
"destination"))
1015 sendError(pageNumber, 400,
"Missing required parameter: uri and/or destination");
1019 Data destination = param(
query,
"destination");
1024 if (routeStore.
addRoute(rmethod, event, uri, destination, order))
1027 obj[
"uri"] = json::String(uri.
c_str());
1028 obj[
"destination"] = json::String(destination.
c_str());
1029 obj[
"method"] = json::String(rmethod.
c_str());
1030 obj[
"event"] = json::String(event.c_str());
1031 obj[
"order"] = json::Number(order);
1032 sendJson(pageNumber, 200, successEnvelope(obj));
1036 sendError(pageNumber, 500,
"Failed to add route (duplicate or database error)");
1041 if (path.size() < 2)
1043 sendMethodNotAllowed(pageNumber, method);
1047 const Data& key = path[1];
1049 if (method ==
"PUT")
1058 sendNotFound(pageNumber);
1063 Data uri = hasParam(
query,
"uri") ? param(
query,
"uri") : rec.mMatchingPattern;
1064 Data destination = hasParam(
query,
"destination") ? param(
query,
"destination") : rec.mRewriteExpression;
1065 Data rmethod = hasParam(
query,
"method") ? param(
query,
"method") : rec.mMethod;
1066 Data event = hasParam(
query,
"event") ? param(
query,
"event") : rec.mEvent;
1071 sendError(pageNumber, 400,
"Route uri and destination must not be empty");
1075 if (routeStore.
updateRoute(key, rmethod, event, uri, destination, order))
1078 sendJson(pageNumber, 200, successEnvelope(routeToJson(updated, key)));
1082 sendError(pageNumber, 500,
"Failed to update route (database error)");
1087 if (method ==
"DELETE")
1094 sendMethodNotAllowed(pageNumber, method);
1101RestAdmin::handleFilters(
const Data& method,
1102 const std::vector<Data>& path,
1108 if (method ==
"GET" && path.size() == 1)
1116 Data actionStr(
"Accept");
1121 obj[
"key"] = json::String(key.
c_str());
1128 obj[
"action"] = json::String(actionStr.c_str());
1130 obj[
"order"] = json::Number(rec.
mOrder);
1133 sendJson(pageNumber, 200, successEnvelope(arr));
1137 sendMethodNotAllowed(pageNumber, method);
1144RestAdmin::handleSettings(
const Data& method,
int pageNumber)
1146 if (method !=
"GET")
1148 sendMethodNotAllowed(pageNumber, method);
1158 sendJson(pageNumber, 200, successEnvelope(json::String(buffer.
c_str())));
1162RestAdmin::handleStackInfo(
const Data& method,
int pageNumber)
1164 if (method !=
"GET")
1166 sendMethodNotAllowed(pageNumber, method);
1176 sendJson(pageNumber, 200, successEnvelope(json::String(buffer.
c_str())));
1180RestAdmin::handleStats(
const Data& method,
1181 const std::vector<Data>& path,
1185 if (method ==
"POST" && path.size() == 2 && path[1] ==
"reset")
1196 if (method ==
"GET" && path.size() == 1)
1199 bool gotPayload =
false;
1202 Lock lock(mWebAdmin.mStatsMutex);
1205 mWebAdmin.mStatsReady =
false;
1209 sendError(pageNumber, 503,
1210 "Statistics Manager is not enabled "
1211 "(set StatisticsLogInterval in repro.config)");
1218 const std::chrono::steady_clock::time_point deadline =
1219 std::chrono::steady_clock::now() + std::chrono::seconds(10);
1220 while (!mWebAdmin.mStatsReady)
1222 std::chrono::steady_clock::duration remaining =
1223 deadline - std::chrono::steady_clock::now();
1224 if (remaining <= std::chrono::steady_clock::duration::zero())
1228 mWebAdmin.mStatsCondition.wait_for(lock, remaining);
1231 if (mWebAdmin.mStatsReady)
1235 payload = mWebAdmin.mStatsPayload;
1242 sendError(pageNumber, 504,
1243 "Timed out waiting for stack statistics");
1247 sendJson(pageNumber, 200, successEnvelope(payloadToJson(payload)));
1251 sendMethodNotAllowed(pageNumber, method);
1255RestAdmin::handleCongestion(
const Data& method,
int pageNumber)
1257 if (method !=
"GET")
1259 sendMethodNotAllowed(pageNumber, method);
1265 sendJson(pageNumber, 200, successEnvelope(json::Null()));
1275 sendJson(pageNumber, 200, successEnvelope(json::String(buffer.
c_str())));
1282RestAdmin::handleLogLevel(
const Data& method,
1283 const ParamMap&
query,
1291 const Data prefix(
"LOG_");
1294 return s.
substr(prefix.size());
1299 if (method ==
"GET")
1302 obj[
"level"] = json::String(levelName(
Log::level()).c_str());
1303 sendJson(pageNumber, 200, successEnvelope(obj));
1307 if (method ==
"PUT")
1309 if (!hasParam(
query,
"level"))
1311 sendError(pageNumber, 400,
"Missing required parameter: level");
1317 InfoLog(<<
"Log level changed via REST API to: " << levelStr);
1320 obj[
"level"] = json::String(levelName(
Log::level()).c_str());
1321 sendJson(pageNumber, 200, successEnvelope(obj));
1325 sendMethodNotAllowed(pageNumber, method);
1332RestAdmin::handleDnsCache(
const Data& method,
1333 const std::vector<Data>& path,
1337 if (method ==
"GET" && path.size() == 1)
1341 Lock lock(mWebAdmin.mDnsCacheMutex);
1345 mWebAdmin.mDnsCacheCondition.wait(lock);
1346 cacheDump = mWebAdmin.mDnsCache;
1348 sendJson(pageNumber, 200, successEnvelope(json::String(cacheDump.
c_str())));
1353 if (method ==
"DELETE" && path.size() == 1)
1361 if (method ==
"POST" && path.size() == 2 && path[1] ==
"reload")
1368 sendMethodNotAllowed(pageNumber, method);
1375RestAdmin::handleRestart(
const Data& method,
int pageNumber)
1377 if (method !=
"POST")
1379 sendMethodNotAllowed(pageNumber, method);
1386 sendError(pageNumber, 503,
"CommandServer must be running (CommandPort must be set) to use restart");
1392 const char* host =
"127.0.0.1";
1393 struct addrinfo hints = {};
1394 struct addrinfo* res =
nullptr;
1395 hints.ai_family = AF_INET;
1396 hints.ai_socktype = SOCK_STREAM;
1398 if (getaddrinfo(host,
nullptr, &hints, &res) != 0 || res ==
nullptr)
1400 sendError(pageNumber, 500,
"Failed to resolve loopback for restart");
1404 struct sockaddr_in servAddr = {};
1405 memcpy(&servAddr, res->ai_addr, res->ai_addrlen);
1406 servAddr.sin_port = htons(port);
1409 int sd = (int)socket(AF_INET, SOCK_STREAM, 0);
1412 sendError(pageNumber, 500,
"Failed to create socket for restart");
1416 struct sockaddr_in localAddr = {};
1417 localAddr.sin_family = AF_INET;
1418 localAddr.sin_addr.s_addr = htonl(INADDR_ANY);
1419 localAddr.sin_port = 0;
1420 if (::bind(sd, (
struct sockaddr*)&localAddr,
sizeof(localAddr)) < 0)
1423 sendError(pageNumber, 500,
"Failed to bind local socket for restart");
1427 if (::connect(sd, (
struct sockaddr*)&servAddr,
sizeof(servAddr)) < 0)
1430 sendError(pageNumber, 500,
"Failed to connect to CommandPort for restart");
1434 Data request(
"<Restart>\r\n <Request>\r\n </Request>\r\n</Restart>\r\n");
1435 if (send(sd, request.c_str(), (
int)request.size(), 0) < 0)
1438 sendError(pageNumber, 500,
"Failed to send restart command");
1445 obj[
"status"] = json::String(
"restarting");
1446 sendJson(pageNumber, 200, successEnvelope(obj));
1453RestAdmin::handleCertsReload(
const Data& method,
int pageNumber)
1455 if (method !=
"POST")
1457 sendMethodNotAllowed(pageNumber, method);
1465 sendError(pageNumber, 501,
"Certificates not supported (built without SSL)");
#define WarningLog(args_)
Handles cross-platform sockets compatibility.
resip::Data mCondition1Header
resip::Data mCondition2Regex
resip::Data mCondition2Header
resip::Data mCondition1Regex
resip::Data mRewriteExpression
resip::Data mMatchingPattern
resip::Data passwordHashAlt
void eraseAcl(const resip::Data &tlsPeerName, const resip::Data &address, const short &mask, const short &port, const short &family, const short &transport)
resip::Data getTlsPeerName(const resip::Data &key)
short getAddressMask(const resip::Data &key)
Key getNextTlsPeerNameKey(Key &key)
Key getFirstTlsPeerNameKey()
Key getNextAddressKey(Key &key)
resip::Tuple getAddressTuple(const resip::Data &key)
bool addAcl(const resip::Data &tlsPeerName, const resip::Data &address, const short &mask, const short &port, const short &family, const short &transport)
bool addDomain(const resip::Data &domain, const int tlsPort)
std::map< resip::Data, AbstractDb::ConfigRecord > ConfigData
void eraseDomain(const resip::Data &domain)
const ConfigData & getConfigs() const
AbstractDb::FilterRecord getFilterRecord(const resip::Data &key)
ProxyConfig & getConfig() noexcept
resip::SipStack & getStack() noexcept
RestAdmin(WebAdmin &webAdmin)
void dispatch(const resip::Data &method, const resip::Data &uri, int pageNumber, const resip::Data &authenticatedUser)
bool addRoute(const resip::Data &method, const resip::Data &event, const resip::Data &matchingPattern, const resip::Data &rewriteExpression, const short order)
AbstractDb::RouteRecord getRouteRecord(const resip::Data &key)
void eraseRoute(const resip::Data &method, const resip::Data &event, const resip::Data &matchingPattern, const short order)
bool updateRoute(const resip::Data &originalKey, const resip::Data &method, const resip::Data &event, const resip::Data &matchingPattern, const resip::Data &rewriteExpression, const short order)
void eraseStaticReg(const resip::Uri &aor, const resip::NameAddr &contact)
StaticRegStore mStaticRegStore
static Key buildKey(const resip::Data &user, const resip::Data &domain)
bool addUser(const resip::Data &user, const resip::Data &domain, const resip::Data &realm, const resip::Data &password, bool applyA1HashToPassword, const resip::Data &fullName, const resip::Data &emailAddress, const resip::Data &passwordHashAlt=resip::Data::Empty)
void eraseUser(const Key &key)
bool updateUser(const Key &originalKey, const resip::Data &user, const resip::Data &domain, const resip::Data &realm, const resip::Data &password, bool applyA1HashToPassword, const resip::Data &fullName, const resip::Data &emailAddress, const resip::Data &passwordHashAlt=resip::Data::Empty)
AbstractDb::UserRecord getUserInfo(const Key &key) const
void setApiResponse(int pageNumber, int statusCode, const resip::Data &jsonBody)
The abstract base-class for all exceptions thrown by resip code.
unsigned short getConfigUnsignedShort(const resip::Data &name, int defaultValue) const
virtual EncodeStream & encodeCurrentState(EncodeStream &strm) const =0
Get the current state of all monitored fifos.to a stream.
An iostream that operates on an existing Data.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
static const Data Empty
Constant that represents a zero-length data.
const char * c_str() const
Returns a null-terminated string representing.
bool prefix(const Data &pre) const noexcept
Returns true if this Data starts with the bytes indicated by the passed-in Data.
Data substr(size_type first, size_type count=Data::npos) const
Copies a portion of this Data into a new Data.
bool empty() const noexcept
Checks whether the Data is empty.
Data urlDecoded() const
Performs in-place HTTP URL un-escaping of a Data.
size_type size() const noexcept
Returns the number of bytes in this Data.
static Data from(const T &x)
Converts from arbitrary other type to Data.
size_type find(const Data &match, size_type start=0) const
Finds a specified sequence of bytes in this Data.
static const size_type npos
Represents an impossible position; returned to indicate failure to find.
int convertInt() const
Takes the contents of the Data and converts them to an integer.
const char * data() const noexcept
Returns a pointer to the contents of this Data.
SIP body type for holding PIDF contents (MIME content-type application/pidf+xml).
const bool getSimplePresenceOnline()
const Data & getSimplePresenceNote()
static Data toString(Level l)
static Level toLevel(const Data &l)
static void setLevel(Level level)
Set logging level for current thread.
static Level level()
Return logging level for current thread.
bool exists(const Param< NameAddr > ¶mType) const
const Data & param(const ExtensionParameter ¶m) const
Const accessor for non-natively-supported parameter types.
Provides string-parsing functionality with protection from buffer overflow.
iterator end()
Returns an iterator pointing to the last header field value.
iterator begin()
Returns an iterator pointing to the first header field value.
Abstract interface of a datastore of all publication documents processed by DUM.
virtual void unlockDocuments()=0
std::map< resip::Data, ETagToDocumentMap > KeyToETagMap
virtual KeyToETagMap & getDocuments()=0
virtual void lockDocuments()=0
Abstract interface of a datastore of all registered endpoints processed by DUM.
virtual void removeContact(const Uri &aor, const ContactInstanceRecord &rec)=0
virtual void getContacts(const Uri &aor, ContactList &container)=0
virtual void getAors(UriList &container)=0
EncodeStream & dump(EncodeStream &strm) const
output current state of the stack - for debug
void clearDnsCache()
Clear the DNS Cache.
void getDnsCacheDump(std::pair< unsigned long, unsigned long > key, GetDnsCacheDumpHandler *handler)
Get a string representation of the DNS Cache.
void reloadCertificates()
reload the TLS X.509 certificates
void zeroOutStatistics()
Resets all of the cumulative statistics counters.
bool pollStatistics()
Immediately polls for statistics to be logged and sent to external handlers, instead of waiting for n...
void reloadDnsServers()
Check if DnsServers list has changed, and if so reinitializes the DNS resolver (ares).
static uint64_t getTimeSecs()
Returns the current clock time in seconds.
Data presentationFormat() const
Wrapper around the inet_top() method.
static const Data & toData(TransportType)
Converts the TransportType to a string representation of the transport type, e.g.
TransportType getType() const
static TransportType toTransport(const Data &)
Converts a string representation of transport type, i.e.
Represents the "SIP-URI" and "SIPS-URI" elements in the RFC 3261 grammar.
CongestionManager * getCongestionManager()
Accessor for the CongestionManager object the stack is using.
This Class is used to implement a primitive form of RPC using loose XML formatting.
dcm! – add UnusedChecking(_enum) below;
static const uint64_t NeverExpire
std::unique_lock< Mutex > Lock
A convenience class to lock a Lockable (such as a Mutex) on object creation, and unlock on destructio...
int closeSocket(Socket fd)
TransportType
An enumeration of transport protocols.
std::list< ContactInstanceRecord > ContactList
unsigned __int64 uint64_t
unsigned int responsesSentByMethod[MAX_METHODS]
unsigned int responsesReceived
unsigned int requestsReceived
unsigned int pendingDnsQueries
unsigned int activeClientTransactions
unsigned int responsesSent
unsigned int responsesRetransmitted
unsigned int responsesSentByMethodByCode[MAX_METHODS][MaxCode]
unsigned int transportFifoSizeSum
unsigned int requestsSentByMethod[MAX_METHODS]
unsigned int responsesRetransmittedByMethod[MAX_METHODS]
unsigned int responsesByCode[MaxCode]
unsigned int activeTimers
unsigned int responsesReceivedByMethodByCode[MAX_METHODS][MaxCode]
unsigned int requestsRetransmitted
unsigned int transactionFifoSize
unsigned int requestsRetransmittedByMethod[MAX_METHODS]
unsigned int responsesRetransmittedByMethodByCode[MAX_METHODS][MaxCode]
unsigned int requestsSent
unsigned int requestsReceivedByMethod[MAX_METHODS]
unsigned int activeServerTransactions
unsigned int openTcpConnections
unsigned int responsesReceivedByMethod[MAX_METHODS]