app/testpmd: fix some indent
[dpdk.git] / app / test-pmd / icmpecho.c
index c28ff5a..010c5a9 100644 (file)
@@ -88,7 +88,7 @@ arp_op_name(uint16_t arp_op)
 }
 
 static const char *
-ip_proto_name(uint8_t ip_proto)
+ip_proto_name(uint16_t ip_proto)
 {
        static const char * ip_proto_names[] = {
                "IP6HOPOPTS", /**< IP6 hop-by-hop options */
@@ -221,12 +221,16 @@ ip_proto_name(uint8_t ip_proto)
        if (ip_proto < sizeof(ip_proto_names) / sizeof(ip_proto_names[0]))
                return ip_proto_names[ip_proto];
        switch (ip_proto) {
+#ifdef IPPROTO_PGM
        case IPPROTO_PGM:  /**< PGM */
                return "PGM";
+#endif
        case IPPROTO_SCTP:  /**< Stream Control Transport Protocol */
                return "SCTP";
+#ifdef IPPROTO_DIVERT
        case IPPROTO_DIVERT: /**< divert pseudo-protocol */
                return "DIVERT";
+#endif
        case IPPROTO_RAW: /**< raw IP packet */
                return "RAW";
        default:
@@ -235,18 +239,6 @@ ip_proto_name(uint8_t ip_proto)
        return "UNASSIGNED";
 }
 
-static void
-ether_addr_to_hexa(const struct ether_addr *ea, char *buf)
-{
-       sprintf(buf, "%02x:%02x:%02x:%02x:%02x:%02x",
-               ea->addr_bytes[0],
-               ea->addr_bytes[1],
-               ea->addr_bytes[2],
-               ea->addr_bytes[3],
-               ea->addr_bytes[4],
-               ea->addr_bytes[5]);
-}
-
 static void
 ipv4_addr_to_dot(uint32_t be_ipv4_addr, char *buf)
 {
@@ -261,9 +253,9 @@ ipv4_addr_to_dot(uint32_t be_ipv4_addr, char *buf)
 static void
 ether_addr_dump(const char *what, const struct ether_addr *ea)
 {
-       char buf[18];
+       char buf[ETHER_ADDR_FMT_SIZE];
 
-       ether_addr_to_hexa(ea, buf);
+       ether_format_addr(buf, ETHER_ADDR_FMT_SIZE, ea);
        if (what)
                printf("%s", what);
        printf("%s", buf);
@@ -330,12 +322,12 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs)
        nb_replies = 0;
        for (i = 0; i < nb_rx; i++) {
                pkt = pkts_burst[i];
-               eth_h = (struct ether_hdr *) pkt->pkt.data;
+               eth_h = rte_pktmbuf_mtod(pkt, struct ether_hdr *);
                eth_type = RTE_BE_TO_CPU_16(eth_h->ether_type);
                l2_len = sizeof(struct ether_hdr);
                if (verbose_level > 0) {
                        printf("\nPort %d pkt-len=%u nb-segs=%u\n",
-                              fs->rx_port, pkt->pkt.pkt_len, pkt->pkt.nb_segs);
+                              fs->rx_port, pkt->pkt_len, pkt->nb_segs);
                        ether_addr_dump("  ETH:  src=", &eth_h->s_addr);
                        ether_addr_dump(" dst=", &eth_h->d_addr);
                }
@@ -379,18 +371,14 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs)
                                continue;
                        }
                        if (verbose_level > 0) {
-                               memcpy(&eth_addr,
-                                      arp_h->arp_data.arp_ip.arp_sha, 6);
+                               ether_addr_copy(&arp_h->arp_data.arp_sha, &eth_addr);
                                ether_addr_dump("        sha=", &eth_addr);
-                               memcpy(&ip_addr,
-                                      arp_h->arp_data.arp_ip.arp_sip, 4);
+                               ip_addr = arp_h->arp_data.arp_sip;
                                ipv4_addr_dump(" sip=", ip_addr);
                                printf("\n");
-                               memcpy(&eth_addr,
-                                      arp_h->arp_data.arp_ip.arp_tha, 6);
+                               ether_addr_copy(&arp_h->arp_data.arp_tha, &eth_addr);
                                ether_addr_dump("        tha=", &eth_addr);
-                               memcpy(&ip_addr,
-                                      arp_h->arp_data.arp_ip.arp_tip, 4);
+                               ip_addr = arp_h->arp_data.arp_tip;
                                ipv4_addr_dump(" tip=", ip_addr);
                                printf("\n");
                        }
@@ -410,17 +398,14 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs)
                                        &eth_h->s_addr);
 
                        arp_h->arp_op = rte_cpu_to_be_16(ARP_OP_REPLY);
-                       memcpy(&eth_addr, arp_h->arp_data.arp_ip.arp_tha, 6);
-                       memcpy(arp_h->arp_data.arp_ip.arp_tha,
-                              arp_h->arp_data.arp_ip.arp_sha, 6);
-                       memcpy(arp_h->arp_data.arp_ip.arp_sha,
-                              &eth_h->s_addr, 6);
+                       ether_addr_copy(&arp_h->arp_data.arp_tha, &eth_addr);
+                       ether_addr_copy(&arp_h->arp_data.arp_sha, &arp_h->arp_data.arp_tha);
+                       ether_addr_copy(&eth_addr, &arp_h->arp_data.arp_sha);
 
                        /* Swap IP addresses in ARP payload */
-                       memcpy(&ip_addr, arp_h->arp_data.arp_ip.arp_sip, 4);
-                       memcpy(arp_h->arp_data.arp_ip.arp_sip,
-                              arp_h->arp_data.arp_ip.arp_tip, 4);
-                       memcpy(arp_h->arp_data.arp_ip.arp_tip, &ip_addr, 4);
+                       ip_addr = arp_h->arp_data.arp_sip;
+                       arp_h->arp_data.arp_sip = arp_h->arp_data.arp_tip;
+                       arp_h->arp_data.arp_tip = ip_addr;
                        pkts_burst[nb_replies++] = pkt;
                        continue;
                }