lib/sw_apps/img_rcvry/src/xbir_http.c
static int Xbir_HttpProcessPostReq (struct tcp_pcb *Tpcb, u8 *HttpReq,
	u16 HttpReqLen)
{
	int Status = XST_FAILURE;
	char FileName[XBIR_HTTP_MAX_FILE_NAME_LEN] = "";
	char *JsonStr;

	Xbir_HttpExtractFileName((char *)HttpReq, HttpReqLen, FileName,
		XBIR_HTTP_MAX_FILE_NAME_LEN - 1U);

	if (strncmp(FileName, "cfg_boot_img", strlen("cfg_boot_img")) == 0) {
		JsonStr = strstr((char *)HttpReq, "\r\n\r\n");
		if (JsonStr != NULL) {
			JsonStr += strlen("\r\n\r\n");
			Status = Xbir_SsiJsonCfgBootImgStatus(JsonStr,
					strlen(JsonStr));
		}
		else {
			Status = XST_SUCCESS;
		}
		Xbir_HttpSendStatus(Tpcb, HttpReq, HttpReqLen, Status);
	}
	else if (strncmp(FileName, "download_imgA", strlen("download_imgA")) == 0) {
		Status = Xbir_SsiUpdateImgA(Tpcb, HttpReq, HttpReqLen);
	}
	else if (strncmp(FileName, "download_imgB", strlen("download_imgB")) == 0) {
		Status = Xbir_SsiUpdateImgB(Tpcb, HttpReq, HttpReqLen);
	}
	else if (strncmp(FileName, "validate_crc", strlen("validate_crc")) == 0) {
		JsonStr = strstr((char *)HttpReq, "\r\n\r\n");
		if (JsonStr != NULL) {
			JsonStr += strlen("\r\n\r\n");
			Status = Xbir_SsiValidateLastUpdate(JsonStr,
				strlen(JsonStr));
		}
		Status = Xbir_HttpSendStatus(Tpcb, HttpReq, HttpReqLen, Status);
	}
	else {
		Xbir_HttpSendResponse404(Tpcb, HttpReq, HttpReqLen);
	}

	return Status;
}
/*****************************************************************************/
/**
 * @brief
 * This function processes HTTP POST request and sends the response
 *
 * @param	Tpcb		Pointer to TCP PCB
 * @param	HttpReq		Pointer to HTTP payload
 * @param	HttpReqLen	HTTP payload length
 *
 * @return	XST_SUCCESS if request is processed successfully
 *		XST_FAILURE if request is not processed
 *
 *****************************************************************************/
@brief
This function processes HTTP POST request and sends the response

@param       Tpcb            Pointer to TCP PCB
@param       HttpReq         Pointer to HTTP payload
@param       HttpReqLen      HTTP payload length

@return      XST_SUCCESS if request is processed successfully
XST_FAILURE if request is not processed
@brief This function processes HTTP POST request and sends the response @param Tpcb Pointer to TCP PCB @param HttpReq Pointer to HTTP payload @param HttpReqLen HTTP payload length @return XST_SUCCESS if request is processed successfully XST_FAILURE if request is not processed
static int Xbir_HttpProcessPostReq (struct tcp_pcb *Tpcb, u8 *HttpReq,
	u16 HttpReqLen)
{
	int Status = XST_FAILURE;
	char FileName[XBIR_HTTP_MAX_FILE_NAME_LEN] = "";
	char *JsonStr;
	Xbir_HttpExtractFileName((char *)HttpReq, HttpReqLen, FileName,
		XBIR_HTTP_MAX_FILE_NAME_LEN - 1U);
	if (strncmp(FileName, "cfg_boot_img", strlen("cfg_boot_img")) == 0) {
		JsonStr = strstr((char *)HttpReq, "\r\n\r\n");
		if (JsonStr != NULL) {
			JsonStr += strlen("\r\n\r\n");
			Status = Xbir_SsiJsonCfgBootImgStatus(JsonStr,
					strlen(JsonStr));
		}
		else {
			Status = XST_SUCCESS;
		}
		Xbir_HttpSendStatus(Tpcb, HttpReq, HttpReqLen, Status);
	}
	else if (strncmp(FileName, "download_imgA", strlen("download_imgA")) == 0) {
		Status = Xbir_SsiUpdateImgA(Tpcb, HttpReq, HttpReqLen);
	}
	else if (strncmp(FileName, "download_imgB", strlen("download_imgB")) == 0) {
		Status = Xbir_SsiUpdateImgB(Tpcb, HttpReq, HttpReqLen);
	}
	else if (strncmp(FileName, "validate_crc", strlen("validate_crc")) == 0) {
		JsonStr = strstr((char *)HttpReq, "\r\n\r\n");
		if (JsonStr != NULL) {
			JsonStr += strlen("\r\n\r\n");
			Status = Xbir_SsiValidateLastUpdate(JsonStr,
				strlen(JsonStr));
		}
		Status = Xbir_HttpSendStatus(Tpcb, HttpReq, HttpReqLen, Status);
	}
	else {
		Xbir_HttpSendResponse404(Tpcb, HttpReq, HttpReqLen);
	}
	return Status;
}
static int Xbir_HttpProcessPostReq ( struct tcp_pcb * Tpcb , u8 * HttpReq , u16 HttpReqLen ) { int Status = XST_FAILURE ; char FileName [ XBIR_HTTP_MAX_FILE_NAME_LEN ] = " " ; char * JsonStr ; Xbir_HttpExtractFileName ( ( char * ) HttpReq , HttpReqLen , FileName , XBIR_HTTP_MAX_FILE_NAME_LEN - 1U ) ; if ( strncmp ( FileName , " " , strlen ( " " ) ) == 0 ) { JsonStr = strstr ( ( char * ) HttpReq , " \r \n \r \n " ) ; if ( JsonStr != NULL ) { JsonStr += strlen ( " \r \n \r \n " ) ; Status = Xbir_SsiJsonCfgBootImgStatus ( JsonStr , strlen ( JsonStr ) ) ; } else { Status = XST_SUCCESS ; } Xbir_HttpSendStatus ( Tpcb , HttpReq , HttpReqLen , Status ) ; } else if ( strncmp ( FileName , " " , strlen ( " " ) ) == 0 ) { Status = Xbir_SsiUpdateImgA ( Tpcb , HttpReq , HttpReqLen ) ; } else if ( strncmp ( FileName , " " , strlen ( " " ) ) == 0 ) { Status = Xbir_SsiUpdateImgB ( Tpcb , HttpReq , HttpReqLen ) ; } else if ( strncmp ( FileName , " " , strlen ( " " ) ) == 0 ) { JsonStr = strstr ( ( char * ) HttpReq , " \r \n \r \n " ) ; if ( JsonStr != NULL ) { JsonStr += strlen ( " \r \n \r \n " ) ; Status = Xbir_SsiValidateLastUpdate ( JsonStr , strlen ( JsonStr ) ) ; } Status = Xbir_HttpSendStatus ( Tpcb , HttpReq , HttpReqLen , Status ) ; } else { Xbir_HttpSendResponse404 ( Tpcb , HttpReq , HttpReqLen ) ; } return Status ; }
@brief
 This function processes HTTP POST request and sends the response
@brief This function processes HTTP POST request and sends the response