Exemple #1
0
LOCAL BOOL	FindCommand(MACRO_FILE_HANDLE fh, ITEMID idCommand)
/***********************************************************************/
{
LPVOID lpParms;
LPTSTR lpCommand;
int i;
BOOL found;

if (!(lpCommand = (LPTSTR)Alloc(MAX_CMD_LEN)))
	{
	Message(IDS_EMEMALLOC);
	return(FALSE);
	}
found = FALSE;
while (ReadLine(fh, lpCommand, MAX_CMD_LEN))
	{
	i = ReadParms(fh, lpCommand, &lpParms);
	if (i < 0)
		continue;
	if (lpParms)
		FreeUpParms(GetCommandId(i), lpParms);
	if (GetCommandId(i) == idCommand)
		{
		found = TRUE;
		break;
		}
	}
FreeUp(lpCommand);
return(found);
}
GMI_RESULT  SysGetWorkStateCommandExecutor::Create( ReferrencePtr<BasePacket>& Packet, SafePtr<BaseCommandExecutor>& CommandExecutor )
{
    SystemPacket *SysPacket = (SystemPacket*) Packet.GetPtr();

    if (GetCommandId() != SysPacket->GetMessageCode())
    {
        return GMI_FAIL;
    }

    SafePtr<SysGetWorkStateCommandExecutor> GetWorkStateCommandExecutor( BaseMemoryManager::Instance().New<SysGetWorkStateCommandExecutor>() );
    if (NULL == GetWorkStateCommandExecutor.GetPtr())
    {
        return GMI_OUT_OF_MEMORY;
    }

    GetWorkStateCommandExecutor->m_Session = Packet->GetSession();
    GetWorkStateCommandExecutor->m_Reply = Packet->Clone();
    GMI_RESULT Result = GetWorkStateCommandExecutor->SetParameter(m_SystemServiceManager, m_Argument, m_ArgumentSize);
    if (FAILED(Result))
    {
        return Result;
    }

    CommandExecutor = GetWorkStateCommandExecutor;

    return GMI_SUCCESS;
}
Exemple #3
0
GMI_RESULT  SysStop3ACommandExecutor::Create( ReferrencePtr<BasePacket>& Packet, SafePtr<BaseCommandExecutor>& CommandExecutor )
{
    SystemPacket *SysPacket = (SystemPacket*) Packet.GetPtr();

    if (GetCommandId() != SysPacket->GetMessageCode())
    {
        return GMI_FAIL;
    }

    SafePtr<SysStop3ACommandExecutor>Stop3ACommandExecutor( BaseMemoryManager::Instance().New<SysStop3ACommandExecutor>() );
    if (NULL == Stop3ACommandExecutor.GetPtr())
    {
        return GMI_OUT_OF_MEMORY;
    }

    if (1 != SysPacket->GetAttrCount())
    {
        return GMI_FAIL;
    }

    Stop3ACommandExecutor->m_Session = Packet->GetSession();
    Stop3ACommandExecutor->m_Reply   = Packet->Clone();
    Stop3ACommandExecutor->SetParameter(m_SystemServiceManager, m_Argument, m_ArgumentSize);

    CommandExecutor = Stop3ACommandExecutor;

    return GMI_SUCCESS;
}
Exemple #4
0
LOCAL int CountType(LPTSTR lpFileName, COMMAND_TYPE Type)
/***********************************************************************/
{
LPVOID lpParms;
LPTSTR lpCommand;
int i;
int nType = 0;
MACRO_FILE_HANDLE fh;
FNAME       OEMName;

if (!(lpCommand = (LPTSTR)Alloc(MAX_CMD_LEN)))
	{
	Message(IDS_EMEMALLOC);
	return(-1);
	}

#ifdef BUFFERED_IO
AnsiToOem(lpFileName, OEMName);
fh = fopen(OEMName, _T("rb"));
if (fh == NULL)
#else
fh = FileOpen(lpFileName, FO_READ);
if (fh == MACRO_FILE_HANDLE_INVALID)
#endif
	{
	FreeUp((LPTR)lpCommand);
	Message(IDS_EOPEN, lpFileName);
	return(-1);
	}
while (ReadLine(fh, lpCommand, MAX_CMD_LEN))
	{
	i = ReadParms(fh, lpCommand, &lpParms);
	if (i < 0)
		continue;
	if (GetCommandType(GetCommandId(i)) == Type)
		++nType;
	if (lpParms)
		FreeUpParms(GetCommandId(i), lpParms);
	}
#ifdef BUFFERED_IO
fclose(fh);
#else
FileClose(fh);
#endif
FreeUp((LPTR)lpCommand);
return(nType);
}
void IPCommandSenderBase::DoCall()
{
    WriteCommandId(GetCommandId());
    SendRequest();

    int ret = ReadResult();
    if(ret != 0) {
        throw pipe_error("Fail to process the request in the server.");
    }
}
Exemple #6
0
bool Frame::IsDataRequestCommand(void) const
{
    bool    isDataRequest = false;
    uint8_t commandId     = 0;

    VerifyOrExit(GetType() == kFcfFrameMacCmd);
    SuccessOrExit(GetCommandId(commandId));
    isDataRequest = (commandId == kMacCmdDataRequest);

exit:
    return isDataRequest;
}
GMI_RESULT MediaCenterSetAutoFocusStepCommandExecutor::Create( ReferrencePtr<BasePacket>& Packet, SafePtr<BaseCommandExecutor>& CommandExecutor )
{
    ApplicationPacket *MediaCenterPacket = (ApplicationPacket*) Packet.GetPtr();

    if ( (0 == (GMI_MESSAGE_TYPE_REQUEST & MediaCenterPacket->GetMessageType())) || ( GetCommandId() != MediaCenterPacket->GetMessageId() ) )
    {
        return GMI_FAIL;
    }

    SafePtr<MediaCenterSetAutoFocusStepCommandExecutor> SetAutoFocusStepCommandExecutor( BaseMemoryManager::Instance().New<MediaCenterSetAutoFocusStepCommandExecutor>() );
    if ( NULL == SetAutoFocusStepCommandExecutor.GetPtr() )
    {
        return GMI_OUT_OF_MEMORY;
    }

    CommandExecutor = SetAutoFocusStepCommandExecutor;
    return MediaCenterSetOperationWithOneParameterCommandExecutor::Create( Packet, CommandExecutor );
}
GMI_RESULT MediaCenterGetVinVoutConfigurationCommandExecutor::Create( ReferrencePtr<BasePacket>& Packet, SafePtr<BaseCommandExecutor>& CommandExecutor )
{
    ApplicationPacket *MediaCenterPacket = (ApplicationPacket*) Packet.GetPtr();

    if ( (0 == (GMI_MESSAGE_TYPE_REQUEST & MediaCenterPacket->GetMessageType())) || ( GetCommandId() != MediaCenterPacket->GetMessageId() ) )
    {
        return GMI_FAIL;
    }

    SafePtr<MediaCenterGetVinVoutConfigurationCommandExecutor> GetVinVoutConfigurationCommandExecutor( BaseMemoryManager::Instance().New<MediaCenterGetVinVoutConfigurationCommandExecutor>() );
    if ( NULL == GetVinVoutConfigurationCommandExecutor.GetPtr() )
    {
        return GMI_OUT_OF_MEMORY;
    }

    GetVinVoutConfigurationCommandExecutor->m_Session = Packet->GetSession();
    GetVinVoutConfigurationCommandExecutor->m_Reply = Packet->Clone();
    GetVinVoutConfigurationCommandExecutor->SetParameter( m_MediaCenter );

    uint8_t *Offset = Packet->GetPacketPayloadBuffer();

    BIGENDIAN_TO_UINT( Offset, GetVinVoutConfigurationCommandExecutor->m_Token );                  // Token
    Offset += sizeof(uint32_t);

    BIGENDIAN_TO_USHORT( Offset, GetVinVoutConfigurationCommandExecutor->m_VinParameterLength );   // VinParameterLength
    Offset += sizeof(uint16_t);

    BIGENDIAN_TO_USHORT( Offset, GetVinVoutConfigurationCommandExecutor->m_VoutParameterLength );  // VoutParameterLength
    Offset += sizeof(uint16_t);

    CommandExecutor = GetVinVoutConfigurationCommandExecutor;

    return GMI_SUCCESS;
}
Exemple #9
0
const char *Frame::ToInfoString(char *aBuf, uint16_t aSize) const
{
    uint8_t     type, commandId;
    Address     src, dst;
    const char *typeStr;
    char        stringBuffer[10];
    char        srcStringBuffer[Address::kAddressStringSize];
    char        dstStringBuffer[Address::kAddressStringSize];

    type = GetType();

    switch (type)
    {
    case kFcfFrameBeacon:
        typeStr = "Beacon";
        break;

    case kFcfFrameData:
        typeStr = "Data";
        break;

    case kFcfFrameAck:
        typeStr = "Ack";
        break;

    case kFcfFrameMacCmd:
        if (GetCommandId(commandId) != OT_ERROR_NONE)
        {
            commandId = 0xff;
        }

        switch (commandId)
        {
        case kMacCmdDataRequest:
            typeStr = "Cmd(DataReq)";
            break;

        case kMacCmdBeaconRequest:
            typeStr = "Cmd(BeaconReq)";
            break;

        default:
            snprintf(stringBuffer, sizeof(stringBuffer), "Cmd(%d)", commandId);
            typeStr = stringBuffer;
            break;
        }

        break;

    default:
        snprintf(stringBuffer, sizeof(stringBuffer), "%d", type);
        typeStr = stringBuffer;
        break;
    }

    GetSrcAddr(src);
    GetDstAddr(dst);

    snprintf(aBuf, aSize, "len:%d, seqnum:%d, type:%s, src:%s, dst:%s, sec:%s, ackreq:%s", GetLength(), GetSequence(),
             typeStr, src.ToString(srcStringBuffer, sizeof(srcStringBuffer)),
             dst.ToString(dstStringBuffer, sizeof(dstStringBuffer)), GetSecurityEnabled() ? "yes" : "no",
             GetAckRequest() ? "yes" : "no");

    return aBuf;
}