Agora  1.2.0
Agora project
AgoraScrambler::Scrambler Class Reference

#include <scrambler.h>

Public Member Functions

 Scrambler ()
 
 ~Scrambler ()=default
 
void Scramble (void *scrambled, const void *to_scramble, size_t bytes_to_scramble)
 
void Scramble (void *inout_bytes, size_t bytes_to_scramble)
 
void Descramble (void *descrambled, const void *scrambled, size_t bytes_to_descramble)
 
void Descramble (void *inout_bytes, size_t bytes_to_descramble)
 

Static Private Member Functions

static void WlanScrambler (void *output_buffer, const void *input_buffer, size_t num_bytes, std::bitset< kScramblerlength > &scram_buffer, std::vector< std::byte > &bit_buffer)
 WLAN Scrambler of IEEE 802.11-2012. More...
 
static void ConvertBytesToBits (const std::byte *in_byte_buffer, size_t byte_buffer_size, std::byte *out_bit_buffer)
 Convert a byte array to a bit array. MSB first. More...
 
static void ConvertBitsToBytes (const std::byte *in_bit_buffer, size_t byte_buffer_size, std::byte *out_byte_buffer)
 Convert a bit array to a byte array. MSB first. More...
 

Private Attributes

std::bitset< kScramblerlengthscram_buffer_
 
std::vector< std::byte > bit_buffer_
 

Constructor & Destructor Documentation

◆ Scrambler()

AgoraScrambler::Scrambler::Scrambler ( )

◆ ~Scrambler()

AgoraScrambler::Scrambler::~Scrambler ( )
default

Member Function Documentation

◆ ConvertBitsToBytes()

void AgoraScrambler::Scrambler::ConvertBitsToBytes ( const std::byte *  in_bit_buffer,
size_t  byte_buffer_size,
std::byte *  out_byte_buffer 
)
staticprivate

Convert a bit array to a byte array. MSB first.

Parameters
in_bit_bufferInput bit array
byte_buffer_sizeOutput byte array size
out_byte_bufferOutput byte array
Here is the caller graph for this function:

◆ ConvertBytesToBits()

void AgoraScrambler::Scrambler::ConvertBytesToBits ( const std::byte *  in_byte_buffer,
size_t  byte_buffer_size,
std::byte *  out_bit_buffer 
)
staticprivate

Convert a byte array to a bit array. MSB first.

Parameters
in_byte_bufferInput byte array
byte_buffer_sizeInput byte array size
out_bit_bufferOutput bit array
Here is the caller graph for this function:

◆ Descramble() [1/2]

void AgoraScrambler::Scrambler::Descramble ( void *  descrambled,
const void *  scrambled,
size_t  bytes_to_descramble 
)
Here is the call graph for this function:

◆ Descramble() [2/2]

void AgoraScrambler::Scrambler::Descramble ( void *  inout_bytes,
size_t  bytes_to_descramble 
)
Here is the call graph for this function:

◆ Scramble() [1/2]

void AgoraScrambler::Scrambler::Scramble ( void *  inout_bytes,
size_t  bytes_to_scramble 
)
Here is the call graph for this function:

◆ Scramble() [2/2]

void AgoraScrambler::Scrambler::Scramble ( void *  scrambled,
const void *  to_scramble,
size_t  bytes_to_scramble 
)
Here is the call graph for this function:

◆ WlanScrambler()

void AgoraScrambler::Scrambler::WlanScrambler ( void *  output_buffer,
const void *  input_buffer,
size_t  num_bytes,
std::bitset< kScramblerlength > &  scram_buffer,
std::vector< std::byte > &  bit_buffer 
)
staticprivate

WLAN Scrambler of IEEE 802.11-2012.

Section 18.3.5.5. The same scrambler is used to both scramble bits at the transmitter and descramble at the receiver.

The input is scrambled with a length-127 frame-synchronous scrambler using the generator polynomial s(x) = x7 + x4 + 1 and a pseudorandom nonzero initial state (default 0x5D), which is an integer picked in the range [1,127]. The mapping of the seed to the generator is Bit0 ~ Bit6 to x1 ~ x7. The output is the scrambld data of the same size and type as the input.

Parameters
output_bufferByte array for output scrambled data (can the the same as input)
input_bufferByte array for input to be scrambled
num_bytesByte array size - number of bytes to scramble / descramble
scram_bufferScratch memory
bit_bufferScratch memory
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ bit_buffer_

std::vector<std::byte> AgoraScrambler::Scrambler::bit_buffer_
private

◆ scram_buffer_

std::bitset<kScramblerlength> AgoraScrambler::Scrambler::scram_buffer_
private

The documentation for this class was generated from the following files: