This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * These examples show how to do bit manipulations and operation in C++ | |
| * Standart bit operation are shown as well as utility functions from C++20 STL bit.h | |
| */ | |
| void bit_examples() | |
| { | |
| endian_example(); | |
| uint16_t number = 0x1D10u; // 0b0001110100010000u; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SCENARIO( "Representing colors as RGB with alpha value" ) | |
| { | |
| uint32_t RGBA = 0xE64155FF; // Redish fully opaque color | |
| WHEN( "Need to get RED value" ) | |
| { | |
| // Lets first prepare the mask, remember that bitwise AND works 1 & 1 = 1 and everything | |
| // else is 0 | |
| // We can use this to zero everything else except for RED value | |
| uint32_t mask = 0xFF000000; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SCENARIO( "Bit manipulations" ) | |
| { | |
| // We can also use uint16_t, uint32_t or uint64_t (1B, 4B, 8B) variable | |
| uint8_t bits = 0b01001011u; | |
| SECTION( "Bitwise AND" ) | |
| { | |
| uint8_t mask = 0x0F; // 0b00001111 | |
| uint8_t result = bits & mask; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rec1value PDUSessionResourceSetupRequestTransfer ::= | |
| { | |
| --TYPE INFORMATION: SEQUENCE | |
| --OFFSET: 0,0 | |
| --extension flag: <.0> | |
| protocolIEs | |
| { | |
| --TYPE INFORMATION: SEQUENCE (SIZE(0..65535)) OF | |
| --OFFSET: 0,1 | |
| --padding: <0000000> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jkalmar@supercomp:~/projects/5g/app/build> ./app -iaper in.hex -dd | |
| AD: Processing in.hex | |
| AD: Decoding 61 bytes | |
| Decoding PDUSessionResourceSetupRequestTransfer as SEQUENCE (APER) (/home/jkalmar/projects/5g/app/constr_SEQUENCE.c:1509) | |
| [PER got 1<=488 bits => span 1 +0[1..488]:00 (487) => 0x0] (/home/jkalmar/projects/5g/app/asn_bit_data.c:139) | |
| Decoding member "protocolIEs" in PDUSessionResourceSetupRequestTransfer (/home/jkalmar/projects/5g/app/constr_SEQUENCE.c:1599) | |
| getting nsnnwn with range 65536 (/home/jkalmar/projects/5g/app/per_support.c:361) | |
| Aligning 7 bits (/home/jkalmar/projects/5g/app/per_support.c:301) | |
| [PER got 7<=487 bits => span 8 +0[8..488]:00 (480) => 0x0] (/home/jkalmar/projects/5g/app/asn_bit_data.c:139) | |
| [PER got 16<=480 bits => span 24 +1[16..480]:00 (464) => 0x4] (/home/jkalmar/projects/5g/app/asn_bit_data.c:139) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <PDUSessionResourceSetupRequestTransfer.h> | |
| void testAsn( void ) | |
| { | |
| char theData[] = | |
| { | |
| 0x00, 0x00, 0x04, 0x00, 0x82, 0x00, 0x08, 0x08, | |
| 0x1e, 0x84, 0x80, 0x20, 0x3d, 0x09, 0x00, 0x00, | |
| 0x86, 0x00, 0x01, 0x00, 0x00, 0x8b, 0x00, 0x1a, | |
| 0x09, 0xf0, 0x11, 0x46, 0x10, 0x10, 0x3f, 0xfe, |