コード例 #1
0
ファイル: aj_peer.c プロジェクト: bigzero/ajtcl
AJ_Status AJ_PeerAuthenticate(AJ_BusAttachment* bus, const char* peerName, AJ_PeerAuthenticateCallback callback, void* cbContext)
{
    AJ_Message msg;
    char guidStr[33];
    AJ_GUID localGuid;
    uint32_t version = REQUIRED_AUTH_VERSION;

    /*
     * Check there isn't an authentication in progress
     */
    if (authContext.callback || authContext.peerGuid) {
        /*
         * The existing authentication may have timed-out
         */
        if (AJ_GetElapsedTime(&authContext.timer, TRUE) < MAX_AUTH_TIME) {
            return AJ_ERR_RESOURCES;
        }
        /*
         * Report the failed authentication
         */
        PeerAuthComplete(AJ_ERR_TIMEOUT);
    }
    authContext.callback = callback;
    authContext.cbContext = cbContext;
    authContext.peerName = peerName;
    AJ_InitTimer(&authContext.timer);
    /*
     * Kick off autnetication with an ExchangeGUIDS method call
     */
    AJ_MarshalMethodCall(bus, &msg, AJ_METHOD_EXCHANGE_GUIDS, peerName, 0, AJ_NO_FLAGS, CALL_TIMEOUT);
    AJ_GetLocalGUID(&localGuid);
    AJ_GUID_ToString(&localGuid, guidStr, sizeof(guidStr));
    AJ_MarshalArgs(&msg, "su", guidStr, version);
    return AJ_DeliverMsg(&msg);
}
コード例 #2
0
ファイル: bastress2.c プロジェクト: fonlabs/ajtcl
AJ_Status AppHandleCat(AJ_Message* msg)
{
    AJ_Status status = AJ_OK;
    AJ_Message reply;
    char* partA;
    char* partB;
    char* totalString;
    AJ_AlwaysPrintf(("%s:%d:%s %d\n", __FILE__, __LINE__, __FUNCTION__, 0));

    AJ_UnmarshalArgs(msg, "ss", &partA, &partB);

    totalString = (char*) AJ_Malloc(strlen(partA) + strlen(partB) + 1);
    if (!totalString) {
        return AJ_ERR_RESOURCES;
    }
    strcpy(totalString, partA);
    strcpy(totalString + strlen(partA), partB);

    AJ_MarshalReplyMsg(msg, &reply);
    AJ_MarshalArgs(&reply, "s", totalString);

    status = AJ_DeliverMsg(&reply);
    AJ_Free(totalString);
    return status;
}
コード例 #3
0
AJSVC_ServiceStatus EventsAndActionsMessageProcessor(AJ_BusAttachment* busAttachment, AJ_Message* msg, AJ_Status* msgStatus)
{
    AJ_Message reply;
    AJSVC_ServiceStatus serviceStatus = AJSVC_SERVICE_STATUS_HANDLED;

    switch (msg->msgId) {
    case EVENTSANDACTIONS_GET_PROP:
        *msgStatus = AJ_BusPropGet(msg, EventsAndActionsPropGetHandler, NULL);
        break;

    case EVENTSANDACTIONS_SET_PROP:
        *msgStatus = AJ_BusPropSet(msg, EventsAndActionsPropSetHandler, NULL);
        break;

    case ACTIONS_SETMODETOAUTO:
    case ACTIONS_SETMODETOCOOL:
    case ACTIONS_SETMODETOHEAT:
    case ACTIONS_SETMODETOFAN:
    case ACTIONS_SETMODETOOFF:
        AJ_MarshalReplyMsg(msg, &reply);
        setCurrentMode((msg->msgId & 0xFF) - (ACTIONS_SETMODETOAUTO & 0xFF));
        *msgStatus = AJ_DeliverMsg(&reply);
        break;

    default:
        serviceStatus = AJSVC_SERVICE_STATUS_NOT_HANDLED;
        break;
    }

    return serviceStatus;
}
コード例 #4
0
ファイル: aj_bus.c プロジェクト: durake/core-ajtcl
AJ_Status AJ_BusSetSignalRuleSerial(AJ_BusAttachment* bus, const char* ruleString, uint8_t rule, uint8_t flags, uint32_t* serialNum)
{
    AJ_Status status;
    AJ_Message msg;
    uint32_t msgId = (rule == AJ_BUS_SIGNAL_ALLOW) ? AJ_METHOD_ADD_MATCH : AJ_METHOD_REMOVE_MATCH;

    AJ_InfoPrintf(("AJ_BusSetSignalRuleSerial(bus=0x%p, ruleString=\"%s\", rule=%d.)\n", bus, ruleString, rule));

    status = AJ_MarshalMethodCall(bus, &msg, msgId, AJ_DBusDestination, 0, flags, AJ_METHOD_TIMEOUT);
    if (status == AJ_OK) {
        uint32_t sz = 0;
        uint8_t nul = 0;
        if (serialNum) {
            *serialNum = msg.hdr->serialNum;
        }
        sz = (uint32_t)strlen(ruleString);
        status = AJ_DeliverMsgPartial(&msg, sz + 5);
        AJ_MarshalRaw(&msg, &sz, 4);
        AJ_MarshalRaw(&msg, ruleString, strlen(ruleString));
        AJ_MarshalRaw(&msg, &nul, 1);
    }
    if (status == AJ_OK) {
        status = AJ_DeliverMsg(&msg);
    }
    return status;
}
コード例 #5
0
static AJ_Status SendEvent(AJ_BusAttachment* busAttachment, uint32_t eventId)
{
    AJ_Status status = AJ_OK;
    AJ_Message msg;

    status = AJ_MarshalSignal(busAttachment, &msg, eventId, NULL, 0, AJ_FLAG_SESSIONLESS, 0);
    if (status != AJ_OK) {
        goto ErrorExit;
    }
    status = AJ_DeliverMsg(&msg);
    if (status != AJ_OK) {
        goto ErrorExit;
    }
    status = AJ_CloseMsg(&msg);
    if (status != AJ_OK) {
        goto ErrorExit;
    }
    AJ_AlwaysPrintf(("Event sent successfully\n"));
    return status;

ErrorExit:

    AJ_AlwaysPrintf(("Event sending failed with status=%s\n", AJ_StatusText(status)));
    return status;
}
コード例 #6
0
ファイル: basic_service.cpp プロジェクト: CasyWang/Triton
static AJ_Status AppHandleCat(AJ_Message* msg)
{
#define BUFFER_SIZE 256
    const char* string0;
    const char* string1;
    char buffer[BUFFER_SIZE];
    AJ_Message reply;
    AJ_Arg replyArg;

    AJ_UnmarshalArgs(msg, "ss", &string0, &string1);
    AJ_MarshalReplyMsg(msg, &reply);

    /* We have the arguments. Now do the concatenation. */
    strncpy(buffer, string0, BUFFER_SIZE);
    buffer[BUFFER_SIZE - 1] = '\0';
    strncat(buffer, string1, BUFFER_SIZE - strlen(buffer));
    buffer[BUFFER_SIZE - 1] = '\0';

    AJ_InitArg(&replyArg, AJ_ARG_STRING, 0, buffer, 0);
    AJ_MarshalArg(&reply, &replyArg);

    return AJ_DeliverMsg(&reply);

#undef BUFFER_SIZE
}
コード例 #7
0
AJ_Status AJ_BusAddSignalRule(AJ_BusAttachment* bus, const char* signalName, const char* interfaceName, uint8_t rule)
{
    AJ_Status status;
    AJ_Message msg;
    const char* str[5];
    uint32_t msgId = (rule == AJ_BUS_SIGNAL_ALLOW) ? AJ_METHOD_ADD_MATCH : AJ_METHOD_REMOVE_MATCH;

    AJ_InfoPrintf(("AJ_BusAddSignalRule(bus=0x%p, signalName=\"%s\", interfaceName=\"%s\", rule=%d.)\n", bus, signalName, interfaceName, rule));

    str[0] = "type='signal',member='";
    str[1] = signalName;
    str[2] = "'interface='";
    str[3] = interfaceName;
    str[4] = "'";

    status = AJ_MarshalMethodCall(bus, &msg, msgId, AJ_DBusDestination, 0, 0, AJ_METHOD_TIMEOUT);
    if (status == AJ_OK) {
        size_t i;
        uint32_t sz = 0;
        uint8_t nul = 0;
        for (i = 0; i < ArraySize(str); ++i) {
            sz += (uint32_t)strlen(str[i]);
        }
        status = AJ_DeliverMsgPartial(&msg, sz + 5);
        AJ_MarshalRaw(&msg, &sz, 4);
        for (i = 0; i < ArraySize(str); ++i) {
            AJ_MarshalRaw(&msg, str[i], strlen(str[i]));
        }
        AJ_MarshalRaw(&msg, &nul, 1);
    }
    if (status == AJ_OK) {
        status = AJ_DeliverMsg(&msg);
    }
    return status;
}
コード例 #8
0
AJ_Status ExecuteAction(AJ_Message* msg, uint32_t msgId, ExecuteActionContext* context)
{
    AJ_Message reply;
    AJ_MarshalReplyMsg(msg, &reply);

    switch (msgId) {
    case EN_MYDEVICE_OVENACTION_EXEC:
    case DE_AT_MYDEVICE_OVENACTION_EXEC:
        {
            AJ_InfoPrintf(("Starting the Oven. Execute was called\n"));
        }
        break;

    case EN_MYDEVICE_LIGHTCONFIRM_EXEC_ACTION1:
    case DE_AT_MYDEVICE_LIGHTCONFIRM_EXEC_ACTION1:
        {
            AJ_InfoPrintf(("Execute Action1 was called\n"));
        }
        break;

    case EN_MYDEVICE_LIGHTCONFIRM_EXEC_ACTION2:
    case DE_AT_MYDEVICE_LIGHTCONFIRM_EXEC_ACTION2:
        {
            AJ_InfoPrintf(("Execute Action2 was called\n"));
        }
        break;

    case EN_MYDEVICE_LIGHTCONFIRM_EXEC_ACTION3:
    case DE_AT_MYDEVICE_LIGHTCONFIRM_EXEC_ACTION3:
        {
            AJ_InfoPrintf(("Execute Action3 was called\n"));
        }
        break;

    case EN_MYDEVICE_AREYOUSURE_EXEC_ACTION1:
    case DE_AT_MYDEVICE_AREYOUSURE_EXEC_ACTION1:
        {
            AJ_InfoPrintf(("Execute Action1 was called\n")); addDismissSignal(context, MYDEVICE_NOTIFICATION_ACTION_AREYOUSURE_SIGNAL_DISMISS);
        }
        break;

    case EN_MYDEVICE_AREYOUSURE_EXEC_ACTION2:
    case DE_AT_MYDEVICE_AREYOUSURE_EXEC_ACTION2:
        {
            AJ_MarshalErrorMsg(msg, &reply, AJ_ErrServiceUnknown);
        }
        break;

    case EN_MYDEVICE_AREYOUSURE_EXEC_ACTION3:
    case DE_AT_MYDEVICE_AREYOUSURE_EXEC_ACTION3:
        {
            AJ_MarshalErrorMsg(msg, &reply, AJ_ErrServiceUnknown);
        }
        break;


    }

    return AJ_DeliverMsg(&reply);
}
コード例 #9
0
/**
 * Send notify signal
 */
static AJ_Status AJNS_Producer_SendNotifySignal(AJ_BusAttachment* busAttachment, AJNS_Notification* notification, uint32_t ttl, uint32_t* messageSerialNumber)
{
    AJ_Status status;
    AJ_Message msg;
    uint32_t serialNum;

//    AJ_InfoPrintf(("In SendNotifySignal\n"));
    status = AJNS_Producer_MarshalNotificationMsg(busAttachment, &msg, notification, ttl);
    if (status != AJ_OK) 
	{
 //       AJ_InfoPrintf(("Could not Marshal Message\n"));
        return status;
    }
    serialNum = msg.hdr->serialNum;
    status = AJ_DeliverMsg(&msg);
    if (status != AJ_OK) 
	{
        AJ_ErrPrintf(("Could not Deliver Message\n"));
        return status;
    }
 //   AJ_InfoPrintf(("***************** Notification id %d delivered successfully with serial number %u *****************\n", notification->notificationId, serialNum));
    if (messageSerialNumber != NULL)
	{
        *messageSerialNumber = serialNum;
    }

    AJ_CloseMsg(&msg);

    return status;
}
コード例 #10
0
void CPS_IdleConnectedHandler(AJ_BusAttachment*bus)
{
    if (runningTestNum == lastTestRun || CPSsessionId == 0) {
        return;
    }

    if (runningTestNum == numTests) {
        runningTestNum = 0;
        AJ_InfoPrintf(("Finished running all the tests\n"));
        exit(0);
    }

    AJ_Status status;
    AJ_Message msg;

    status = AJ_MarshalMethodCall(&busAttachment, &msg, testsToRun[runningTestNum].msgId,
                                  announceSender, CPSsessionId, 0, CPSC_CONNECT_TIMEOUT);

    uint16_t numParam;
    for (numParam = 0; numParam < testsToRun[runningTestNum].numParams; numParam++) {
        if (status == AJ_OK) {
            status = AJ_MarshalArgs(&msg, "q", testsToRun[runningTestNum].param[numParam]);
        }
    }

    if (status == AJ_OK) {
        status = AJ_DeliverMsg(&msg);
        lastTestRun = runningTestNum;
    }

    AJ_InfoPrintf(("MakeMethodCall() test number %i resulted in a status of %s.\n", lastTestRun + 1, AJ_StatusText(status)));
}
コード例 #11
0
AJ_Status AJNS_Consumer_SendDismissRequest(AJ_BusAttachment* busAttachment, uint16_t version, int32_t notificationId, const char* appId, const char* senderName, uint32_t sessionId)
{
    AJ_Status status = AJ_OK;

    if ((status == AJ_OK) && (sessionId != 0)) {
        AJ_Message dismissMsg;
        status = AJ_MarshalMethodCall(busAttachment, &dismissMsg, NOTIFICATION_PRODUCER_DISMISS_PROXY, senderName, sessionId, AJ_NO_FLAGS, AJ_CALL_TIMEOUT);
        if (status != AJ_OK) {
            AJ_ErrPrintf(("Could not marshal method call\n"));
            return status;
        }
        status = AJ_MarshalArgs(&dismissMsg, "i", notificationId);
        if (status != AJ_OK) {
            AJ_ErrPrintf(("Could not marshal arguments\n"));
            return status;
        }
        status = AJ_DeliverMsg(&dismissMsg);
        if (status != AJ_OK) {
            AJ_ErrPrintf(("Could not deliver message\n"));
            return status;
        }
        AJ_CloseMsg(&dismissMsg);
    }

    return status;
}
コード例 #12
0
ファイル: SecureService.cpp プロジェクト: CasyWang/Triton
static AJ_Status AppHandlePing(AJ_Message* msg)
{
    AJ_Status status;
    AJ_Message reply;
    AJ_Arg arg;

    status = AJ_UnmarshalArg(msg, &arg);

    if (AJ_OK == status) {

        if (arg.typeId == AJ_ARG_STRING) {
            AJ_Printf("Received ping request '%s'.\n", arg.val.v_string);
        } else {
            AJ_Printf("Unexpected arg type '%d' in ping request.\n", arg.typeId);
        }

        status = AJ_MarshalReplyMsg(msg, &reply);

        if (AJ_OK == status) {
            /*
             * Just return the arg we received
             */
            status = AJ_MarshalArg(&reply, &arg);

            if (AJ_OK == status) {
                status = AJ_DeliverMsg(&reply);
            }
        }
    }

    return status;
}
コード例 #13
0
ファイル: SecureClient.c プロジェクト: durake/core-ajtcl
AJ_Status SendPing(AJ_BusAttachment* bus, uint32_t sessionId)
{
    AJ_Status status;
    AJ_Message msg;

    AJ_AlwaysPrintf(("Sending ping request '%s'.\n", pingString));

    status = AJ_MarshalMethodCall(bus,
                                  &msg,
                                  PRX_PING,
                                  fullServiceName,
                                  sessionId,
                                  AJ_FLAG_ENCRYPTED,
                                  METHOD_TIMEOUT);
    if (AJ_OK == status) {
        status = AJ_MarshalArgs(&msg, "s", pingString);
    } else {
        AJ_InfoPrintf(("In SendPing() AJ_MarshalMethodCall() status = %d.\n", status));
    }

    if (AJ_OK == status) {
        status = AJ_DeliverMsg(&msg);
    } else {
        AJ_InfoPrintf(("In SendPing() AJ_MarshalArgs() status = %d.\n", status));
    }

    if (AJ_OK != status) {
        AJ_InfoPrintf(("In SendPing() AJ_DeliverMsg() status = %d.\n", status));
    }

    return status;
}
コード例 #14
0
AJ_Status AJCFG_GetConfigurationsHandler(AJ_Message* msg)
{
    AJ_Status status = AJ_OK;
    AJ_Message reply;
    char* language;
    int8_t langIndex = AJSVC_PROPERTY_STORE_ERROR_LANGUAGE_INDEX;
    AJSVC_PropertyStoreCategoryFilter filter;

    AJ_InfoPrintf(("Handling GetConfigurations request\n"));

    memset(&filter, 0, sizeof(AJSVC_PropertyStoreCategoryFilter));
    filter.bit1Config = TRUE;
    status = AJ_UnmarshalArgs(msg, "s", &language);
    if (status != AJ_OK) {
        return status;
    }
    if (AJSVC_IsLanguageSupported(msg, &reply, language, &langIndex)) {
        status = AJ_MarshalReplyMsg(msg, &reply);
        if (status != AJ_OK) {
            return status;
        }
        status = AJSVC_PropertyStore_ReadAll(&reply, filter, langIndex);
        if (status != AJ_OK) {
            return status;
        }
    }
    status = AJ_DeliverMsg(&reply);
    if (status != AJ_OK) {
        return status;
    }

    return status;
}
コード例 #15
0
AJ_Status AJSUSI_VgaGetBacklightBrightness_Handler(AJ_Message* msg)
{
    AJ_Status status = AJ_OK;
    AJ_Message reply;
    AJ_Arg replyArg;
    uint32_t id, bright;

    //Get Args
    status = AJ_UnmarshalArgs(msg, "u", &id);
    if (status != AJ_OK) {
        return status;
    }
    AJ_InfoPrintf(("%s : id=%d\n", __func__, id));

    //SUSI API
    if (AJ_SusiVgaGetBacklightBrightness(id, &bright)) {
        AJ_MarshalErrorMsg(msg, &reply, AJ_ErrFeatureNotAvailable);
        return AJ_DeliverMsg(&reply);
    }

    //Status Reply
    AJ_InfoPrintf(("%s : ret=0x%x\n", __func__, bright));
    AJ_InitArg(&replyArg, AJ_ARG_UINT32, 0, &bright, 0);
    return SendReplyMsg(msg, &replyArg);
}
コード例 #16
0
AJ_Status AJOBS_GetScanInfoHandler(AJ_Message* msg)
{
    AJ_Status status = AJ_OK;
    AJ_Message reply;
    AJ_Arg array;
    AJ_Arg structure;
    uint32_t elapsed;

    AJ_InfoPrintf(("Handling GetScanInfo request\n"));

    status = AJ_MarshalReplyMsg(msg, &reply);
    if (status != AJ_OK) {
        return status;
    }

    elapsed = AJ_GetElapsedTime(AJOBS_GetLastScanTime(), TRUE);
    if (elapsed > 0) {
        elapsed /= 60000;
    }
    status = AJ_MarshalArgs(&reply, "q", (uint16_t) elapsed);
    if (status != AJ_OK) {
        return status;
    }
    status = AJ_MarshalContainer(&reply, &array, AJ_ARG_ARRAY);
    if (status != AJ_OK) {
        return status;
    }

    int i = 0;
    for (; i < AJOBS_GetScanInfoCount(); ++i) {
        status = AJ_MarshalContainer(&reply, &structure, AJ_ARG_STRUCT);
        if (status != AJ_OK) {
            return status;
        }
        status = AJ_MarshalArgs(&reply, "s", (AJOBS_GetScanInfos())[i].ssid);
        if (status != AJ_OK) {
            return status;
        }
        status = AJ_MarshalArgs(&reply, "n", (AJOBS_GetScanInfos())[i].authType);
        if (status != AJ_OK) {
            return status;
        }
        status = AJ_MarshalCloseContainer(&reply, &structure);
        if (status != AJ_OK) {
            return status;
        }
    }

    status = AJ_MarshalCloseContainer(&reply, &array);
    if (status != AJ_OK) {
        return status;
    }
    status = AJ_DeliverMsg(&reply);
    if (status != AJ_OK) {
        return status;
    }

    return status;
}
コード例 #17
0
ファイル: due_led.cpp プロジェクト: durake/core-ajtcl
static AJ_Status AppHandleOnOff(AJ_Message* msg, uint8_t on)
{
    AJ_Message reply;

    AJ_AlwaysPrintf(("AppHandleOnOff(%u)\n", on));
    DUE_led(on);

    AJ_MarshalReplyMsg(msg, &reply);
    return AJ_DeliverMsg(&reply);
}
コード例 #18
0
AJ_Status AJ_BusReplyAcceptSession(AJ_Message* msg, uint32_t accept)
{
    AJ_Message reply;

    AJ_InfoPrintf(("AJ_BusReplyAcceptSession(msg=0x%p, accept=%d.)\n", msg, accept));

    AJ_MarshalReplyMsg(msg, &reply);
    AJ_MarshalArgs(&reply, "b", accept);
    return AJ_DeliverMsg(&reply);
}
コード例 #19
0
ファイル: aj_connect.c プロジェクト: reignme/ajtcl
static AJ_Status SendHello(AJ_BusAttachment* bus)
{
    AJ_Status status;
    AJ_Message msg;

    status = AJ_MarshalMethodCall(bus, &msg, AJ_METHOD_HELLO, AJ_DBusDestination, 0, AJ_FLAG_ALLOW_REMOTE_MSG, 5000);
    if (status == AJ_OK) {
        status = AJ_DeliverMsg(&msg);
    }
    return status;
}
コード例 #20
0
AJ_Status ExecuteAction(AJ_Message* msg, uint32_t msgId, ExecuteActionContext* context)
{
    AJ_Message reply;
    AJ_MarshalReplyMsg(msg, &reply);

    switch (msgId) {
//EXECUTE_ACTION_GO_HERE
    }

    return AJ_DeliverMsg(&reply);
}
コード例 #21
0
AJ_Status AJCFG_SetPasscodeHandler(AJ_Message* msg)
{
    AJ_Status status = AJ_OK;
    char* daemonRealm;
    AJ_Arg newPasscode;
    AJ_Message reply;
    uint8_t forceRoutingNodeDisconnect = FALSE;
    uint8_t errorReply = FALSE;

    AJ_InfoPrintf(("Handling SetPasscode request\n"));

    status = AJ_UnmarshalArgs(msg, "s", &daemonRealm);
    if (status != AJ_OK) {
        return status;
    }
    AJ_InfoPrintf(("Realm=%s\n", daemonRealm));
    status = AJ_UnmarshalArg(msg, &newPasscode);
    if (status != AJ_OK) {
        return status;
    }
    AJ_InfoPrintf(("Passcode=%d bytes long\n", newPasscode.len));
    if (newPasscode.len > 0) { // Check passcode is not empty
        if (AppSetPasscode) {
            status = (AppSetPasscode)(daemonRealm, (const uint8_t*)newPasscode.val.v_string, (uint8_t)newPasscode.len);
            if (status == AJ_ERR_RESOURCES) { // Check passcode is too long to persist
                status = AJ_MarshalErrorMsg(msg, &reply, AJSVC_ERROR_MAX_SIZE_EXCEEDED);
                if (status != AJ_OK) {
                    return status;
                }
                errorReply = TRUE;
            }
            forceRoutingNodeDisconnect = (status == AJ_ERR_READ);
        }
    } else {
        AJ_ErrPrintf(("Error - newPasscode cannot be empty!\n"));
        status = AJ_MarshalErrorMsg(msg, &reply, AJSVC_ERROR_INVALID_VALUE);
        if (status != AJ_OK) {
            return status;
        }
        errorReply = TRUE;
    }
    if (!errorReply) {
        status = AJ_MarshalReplyMsg(msg, &reply);
        if (status != AJ_OK) {
            return status;
        }
    }
    status = AJ_DeliverMsg(&reply);

    if (forceRoutingNodeDisconnect) {
        return AJ_ERR_READ;
    }
    return status;
}
コード例 #22
0
AJ_Status SendGetProp(AJ_BusAttachment* bus, uint32_t sessionId)
{
    AJ_Status status;
    AJ_Message msg;

    status = AJ_MarshalMethodCall(bus, &msg, PRX_GET_PROP, ServiceName, sessionId, 0, METHOD_TIMEOUT);
    if (status == AJ_OK) {
        AJ_MarshalPropertyArgs(&msg, PRX_GET_INT);
        status = AJ_DeliverMsg(&msg);
    }
    return status;
}
コード例 #23
0
static AJ_Status SendSignal()
{
    AJ_Message msg;

    AJ_AlwaysPrintf(("Emitting Name Changed Signal. New value for property 'name' is '%s'.\n", propertyName));

    /* For the signal to transmit outside of the current process the session ID must be 0. */
    AJ_MarshalSignal(&busAttachment, &msg, BASIC_SIGNAL_SERVICE_SIGNAL, NULL, 0, AJ_FLAG_GLOBAL_BROADCAST, 0);
    AJ_MarshalArgs(&msg, "s", propertyName);

    return AJ_DeliverMsg(&msg);
}
コード例 #24
0
static AJ_Status AJ_SendLinkProbeReq(AJ_BusAttachment* bus)
{
    AJ_Status status;
    AJ_Message msg;

    status = AJ_MarshalSignal(bus, &msg, AJ_SIGNAL_PROBE_REQ, AJ_BusDestination, 0, 0, 0);
    if (status == AJ_OK) 
	{
        status = AJ_DeliverMsg(&msg);
    }
    return status;
}
コード例 #25
0
ファイル: aj_peer.c プロジェクト: bigzero/ajtcl
AJ_Status AJ_PeerHandleGenSessionKeyReply(AJ_Message* msg)
{
    AJ_Status status;
    /*
     * For 12 bytes of verifier, we need at least 12 * 2 characters
     * to store its representation in hex (24 octets + 1 octet for \0).
     * However, the KeyGen function demands a bigger buffer
     * (to store 16 bytes key in addition to the 12 bytes verifier).
     * Hence we allocate, the maximum of (12 * 2 + 1) and (16 + 12).
     */
    char verifier[VERIFIER_LEN + AES_KEY_LEN];
    char* nonce;
    char* remVerifier;

    /*
     * Check we are in an auth conversation with the sender
     */
    status = CheckAuthPeer(msg);
    if (status != AJ_OK) {
        return status;
    }
    if (msg->hdr->msgType == AJ_MSG_ERROR) {
        status = AJ_ERR_SECURITY;
    } else {
        AJ_UnmarshalArgs(msg, "ss", &nonce, &remVerifier);
        status = KeyGen(msg->sender, AJ_ROLE_KEY_INITIATOR, authContext.nonce, nonce, (uint8_t*)verifier, sizeof(verifier));
        if (status == AJ_OK) {
            /*
             * Check verifier strings match as expected
             */
            if (strcmp(remVerifier, verifier) != 0) {
                status = AJ_ERR_SECURITY;
            }
        }
        if (status == AJ_OK) {
            AJ_Arg key;
            AJ_Message call;
            uint8_t groupKey[AES_KEY_LEN];
            /*
             * Group keys are exchanged via an encrypted message
             */
            AJ_MarshalMethodCall(msg->bus, &call, AJ_METHOD_EXCHANGE_GROUP_KEYS, msg->sender, 0, AJ_FLAG_ENCRYPTED, CALL_TIMEOUT);
            AJ_GetGroupKey(NULL, groupKey);
            AJ_MarshalArg(&call, AJ_InitArg(&key, AJ_ARG_BYTE, AJ_ARRAY_FLAG, groupKey, sizeof(groupKey)));
            status = AJ_DeliverMsg(&call);
        }
    }
    if (status != AJ_OK) {
        PeerAuthComplete(status);
    }
    return AJ_OK;
}
コード例 #26
0
ファイル: due_led.cpp プロジェクト: durake/core-ajtcl
static AJ_Status AppHandleFlash(AJ_Message* msg)
{
    AJ_Message reply;
    uint32_t timeout;
    AJ_UnmarshalArgs(msg, "u", &timeout);
    AJ_AlwaysPrintf(("AppHandleFlash(%u)\n", timeout));

    DUE_led_timed(timeout);


    AJ_MarshalReplyMsg(msg, &reply);
    return AJ_DeliverMsg(&reply);
}
コード例 #27
0
static AJ_Status AppHandlePing(AJ_Message* msg)
{
    AJ_Message reply;
    AJ_Arg arg;

    AJ_UnmarshalArg(msg, &arg);
    AJ_MarshalReplyMsg(msg, &reply);
    /*
     * Just return the arg we received
     */
    AJ_MarshalArg(&reply, &arg);
    return AJ_DeliverMsg(&reply);
}
コード例 #28
0
AJ_Status AJ_BusSetLinkTimeout(AJ_BusAttachment* bus, uint32_t sessionId, uint32_t linkTimeout)
{
    AJ_Status status;
    AJ_Message msg;

    AJ_InfoPrintf(("AJ_BusSetLinkTimeout(bus=0x%p, sessionId=%d., linkTimeout=%d.)\n", bus, sessionId, linkTimeout));

    status = AJ_MarshalMethodCall(bus, &msg, AJ_METHOD_SET_LINK_TIMEOUT, AJ_BusDestination, 0, 0, AJ_METHOD_TIMEOUT);
    if (status == AJ_OK) {
        (void)AJ_MarshalArgs(&msg, "u", sessionId);
        (void)AJ_MarshalArgs(&msg, "u", linkTimeout);
        status = AJ_DeliverMsg(&msg);
    }
    return status;
}
コード例 #29
0
AJ_Status AJ_BusReleaseName(AJ_BusAttachment* bus, const char* name)
{
    AJ_Status status;
    AJ_Message msg;

    AJ_InfoPrintf(("AJ_BusReleaseName(bus=0x%p, name=\"%s\")\n", bus, name));

    status = AJ_MarshalMethodCall(bus, &msg, AJ_METHOD_RELEASE_NAME, AJ_BusDestination, 0, 0, AJ_METHOD_TIMEOUT);
    if (status == AJ_OK) {
        status = AJ_MarshalArgs(&msg, "s", name);
    }
    if (status == AJ_OK) {
        status = AJ_DeliverMsg(&msg);
    }
    return status;
}
コード例 #30
0
ファイル: clientlite.c プロジェクト: gwgoliath/learnalljoyn
AJ_Status SendGetProp(AJ_BusAttachment* bus, uint32_t sessionId, const char* serviceName)
{
    AJ_Status status;
    AJ_Message msg;

    status = AJ_MarshalMethodCall(bus, &msg, PRX_GET_PROP, serviceName, sessionId, 0, METHOD_TIMEOUT);
    if (status == AJ_OK) {
        status = AJ_MarshalPropertyArgs(&msg, PRX_GET_INT);
    }
    if (status == AJ_OK) {
        status = AJ_DeliverMsg(&msg);
    } else {
        AJ_AlwaysPrintf(("SendGetProp %s\n", AJ_StatusText(status)));
    }
    return status;
}