예제 #1
0
static void goodCallback(struct AdminClient_Promise* p, struct AdminClient_Result* res)
{
    struct AdminTestFramework* fw = p->userData;
    Assert_true(CString_strstr(res->messageBytes, "5:error4:none"));
    EventBase_endLoop(fw->eventBase);
    //printf("result content: >>%s<<", res->messageBytes);
}
예제 #2
0
static void rpcCallback(struct AdminClient_Promise* p, struct AdminClient_Result* res)
{
    struct Context* ctx = p->userData;
    Allocator_adopt(ctx->alloc, p->alloc);
    ctx->currentResult = res;
    EventBase_endLoop(ctx->base);
}
예제 #3
0
static void badKeyCallback(struct AdminClient_Promise* p, struct AdminClient_Result* res)
{
    struct AdminTestFramework* fw = p->userData;
    Assert_true(CString_strstr(res->messageBytes, "5:error30:key must be 52 characters long"));
    EventBase_endLoop(fw->eventBase);
    //printf("result content: >>%s<<", res->messageBytes);
}
예제 #4
0
static void ifNewCallback(struct AdminClient_Promise* p, struct AdminClient_Result* res)
{
    struct AdminTestFramework* fw = p->userData;
    Assert_true(!res->err);
    //printf("result content: >>%s<<", res->messageBytes);
    // d11:bindAddress13:0.0.0.0:362615:error4:none15:interfaceNumberi0e4:txid8:01000000e
    Assert_true(CString_strstr(res->messageBytes, "5:error4:none15:interfaceNumberi0e"));
    EventBase_endLoop(fw->eventBase);
}
예제 #5
0
static void checkRunningInstanceCallback(struct AdminClient_Promise* p,
                                         struct AdminClient_Result* res)
{
    struct CheckRunningInstanceContext* ctx = p->userData;
    // Prevent this from freeing until after we drop out of the loop.
    Allocator_adopt(ctx->alloc, p->alloc);
    ctx->res = res;
    EventBase_endLoop(ctx->base);
}
예제 #6
0
파일: Admin_test.c 프로젝트: AdUser/cjdns
static void standardClientCallback(struct AdminClient_Promise* p, struct AdminClient_Result* res)
{
    struct Context* ctx = p->userData;
    //printf("%d\n", res->err);
    Assert_always(!res->err);
    Assert_always(Dict_getInt(res->responseDict, String_CONST("called!")));
    Assert_always(ctx->called);

    EventBase_endLoop(ctx->framework->eventBase);
}
예제 #7
0
static uint8_t receiveMessage(struct Message* message, struct Interface* iface)
{
    struct Context* ctx = iface->receiverContext;
    ctx->message = Message_clone(message, ctx->alloc);

    Timeout_clearTimeout(ctx->timeout);
    EventBase_endLoop(ctx->eventBase);

    return 0;
}
예제 #8
0
static Iface_DEFUN receiveMessageUDP(struct Message* msg, struct Iface* udpIface)
{
    struct TUNTools_pvt* ctx = Identity_containerOf(udpIface, struct TUNTools_pvt, pub.udpIface);

    if (ctx->pub.receivedMessageTUNCount) {
    Log_debug(ctx->pub.log, "test complete");
        // Got the message, test successful, tear everything down by freeing the root alloc.
        EventBase_endLoop(ctx->pub.base);
    }

    return NULL;
}
예제 #9
0
파일: EventBase.c 프로젝트: AdUser/cjdns
static int onFree(struct Allocator_OnFreeJob* job)
{
    struct EventBase_pvt* ctx = Identity_cast((struct EventBase_pvt*) job->userData);
    if (ctx->running) {
        // The job will be completed in EventLoop_beginLoop()
        ctx->onFree = job;
        EventBase_endLoop((struct EventBase*) ctx);
        return Allocator_ONFREE_ASYNC;
    } else {
        uv_loop_delete(ctx->loop);
        return 0;
    }
}
예제 #10
0
파일: sybilsim.c 프로젝트: antinet/cjdns
static Iface_DEFUN messageToAngel(struct Message* msg, struct Iface* iface)
{
    struct NodeContext* ctx = Identity_check((struct NodeContext*) iface);
    if (ctx->boundAddr) { return 0; }
    struct Allocator* alloc = Allocator_child(ctx->alloc);
    Dict* config = BencMessageReader_read(msg, alloc, NULL);
    Dict* admin = Dict_getDict(config, String_CONST("admin"));
    String* bind = Dict_getString(admin, String_CONST("bind"));
    struct Sockaddr_storage ss;
    Assert_true(!Sockaddr_parse(bind->bytes, &ss));
    ctx->boundAddr = Sockaddr_clone(&ss.addr, ctx->alloc);
    Allocator_free(alloc);
    EventBase_endLoop(ctx->base);
    return 0;
}
예제 #11
0
static void runTest(struct TwoNodes* tn)
{
    sendMessage(tn, "Hello World!", tn->nodeA, tn->nodeB);
    sendMessage(tn, "Hello cjdns!", tn->nodeB, tn->nodeA);
    sendMessage(tn, "send", tn->nodeA, tn->nodeB);
    sendMessage(tn, "a", tn->nodeB, tn->nodeA);
    sendMessage(tn, "few", tn->nodeA, tn->nodeB);
    sendMessage(tn, "packets", tn->nodeB, tn->nodeA);
    sendMessage(tn, "to", tn->nodeA, tn->nodeB);
    sendMessage(tn, "make", tn->nodeB, tn->nodeA);
    sendMessage(tn, "sure", tn->nodeA, tn->nodeB);
    sendMessage(tn, "the", tn->nodeB, tn->nodeA);
    sendMessage(tn, "cryptoauth", tn->nodeA, tn->nodeB);
    sendMessage(tn, "can", tn->nodeB, tn->nodeA);
    sendMessage(tn, "establish", tn->nodeA, tn->nodeB);

    Log_debug(tn->logger, "\n\nTest passed, shutting down\n\n");
    EventBase_endLoop(tn->base);
}
예제 #12
0
static void awaken(void* vcontext)
{
    struct Context* ctx = vcontext;
    EventBase_endLoop(ctx->base);
}
예제 #13
0
static void timeout(void* vcontext)
{
    struct Context* ctx = vcontext;
    ctx->timedOut = 1;
    EventBase_endLoop(ctx->eventBase);
}