From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ig0-f176.google.com (mail-ig0-f176.google.com [209.85.213.176]) by dpdk.org (Postfix) with ESMTP id 0008A3787 for ; Wed, 18 Nov 2015 09:47:37 +0100 (CET) Received: by igcph11 with SMTP id ph11so97119969igc.1 for ; Wed, 18 Nov 2015 00:47:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=6eBIiTiffhWbRSBD35M0RnDJHJeCnM1hlgiWQiB5mI8=; b=d+EuuJRq4WPrq2k5hBAFpW5fnTf3xms37Fvo8QA8oOwm1ohCCM/B+76Urqna1gG7T7 0dFUcffXuuimrtvtxzuPUzAe+eOEH3wG2naxV2dLZRRuwkcIBeZfEppLPHcLn6pUEc7R tuaqGF+NJY1OIhnn5yNL61LM5Ed3kuOJiZUZe1BoRM0/6NgcBSasaKuXCDsIOAV3qkpQ /H2nqUX8RpeKrdn9leyh+cD/0t+TxwDxWFt2cdt9AEOPg1J2KASrpSfTsIWCxHgNt8BY WTkpsfzndyDKmC61jNNe/S7yG/uLoxdCenZXV+nRAKKFG+MvMIIwjmCp1TiDwV7Qf2e/ PGhQ== MIME-Version: 1.0 X-Received: by 10.50.43.131 with SMTP id w3mr1760882igl.33.1447836457430; Wed, 18 Nov 2015 00:47:37 -0800 (PST) Received: by 10.79.39.129 with HTTP; Wed, 18 Nov 2015 00:47:37 -0800 (PST) Date: Wed, 18 Nov 2015 17:47:37 +0900 Message-ID: From: Moon-Sang Lee To: dev@dpdk.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: [dpdk-dev] bytes order of ip header in dpdk 2.1 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2015 08:47:38 -0000 Once receiving a packet by rte_eth_rx_burst(), I printed IP header as below. It seems that length(uint16_t) is in big endian, but ip addresses are in little endian. I'm confused and appreciate any comment. ### print_ipv4_header src = 11.0.168.192, dst = 2.173.248.143, length = 60, ttl = 64, proto = 6 This log was printed with these functions. void print_ipv4_header(struct rte_mbuf *m) { struct ether_hdr *eth_header; struct ipv4_hdr *ipv4_header; uint16_t length; uint8_t ttl, proto; uint32_t src_ip, dst_ip; char src_ip_str[MAX_IP_STR_LEN], dst_ip_str[MAX_IP_STR_LEN]; eth_header = rte_pktmbuf_mtod(m, struct ether_hdr *); ipv4_header = (struct ipv4_hdr*)(eth_header + 1); * length = rte_be_to_cpu_16(ipv4_header->total_length);* ttl = ipv4_header->time_to_live; proto = ipv4_header->next_proto_id; * src_ip = rte_be_to_cpu_32(ipv4_header->src_addr);* * dst_ip = rte_be_to_cpu_32(ipv4_header->dst_addr);* convert_ip_to_string(src_ip_str, src_ip); convert_ip_to_string(dst_ip_str, dst_ip); debug("### print_ipv4_header src = %s, dst = %s, length = %d, ttl = %d, proto = %d", src_ip_str, dst_ip_str, length, ttl, proto); } void convert_ip_to_string(char *str, uint32_t ip) { unsigned char *ptr = (unsigned char *)&ip; sprintf(str, "%u.%u.%u.%u", ptr[0], ptr[1], ptr[2], ptr[3]); } -- Moon-Sang Lee, SW Engineer Email: sang0627@gmail.com Wisdom begins in wonder. *Socrates*