/** Handle a DTI command form the Debug & Trace interface */ DTI_STATIC DSL_int_t DSL_CPE_CLI_Dti_Command_Exec( DSL_CPE_Dti_Context_t *pDtiContext, const DSL_char_t *pCliDtiCommand, DSL_CPE_File_t *pOutStream) { DSL_int_t retVal = 0; DSL_char_t cmdBuf[256]; DSL_char_t *pArgBuf = DSL_NULL; /* get command name */ sscanf(pCliDtiCommand, "%s", cmdBuf); if(strlen(cmdBuf) < strlen(pCliDtiCommand)) { pArgBuf = (DSL_char_t *)pCliDtiCommand + strlen(cmdBuf) + 1; } retVal = DSL_CPE_CliDeviceCommandExecute(pDtiContext->pDSLContext, -1, cmdBuf, pArgBuf, pOutStream); return retVal; }
DSL_int_t DSL_CPE_TcpCliHandle( DSL_CPE_Control_Context_t *pCtx, DSL_CPE_TcpDebugCliClientInfo_t *pClient, DSL_int_t socketaccept) { DSL_int_t nBytesReceived; DSL_char_t nCurrChar = 0; DSL_char_t *pArg; /* receive command line */ nBytesReceived = DSL_CPE_SocketRecv(socketaccept, (DSL_char_t *)&nCurrChar, sizeof(nCurrChar)); /* Error or termination from host */ if(nBytesReceived == 0) { return -ENODATA; } /* TODO: Get system last error for analysis*/ if(nBytesReceived < 0) { return 0; } if (nCurrChar == '\r') { return 0; } if (pClient->pPos == DSL_NULL) { pClient->pPos = pClient->buf; } if ((nCurrChar == '\n') || (pClient->pPos >= pClient->buf + DSL_CPE_TCP_CLI_COMMAND_LENGTH_MAX - 1)) { if (pClient->pPos == pClient->buf) { return 0; } if (pClient->pPos > pClient->buf + DSL_CPE_TCP_CLI_COMMAND_LENGTH_MAX - 1) { pClient->pPos = 0; return -EFAULT; } else { *(pClient->pPos) = '\0'; pArg = strstr(pClient->buf, " "); if (pArg == DSL_NULL) { pArg = pClient->pPos; } else { *pArg = '\0'; pArg++; } DSL_CPE_CliDeviceCommandExecute(pCtx, -1, pClient->buf, pArg, pClient->out); pClient->pPos = 0; } } else { *(pClient->pPos) = nCurrChar; (pClient->pPos)++; } return 0; }
int ifx__DslCpeCliAccess (struct soap *soap_server, char *pCommand, char **pReturn ) { char cmd[256] = ""; char *pcArg = DSL_NULL; Soap_env_t *pSoapEnv = soap_server->user; DSL_CPE_File_t *stream = DSL_NULL; struct soap_multipart *attachment; #ifdef DSL_CPE_SOAP_FW_UPDATE DSL_CPE_Firmware_t nFirmware; DSL_CPE_Firmware_t nFirmware2; memset(&nFirmware, 0, sizeof(nFirmware)); memset(&nFirmware2, 0, sizeof(nFirmware2)); #endif /* DSL_CPE_SOAP_FW_UPDATE */ if(pCommand == DSL_NULL) { sprintf(soap_result, "nReturn=-1 nError=\"oops, CLI command received via SOAP is zero\n\r\""); *pReturn = soap_result; return SOAP_OK; } /* get command name */ sscanf(pCommand, "%255s", cmd); if(strlen(cmd) < strlen(pCommand)) { pcArg = pCommand + strlen(cmd) + 1; } for (attachment = soap_server->dime.list; attachment; attachment = attachment->next) { #ifdef DSL_CPE_SOAP_FW_UPDATE if(attachment->type && (strcmp(attachment->type, "image/firmware1") == 0)) { fprintf(stderr, "DIME attachment: firmware1.bin\n\r"); nFirmware.pData = (DSL_uint8_t *)attachment->ptr; nFirmware.nSize = attachment->size; } else if(attachment->type && (strcmp(attachment->type, "image/firmware2") == 0)) { fprintf(stderr, "DIME attachment: firmware2.bin\n\r"); nFirmware2.pData = (DSL_uint8_t *)attachment->ptr; nFirmware2.nSize = attachment->size; } else { fprintf(stderr, "DSL: cannot decode DIME attachment\n\r"); fprintf(stderr, "DIME attachment:\n\r"); fprintf(stderr, "Memory=%p\n\r", attachment->ptr); fprintf(stderr, "Size=%u\n\r", (unsigned int)attachment->size); fprintf(stderr, "Type=%s\n\r", attachment->type ? attachment->type:"null"); fprintf(stderr, "ID=%s\n\r", attachment->id ? attachment->id:"null"); } #else fprintf(stderr, "Firmware download via DIME attachment not supported.\n\r"); #endif } #ifdef DSL_CPE_SOAP_FW_UPDATE if((nFirmware.pData != DSL_NULL) || (nFirmware2.pData != DSL_NULL)) { DSL_CPE_SoapFirmwareUpdate(&nFirmware, &nFirmware2); } #endif /* DSL_CPE_SOAP_FW_UPDATE */ memset(soap_result, 0, sizeof(soap_result)); stream = DSL_CPE_FMemOpen(soap_result, sizeof(soap_result)-1, "w"); if(stream != DSL_NULL) { DSL_CPE_CliDeviceCommandExecute(pSoapEnv->pContext, -1, cmd, pcArg, stream); } else { DSL_CCA_DEBUG(DSL_CCA_DBG_ERR, (DSL_CPE_PREFIX "cannot open SOAP stream" DSL_CPE_CRLF)); } DSL_CPE_FClose(stream); *pReturn = soap_result; return SOAP_OK; }