static void dns(Dict* dns, struct Context* ctx, struct Except* eh) { List* servers = Dict_getList(dns, String_CONST("servers")); int count = List_size(servers); for (int i = 0; i < count; i++) { String* server = List_getString(servers, i); if (!server) { Except_throw(eh, "dns.servers[%d] is not a string", i); } Dict* d = Dict_new(ctx->alloc); Dict_putString(d, String_CONST("addr"), server, ctx->alloc); rpcCall(String_CONST("RainflyClient_addServer"), d, ctx, ctx->alloc); } List* keys = Dict_getList(dns, String_CONST("keys")); count = List_size(keys); for (int i = 0; i < count; i++) { String* key = List_getString(keys, i); if (!key) { Except_throw(eh, "dns.keys[%d] is not a string", i); } Dict* d = Dict_new(ctx->alloc); Dict_putString(d, String_CONST("ident"), key, ctx->alloc); rpcCall(String_CONST("RainflyClient_addKey"), d, ctx, ctx->alloc); } int64_t* minSigs = Dict_getInt(dns, String_CONST("minSignatures")); if (minSigs) { Dict* d = Dict_new(ctx->alloc); Dict_putInt(d, String_CONST("count"), *minSigs, ctx->alloc); rpcCall(String_CONST("RainflyClient_minSignatures"), d, ctx, ctx->alloc); } }
static void authorizedPasswords(List* list, struct Context* ctx) { uint32_t count = List_size(list); for (uint32_t i = 0; i < count; i++) { Dict* d = List_getDict(list, i); Log_info(ctx->logger, "Checking authorized password %d.", i); if (!d) { Log_critical(ctx->logger, "Not a dictionary type %d.", i); exit(-1); } String* passwd = Dict_getString(d, String_CONST("password")); if (!passwd) { Log_critical(ctx->logger, "Must specify a password %d.", i); exit(-1); } } Log_info(ctx->logger, "Flushing existing authorized passwords"); rpcCall(String_CONST("AuthorizedPasswords_flush"), NULL, ctx, ctx->alloc); for (uint32_t i = 0; i < count; i++) { Dict* d = List_getDict(list, i); String* passwd = Dict_getString(d, String_CONST("password")); Log_info(ctx->logger, "Adding authorized password #[%d].", i); Dict args = Dict_CONST( String_CONST("authType"), Int_OBJ(1), Dict_CONST( String_CONST("password"), String_OBJ(passwd), NULL )); struct Allocator* child = ctx->alloc->child(ctx->alloc); rpcCall(String_CONST("AuthorizedPasswords_add"), &args, ctx, child); child->free(child); } }
void NodeLookup::update() { // Out() << "NodeLookup::update" << endl; // Out() << "todo = " << todo.count() << " ; visited = " << visited.count() << endl; // go over the todo list and send find node calls // until we have nothing left while (!todo.empty() && canDoRequest()) { KBucketEntry e = todo.first(); // only send a findNode if we haven't allrready visited the node if (!visited.contains(e)) { // send a findNode to the node FindNodeReq* fnr = new FindNodeReq(node->getOurID(),node_id); fnr->setOrigin(e.getAddress()); rpcCall(fnr); visited.append(e); } // remove the entry from the todo list todo.pop_front(); } if (todo.empty() && getNumOutstandingRequests() == 0 && !isFinished()) done(); else if (num_nodes_rsp > 50) done(); // quit after 50 nodes responses }
static void udpInterface(Dict* config, struct Context* ctx) { Dict* udp = Dict_getDict(config, String_CONST("UDPInterface")); Dict* connectTo = Dict_getDict(udp, String_CONST("connectTo")); if (connectTo) { struct Dict_Entry* entry = *connectTo; while (entry != NULL) { String* key = (String*) entry->key; if (entry->val->type != Object_DICT) { Log_critical1(ctx->logger, "interfaces.UDPInterface.connectTo: entry [%s] " "is not a dictionary type.", key->bytes); exit(-1); } Dict* value = entry->val->as.dictionary; Log_keys1(ctx->logger, "Attempting to connect to node [%s].", key->bytes); struct Allocator* perCallAlloc = ctx->alloc->child(ctx->alloc); Dict_putString(value, String_CONST("address"), key, perCallAlloc); rpcCall(String_CONST("UDPInterface_beginConnection"), value, ctx, perCallAlloc); perCallAlloc->free(perCallAlloc); entry = entry->next; } } }
void IPCEngineHost::executeRunToFunction(const QString &functionName) { QByteArray p; { QDataStream s(&p, QIODevice::WriteOnly); SET_NATIVE_BYTE_ORDER(s); s << functionName; } rpcCall(ExecuteRunToFunction, p); }
void IPCEngineGuest::notifyInferiorPid(qint64 pid) { QByteArray p; { QDataStream s(&p, QIODevice::WriteOnly); SET_NATIVE_BYTE_ORDER(s); s << pid; } rpcCall(NotifyInferiorPid, p); }
void IPCEngineHost::fetchFrameSource(qint64 id) { QByteArray p; { QDataStream s(&p, QIODevice::WriteOnly); SET_NATIVE_BYTE_ORDER(s); s << id; } rpcCall(FetchFrameSource, p); }
void IPCEngineGuest::notifyChangeBreakpointFailed(BreakpointId id) { QByteArray p; { QDataStream s(&p, QIODevice::WriteOnly); SET_NATIVE_BYTE_ORDER(s); s << id; } rpcCall(NotifyChangeBreakpointFailed, p); }
void IPCEngineGuest::listThreads(const Threads &threads) { QByteArray p; { QDataStream s(&p, QIODevice::WriteOnly); SET_NATIVE_BYTE_ORDER(s); s << threads; } rpcCall(ListThreads, p); }
void IPCEngineGuest::listFrames(const StackFrames &frames) { QByteArray p; { QDataStream s(&p, QIODevice::WriteOnly); SET_NATIVE_BYTE_ORDER(s); s << frames; } rpcCall(ListFrames, p); }
void IPCEngineGuest::currentThreadChanged(qint64 osid) { QByteArray p; { QDataStream s(&p, QIODevice::WriteOnly); SET_NATIVE_BYTE_ORDER(s); s << osid; } rpcCall(CurrentThreadChanged, p); }
void IPCEngineHost::m_stateChanged(const Debugger::DebuggerState &state) { QByteArray p; { QDataStream s(&p, QIODevice::WriteOnly); SET_NATIVE_BYTE_ORDER(s); s << (qint64)state; } rpcCall(StateChanged, p); }
void IPCEngineHost::removeBreakpoint(BreakpointId id) { breakHandler()->notifyBreakpointRemoveProceeding(id); QByteArray p; { QDataStream s(&p, QIODevice::WriteOnly); SET_NATIVE_BYTE_ORDER(s); s << id; } rpcCall(RemoveBreakpoint, p); }
void IPCEngineHost::activateFrame(int index) { resetLocation(); QByteArray p; { QDataStream s(&p, QIODevice::WriteOnly); SET_NATIVE_BYTE_ORDER(s); s << quint64(index); } rpcCall(ActivateFrame, p); }
void IPCEngineGuest::notifyBreakpointAdjusted(BreakpointId id, const BreakpointParameters &bp) { QByteArray p; { QDataStream s(&p, QIODevice::WriteOnly); SET_NATIVE_BYTE_ORDER(s); s << id << bp; } rpcCall(NotifyBreakpointAdjusted, p); }
void IPCEngineGuest::disassembled(quint64 pc, const DisassemblerLines &da) { QByteArray p; { QDataStream s(&p, QIODevice::WriteOnly); SET_NATIVE_BYTE_ORDER(s); s << pc; s << da; } rpcCall(Disassembled, p); }
void IPCEngineGuest::showStatusMessage(const QString &msg, quint64 timeout) { QByteArray p; { QDataStream s(&p, QIODevice::WriteOnly); SET_NATIVE_BYTE_ORDER(s); s << msg; s << (qint64)timeout; } rpcCall(ShowStatusMessage, p); }
void IPCEngineHost::executeJumpToLine(const ContextData &data) { QByteArray p; { QDataStream s(&p, QIODevice::WriteOnly); SET_NATIVE_BYTE_ORDER(s); s << data.fileName; s << quint64(data.lineNumber); } rpcCall(ExecuteJumpToLine, p); }
void IPCEngineGuest::frameSourceFetched(qint64 id, const QString &name, const QString &source) { QByteArray p; { QDataStream s(&p, QIODevice::WriteOnly); SET_NATIVE_BYTE_ORDER(s); s << id; s << name; s << source; } rpcCall(FrameSourceFetched, p); }
void IPCEngineHost::insertBreakpoint(BreakpointId id) { breakHandler()->notifyBreakpointInsertProceeding(id); QByteArray p; { QDataStream s(&p, QIODevice::WriteOnly); SET_NATIVE_BYTE_ORDER(s); s << id; s << breakHandler()->breakpointData(id); } rpcCall(AddBreakpoint, p); }
void IPCEngineHost::updateWatchData(const WatchData &data, const WatchUpdateFlags &flags) { Q_UNUSED(flags); QByteArray p; { QDataStream s(&p, QIODevice::WriteOnly); SET_NATIVE_BYTE_ORDER(s); s << data; } rpcCall(RequestUpdateWatchData, p); }
void IPCEngineHost::fetchDisassembler(DisassemblerAgent *v) { quint64 address = v->location().address(); m_frameToDisassemblerAgent.insert(address, v); QByteArray p; { QDataStream s(&p, QIODevice::WriteOnly); SET_NATIVE_BYTE_ORDER(s); s << address; } rpcCall(Disassemble, p); }
void IPCEngineHost::selectThread(int index) { resetLocation(); Threads threads = threadsHandler()->threads(); QTC_ASSERT(index < threads.size(), return); QByteArray p; { QDataStream s(&p, QIODevice::WriteOnly); SET_NATIVE_BYTE_ORDER(s); s << quint64(threads.at(index).id); } rpcCall(SelectThread, p); }
void IPCEngineGuest::updateWatchData(bool fullCycle, const QList<WatchData> &wd) { QByteArray p; { QDataStream s(&p, QIODevice::WriteOnly); SET_NATIVE_BYTE_ORDER(s); s << fullCycle; s << quint64(wd.count()); for (int i = 0; i < wd.count(); ++i) s << wd.at(i); } rpcCall(UpdateWatchData, p); }
int main(int argc, char *argv[]) { int sockfd; char response[MAXRCVLEN]; sockfd = initSocket(SERVER_ADDR, PORTNUM); rpcCall(sockfd, "Arith.Multiply", "{\"A\": 2, \"B\": 3}", response); printf("%s\n", response); close(sockfd); return 0; }
static void ethInterfaceSetBeacon(int ifNum, Dict* eth, struct Context* ctx) { int64_t* beaconP = Dict_getInt(eth, String_CONST("beacon")); if (beaconP) { int64_t beacon = *beaconP; if (beacon > 3 || beacon < 0) { Log_error(ctx->logger, "interfaces.ETHInterface.beacon may only be 0, 1,or 2"); } else { // We can cast beacon to an int here because we know it's small enough Log_info(ctx->logger, "Setting beacon mode on ETHInterface to [%d].", (int) beacon); Dict d = Dict_CONST(String_CONST("interfaceNumber"), Int_OBJ(ifNum), Dict_CONST(String_CONST("state"), Int_OBJ(beacon), NULL)); rpcCall(String_CONST("ETHInterface_beacon"), &d, ctx, ctx->alloc); } } }
static void authorizedPasswords(List* list, struct Context* ctx) { uint32_t count = List_size(list); for (uint32_t i = 0; i < count; i++) { Dict* d = List_getDict(list, i); Log_info(ctx->logger, "Checking authorized password %d.", i); if (!d) { Log_critical(ctx->logger, "Not a dictionary type %d.", i); exit(-1); } String* passwd = Dict_getString(d, String_CONST("password")); if (!passwd) { Log_critical(ctx->logger, "Must specify a password %d.", i); exit(-1); } } for (uint32_t i = 0; i < count; i++) { struct Allocator* child = Allocator_child(ctx->alloc); Dict* d = List_getDict(list, i); String* passwd = Dict_getString(d, String_CONST("password")); String* user = Dict_getString(d, String_CONST("user")); String* displayName = user; if (!displayName) { displayName = String_printf(child, "password [%d]", i); } //String* publicKey = Dict_getString(d, String_CONST("publicKey")); String* ipv6 = Dict_getString(d, String_CONST("ipv6")); Log_info(ctx->logger, "Adding authorized password #[%d] for user [%s].", i, displayName->bytes); Dict *args = Dict_new(child); uint32_t i = 1; Dict_putInt(args, String_CONST("authType"), i, child); Dict_putString(args, String_CONST("password"), passwd, child); if (user) { Dict_putString(args, String_CONST("user"), user, child); } Dict_putString(args, String_CONST("displayName"), displayName, child); if (ipv6) { Log_info(ctx->logger, " This connection password restricted to [%s] only.", ipv6->bytes); Dict_putString(args, String_CONST("ipv6"), ipv6, child); } rpcCall(String_CONST("AuthorizedPasswords_add"), args, ctx, child); Allocator_free(child); } }
static void security(List* securityConf, struct Allocator* tempAlloc, struct Context* ctx) { bool noFiles = false; for (int i = 0; i < List_size(securityConf); i++) { if (String_equals(String_CONST("nofiles"), List_getString(securityConf, i))) { noFiles = true; } else { Dict* userDict = List_getDict(securityConf, i); String* userName = Dict_getString(userDict, String_CONST("setuser")); if (userName) { Dict d = Dict_CONST(String_CONST("user"), String_OBJ(userName), NULL); // If this call returns an error, it is ok. rpcCall0(String_CONST("Security_setUser"), &d, ctx, tempAlloc, false); } } } if (noFiles) { Dict d = NULL; rpcCall(String_CONST("Security_noFiles"), &d, ctx, tempAlloc); } }
static void authorizedPasswords(List* list, struct Context* ctx) { uint32_t count = List_size(list); for (uint32_t i = 0; i < count; i++) { Dict* d = List_getDict(list, i); Log_info(ctx->logger, "Checking authorized password %d.", i); if (!d) { Log_critical(ctx->logger, "Not a dictionary type %d.", i); exit(-1); } String* passwd = Dict_getString(d, String_CONST("password")); if (!passwd) { Log_critical(ctx->logger, "Must specify a password %d.", i); exit(-1); } } for (uint32_t i = 0; i < count; i++) { struct Allocator* child = Allocator_child(ctx->alloc); Dict* d = List_getDict(list, i); String* passwd = Dict_getString(d, String_CONST("password")); String* user = Dict_getString(d, String_CONST("user")); if (!user) { user = String_printf(child, "password [%d]", i); } Log_info(ctx->logger, "Adding authorized password #[%d] for user [%s].", i, user->bytes); Dict args = Dict_CONST( String_CONST("authType"), Int_OBJ(1), Dict_CONST( String_CONST("password"), String_OBJ(passwd), Dict_CONST( String_CONST("user"), String_OBJ(user), NULL ))); rpcCall(String_CONST("AuthorizedPasswords_add"), &args, ctx, child); Allocator_free(child); } }
void IPCEngineHost::interruptInferior() { QTC_ASSERT(state() == InferiorStopRequested, qDebug() << state()); rpcCall(InterruptInferior); }