test_dcp.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. /*********************************************************************
  2. * _ _ _
  3. * _ __ | |_ _ | | __ _ | |__ ___
  4. * | '__|| __|(_)| | / _` || '_ \ / __|
  5. * | | | |_ _ | || (_| || |_) |\__ \
  6. * |_| \__|(_)|_| \__,_||_.__/ |___/
  7. *
  8. * www.rt-labs.com
  9. * Copyright 2018 rt-labs AB, Sweden.
  10. *
  11. * This software is dual-licensed under GPLv3 and a commercial
  12. * license. See the file LICENSE.md distributed with this software for
  13. * full license information.
  14. ********************************************************************/
  15. /**
  16. * @file
  17. * @brief Testing of DCP aspects.
  18. *
  19. * For example
  20. * Sending hello frame
  21. * Handling of get name request
  22. * Read station name
  23. * Set station name
  24. * Set IP address
  25. * Do factory reset
  26. *
  27. * Checks only function return codes. No checking of the sent Ethernet frames is
  28. * done.
  29. *
  30. */
  31. #include "utils_for_testing.h"
  32. #include "mocks.h"
  33. #include "pf_includes.h"
  34. #include <gtest/gtest.h>
  35. class DcpTest : public PnetIntegrationTest
  36. {
  37. };
  38. class DcpUnitTest : public PnetUnitTest
  39. {
  40. };
  41. static uint8_t get_wrong_length_req[] = {
  42. // clang-format off
  43. // Destination MAC address. Pos 0
  44. 0x12, 0x34, 0x00, 0x78, 0x90, 0xab,
  45. // Source MAC address. Pos 6
  46. 0xc8, 0x5b, 0x76, 0xe6, 0x89, 0xdf,
  47. // Ethernet type = Profinet RT. Pos 12
  48. 0x88, 0x92,
  49. // DCP set/get. Pos 14
  50. 0xfe, 0xfd,
  51. // Get, request. Pos 16
  52. 0x03, 0x00,
  53. // XID. Pos 20
  54. 0x00, 0x00, 0x00, 0x01,
  55. // Reserved. Pos 22
  56. 0x04, 0x01,
  57. // DCP data length. Wrong value. Pos 24
  58. 0x04, 0x00,
  59. // Options. Pos 26
  60. 0x00, 0x00
  61. // clang-format on
  62. };
  63. static uint8_t get_name_req[] = {
  64. 0x12, 0x34, 0x00, 0x78, 0x90, 0xab, 0xc8, 0x5b, 0x76, 0xe6, 0x89, 0xdf,
  65. 0x88, 0x92, 0xfe, 0xfd, 0x03, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00,
  66. 0x00, 0x06, 0x02, 0x02, 0x02, 0x03, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00,
  67. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  68. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  69. static uint8_t ident_req[] = {
  70. 0x01, 0x0e, 0xcf, 0x00, 0x00, 0x00, 0xc8, 0x5b, 0x76, 0xe6, 0x89, 0xdf,
  71. 0x88, 0x92, 0xfe, 0xfe, 0x05, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01,
  72. 0x00, 0x10, 0x02, 0x02, 0x00, 0x0c, 0x72, 0x74, 0x2d, 0x6c, 0x61, 0x62,
  73. 0x73, 0x2d, 0x64, 0x65, 0x6d, 0x6f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  74. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  75. static uint8_t set_name_req[] = {
  76. 0x12, 0x34, 0x00, 0x78, 0x90, 0xab, 0xc8, 0x5b, 0x76, 0xe6, 0x89, 0xdf,
  77. 0x88, 0x92, 0xfe, 0xfd, 0x04, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
  78. 0x00, 0x12, 0x02, 0x02, 0x00, 0x0e, 0x00, 0x00, 0x72, 0x74, 0x2d, 0x6c,
  79. 0x61, 0x62, 0x73, 0x2d, 0x64, 0x65, 0x6d, 0x6f, 0x00, 0x00, 0x00, 0x00,
  80. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  81. static uint8_t set_ip_req[] = {
  82. 0x12, 0x34, 0x00, 0x78, 0x90, 0xab, 0xc8, 0x5b, 0x76, 0xe6, 0x89, 0xdf,
  83. 0x88, 0x92, 0xfe, 0xfd, 0x04, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
  84. 0x00, 0x18, 0x01, 0x02, 0x00, 0x0e, 0x00, 0x00, 0xc0, 0xa8, 0x01, 0xab,
  85. 0xff, 0xff, 0xff, 0x00, 0xc0, 0xa8, 0x01, 0x01, 0x05, 0x02, 0x00, 0x02,
  86. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  87. static uint8_t factory_reset_req[] = {
  88. 0x12, 0x34, 0x00, 0x78, 0x90, 0xab, 0xc8, 0x5b, 0x76, 0xe6, 0x89, 0xdf,
  89. 0x88, 0x92, 0xfe, 0xfd, 0x04, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00,
  90. 0x00, 0x06, 0x05, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  91. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  92. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  93. static uint8_t signal_req[] = {
  94. 0x12, 0x34, 0x00, 0x78, 0x90, 0xab, 0xc8, 0x5b, 0x76, 0xe6, 0x89, 0xdf,
  95. 0x88, 0x92, 0xfe, 0xfd, 0x04, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00,
  96. 0x00, 0x06, 0x05, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  97. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  98. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  99. TEST_F (DcpTest, DcpHelloTest)
  100. {
  101. pnal_buf_t * p_buf;
  102. int ret;
  103. mock_clear();
  104. ret = pf_dcp_hello_req (net);
  105. EXPECT_EQ (ret, 0);
  106. mock_clear();
  107. p_buf = pnal_buf_alloc (PF_FRAME_BUFFER_SIZE);
  108. memcpy (p_buf->payload, get_name_req, sizeof (get_name_req));
  109. ret = pf_eth_recv (mock_os_data.eth_if_handle, net, p_buf);
  110. EXPECT_EQ (ret, 1); // Incoming frame is handled
  111. // LLDP frames and one additional frame
  112. EXPECT_EQ (mock_os_data.eth_send_count, PNET_MAX_PHYSICAL_PORTS + 1);
  113. EXPECT_EQ (appdata.call_counters.led_off_calls, 1);
  114. EXPECT_EQ (appdata.call_counters.led_on_calls, 0);
  115. EXPECT_EQ (appdata.call_counters.state_calls, 0);
  116. EXPECT_EQ (appdata.call_counters.connect_calls, 0);
  117. EXPECT_EQ (appdata.call_counters.release_calls, 0);
  118. EXPECT_EQ (appdata.call_counters.dcontrol_calls, 0);
  119. EXPECT_EQ (appdata.call_counters.ccontrol_calls, 0);
  120. EXPECT_EQ (appdata.call_counters.read_calls, 0);
  121. EXPECT_EQ (appdata.call_counters.write_calls, 0);
  122. }
  123. TEST_F (DcpTest, DcpGetWrongLengthTest)
  124. {
  125. pnal_buf_t * p_buf;
  126. int ret;
  127. mock_clear();
  128. p_buf = pnal_buf_alloc (PF_FRAME_BUFFER_SIZE);
  129. memcpy (p_buf->payload, get_wrong_length_req, sizeof (get_wrong_length_req));
  130. p_buf->len = sizeof (get_wrong_length_req);
  131. ret = pf_eth_recv (mock_os_data.eth_if_handle, net, p_buf);
  132. EXPECT_EQ (ret, 1); // Incoming frame is handled
  133. EXPECT_EQ (mock_os_data.eth_send_count, 0); // Drop malformed frame
  134. EXPECT_EQ (appdata.call_counters.led_off_calls, 1);
  135. EXPECT_EQ (appdata.call_counters.led_on_calls, 0);
  136. EXPECT_EQ (appdata.call_counters.state_calls, 0);
  137. EXPECT_EQ (appdata.call_counters.connect_calls, 0);
  138. EXPECT_EQ (appdata.call_counters.release_calls, 0);
  139. EXPECT_EQ (appdata.call_counters.dcontrol_calls, 0);
  140. EXPECT_EQ (appdata.call_counters.ccontrol_calls, 0);
  141. EXPECT_EQ (appdata.call_counters.read_calls, 0);
  142. EXPECT_EQ (appdata.call_counters.write_calls, 0);
  143. }
  144. TEST_F (DcpTest, DcpRunTest)
  145. {
  146. pnal_buf_t * p_buf;
  147. int ret;
  148. TEST_TRACE ("\nGenerating mock set name request\n");
  149. p_buf = pnal_buf_alloc (PF_FRAME_BUFFER_SIZE);
  150. memcpy (p_buf->payload, set_name_req, sizeof (set_name_req));
  151. p_buf->len = sizeof (set_name_req);
  152. ret = pf_eth_recv (mock_os_data.eth_if_handle, net, p_buf);
  153. EXPECT_EQ (ret, 1);
  154. TEST_TRACE ("\nGenerating mock set IP request\n");
  155. p_buf = pnal_buf_alloc (PF_FRAME_BUFFER_SIZE);
  156. memcpy (p_buf->payload, set_ip_req, sizeof (set_ip_req));
  157. p_buf->len = sizeof (set_ip_req);
  158. ret = pf_eth_recv (mock_os_data.eth_if_handle, net, p_buf);
  159. EXPECT_EQ (ret, 1);
  160. TEST_TRACE ("\nGenerating mock set ident request\n");
  161. p_buf = pnal_buf_alloc (PF_FRAME_BUFFER_SIZE);
  162. memcpy (p_buf->payload, ident_req, sizeof (ident_req));
  163. p_buf->len = sizeof (ident_req);
  164. ret = pf_eth_recv (mock_os_data.eth_if_handle, net, p_buf);
  165. EXPECT_EQ (ret, 1);
  166. TEST_TRACE ("\nGenerating mock factory reset request\n");
  167. p_buf = pnal_buf_alloc (PF_FRAME_BUFFER_SIZE);
  168. memcpy (p_buf->payload, factory_reset_req, sizeof (factory_reset_req));
  169. p_buf->len = sizeof (factory_reset_req);
  170. ret = pf_eth_recv (mock_os_data.eth_if_handle, net, p_buf);
  171. EXPECT_EQ (ret, 1);
  172. TEST_TRACE ("\nGenerating mock flash LED request\n");
  173. p_buf = pnal_buf_alloc (PF_FRAME_BUFFER_SIZE);
  174. memcpy (p_buf->payload, signal_req, sizeof (signal_req));
  175. p_buf->len = sizeof (signal_req);
  176. ret = pf_eth_recv (mock_os_data.eth_if_handle, net, p_buf);
  177. EXPECT_EQ (ret, 1);
  178. /* Wait for LED to flash three times at 1 Hz */
  179. run_stack (4 * 1000 * 1000);
  180. EXPECT_EQ (
  181. mock_os_data.eth_send_count,
  182. 9 + (PNET_MAX_PHYSICAL_PORTS - 1) * 4);
  183. EXPECT_EQ (mock_os_data.set_ip_suite_count, 3);
  184. EXPECT_EQ (appdata.call_counters.led_on_calls, 3);
  185. EXPECT_EQ (appdata.call_counters.led_off_calls, 4);
  186. EXPECT_EQ (appdata.call_counters.state_calls, 0);
  187. EXPECT_EQ (appdata.call_counters.connect_calls, 0);
  188. EXPECT_EQ (appdata.call_counters.release_calls, 0);
  189. EXPECT_EQ (appdata.call_counters.dcontrol_calls, 0);
  190. EXPECT_EQ (appdata.call_counters.ccontrol_calls, 0);
  191. EXPECT_EQ (appdata.call_counters.read_calls, 0);
  192. EXPECT_EQ (appdata.call_counters.write_calls, 0);
  193. }
  194. TEST_F (DcpUnitTest, DcpCalculateDelay)
  195. {
  196. pnet_ethaddr_t mac_address = {0};
  197. const uint16_t step = 10000; /* Output resolution in microseconds */
  198. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 0), 0U);
  199. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 1), 0U);
  200. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 2), 0U);
  201. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 10), 0U);
  202. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 100), 0U);
  203. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 1000), 0U);
  204. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 6400), 0U);
  205. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 6401), 0U);
  206. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 0xFFFF), 0U);
  207. mac_address.addr[5] = 0x01;
  208. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 0), 0U);
  209. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 1), 0U);
  210. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 2), 1U * step);
  211. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 10), 1U * step);
  212. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 100), 1U * step);
  213. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 1000), 1U * step);
  214. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 6400), 1U * step);
  215. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 6401), 0U);
  216. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 0xFFFF), 0U);
  217. mac_address.addr[5] = 0x02;
  218. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 0), 0U);
  219. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 0), 0U);
  220. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 1), 0U);
  221. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 2), 0U);
  222. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 10), 2U * step);
  223. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 100), 2U * step);
  224. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 1000), 2U * step);
  225. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 6400), 2U * step);
  226. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 6401), 0U);
  227. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 0xFFFF), 0U);
  228. mac_address.addr[5] = 0xC7; /* 199 */
  229. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 100), 99U * step);
  230. mac_address.addr[5] = 0xFF; /* 255 */
  231. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 0), 0U);
  232. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 1), 0U);
  233. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 2), 1U * step);
  234. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 10), 5U * step);
  235. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 100), 55U * step);
  236. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 252), 3U * step);
  237. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 253), 2U * step);
  238. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 254), 1U * step);
  239. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 255), 0U);
  240. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 256), 255U * step);
  241. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 257), 255U * step);
  242. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 258), 255U * step);
  243. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 1000), 255U * step);
  244. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 6400), 255U * step);
  245. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 6401), 0U);
  246. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 0xFFFF), 0U);
  247. mac_address.addr[5] = 0x00;
  248. mac_address.addr[4] = 0x01; /* 256 */
  249. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 0), 0U);
  250. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 1), 0U);
  251. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 2), 0U);
  252. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 10), 6U * step);
  253. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 100), 56U * step);
  254. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 253), 3U * step);
  255. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 254), 2U * step);
  256. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 255), 1U * step);
  257. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 256), 0U);
  258. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 257), 256U * step);
  259. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 258), 256U * step);
  260. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 1000), 256U * step);
  261. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 1000), 256U * step);
  262. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 6400), 256U * step);
  263. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 6401), 0U);
  264. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 0xFFFF), 0U);
  265. mac_address.addr[4] = 0x02; /* 512 */
  266. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 0), 0U);
  267. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 1), 0U);
  268. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 2), 0U);
  269. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 10), 2U * step);
  270. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 100), 12U * step);
  271. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 1000), 512U * step);
  272. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 6400), 512U * step);
  273. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 6401), 0U);
  274. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 0xFFFF), 0U);
  275. mac_address.addr[4] = 0xFF; /* 65280 */
  276. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 0), 0U);
  277. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 1), 0U);
  278. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 2), 0U);
  279. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 10), 0U);
  280. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 100), 80U * step);
  281. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 1000), 280U * step);
  282. ASSERT_EQ (
  283. pf_dcp_calculate_response_delay (&mac_address, 6400),
  284. 1280U * step);
  285. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 6401), 0U);
  286. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 0xFFFF), 0U);
  287. mac_address.addr[4] = 0xFF;
  288. mac_address.addr[5] = 0xFF; /* 65535 */
  289. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 0), 0U);
  290. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 1), 0U);
  291. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 2), 1U * step);
  292. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 10), 5U * step);
  293. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 100), 35U * step);
  294. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 1000), 535U * step);
  295. ASSERT_EQ (
  296. pf_dcp_calculate_response_delay (&mac_address, 6400),
  297. 1535U * step);
  298. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 6401), 0U);
  299. ASSERT_EQ (pf_dcp_calculate_response_delay (&mac_address, 0xFFFF), 0U);
  300. }
  301. TEST_F (DcpUnitTest, DcpCheckDestinationAddress)
  302. {
  303. pnet_ethaddr_t local_mac_address = {0x12, 0x34, 0x00, 0x78, 0x90, 0xab};
  304. pnet_ethaddr_t unknown_mac_address = {0x12, 0x34, 0x00, 0x78, 0x95, 0xab};
  305. pnet_ethaddr_t multicast_mac_address = {0x01, 0x0e, 0xcf, 0x00, 0x00, 0x00};
  306. ASSERT_EQ (
  307. pf_dcp_check_destination_address (&local_mac_address, &local_mac_address),
  308. true);
  309. ASSERT_EQ (
  310. pf_dcp_check_destination_address (
  311. &local_mac_address,
  312. &unknown_mac_address),
  313. false);
  314. ASSERT_EQ (
  315. pf_dcp_check_destination_address (
  316. &local_mac_address,
  317. &multicast_mac_address),
  318. false);
  319. }