LCOV - code coverage report
Current view: top level - lib/net - rte_arp.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 17 0.0 %
Date: 2024-12-01 18:57:19 Functions: 0 1 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 6 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2018 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <rte_arp.h>
       6                 :            : 
       7                 :            : #define RARP_PKT_SIZE   64
       8                 :            : struct rte_mbuf *
       9                 :          0 : rte_net_make_rarp_packet(struct rte_mempool *mpool,
      10                 :            :                 const struct rte_ether_addr *mac)
      11                 :            : {
      12                 :            :         struct rte_ether_hdr *eth_hdr;
      13                 :            :         struct rte_arp_hdr *rarp;
      14                 :            :         struct rte_mbuf *mbuf;
      15                 :            : 
      16         [ #  # ]:          0 :         if (mpool == NULL)
      17                 :            :                 return NULL;
      18                 :            : 
      19                 :          0 :         mbuf = rte_pktmbuf_alloc(mpool);
      20         [ #  # ]:          0 :         if (mbuf == NULL)
      21                 :            :                 return NULL;
      22                 :            : 
      23                 :            :         eth_hdr = (struct rte_ether_hdr *)
      24                 :            :                 rte_pktmbuf_append(mbuf, RARP_PKT_SIZE);
      25         [ #  # ]:          0 :         if (eth_hdr == NULL) {
      26                 :          0 :                 rte_pktmbuf_free(mbuf);
      27                 :          0 :                 return NULL;
      28                 :            :         }
      29                 :            : 
      30                 :            :         /* Ethernet header. */
      31                 :          0 :         memset(eth_hdr->dst_addr.addr_bytes, 0xff, RTE_ETHER_ADDR_LEN);
      32                 :            :         rte_ether_addr_copy(mac, &eth_hdr->src_addr);
      33                 :          0 :         eth_hdr->ether_type = RTE_BE16(RTE_ETHER_TYPE_RARP);
      34                 :            : 
      35                 :            :         /* RARP header. */
      36                 :            :         rarp = (struct rte_arp_hdr *)(eth_hdr + 1);
      37                 :          0 :         rarp->arp_hardware = RTE_BE16(RTE_ARP_HRD_ETHER);
      38                 :          0 :         rarp->arp_protocol = RTE_BE16(RTE_ETHER_TYPE_IPV4);
      39                 :          0 :         rarp->arp_hlen = RTE_ETHER_ADDR_LEN;
      40                 :          0 :         rarp->arp_plen = 4;
      41                 :          0 :         rarp->arp_opcode  = RTE_BE16(RTE_ARP_OP_REVREQUEST);
      42                 :            : 
      43                 :            :         rte_ether_addr_copy(mac, &rarp->arp_data.arp_sha);
      44                 :            :         rte_ether_addr_copy(mac, &rarp->arp_data.arp_tha);
      45                 :          0 :         memset(&rarp->arp_data.arp_sip, 0x00, 4);
      46                 :          0 :         memset(&rarp->arp_data.arp_tip, 0x00, 4);
      47                 :            : 
      48                 :          0 :         return mbuf;
      49                 :            : }

Generated by: LCOV version 1.14