Ejemplo n.º 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);
}
Ejemplo n.º 2
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);
}
Ejemplo n.º 3
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);
}
Ejemplo n.º 4
0
static Iface_DEFUN responseWithIpCallback(struct Message* message, struct Iface* iface)
{
    struct RouteHeader* rh = (struct RouteHeader*) message->bytes;
    Assert_true(!Bits_memcmp(nodeCjdnsIp6, rh->ip6, 16));
    Assert_true(!Bits_memcmp(fakePubKey, rh->publicKey, 32));

    Message_shift(message, -(RouteHeader_SIZE + DataHeader_SIZE), NULL);
    struct Headers_IP6Header* ip = (struct Headers_IP6Header*) message->bytes;
    Assert_true(Headers_getIpVersion(ip) == 6);
    uint16_t length = Endian_bigEndianToHost16(ip->payloadLength_be);
    Assert_true(length + Headers_IP6Header_SIZE == message->length);
    Assert_true(ip->nextHeader == 17);
    Assert_true(Bits_isZero(ip->sourceAddr, 32));

    Message_shift(message, -Headers_IP6Header_SIZE, NULL);
    struct Headers_UDPHeader* uh = (struct Headers_UDPHeader*) message->bytes;
    Assert_true(!Checksum_udpIp6(ip->sourceAddr, message->bytes, length));

    Assert_true(uh->srcPort_be == 0);
    Assert_true(uh->destPort_be == 0);
    Assert_true(Endian_bigEndianToHost16(uh->length_be) + Headers_UDPHeader_SIZE == length);

    Message_shift(message, -Headers_UDPHeader_SIZE, NULL);

    // We can't check that the message is an exact match because the padding depends on the
    // alignment of the output but we can make sure the right content is there...
    // Message should start with "d0000" (with some number of zeros)
    char* expectedResponse =
        "9:addresses" "d"
            "3:ip6" "16:\xfd\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1"
            "9:ip6Prefix" "i128e"
          "e"
          "4:txid" "4:abcd"
        "e";
    Assert_true(message->length >= (int32_t) CString_strlen(expectedResponse));
    Assert_true(CString_strstr(message->bytes, expectedResponse));
    called |= 2;
    return 0;
}