library/src/network/httpd/BP-HTTPdWebSocketRequestHandlers.cc
// Use masking key to encode send data.  Data will be encoded IN PLACE so ensure
// to supply data you are fine with being modified (pre-copy if necessary).  The
// masking key modulo position is stored within the P_BP_HTTPD_WEBSOCKET_ENCODED_SEND_FRAME_HEADER
// structure.
Use masking key to encode send data.  Data will be encoded IN PLACE so ensure
to supply data you are fine with being modified (pre-copy if necessary).  The
masking key modulo position is stored within the P_BP_HTTPD_WEBSOCKET_ENCODED_SEND_FRAME_HEADER
structure.
Use masking key to encode send data . Data will be encoded IN PLACE so ensure to supply data you are fine with being modified ( pre - copy if necessary ) . The masking key modulo position is stored within the P_BP_HTTPD_WEBSOCKET_ENCODED_SEND_FRAME_HEADER structure .
BP_ERROR_T BP_HTTPdWebsocketEncodeSendData
(
	P_BP_HTTPD_WEBSOCKET_ENCODED_SEND_FRAME_HEADER frame_header_in_out,
	unsigned char                                 *data_to_encode_in_out,
	size_t                                         data_to_encode_size
)
{
	if(!frame_header_in_out)
		return ERR_FAILURE;
	if(!data_to_encode_in_out)
		return ERR_FAILURE;
	if(!data_to_encode_size)
		return ERR_FAILURE;
	if(frame_header_in_out->mask_flag == BP_TRUE)
	{
		size_t n = 0;
		for(n = 0; n < data_to_encode_size; n++)
		{
			data_to_encode_in_out[n] = data_to_encode_in_out[n] ^ frame_header_in_out->masking_key[frame_header_in_out->last_payload_encode_byte_idx % 4];
			frame_header_in_out->last_payload_encode_byte_idx++;
		}
	}
	return ERR_SUCCESS;
}
BP_ERROR_T BP_HTTPdWebsocketEncodeSendData ( P_BP_HTTPD_WEBSOCKET_ENCODED_SEND_FRAME_HEADER frame_header_in_out , unsigned char * data_to_encode_in_out , size_t data_to_encode_size ) { if ( ! frame_header_in_out ) return ERR_FAILURE ; if ( ! data_to_encode_in_out ) return ERR_FAILURE ; if ( ! data_to_encode_size ) return ERR_FAILURE ; if ( frame_header_in_out -> mask_flag == BP_TRUE ) { size_t n = 0 ; for ( n = 0 ; n < data_to_encode_size ; n ++ ) { data_to_encode_in_out [ n ] = data_to_encode_in_out [ n ] ^ frame_header_in_out -> masking_key [ frame_header_in_out -> last_payload_encode_byte_idx % 4 ] ; frame_header_in_out -> last_payload_encode_byte_idx ++ ; } } return ERR_SUCCESS ; }
Use masking key to encode send data.
Use masking key to encode send data .
// run basic checks // Never encode/mask data unless the mask flag is set. // iterate through data // perform xor encoding // increment the encode byte index // return indicating success