@@ -215,6 +215,8 @@ static inline struct net_pkt *prepare_arp_reply(struct net_if *iface,
215
215
216
216
net_buf_add (pkt -> buffer , sizeof (struct net_arp_hdr ));
217
217
218
+ net_pkt_set_ll_proto_type (pkt , NET_ETH_PTYPE_ARP );
219
+
218
220
return pkt ;
219
221
}
220
222
@@ -265,6 +267,8 @@ static inline struct net_pkt *prepare_arp_request(struct net_if *iface,
265
267
266
268
net_buf_add (pkt -> buffer , sizeof (struct net_arp_hdr ));
267
269
270
+ net_pkt_set_ll_proto_type (pkt , NET_ETH_PTYPE_ARP );
271
+
268
272
return pkt ;
269
273
}
270
274
@@ -373,6 +377,8 @@ ZTEST(arp_fn_tests, test_arp)
373
377
net_ipv4_addr_copy_raw (ipv4 -> src , (uint8_t * )& src );
374
378
net_ipv4_addr_copy_raw (ipv4 -> dst , (uint8_t * )& dst );
375
379
380
+ net_pkt_set_ll_proto_type (pkt , NET_ETH_PTYPE_IP );
381
+
376
382
memcpy (net_buf_add (pkt -> buffer , len ), app_data , len );
377
383
378
384
pkt2 = net_arp_prepare (pkt , & dst , NULL );
@@ -381,6 +387,9 @@ ZTEST(arp_fn_tests, test_arp)
381
387
* stored in ARP table.
382
388
*/
383
389
390
+ zassert_equal (net_pkt_ll_proto_type (pkt2 ), NET_ETH_PTYPE_ARP ,
391
+ "ARP packet type is wrong" );
392
+
384
393
/**TESTPOINTS: Check packets*/
385
394
zassert_not_equal ((void * )(pkt2 ), (void * )(pkt ),
386
395
/* The packets cannot be the same as the ARP cache has
@@ -530,6 +539,8 @@ ZTEST(arp_fn_tests, test_arp)
530
539
net_ipv4_addr_copy_raw (arp_hdr -> dst_ipaddr , (uint8_t * )& dst );
531
540
net_ipv4_addr_copy_raw (arp_hdr -> src_ipaddr , (uint8_t * )& src );
532
541
542
+ net_pkt_set_ll_proto_type (pkt , NET_ETH_PTYPE_ARP );
543
+
533
544
pkt2 = prepare_arp_reply (iface , pkt , & eth_hwaddr , & eth_hdr );
534
545
535
546
zassert_not_null (pkt2 , "ARP reply generation failed." );
@@ -554,6 +565,9 @@ ZTEST(arp_fn_tests, test_arp)
554
565
555
566
net_pkt_unref (pkt );
556
567
568
+ /* Clear the ARP cache so that old entries do not confuse the tests */
569
+ net_arp_clear_cache (iface );
570
+
557
571
/* Then feed in ARP request */
558
572
pkt = net_pkt_alloc_with_buffer (iface , sizeof (struct net_eth_hdr ) +
559
573
sizeof (struct net_arp_hdr ),
@@ -571,6 +585,8 @@ ZTEST(arp_fn_tests, test_arp)
571
585
net_ipv4_addr_copy_raw (arp_hdr -> dst_ipaddr , (uint8_t * )& src );
572
586
net_ipv4_addr_copy_raw (arp_hdr -> src_ipaddr , (uint8_t * )& dst );
573
587
588
+ net_pkt_set_ll_proto_type (pkt , NET_ETH_PTYPE_ARP );
589
+
574
590
pkt2 = prepare_arp_request (iface , pkt , & eth_hwaddr , & eth_hdr );
575
591
576
592
/**TESTPOINT: Check if ARP request generation failed*/
@@ -633,6 +649,8 @@ ZTEST(arp_fn_tests, test_arp)
633
649
634
650
net_buf_add (pkt -> buffer , sizeof (struct net_arp_hdr ));
635
651
652
+ net_pkt_set_ll_proto_type (pkt , NET_ETH_PTYPE_ARP );
653
+
636
654
verdict = net_arp_input (pkt , eth_hdr );
637
655
zassert_not_equal (verdict , NET_DROP , "Gratuitous ARP failed" );
638
656
0 commit comments