MCPcopy Create free account
hub / github.com/COVESA/vsomeip / find_magic_cookie

Method find_magic_cookie

implementation/endpoints/src/endpoint_impl.cpp:28–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26
27template<typename Protocol>
28uint32_t endpoint_impl<Protocol>::find_magic_cookie(byte_t* _buffer, size_t _size) {
29 bool is_found(false);
30 uint32_t its_offset = 0xFFFFFFFF;
31
32 uint8_t its_cookie_identifier, its_cookie_type;
33
34 if (is_client()) {
35 its_cookie_identifier = static_cast<uint8_t>(MAGIC_COOKIE_SERVICE_MESSAGE);
36 its_cookie_type = static_cast<uint8_t>(MAGIC_COOKIE_SERVICE_MESSAGE_TYPE);
37 } else {
38 its_cookie_identifier = static_cast<uint8_t>(MAGIC_COOKIE_CLIENT_MESSAGE);
39 its_cookie_type = static_cast<uint8_t>(MAGIC_COOKIE_CLIENT_MESSAGE_TYPE);
40 }
41
42 do {
43 its_offset++; // --> first loop has "its_offset = 0"
44 if (_size > its_offset + 16) {
45 is_found = (_buffer[its_offset] == 0xFF && _buffer[its_offset + 1] == 0xFF && _buffer[its_offset + 2] == its_cookie_identifier
46 && _buffer[its_offset + 3] == 0x00 && _buffer[its_offset + 4] == 0x00 && _buffer[its_offset + 5] == 0x00
47 && _buffer[its_offset + 6] == 0x00 && _buffer[its_offset + 7] == 0x08 && _buffer[its_offset + 8] == 0xDE
48 && _buffer[its_offset + 9] == 0xAD && _buffer[its_offset + 10] == 0xBE && _buffer[its_offset + 11] == 0xEF
49 && _buffer[its_offset + 12] == 0x01 && _buffer[its_offset + 13] == 0x01
50 && _buffer[its_offset + 14] == its_cookie_type && _buffer[its_offset + 15] == 0x00);
51 } else {
52 break;
53 }
54
55 } while (!is_found);
56
57 return (is_found ? its_offset : 0xFFFFFFFF);
58}
59
60template<typename Protocol>
61void endpoint_impl<Protocol>::add_default_target(service_t, const std::string&, uint16_t) { }

Callers 1

receive_cbkMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected